From e85fa91ec6655da593c0b8b31832045da5ad9ad4 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Thu, 2 May 2013 11:45:18 +0200 Subject: update Xorg to 7.7 --- Config.in | 6 +- Makefile | 1 + mk/kernel-ver.mk | 6 +- mk/mirrors.mk | 6 +- package/MesaLib/Makefile | 48 +- package/MesaLib/patches/000-mesalib-xdemos.patch | 14774 ----- package/MesaLib/patches/patch-bin_mklib | 19 +- package/MesaLib/patches/patch-configs_default | 11 - .../patches/patch-include_GL_internal_sarea_h | 12 - package/MesaLib/patches/patch-src_glsl_Makefile | 17 +- .../MesaLib/patches/patch-src_glsl_apps_Makefile | 15 - package/MesaLib/patches/patch-src_mesa_Makefile | 21 - ...patch-src_mesa_drivers_dri_savage_savageioctl_c | 10 - .../MesaLib/patches/patch-src_mesa_main_imports_c | 17 - .../patch-src_mesa_shader_slang_library_Makefile | 11 - package/bigreqsproto/Makefile | 4 +- package/compositeproto/Makefile | 4 +- package/damageproto/Makefile | 4 +- package/dri2proto/Makefile | 4 +- package/fixesproto/Makefile | 4 +- package/font-adobe-100dpi/Makefile | 4 +- package/font-adobe-75dpi/Makefile | 4 +- package/font-bh-100dpi/Makefile | 4 +- package/font-bh-75dpi/Makefile | 4 +- package/font-bh-lucidatypewriter-100dpi/Makefile | 4 +- package/font-bh-lucidatypewriter-75dpi/Makefile | 4 +- package/font-bh-ttf/Makefile | 4 +- package/font-bitstream-100dpi/Makefile | 4 +- package/font-bitstream-75dpi/Makefile | 4 +- package/font-bitstream-type1/Makefile | 4 +- package/font-misc-misc/Makefile | 4 +- package/font-xfree86-type1/Makefile | 4 +- package/fontsproto/Makefile | 4 +- package/glproto/Makefile | 4 +- package/inputproto/Makefile | 4 +- package/kbproto/Makefile | 4 +- package/libICE/Makefile | 4 +- package/libICE/patches/patch-ltmain_sh | 11 - package/libSM/Makefile | 4 +- package/libSM/patches/patch-ltmain_sh | 11 - package/libX11/Makefile | 4 +- package/libX11/patches/patch-ltmain_sh | 6 +- package/libX11/patches/patch-src_util_Makefile_in | 40 +- package/libXau/Makefile | 4 +- package/libXau/patches/patch-ltmain_sh | 11 - package/libXaw/Makefile | 4 +- package/libXaw/patches/patch-ltmain_sh | 11 - package/libXcursor/Makefile | 6 +- package/libXcursor/patches/patch-ltmain_sh | 11 - package/libXdmcp/Makefile | 4 +- package/libXdmcp/patches/patch-ltmain_sh | 11 - package/libXext/Makefile | 4 +- package/libXext/patches/patch-ltmain_sh | 11 - package/libXfixes/Makefile | 4 +- package/libXfont/Makefile | 4 +- package/libXfont/patches/patch-ltmain_sh | 11 - package/libXft/Makefile | 4 +- package/libXft/patches/autotool.patch | 63433 ------------------- package/libXi/Makefile | 4 +- package/libXi/patches/patch-ltmain_sh | 11 - package/libXinerama/Makefile | 4 +- package/libXmu/Makefile | 4 +- package/libXmu/patches/patch-ltmain_sh | 11 - package/libXpm/Makefile | 6 +- package/libXpm/patches/patch-ltmain_sh | 11 - package/libXrandr/Makefile | 37 + package/libXrender/Makefile | 4 +- package/libXt/Makefile | 4 +- package/libXt/patches/patch-ltmain_sh | 11 - package/libXt/patches/patch-util_Makefile_in | 12 +- package/libXtst/Makefile | 4 +- package/libXv/Makefile | 4 +- package/libXv/patches/patch-ltmain_sh | 11 - package/libXxf86dga/Makefile | 4 +- package/libXxf86vm/Makefile | 4 +- package/libdrm/Makefile | 4 +- package/libfontenc/Makefile | 4 +- package/libfontenc/patches/patch-ltmain_sh | 11 - package/libpciaccess/Makefile | 4 +- package/libpciaccess/patches/patch-ltmain_sh | 11 - package/libxkbfile/Makefile | 4 +- package/libxkbfile/patches/autotool.patch | 61366 ------------------ package/mkfontdir/Makefile | 6 +- package/mkfontscale/Makefile | 6 +- package/randrproto/Makefile | 4 +- package/recordproto/Makefile | 4 +- package/resourceproto/Makefile | 4 +- package/scrnsaverproto/Makefile | 4 +- package/setxkbmap/Makefile | 6 +- package/util-linux/Makefile | 1 + package/xauth/Makefile | 4 +- package/xbitmaps/Makefile | 17 +- package/xbitmaps/patches/patch-Makefile_in | 11 + package/xextproto/Makefile | 4 +- package/xf86-input-evdev/Makefile | 2 +- package/xf86-input-keyboard/Makefile | 4 +- .../xf86-input-keyboard/patches/patch-ltmain_sh | 11 - package/xf86-input-mouse/Makefile | 4 +- package/xf86-input-mouse/patches/patch-ltmain_sh | 11 - package/xf86-video-ati/Makefile | 2 +- package/xf86-video-cirrus/Makefile | 2 +- package/xf86-video-geode/Makefile | 2 +- package/xf86-video-intel/Makefile | 2 +- package/xf86-video-siliconmotion/Makefile | 4 +- .../patches/patch-ltmain_sh | 11 - package/xf86vidmodeproto/Makefile | 4 +- package/xineramaproto/Makefile | 6 +- package/xinput/Makefile | 8 +- package/xkeyboard-config/Makefile | 8 +- package/xorg-server/Makefile | 4 +- package/xorg-server/patches/patch-fb_fb_h | 6 +- .../patches/patch-hw_xfree86_common_compiler_h | 51 +- .../patches/patch-hw_xfree86_dri_sarea_h | 8 +- .../patch-hw_xfree86_os-support_linux_lnx_init_c | 6 +- .../patch-hw_xfree86_os-support_linux_lnx_video_c | 67 +- package/xorg-server/patches/patch-ltmain_sh | 6 +- package/xproto/Makefile | 4 +- package/xset/Makefile | 4 +- package/xsetroot/Makefile | 2 +- .../linux/patches/3.4.41/bsd-compatibility.patch | 2512 - target/linux/patches/3.4.41/cris-etrax.patch | 12 - target/linux/patches/3.4.41/defaults.patch | 22 - target/linux/patches/3.4.41/gemalto.patch | 11 - target/linux/patches/3.4.41/lemote-rfkill.patch | 21 - target/linux/patches/3.4.41/mmc-host.patch | 36 - .../patches/3.4.41/module-alloc-size-check.patch | 21 - target/linux/patches/3.4.41/non-static.patch | 33 - target/linux/patches/3.4.41/sparc-include.patch | 11 - target/linux/patches/3.4.41/startup.patch | 20 - target/linux/patches/3.4.41/usb-defaults-off.patch | 32 - target/linux/patches/3.4.41/uuid.patch | 263 - .../patches/3.4.41/vga-cons-default-off.patch | 12 - target/linux/patches/3.4.41/wlan-cf.patch | 11 - target/linux/patches/3.4.41/zlib-inflate.patch | 12 - .../linux/patches/3.4.42/bsd-compatibility.patch | 2512 + target/linux/patches/3.4.42/cris-etrax.patch | 12 + target/linux/patches/3.4.42/defaults.patch | 22 + target/linux/patches/3.4.42/gemalto.patch | 11 + target/linux/patches/3.4.42/lemote-rfkill.patch | 21 + target/linux/patches/3.4.42/mmc-host.patch | 36 + .../patches/3.4.42/module-alloc-size-check.patch | 21 + target/linux/patches/3.4.42/non-static.patch | 33 + target/linux/patches/3.4.42/sparc-include.patch | 11 + target/linux/patches/3.4.42/startup.patch | 20 + target/linux/patches/3.4.42/usb-defaults-off.patch | 32 + target/linux/patches/3.4.42/uuid.patch | 263 + .../patches/3.4.42/vga-cons-default-off.patch | 12 + target/linux/patches/3.4.42/wlan-cf.patch | 11 + target/linux/patches/3.4.42/zlib-inflate.patch | 12 + target/packages/pkg-available/development | 1 + .../kernel-headers/patches/3.4.41/aufs2.patch | 238 - .../patches/3.4.41/cleankernel.patch | 11 - .../patches/3.4.41/etrax-header.patch | 95 - .../patches/3.4.41/linux-gcc-check.patch | 18 - .../kernel-headers/patches/3.4.41/microperl.patch | 24 - .../kernel-headers/patches/3.4.41/mkpiggy.patch | 28 - .../kernel-headers/patches/3.4.41/relocs.patch | 3131 - .../kernel-headers/patches/3.4.42/aufs2.patch | 238 + .../patches/3.4.42/cleankernel.patch | 11 + .../patches/3.4.42/etrax-header.patch | 95 + .../patches/3.4.42/linux-gcc-check.patch | 18 + .../kernel-headers/patches/3.4.42/microperl.patch | 24 + .../kernel-headers/patches/3.4.42/mkpiggy.patch | 28 + .../kernel-headers/patches/3.4.42/relocs.patch | 3131 + 164 files changed, 6935 insertions(+), 146745 deletions(-) delete mode 100644 package/MesaLib/patches/000-mesalib-xdemos.patch delete mode 100644 package/MesaLib/patches/patch-configs_default delete mode 100644 package/MesaLib/patches/patch-include_GL_internal_sarea_h delete mode 100644 package/MesaLib/patches/patch-src_glsl_apps_Makefile delete mode 100644 package/MesaLib/patches/patch-src_mesa_Makefile delete mode 100644 package/MesaLib/patches/patch-src_mesa_drivers_dri_savage_savageioctl_c delete mode 100644 package/MesaLib/patches/patch-src_mesa_main_imports_c delete mode 100644 package/MesaLib/patches/patch-src_mesa_shader_slang_library_Makefile delete mode 100644 package/libICE/patches/patch-ltmain_sh delete mode 100644 package/libSM/patches/patch-ltmain_sh delete mode 100644 package/libXau/patches/patch-ltmain_sh delete mode 100644 package/libXaw/patches/patch-ltmain_sh delete mode 100644 package/libXcursor/patches/patch-ltmain_sh delete mode 100644 package/libXdmcp/patches/patch-ltmain_sh delete mode 100644 package/libXext/patches/patch-ltmain_sh delete mode 100644 package/libXfont/patches/patch-ltmain_sh delete mode 100644 package/libXft/patches/autotool.patch delete mode 100644 package/libXi/patches/patch-ltmain_sh delete mode 100644 package/libXmu/patches/patch-ltmain_sh delete mode 100644 package/libXpm/patches/patch-ltmain_sh create mode 100644 package/libXrandr/Makefile delete mode 100644 package/libXt/patches/patch-ltmain_sh delete mode 100644 package/libXv/patches/patch-ltmain_sh delete mode 100644 package/libfontenc/patches/patch-ltmain_sh delete mode 100644 package/libpciaccess/patches/patch-ltmain_sh delete mode 100644 package/libxkbfile/patches/autotool.patch create mode 100644 package/xbitmaps/patches/patch-Makefile_in delete mode 100644 package/xf86-input-keyboard/patches/patch-ltmain_sh delete mode 100644 package/xf86-input-mouse/patches/patch-ltmain_sh delete mode 100644 package/xf86-video-siliconmotion/patches/patch-ltmain_sh delete mode 100644 target/linux/patches/3.4.41/bsd-compatibility.patch delete mode 100644 target/linux/patches/3.4.41/cris-etrax.patch delete mode 100644 target/linux/patches/3.4.41/defaults.patch delete mode 100644 target/linux/patches/3.4.41/gemalto.patch delete mode 100644 target/linux/patches/3.4.41/lemote-rfkill.patch delete mode 100644 target/linux/patches/3.4.41/mmc-host.patch delete mode 100644 target/linux/patches/3.4.41/module-alloc-size-check.patch delete mode 100644 target/linux/patches/3.4.41/non-static.patch delete mode 100644 target/linux/patches/3.4.41/sparc-include.patch delete mode 100644 target/linux/patches/3.4.41/startup.patch delete mode 100644 target/linux/patches/3.4.41/usb-defaults-off.patch delete mode 100644 target/linux/patches/3.4.41/uuid.patch delete mode 100644 target/linux/patches/3.4.41/vga-cons-default-off.patch delete mode 100644 target/linux/patches/3.4.41/wlan-cf.patch delete mode 100644 target/linux/patches/3.4.41/zlib-inflate.patch create mode 100644 target/linux/patches/3.4.42/bsd-compatibility.patch create mode 100644 target/linux/patches/3.4.42/cris-etrax.patch create mode 100644 target/linux/patches/3.4.42/defaults.patch create mode 100644 target/linux/patches/3.4.42/gemalto.patch create mode 100644 target/linux/patches/3.4.42/lemote-rfkill.patch create mode 100644 target/linux/patches/3.4.42/mmc-host.patch create mode 100644 target/linux/patches/3.4.42/module-alloc-size-check.patch create mode 100644 target/linux/patches/3.4.42/non-static.patch create mode 100644 target/linux/patches/3.4.42/sparc-include.patch create mode 100644 target/linux/patches/3.4.42/startup.patch create mode 100644 target/linux/patches/3.4.42/usb-defaults-off.patch create mode 100644 target/linux/patches/3.4.42/uuid.patch create mode 100644 target/linux/patches/3.4.42/vga-cons-default-off.patch create mode 100644 target/linux/patches/3.4.42/wlan-cf.patch create mode 100644 target/linux/patches/3.4.42/zlib-inflate.patch delete mode 100644 toolchain/kernel-headers/patches/3.4.41/aufs2.patch delete mode 100644 toolchain/kernel-headers/patches/3.4.41/cleankernel.patch delete mode 100644 toolchain/kernel-headers/patches/3.4.41/etrax-header.patch delete mode 100644 toolchain/kernel-headers/patches/3.4.41/linux-gcc-check.patch delete mode 100644 toolchain/kernel-headers/patches/3.4.41/microperl.patch delete mode 100644 toolchain/kernel-headers/patches/3.4.41/mkpiggy.patch delete mode 100644 toolchain/kernel-headers/patches/3.4.41/relocs.patch create mode 100644 toolchain/kernel-headers/patches/3.4.42/aufs2.patch create mode 100644 toolchain/kernel-headers/patches/3.4.42/cleankernel.patch create mode 100644 toolchain/kernel-headers/patches/3.4.42/etrax-header.patch create mode 100644 toolchain/kernel-headers/patches/3.4.42/linux-gcc-check.patch create mode 100644 toolchain/kernel-headers/patches/3.4.42/microperl.patch create mode 100644 toolchain/kernel-headers/patches/3.4.42/mkpiggy.patch create mode 100644 toolchain/kernel-headers/patches/3.4.42/relocs.patch diff --git a/Config.in b/Config.in index e2aa4820f..6670f8965 100644 --- a/Config.in +++ b/Config.in @@ -110,8 +110,8 @@ config ADK_KERNEL_VERSION_3_8_10 prompt "3.8.10" boolean -config ADK_KERNEL_VERSION_3_4_41 - prompt "3.4.41" +config ADK_KERNEL_VERSION_3_4_42 + prompt "3.4.42" boolean endchoice @@ -119,7 +119,7 @@ endchoice config ADK_KERNEL_VERSION string default "3.8.10" if ADK_KERNEL_VERSION_3_8_10 - default "3.4.41" if ADK_KERNEL_VERSION_3_4_41 + default "3.4.42" if ADK_KERNEL_VERSION_3_4_42 help choice diff --git a/Makefile b/Makefile index 590c0dac2..3907452b9 100644 --- a/Makefile +++ b/Makefile @@ -235,3 +235,4 @@ checkreloc: @bash scripts/reloc.sh .PHONY: prereq prereq-noerror checkreloc +# DO NOT DELETE diff --git a/mk/kernel-ver.mk b/mk/kernel-ver.mk index 7764296bc..a7932a76e 100644 --- a/mk/kernel-ver.mk +++ b/mk/kernel-ver.mk @@ -10,9 +10,9 @@ KERNEL_MOD_VERSION:= $(KERNEL_VERSION) KERNEL_RELEASE:= 1 KERNEL_MD5SUM:= 3d5fb6d9add9cce7725bbe9b139c8d6e endif -ifeq ($(ADK_KERNEL_VERSION_3_4_41),y) -KERNEL_VERSION:= 3.4.41 +ifeq ($(ADK_KERNEL_VERSION_3_4_42),y) +KERNEL_VERSION:= 3.4.42 KERNEL_MOD_VERSION:= $(KERNEL_VERSION) KERNEL_RELEASE:= 1 -KERNEL_MD5SUM:= 3078c420a7adf1393deca76d07de548d +KERNEL_MD5SUM:= 1d802f8c5b881186d74e087aced2d553 endif diff --git a/mk/mirrors.mk b/mk/mirrors.mk index 23bfe2196..43bc1a6f4 100644 --- a/mk/mirrors.mk +++ b/mk/mirrors.mk @@ -15,9 +15,9 @@ MASTER_SITE_KERNEL?= \ http://www.kernel.org/pub/linux/ \ MASTER_SITE_XORG?= \ - http://www.x.org/releases/X11R7.6/src/everything/ \ - http://ftp.gwdg.de/pub/x11/x.org/pub/X11R7.6/src/everything/ \ - http://xorg.freedesktop.org/releases/X11R7.6/src/everything/ \ + http://www.x.org/releases/X11R7.7/src/everything/ \ + http://ftp.gwdg.de/pub/x11/x.org/pub/X11R7.7/src/everything/ \ + http://xorg.freedesktop.org/releases/X11R7.7/src/everything/ \ http://xorg.freedesktop.org/releases/individual/app/ \ http://xorg.freedesktop.org/releases/individual/lib/ \ http://xorg.freedesktop.org/releases/individual/driver/ \ diff --git a/package/MesaLib/Makefile b/package/MesaLib/Makefile index 3dd7ee490..c55aa1db1 100644 --- a/package/MesaLib/Makefile +++ b/package/MesaLib/Makefile @@ -4,25 +4,21 @@ include $(TOPDIR)/rules.mk PKG_NAME:= MesaLib -PKG_VERSION:= 7.8.2 -PKG_RELEASE:= 3 -PKG_MD5SUM:= c89b63d253605ed40e8ac370d25a833c +PKG_VERSION:= 8.0.5 +PKG_RELEASE:= 1 +PKG_MD5SUM:= cda5d101f43b8784fa60bdeaca4056f2 PKG_DESCR:= MESA library PKG_SECTION:= libs PKG_DEPENDS:= libxdamage libxfixes libdrm libxxf86vm libexpat PKG_BUILDDEP:= libXdamage libXfixes libXxf86vm libdrm PKG_BUILDDEP+= dri2proto glproto expat libXext PKG_URL:= http://www.mesa3d.org/ -PKG_SITES:= ftp://ftp.freedesktop.org/pub/mesa/7.8.2/ +PKG_SITES:= ftp://ftp.freedesktop.org/pub/mesa/${PKG_VERSION}/ PKG_NEED_CXX:= 1 -PKG_SUBPKGS:= MESALIB MESALIB_DEV GLXINFO GLXGEARS +PKG_SUBPKGS:= MESALIB MESALIB_DEV PKGSD_MESALIB_DEV:= MESA headers PKGSC_MESALIB_DEV:= devel -PKGSD_GLXINFO:= Display various GLX information -PKGSC_GLXINFO:= x11/apps -PKGSD_GLXGEARS:= Nice little OpenGL demo application -PKGSC_GLXGEARS:= x11/apps PKG_ARCH_DEPENDS:= x86 x86_64 mips mipsel mips64 mips64el @@ -32,21 +28,22 @@ include $(TOPDIR)/mk/package.mk $(eval $(call PKG_template,MESALIB,mesalib,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION})) $(eval $(call PKG_template,MESALIB_DEV,mesalib-dev,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKGSD_MESALIB_DEV},${PKGSC_MESALIB_DEV})) -$(eval $(call PKG_template,GLXINFO,glxinfo,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKGSD_GLXINFO},${PKGSC_GLXINFO})) -$(eval $(call PKG_template,GLXGEARS,glxgears,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKGSD_GLXGEARS},${PKGSC_GLXGEARS})) TARGET_CFLAGS:= $(filter-out -flto,$(TARGET_CFLAGS)) +XAKE_FLAGS+= GCC_HONOUR_COPTS=s ifeq (${ADK_TARGET_SYSTEM_IBM_X40},y) DRI_DRIVERS:=i915 endif CONFIGURE_ARGS+= --disable-static \ - --disable-gallium \ - --disable-glw \ + --disable-gallium-llvm \ + --with-gallium-drivers=swrast \ --with-driver=dri \ - --with-dri-drivers=${DRI_DRIVERS},swrast \ - --with-demos=xdemos + --disable-gles1 \ + --disable-gles2 \ + --with-dri-drivers=${DRI_DRIVERS},swrast +CONFIGURE_ENV+= PYTHON2=/usr/bin/python XAKE_FLAGS+= HOST_CC=${CC_FOR_BUILD} GLSL_CL=${STAGING_HOST_DIR}/bin/glslcompile ifeq ($(ADK_NATIVE),y) @@ -57,14 +54,15 @@ post-extract: (cd ${WRKBUILD}; rm -rf config.{cache,status}; \ ./configure \ --disable-static \ - --disable-glw \ - --disable-gallium \ + --disable-gallium-llvm \ + --with-gallium-drivers=swrast \ --with-driver=xlib \ ); ${MAKE} -C ${WRKBUILD}/src/glsl - ${MAKE} -C ${WRKBUILD}/src/glsl/apps - ${CP} ${WRKBUILD}/src/glsl/apps/compile \ - ${STAGING_HOST_DIR}/bin/glslcompile + ${CP} ${WRKBUILD}/src/glsl/glsl_compiler \ + ${STAGING_HOST_DIR}/bin/glsl_compiler + ${CP} ${WRKBUILD}/src/glsl/builtin_compiler \ + ${STAGING_HOST_DIR}/bin/builtin_compiler ${MAKE} -C ${WRKBUILD}/src/glsl clean mesalib-install: @@ -78,16 +76,6 @@ ifeq (${ADK_TARGET_SYSTEM_IBM_X40},y) ${IDIR_MESALIB}/usr/lib/dri/ endif -glxinfo-install: - ${INSTALL_DIR} ${IDIR_GLXINFO}/usr/bin - ${INSTALL_BIN} ${WRKBUILD}/progs/xdemos/glxinfo \ - ${IDIR_GLXINFO}/usr/bin/ - -glxgears-install: - ${INSTALL_DIR} ${IDIR_GLXGEARS}/usr/bin - ${INSTALL_BIN} ${WRKBUILD}/progs/xdemos/glxgears \ - ${IDIR_GLXGEARS}/usr/bin/ - mesalib-dev-install: $(INSTALL_DIR) $(IDIR_MESALIB_DEV)/usr/include ${CP} ${WRKINST}/usr/include/* \ diff --git a/package/MesaLib/patches/000-mesalib-xdemos.patch b/package/MesaLib/patches/000-mesalib-xdemos.patch deleted file mode 100644 index 0ebf160e5..000000000 --- a/package/MesaLib/patches/000-mesalib-xdemos.patch +++ /dev/null @@ -1,14774 +0,0 @@ -diff -Naurp Mesa-7.8.1/progs/xdemos/corender.c Mesa-7.8.1.patched/progs/xdemos/corender.c ---- Mesa-7.8.1/progs/xdemos/corender.c 1970-01-01 01:00:00.000000000 +0100 -+++ Mesa-7.8.1.patched/progs/xdemos/corender.c 2010-06-13 13:45:06.789793146 +0200 -@@ -0,0 +1,400 @@ -+/** -+ * Example of cooperative rendering into one window by two processes. -+ * The first instance of the program creates the GLX window. -+ * The second instance of the program gets the window ID from the first -+ * and draws into it. -+ * Socket IPC is used for synchronization. -+ * -+ * Usage: -+ * 1. run 'corender &' -+ * 2. run 'corender 2' (any arg will do) -+ * -+ * Brian Paul -+ * 11 Oct 2007 -+ */ -+ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include "ipc.h" -+ -+ -+#ifndef M_PI -+#define M_PI 3.14159265358979323846 -+#endif -+ -+static int MyID = 0; /* 0 or 1 */ -+static int WindowID = 0; -+static GLXContext Context = 0; -+static int Width = 700, Height = 350; -+static int Rot = 0; -+static int Sock = 0; -+ -+static GLfloat Red[4] = {1.0, 0.2, 0.2, 1.0}; -+static GLfloat Blue[4] = {0.2, 0.2, 1.0, 1.0}; -+ -+static int Sync = 1; /** synchronized rendering? */ -+ -+ -+static void -+setup_ipc(void) -+{ -+ int k, port = 10001; -+ -+ if (MyID == 0) { -+ /* I'm the first one, wait for connection from second */ -+ k = CreatePort(&port); -+ assert(k != -1); -+ -+ printf("Waiting for connection from another 'corender'\n"); -+ Sock = AcceptConnection(k); -+ assert(Sock != -1); -+ -+ printf("Got connection, sending windowID\n"); -+ -+ /* send windowID */ -+ SendData(Sock, &WindowID, sizeof(WindowID)); -+ } -+ else { -+ /* I'm the second one, connect to first */ -+ char hostname[1000]; -+ -+ MyHostName(hostname, 1000); -+ Sock = Connect(hostname, port); -+ assert(Sock != -1); -+ -+ /* get windowID */ -+ ReceiveData(Sock, &WindowID, sizeof(WindowID)); -+ printf("Contacted first 'corender', getting WindowID\n"); -+ } -+} -+ -+ -+ -+/** from GLUT */ -+static void -+doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings) -+{ -+ int i, j; -+ GLfloat theta, phi, theta1; -+ GLfloat cosTheta, sinTheta; -+ GLfloat cosTheta1, sinTheta1; -+ GLfloat ringDelta, sideDelta; -+ -+ ringDelta = 2.0 * M_PI / rings; -+ sideDelta = 2.0 * M_PI / nsides; -+ -+ theta = 0.0; -+ cosTheta = 1.0; -+ sinTheta = 0.0; -+ for (i = rings - 1; i >= 0; i--) { -+ theta1 = theta + ringDelta; -+ cosTheta1 = cos(theta1); -+ sinTheta1 = sin(theta1); -+ glBegin(GL_QUAD_STRIP); -+ phi = 0.0; -+ for (j = nsides; j >= 0; j--) { -+ GLfloat cosPhi, sinPhi, dist; -+ -+ phi += sideDelta; -+ cosPhi = cos(phi); -+ sinPhi = sin(phi); -+ dist = R + r * cosPhi; -+ -+ glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); -+ glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); -+ glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); -+ glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi); -+ } -+ glEnd(); -+ theta = theta1; -+ cosTheta = cosTheta1; -+ sinTheta = sinTheta1; -+ } -+} -+ -+ -+static void -+redraw(Display *dpy) -+{ -+ int dbg = 0; -+ -+ glXMakeCurrent(dpy, WindowID, Context); -+ glEnable(GL_LIGHTING); -+ glEnable(GL_LIGHT0); -+ glEnable(GL_DEPTH_TEST); -+ glClearColor(0.5, 0.5, 0.5, 0.0); -+ -+ if (MyID == 0) { -+ /* First process */ -+ -+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -+ -+ glPushMatrix(); -+ glTranslatef(-1, 0, 0); -+ glRotatef(Rot, 1, 0, 0); -+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Red); -+ doughnut(0.5, 2.0, 20, 30); -+ glPopMatrix(); -+ -+ glFinish(); -+ if (!Sync) { -+ usleep(1000*10); -+ } -+ -+ /* signal second process to render */ -+ if (Sync) { -+ int code = 1; -+ if (dbg) printf("0: send signal\n"); -+ SendData(Sock, &code, sizeof(code)); -+ SendData(Sock, &Rot, sizeof(Rot)); -+ } -+ -+ /* wait for second process to finish rendering */ -+ if (Sync) { -+ int code = 0; -+ if (dbg) printf("0: wait signal\n"); -+ ReceiveData(Sock, &code, sizeof(code)); -+ if (dbg) printf("0: got signal\n"); -+ assert(code == 2); -+ } -+ -+ } -+ else { -+ /* Second process */ -+ -+ /* wait for first process's signal for me to render */ -+ if (Sync) { -+ int code = 0; -+ if (dbg) printf("1: wait signal\n"); -+ ReceiveData(Sock, &code, sizeof(code)); -+ ReceiveData(Sock, &Rot, sizeof(Rot)); -+ -+ if (dbg) printf("1: got signal\n"); -+ assert(code == 1); -+ } -+ -+ /* XXX this clear should not be here, but for some reason, it -+ * makes things _mostly_ work correctly w/ NVIDIA's driver. -+ * There's only occasional glitches. -+ * Without this glClear(), depth buffer for the second process -+ * is pretty much broken. -+ */ -+ /* glClear(GL_DEPTH_BUFFER_BIT); */ -+ -+ glPushMatrix(); -+ glTranslatef(1, 0, 0); -+ glRotatef(Rot + 90 , 1, 0, 0); -+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Blue); -+ doughnut(0.5, 2.0, 20, 30); -+ glPopMatrix(); -+ glFinish(); -+ -+ glXSwapBuffers(dpy, WindowID); -+ usleep(1000*10); -+ -+ /* signal first process that I'm done rendering */ -+ if (Sync) { -+ int code = 2; -+ if (dbg) printf("1: send signal\n"); -+ SendData(Sock, &code, sizeof(code)); -+ } -+ } -+} -+ -+ -+static void -+resize(Display *dpy, int width, int height) -+{ -+ float ar = (float) width / height; -+ -+ glXMakeCurrent(dpy, WindowID, Context); -+ -+ glViewport(0, 0, width, height); -+ glMatrixMode(GL_PROJECTION); -+ glLoadIdentity(); -+ glFrustum(-ar, ar, 1.0, -1.0, 5.0, 200.0); -+ glMatrixMode(GL_MODELVIEW); -+ glLoadIdentity(); -+ glTranslatef(0, 0, -15); -+ -+ Width = width; -+ Height = height; -+} -+ -+ -+ -+static void -+set_window_title(Display *dpy, Window win, const char *title) -+{ -+ XSizeHints sizehints; -+ sizehints.flags = 0; -+ XSetStandardProperties(dpy, win, title, title, -+ None, (char **)NULL, 0, &sizehints); -+} -+ -+ -+static Window -+make_gl_window(Display *dpy, XVisualInfo *visinfo, int width, int height) -+{ -+ int scrnum; -+ XSetWindowAttributes attr; -+ unsigned long mask; -+ Window root; -+ Window win; -+ int x = 0, y = 0; -+ char *name = NULL; -+ -+ scrnum = DefaultScreen( dpy ); -+ root = RootWindow( dpy, scrnum ); -+ -+ /* window attributes */ -+ attr.background_pixel = 0; -+ attr.border_pixel = 0; -+ attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); -+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; -+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; -+ -+ win = XCreateWindow( dpy, root, x, y, width, height, -+ 0, visinfo->depth, InputOutput, -+ visinfo->visual, mask, &attr ); -+ -+ /* set hints and properties */ -+ { -+ XSizeHints sizehints; -+ sizehints.x = x; -+ sizehints.y = y; -+ sizehints.width = width; -+ sizehints.height = height; -+ sizehints.flags = USSize | USPosition; -+ XSetNormalHints(dpy, win, &sizehints); -+ XSetStandardProperties(dpy, win, name, name, -+ None, (char **)NULL, 0, &sizehints); -+ } -+ -+ return win; -+} -+ -+ -+static void -+set_event_mask(Display *dpy, Window win) -+{ -+ XSetWindowAttributes attr; -+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; -+ XChangeWindowAttributes(dpy, win, CWEventMask, &attr); -+} -+ -+ -+static void -+event_loop(Display *dpy) -+{ -+ while (1) { -+ while (XPending(dpy) > 0) { -+ XEvent event; -+ XNextEvent(dpy, &event); -+ -+ switch (event.type) { -+ case Expose: -+ redraw(dpy); -+ break; -+ case ConfigureNotify: -+ resize(dpy, event.xconfigure.width, event.xconfigure.height); -+ break; -+ case KeyPress: -+ { -+ char buffer[10]; -+ int r, code; -+ code = XLookupKeysym(&event.xkey, 0); -+ if (code == XK_Left) { -+ } -+ else { -+ r = XLookupString(&event.xkey, buffer, sizeof(buffer), -+ NULL, NULL); -+ if (buffer[0] == 27) { -+ exit(0); -+ } -+ } -+ } -+ default: -+ /* nothing */ -+ ; -+ } -+ } -+ -+ if (MyID == 0 || !Sync) -+ Rot += 1; -+ redraw(dpy); -+ } -+} -+ -+ -+static XVisualInfo * -+choose_visual(Display *dpy) -+{ -+ int attribs[] = { GLX_RGBA, -+ GLX_RED_SIZE, 1, -+ GLX_GREEN_SIZE, 1, -+ GLX_BLUE_SIZE, 1, -+ GLX_DOUBLEBUFFER, -+ GLX_DEPTH_SIZE, 1, -+ None }; -+ int scrnum = DefaultScreen( dpy ); -+ return glXChooseVisual(dpy, scrnum, attribs); -+} -+ -+ -+static void -+parse_opts(int argc, char *argv[]) -+{ -+ if (argc > 1) { -+ MyID = 1; -+ } -+} -+ -+ -+int -+main( int argc, char *argv[] ) -+{ -+ Display *dpy; -+ XVisualInfo *visinfo; -+ -+ parse_opts(argc, argv); -+ -+ dpy = XOpenDisplay(NULL); -+ -+ visinfo = choose_visual(dpy); -+ -+ Context = glXCreateContext( dpy, visinfo, NULL, True ); -+ if (!Context) { -+ printf("Error: glXCreateContext failed\n"); -+ exit(1); -+ } -+ -+ if (MyID == 0) { -+ WindowID = make_gl_window(dpy, visinfo, Width, Height); -+ set_window_title(dpy, WindowID, "corender"); -+ XMapWindow(dpy, WindowID); -+ /*printf("WindowID 0x%x\n", (int) WindowID);*/ -+ } -+ -+ /* do ipc hand-shake here */ -+ setup_ipc(); -+ assert(Sock); -+ assert(WindowID); -+ -+ if (MyID == 1) { -+ set_event_mask(dpy, WindowID); -+ } -+ -+ resize(dpy, Width, Height); -+ -+ event_loop(dpy); -+ -+ return 0; -+} -diff -Naurp Mesa-7.8.1/progs/xdemos/glsync.c Mesa-7.8.1.patched/progs/xdemos/glsync.c ---- Mesa-7.8.1/progs/xdemos/glsync.c 1970-01-01 01:00:00.000000000 +0100 -+++ Mesa-7.8.1.patched/progs/xdemos/glsync.c 2010-06-13 13:45:06.789793146 +0200 -@@ -0,0 +1,295 @@ -+/* -+ * Copyright © 2007 Intel Corporation -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the "Software"), -+ * to deal in the Software without restriction, including without limitation -+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, -+ * and/or sell copies of the Software, and to permit persons to whom the -+ * Software is furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice (including the next -+ * paragraph) shall be included in all copies or substantial portions of the -+ * Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -+ * IN THE SOFTWARE. -+ * -+ * Authors: -+ * Jesse Barnes -+ * -+ */ -+ -+/** @file glsync.c -+ * The program is simple: it paints a window alternating colors (red & -+ * white) either as fast as possible or synchronized to vblank events -+ * -+ * If run normally, the program should display a window that exhibits -+ * significant tearing between red and white colors (e.g. you might get -+ * a "waterfall" effect of red and white horizontal bars). -+ * -+ * If run with the '-s b' option, the program should synchronize the -+ * window color changes with the vertical blank period, resulting in a -+ * window that looks orangish with a high frequency flicker (which may -+ * be invisible). If the window is moved to another screen, this -+ * property should be preserved. If the window spans two screens, it -+ * shouldn't tear on whichever screen most of the window is on; the -+ * portion on the other screen may show some tearing (like the -+ * waterfall effect above). -+ * -+ * Other options include '-w ' and '-h -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+void (*video_sync_get)(); -+void (*video_sync)(); -+void (*swap_interval)(); -+ -+static int GLXExtensionSupported(Display *dpy, const char *extension) -+{ -+ const char *extensionsString, *pos; -+ -+ extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy)); -+ -+ pos = strstr(extensionsString, extension); -+ -+ if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') && -+ (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0')) -+ return 1; -+ -+ return 0; -+} -+ -+extern char *optarg; -+extern int optind, opterr, optopt; -+static char optstr[] = "w:h:s:vi:"; -+ -+enum sync_type { -+ none = 0, -+ sgi_video_sync, -+ buffer_swap -+}; -+ -+static void usage(char *name) -+{ -+ printf("usage: %s [-w ] [-h ] [-s] " -+ "[-v]\n", name); -+ printf("\t-s:\n"); -+ printf("\t\tn: none\n"); -+ printf("\t\ts: SGI video sync extension\n"); -+ printf("\t\tb: buffer swap\n"); -+ printf("\t-i\n"); -+ printf("\t-v: verbose (print count)\n"); -+ exit(-1); -+} -+ -+int main(int argc, char *argv[]) -+{ -+ Display *disp; -+ XVisualInfo *pvi; -+ XSetWindowAttributes swa; -+ GLint last_val = -1, count = 0; -+ Window winGL; -+ GLXContext context; -+ int dummy; -+ Atom wmDelete; -+ enum sync_type waitforsync = none; -+ int width = 500, height = 500, verbose = 0, interval = 1; -+ int c, i = 1; -+ int ret; -+ int attribs[] = { GLX_RGBA, -+ GLX_RED_SIZE, 1, -+ GLX_GREEN_SIZE, 1, -+ GLX_BLUE_SIZE, 1, -+ None }; -+ int db_attribs[] = { GLX_RGBA, -+ GLX_RED_SIZE, 1, -+ GLX_GREEN_SIZE, 1, -+ GLX_BLUE_SIZE, 1, -+ GLX_DOUBLEBUFFER, -+ GLX_DEPTH_SIZE, 1, -+ None }; -+ XSizeHints sizehints; -+ -+ opterr = 0; -+ while ((c = getopt(argc, argv, optstr)) != -1) { -+ switch (c) { -+ case 'w': -+ width = atoi(optarg); -+ break; -+ case 'h': -+ height = atoi(optarg); -+ break; -+ case 's': -+ switch (optarg[0]) { -+ case 'n': -+ waitforsync = none; -+ break; -+ case 's': -+ waitforsync = sgi_video_sync; -+ break; -+ case 'b': -+ waitforsync = buffer_swap; -+ break; -+ default: -+ usage(argv[0]); -+ break; -+ } -+ break; -+ case 'v': -+ verbose = 1; -+ break; -+ case 'i': -+ interval = atoi(optarg); -+ break; -+ default: -+ usage(argv[0]); -+ break; -+ } -+ } -+ -+ disp = XOpenDisplay(NULL); -+ if (!disp) { -+ fprintf(stderr, "failed to open display\n"); -+ return -1; -+ } -+ -+ if (!glXQueryExtension(disp, &dummy, &dummy)) { -+ fprintf(stderr, "glXQueryExtension failed\n"); -+ return -1; -+ } -+ -+ if (!GLXExtensionSupported(disp, "GLX_SGI_video_sync")) { -+ fprintf(stderr, "GLX_SGI_video_sync not supported, exiting\n"); -+ return -1; -+ } -+ -+ if (waitforsync != buffer_swap) { -+ pvi = glXChooseVisual(disp, DefaultScreen(disp), attribs); -+ } else { -+ pvi = glXChooseVisual(disp, DefaultScreen(disp), db_attribs); -+ } -+ -+ if (!pvi) { -+ fprintf(stderr, "failed to choose visual, exiting\n"); -+ return -1; -+ } -+ -+ pvi->screen = DefaultScreen(disp); -+ -+ swa.colormap = XCreateColormap(disp, RootWindow(disp, pvi->screen), -+ pvi->visual, AllocNone); -+ swa.border_pixel = 0; -+ swa.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | -+ StructureNotifyMask; -+ winGL = XCreateWindow(disp, RootWindow(disp, pvi->screen), -+ 0, 0, -+ width, height, -+ 0, pvi->depth, InputOutput, pvi->visual, -+ CWBorderPixel | CWColormap | CWEventMask, &swa); -+ if (!winGL) { -+ fprintf(stderr, "window creation failed\n"); -+ return -1; -+ } -+ wmDelete = XInternAtom(disp, "WM_DELETE_WINDOW", True); -+ XSetWMProtocols(disp, winGL, &wmDelete, 1); -+ -+ sizehints.x = 0; -+ sizehints.y = 0; -+ sizehints.width = width; -+ sizehints.height = height; -+ sizehints.flags = USSize | USPosition; -+ -+ XSetNormalHints(disp, winGL, &sizehints); -+ XSetStandardProperties(disp, winGL, "glsync test", "glsync text", -+ None, NULL, 0, &sizehints); -+ -+ context = glXCreateContext(disp, pvi, NULL, GL_TRUE); -+ if (!context) { -+ fprintf(stderr, "failed to create glx context\n"); -+ return -1; -+ } -+ -+ XMapWindow(disp, winGL); -+ ret = glXMakeCurrent(disp, winGL, context); -+ if (!ret) { -+ fprintf(stderr, "failed to make context current: %d\n", ret); -+ } -+ -+ video_sync_get = glXGetProcAddress((unsigned char *)"glXGetVideoSyncSGI"); -+ video_sync = glXGetProcAddress((unsigned char *)"glXWaitVideoSyncSGI"); -+ -+ swap_interval = glXGetProcAddress((unsigned char *)"glXSwapIntervalSGI"); -+ -+ if (!video_sync_get || !video_sync || !swap_interval) { -+ fprintf(stderr, "failed to get sync functions\n"); -+ return -1; -+ } -+ -+ if (waitforsync == buffer_swap) { -+ swap_interval(interval); -+ fprintf(stderr, "set swap interval to %d\n", interval); -+ } -+ video_sync_get(&count); -+ count++; -+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -+ while (i++) { -+ /* Alternate colors to make tearing obvious */ -+ if (i & 1) { -+ glClearColor(1.0f, 1.0f, 1.0f, 1.0f); -+ glColor3f(1.0f, 1.0f, 1.0f); -+ } else { -+ glClearColor(1.0f, 0.0f, 0.0f, 0.0f); -+ glColor3f(1.0f, 0.0f, 0.0f); -+ } -+ -+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -+ glRectf(0, 0, width, height); -+ -+ /* Wait for vsync */ -+ if (waitforsync == sgi_video_sync) { -+ if (verbose) -+ fprintf(stderr, "waiting on count %d\n", count); -+ video_sync(2, (count + 1) % 2, &count); -+ if (count < last_val) -+ fprintf(stderr, "error: vblank count went backwards: %d -> %d\n", last_val, count); -+ if (count == last_val) -+ fprintf(stderr, "error: count didn't change: %d\n", count); -+ last_val = count; -+ glFlush(); -+ } else if (waitforsync == buffer_swap) { -+ glXSwapBuffers(disp, winGL); -+ } else { -+ video_sync_get(&count); -+ sleep(1); -+ glFinish(); -+ } -+ -+ if (verbose) { -+ video_sync_get(&count); -+ fprintf(stderr, "current count: %d\n", count); -+ } -+ } -+ -+ XDestroyWindow(disp, winGL); -+ glXDestroyContext(disp, context); -+ XCloseDisplay(disp); -+ -+ return 0; -+} -diff -Naurp Mesa-7.8.1/progs/xdemos/glthreads.c Mesa-7.8.1.patched/progs/xdemos/glthreads.c ---- Mesa-7.8.1/progs/xdemos/glthreads.c 1970-01-01 01:00:00.000000000 +0100 -+++ Mesa-7.8.1.patched/progs/xdemos/glthreads.c 2010-06-13 13:45:06.789793146 +0200 -@@ -0,0 +1,716 @@ -+/* -+ * Copyright (C) 2000 Brian Paul All Rights Reserved. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the "Software"), -+ * to deal in the Software without restriction, including without limitation -+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, -+ * and/or sell copies of the Software, and to permit persons to whom the -+ * Software is furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included -+ * in all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -+ */ -+ -+ -+/* -+ * This program tests GLX thread safety. -+ * Command line options: -+ * -p Open a display connection for each thread -+ * -l Enable application-side locking -+ * -n Number of threads to create (default is 2) -+ * -display Specify X display (default is $DISPLAY) -+ * -t Use texture mapping -+ * -+ * Brian Paul 20 July 2000 -+ */ -+ -+ -+/* -+ * Notes: -+ * - Each thread gets its own GLX context. -+ * -+ * - The GLX contexts share texture objects. -+ * -+ * - When 't' is pressed to update the texture image, the window/thread which -+ * has input focus is signalled to change the texture. The other threads -+ * should see the updated texture the next time they call glBindTexture. -+ */ -+ -+ -+#if defined(PTHREADS) /* defined by Mesa on Linux and other platforms */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+ -+/* -+ * Each window/thread/context: -+ */ -+struct winthread { -+ Display *Dpy; -+ int Index; -+ pthread_t Thread; -+ Window Win; -+ GLXContext Context; -+ float Angle; -+ int WinWidth, WinHeight; -+ GLboolean NewSize; -+ GLboolean Initialized; -+ GLboolean MakeNewTexture; -+}; -+ -+ -+#define MAX_WINTHREADS 100 -+static struct winthread WinThreads[MAX_WINTHREADS]; -+static int NumWinThreads = 0; -+static volatile GLboolean ExitFlag = GL_FALSE; -+ -+static GLboolean MultiDisplays = 0; -+static GLboolean Locking = 0; -+static GLboolean Texture = GL_FALSE; -+static GLuint TexObj = 12; -+static GLboolean Animate = GL_TRUE; -+ -+static pthread_mutex_t Mutex; -+static pthread_cond_t CondVar; -+static pthread_mutex_t CondMutex; -+ -+ -+static void -+Error(const char *msg) -+{ -+ fprintf(stderr, "Error: %s\n", msg); -+ exit(1); -+} -+ -+ -+static void -+signal_redraw(void) -+{ -+ pthread_mutex_lock(&CondMutex); -+ pthread_cond_broadcast(&CondVar); -+ pthread_mutex_unlock(&CondMutex); -+} -+ -+ -+static void -+MakeNewTexture(struct winthread *wt) -+{ -+#define TEX_SIZE 128 -+ static float step = 0.0; -+ GLfloat image[TEX_SIZE][TEX_SIZE][4]; -+ GLint width; -+ int i, j; -+ -+ for (j = 0; j < TEX_SIZE; j++) { -+ for (i = 0; i < TEX_SIZE; i++) { -+ float dt = 5.0 * (j - 0.5 * TEX_SIZE) / TEX_SIZE; -+ float ds = 5.0 * (i - 0.5 * TEX_SIZE) / TEX_SIZE; -+ float r = dt * dt + ds * ds + step; -+ image[j][i][0] = -+ image[j][i][1] = -+ image[j][i][2] = 0.75 + 0.25 * cos(r); -+ image[j][i][3] = 1.0; -+ } -+ } -+ -+ step += 0.5; -+ -+ glBindTexture(GL_TEXTURE_2D, TexObj); -+ -+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); -+ if (width) { -+ assert(width == TEX_SIZE); -+ /* sub-tex replace */ -+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEX_SIZE, TEX_SIZE, -+ GL_RGBA, GL_FLOAT, image); -+ } -+ else { -+ /* create new */ -+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); -+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -+ -+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_SIZE, TEX_SIZE, 0, -+ GL_RGBA, GL_FLOAT, image); -+ } -+} -+ -+ -+ -+/* draw a colored cube */ -+static void -+draw_object(void) -+{ -+ glPushMatrix(); -+ glScalef(0.75, 0.75, 0.75); -+ -+ glColor3f(1, 0, 0); -+ -+ if (Texture) { -+ glBindTexture(GL_TEXTURE_2D, TexObj); -+ glEnable(GL_TEXTURE_2D); -+ } -+ else { -+ glDisable(GL_TEXTURE_2D); -+ } -+ -+ glBegin(GL_QUADS); -+ -+ /* -X */ -+ glColor3f(0, 1, 1); -+ glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); -+ glTexCoord2f(1, 0); glVertex3f(-1, 1, -1); -+ glTexCoord2f(1, 1); glVertex3f(-1, 1, 1); -+ glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); -+ -+ /* +X */ -+ glColor3f(1, 0, 0); -+ glTexCoord2f(0, 0); glVertex3f(1, -1, -1); -+ glTexCoord2f(1, 0); glVertex3f(1, 1, -1); -+ glTexCoord2f(1, 1); glVertex3f(1, 1, 1); -+ glTexCoord2f(0, 1); glVertex3f(1, -1, 1); -+ -+ /* -Y */ -+ glColor3f(1, 0, 1); -+ glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); -+ glTexCoord2f(1, 0); glVertex3f( 1, -1, -1); -+ glTexCoord2f(1, 1); glVertex3f( 1, -1, 1); -+ glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); -+ -+ /* +Y */ -+ glColor3f(0, 1, 0); -+ glTexCoord2f(0, 0); glVertex3f(-1, 1, -1); -+ glTexCoord2f(1, 0); glVertex3f( 1, 1, -1); -+ glTexCoord2f(1, 1); glVertex3f( 1, 1, 1); -+ glTexCoord2f(0, 1); glVertex3f(-1, 1, 1); -+ -+ /* -Z */ -+ glColor3f(1, 1, 0); -+ glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); -+ glTexCoord2f(1, 0); glVertex3f( 1, -1, -1); -+ glTexCoord2f(1, 1); glVertex3f( 1, 1, -1); -+ glTexCoord2f(0, 1); glVertex3f(-1, 1, -1); -+ -+ /* +Y */ -+ glColor3f(0, 0, 1); -+ glTexCoord2f(0, 0); glVertex3f(-1, -1, 1); -+ glTexCoord2f(1, 0); glVertex3f( 1, -1, 1); -+ glTexCoord2f(1, 1); glVertex3f( 1, 1, 1); -+ glTexCoord2f(0, 1); glVertex3f(-1, 1, 1); -+ -+ glEnd(); -+ -+ glPopMatrix(); -+} -+ -+ -+/* signal resize of given window */ -+static void -+resize(struct winthread *wt, int w, int h) -+{ -+ wt->NewSize = GL_TRUE; -+ wt->WinWidth = w; -+ wt->WinHeight = h; -+ if (!Animate) -+ signal_redraw(); -+} -+ -+ -+/* -+ * We have an instance of this for each thread. -+ */ -+static void -+draw_loop(struct winthread *wt) -+{ -+ while (!ExitFlag) { -+ -+ if (Locking) -+ pthread_mutex_lock(&Mutex); -+ -+ glXMakeCurrent(wt->Dpy, wt->Win, wt->Context); -+ if (!wt->Initialized) { -+ printf("glthreads: %d: GL_RENDERER = %s\n", wt->Index, -+ (char *) glGetString(GL_RENDERER)); -+ if (Texture /*&& wt->Index == 0*/) { -+ MakeNewTexture(wt); -+ } -+ wt->Initialized = GL_TRUE; -+ } -+ -+ if (Locking) -+ pthread_mutex_unlock(&Mutex); -+ -+ glEnable(GL_DEPTH_TEST); -+ -+ if (wt->NewSize) { -+ GLfloat w = (float) wt->WinWidth / (float) wt->WinHeight; -+ glViewport(0, 0, wt->WinWidth, wt->WinHeight); -+ glMatrixMode(GL_PROJECTION); -+ glLoadIdentity(); -+ glFrustum(-w, w, -1.0, 1.0, 1.5, 10); -+ glMatrixMode(GL_MODELVIEW); -+ glLoadIdentity(); -+ glTranslatef(0, 0, -2.5); -+ wt->NewSize = GL_FALSE; -+ } -+ -+ if (wt->MakeNewTexture) { -+ MakeNewTexture(wt); -+ wt->MakeNewTexture = GL_FALSE; -+ } -+ -+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -+ -+ glPushMatrix(); -+ glRotatef(wt->Angle, 0, 1, 0); -+ glRotatef(wt->Angle, 1, 0, 0); -+ glScalef(0.7, 0.7, 0.7); -+ draw_object(); -+ glPopMatrix(); -+ -+ if (Locking) -+ pthread_mutex_lock(&Mutex); -+ -+ glXSwapBuffers(wt->Dpy, wt->Win); -+ -+ if (Locking) -+ pthread_mutex_unlock(&Mutex); -+ -+ if (Animate) { -+ usleep(5000); -+ } -+ else { -+ /* wait for signal to draw */ -+ pthread_mutex_lock(&CondMutex); -+ pthread_cond_wait(&CondVar, &CondMutex); -+ pthread_mutex_unlock(&CondMutex); -+ } -+ wt->Angle += 1.0; -+ } -+} -+ -+ -+static void -+keypress(XEvent *event, struct winthread *wt) -+{ -+ char buf[100]; -+ KeySym keySym; -+ XComposeStatus stat; -+ -+ XLookupString(&event->xkey, buf, sizeof(buf), &keySym, &stat); -+ -+ switch (keySym) { -+ case XK_Escape: -+ /* tell all threads to exit */ -+ if (!Animate) { -+ signal_redraw(); -+ } -+ ExitFlag = GL_TRUE; -+ /*printf("exit draw_loop %d\n", wt->Index);*/ -+ return; -+ case XK_t: -+ case XK_T: -+ if (Texture) { -+ wt->MakeNewTexture = GL_TRUE; -+ if (!Animate) -+ signal_redraw(); -+ } -+ break; -+ case XK_a: -+ case XK_A: -+ Animate = !Animate; -+ if (Animate) /* yes, prev Animate state! */ -+ signal_redraw(); -+ break; -+ case XK_s: -+ case XK_S: -+ if (!Animate) -+ signal_redraw(); -+ break; -+ default: -+ ; /* nop */ -+ } -+} -+ -+ -+/* -+ * The main process thread runs this loop. -+ * Single display connection for all threads. -+ */ -+static void -+event_loop(Display *dpy) -+{ -+ XEvent event; -+ int i; -+ -+ assert(!MultiDisplays); -+ -+ while (!ExitFlag) { -+ -+ if (Locking) { -+ while (1) { -+ int k; -+ pthread_mutex_lock(&Mutex); -+ k = XPending(dpy); -+ if (k) { -+ XNextEvent(dpy, &event); -+ pthread_mutex_unlock(&Mutex); -+ break; -+ } -+ pthread_mutex_unlock(&Mutex); -+ usleep(5000); -+ } -+ } -+ else { -+ XNextEvent(dpy, &event); -+ } -+ -+ switch (event.type) { -+ case ConfigureNotify: -+ /* Find winthread for this event's window */ -+ for (i = 0; i < NumWinThreads; i++) { -+ struct winthread *wt = &WinThreads[i]; -+ if (event.xconfigure.window == wt->Win) { -+ resize(wt, event.xconfigure.width, -+ event.xconfigure.height); -+ break; -+ } -+ } -+ break; -+ case KeyPress: -+ for (i = 0; i < NumWinThreads; i++) { -+ struct winthread *wt = &WinThreads[i]; -+ if (event.xkey.window == wt->Win) { -+ keypress(&event, wt); -+ break; -+ } -+ } -+ break; -+ default: -+ /*no-op*/ ; -+ } -+ } -+} -+ -+ -+/* -+ * Separate display connection for each thread. -+ */ -+static void -+event_loop_multi(void) -+{ -+ XEvent event; -+ int w = 0; -+ -+ assert(MultiDisplays); -+ -+ while (!ExitFlag) { -+ struct winthread *wt = &WinThreads[w]; -+ if (XPending(wt->Dpy)) { -+ XNextEvent(wt->Dpy, &event); -+ switch (event.type) { -+ case ConfigureNotify: -+ resize(wt, event.xconfigure.width, event.xconfigure.height); -+ break; -+ case KeyPress: -+ keypress(&event, wt); -+ break; -+ default: -+ ; /* nop */ -+ } -+ } -+ w = (w + 1) % NumWinThreads; -+ usleep(5000); -+ } -+} -+ -+ -+ -+/* -+ * we'll call this once for each thread, before the threads are created. -+ */ -+static void -+create_window(struct winthread *wt, GLXContext shareCtx) -+{ -+ Window win; -+ GLXContext ctx; -+ int attrib[] = { GLX_RGBA, -+ GLX_RED_SIZE, 1, -+ GLX_GREEN_SIZE, 1, -+ GLX_BLUE_SIZE, 1, -+ GLX_DEPTH_SIZE, 1, -+ GLX_DOUBLEBUFFER, -+ None }; -+ int scrnum; -+ XSetWindowAttributes attr; -+ unsigned long mask; -+ Window root; -+ XVisualInfo *visinfo; -+ int width = 160, height = 160; -+ int xpos = (wt->Index % 8) * (width + 10); -+ int ypos = (wt->Index / 8) * (width + 20); -+ -+ scrnum = DefaultScreen(wt->Dpy); -+ root = RootWindow(wt->Dpy, scrnum); -+ -+ visinfo = glXChooseVisual(wt->Dpy, scrnum, attrib); -+ if (!visinfo) { -+ Error("Unable to find RGB, Z, double-buffered visual"); -+ } -+ -+ /* window attributes */ -+ attr.background_pixel = 0; -+ attr.border_pixel = 0; -+ attr.colormap = XCreateColormap(wt->Dpy, root, visinfo->visual, AllocNone); -+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; -+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; -+ -+ win = XCreateWindow(wt->Dpy, root, xpos, ypos, width, height, -+ 0, visinfo->depth, InputOutput, -+ visinfo->visual, mask, &attr); -+ if (!win) { -+ Error("Couldn't create window"); -+ } -+ -+ { -+ XSizeHints sizehints; -+ sizehints.x = xpos; -+ sizehints.y = ypos; -+ sizehints.width = width; -+ sizehints.height = height; -+ sizehints.flags = USSize | USPosition; -+ XSetNormalHints(wt->Dpy, win, &sizehints); -+ XSetStandardProperties(wt->Dpy, win, "glthreads", "glthreads", -+ None, (char **)NULL, 0, &sizehints); -+ } -+ -+ -+ ctx = glXCreateContext(wt->Dpy, visinfo, shareCtx, True); -+ if (!ctx) { -+ Error("Couldn't create GLX context"); -+ } -+ -+ XMapWindow(wt->Dpy, win); -+ XSync(wt->Dpy, 0); -+ -+ /* save the info for this window/context */ -+ wt->Win = win; -+ wt->Context = ctx; -+ wt->Angle = 0.0; -+ wt->WinWidth = width; -+ wt->WinHeight = height; -+ wt->NewSize = GL_TRUE; -+} -+ -+ -+/* -+ * Called by pthread_create() -+ */ -+static void * -+thread_function(void *p) -+{ -+ struct winthread *wt = (struct winthread *) p; -+ draw_loop(wt); -+ return NULL; -+} -+ -+ -+/* -+ * called before exit to wait for all threads to finish -+ */ -+static void -+clean_up(void) -+{ -+ int i; -+ -+ /* wait for threads to finish */ -+ for (i = 0; i < NumWinThreads; i++) { -+ pthread_join(WinThreads[i].Thread, NULL); -+ } -+ -+ for (i = 0; i < NumWinThreads; i++) { -+ glXDestroyContext(WinThreads[i].Dpy, WinThreads[i].Context); -+ XDestroyWindow(WinThreads[i].Dpy, WinThreads[i].Win); -+ } -+} -+ -+ -+static void -+usage(void) -+{ -+ printf("glthreads: test of GL thread safety (any key = exit)\n"); -+ printf("Usage:\n"); -+ printf(" glthreads [options]\n"); -+ printf("Options:\n"); -+ printf(" -display DISPLAYNAME Specify display string\n"); -+ printf(" -n NUMTHREADS Number of threads to create\n"); -+ printf(" -p Use a separate display connection for each thread\n"); -+ printf(" -l Use application-side locking\n"); -+ printf(" -t Enable texturing\n"); -+ printf("Keyboard:\n"); -+ printf(" Esc Exit\n"); -+ printf(" t Change texture image (requires -t option)\n"); -+ printf(" a Toggle animation\n"); -+ printf(" s Step rotation (when not animating)\n"); -+} -+ -+ -+int -+main(int argc, char *argv[]) -+{ -+ char *displayName = NULL; -+ int numThreads = 2; -+ Display *dpy = NULL; -+ int i; -+ Status threadStat; -+ -+ if (argc == 1) { -+ usage(); -+ } -+ else { -+ int i; -+ for (i = 1; i < argc; i++) { -+ if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) { -+ displayName = argv[i + 1]; -+ i++; -+ } -+ else if (strcmp(argv[i], "-p") == 0) { -+ MultiDisplays = 1; -+ } -+ else if (strcmp(argv[i], "-l") == 0) { -+ Locking = 1; -+ } -+ else if (strcmp(argv[i], "-t") == 0) { -+ Texture = 1; -+ } -+ else if (strcmp(argv[i], "-n") == 0 && i + 1 < argc) { -+ numThreads = atoi(argv[i + 1]); -+ if (numThreads < 1) -+ numThreads = 1; -+ else if (numThreads > MAX_WINTHREADS) -+ numThreads = MAX_WINTHREADS; -+ i++; -+ } -+ else { -+ usage(); -+ exit(1); -+ } -+ } -+ } -+ -+ if (Locking) -+ printf("glthreads: Using explicit locks around Xlib calls.\n"); -+ else -+ printf("glthreads: No explict locking.\n"); -+ -+ if (MultiDisplays) -+ printf("glthreads: Per-thread display connections.\n"); -+ else -+ printf("glthreads: Single display connection.\n"); -+ -+ /* -+ * VERY IMPORTANT: call XInitThreads() before any other Xlib functions. -+ */ -+ if (!MultiDisplays) { -+ if (!Locking) { -+ threadStat = XInitThreads(); -+ if (threadStat) { -+ printf("XInitThreads() returned %d (success)\n", (int) threadStat); -+ } -+ else { -+ printf("XInitThreads() returned 0 (failure- this program may fail)\n"); -+ } -+ } -+ -+ dpy = XOpenDisplay(displayName); -+ if (!dpy) { -+ fprintf(stderr, "Unable to open display %s\n", XDisplayName(displayName)); -+ return -1; -+ } -+ } -+ -+ pthread_mutex_init(&Mutex, NULL); -+ pthread_mutex_init(&CondMutex, NULL); -+ pthread_cond_init(&CondVar, NULL); -+ -+ printf("glthreads: creating windows\n"); -+ -+ NumWinThreads = numThreads; -+ -+ /* Create the GLX windows and contexts */ -+ for (i = 0; i < numThreads; i++) { -+ GLXContext share; -+ -+ if (MultiDisplays) { -+ WinThreads[i].Dpy = XOpenDisplay(displayName); -+ assert(WinThreads[i].Dpy); -+ } -+ else { -+ WinThreads[i].Dpy = dpy; -+ } -+ WinThreads[i].Index = i; -+ WinThreads[i].Initialized = GL_FALSE; -+ -+ share = (Texture && i > 0) ? WinThreads[0].Context : 0; -+ -+ create_window(&WinThreads[i], share); -+ } -+ -+ printf("glthreads: creating threads\n"); -+ -+ /* Create the threads */ -+ for (i = 0; i < numThreads; i++) { -+ pthread_create(&WinThreads[i].Thread, NULL, thread_function, -+ (void*) &WinThreads[i]); -+ printf("glthreads: Created thread %p\n", (void *) WinThreads[i].Thread); -+ } -+ -+ if (MultiDisplays) -+ event_loop_multi(); -+ else -+ event_loop(dpy); -+ -+ clean_up(); -+ -+ if (MultiDisplays) { -+ for (i = 0; i < numThreads; i++) { -+ XCloseDisplay(WinThreads[i].Dpy); -+ } -+ } -+ else { -+ XCloseDisplay(dpy); -+ } -+ -+ return 0; -+} -+ -+ -+#else /* PTHREADS */ -+ -+ -+#include -+ -+int -+main(int argc, char *argv[]) -+{ -+ printf("Sorry, this program wasn't compiled with PTHREADS defined.\n"); -+ return 0; -+} -+ -+ -+#endif /* PTHREADS */ -diff -Naurp Mesa-7.8.1/progs/xdemos/glxcontexts.c Mesa-7.8.1.patched/progs/xdemos/glxcontexts.c ---- Mesa-7.8.1/progs/xdemos/glxcontexts.c 1970-01-01 01:00:00.000000000 +0100 -+++ Mesa-7.8.1.patched/progs/xdemos/glxcontexts.c 2010-06-13 13:45:06.789793146 +0200 -@@ -0,0 +1,548 @@ -+/* -+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the "Software"), -+ * to deal in the Software without restriction, including without limitation -+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, -+ * and/or sell copies of the Software, and to permit persons to whom the -+ * Software is furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included -+ * in all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -+ */ -+ -+/* -+ * Version of glxgears that creates/destroys the rendering context for each -+ * frame. Also periodically destroy/recreate the window. -+ * Good for finding memory leaks, etc. -+ * -+ * Command line options: -+ * -info print GL implementation information -+ * -+ */ -+ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+ -+#define BENCHMARK -+ -+#ifdef BENCHMARK -+ -+/* XXX this probably isn't very portable */ -+ -+#include -+#include -+ -+/* return current time (in seconds) */ -+static double -+current_time(void) -+{ -+ struct timeval tv; -+#ifdef __VMS -+ (void) gettimeofday(&tv, NULL ); -+#else -+ struct timezone tz; -+ (void) gettimeofday(&tv, &tz); -+#endif -+ return (double) tv.tv_sec + tv.tv_usec / 1000000.0; -+} -+ -+#else /*BENCHMARK*/ -+ -+/* dummy */ -+static double -+current_time(void) -+{ -+ /* update this function for other platforms! */ -+ static double t = 0.0; -+ static int warn = 1; -+ if (warn) { -+ fprintf(stderr, "Warning: current_time() not implemented!!\n"); -+ warn = 0; -+ } -+ return t += 1.0; -+} -+ -+#endif /*BENCHMARK*/ -+ -+ -+ -+#ifndef M_PI -+#define M_PI 3.14159265 -+#endif -+ -+ -+static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; -+static GLint gear1, gear2, gear3; -+static GLfloat angle = 0.0; -+ -+static XVisualInfo *visinfo = NULL; -+static int WinWidth = 300, WinHeight = 300; -+ -+ -+/* -+ * -+ * Draw a gear wheel. You'll probably want to call this function when -+ * building a display list since we do a lot of trig here. -+ * -+ * Input: inner_radius - radius of hole at center -+ * outer_radius - radius at center of teeth -+ * width - width of gear -+ * teeth - number of teeth -+ * tooth_depth - depth of tooth -+ */ -+static void -+gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, -+ GLint teeth, GLfloat tooth_depth) -+{ -+ GLint i; -+ GLfloat r0, r1, r2; -+ GLfloat angle, da; -+ GLfloat u, v, len; -+ -+ r0 = inner_radius; -+ r1 = outer_radius - tooth_depth / 2.0; -+ r2 = outer_radius + tooth_depth / 2.0; -+ -+ da = 2.0 * M_PI / teeth / 4.0; -+ -+ glShadeModel(GL_FLAT); -+ -+ glNormal3f(0.0, 0.0, 1.0); -+ -+ /* draw front face */ -+ glBegin(GL_QUAD_STRIP); -+ for (i = 0; i <= teeth; i++) { -+ angle = i * 2.0 * M_PI / teeth; -+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); -+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); -+ if (i < teeth) { -+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); -+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -+ width * 0.5); -+ } -+ } -+ glEnd(); -+ -+ /* draw front sides of teeth */ -+ glBegin(GL_QUADS); -+ da = 2.0 * M_PI / teeth / 4.0; -+ for (i = 0; i < teeth; i++) { -+ angle = i * 2.0 * M_PI / teeth; -+ -+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); -+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); -+ glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -+ width * 0.5); -+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -+ width * 0.5); -+ } -+ glEnd(); -+ -+ glNormal3f(0.0, 0.0, -1.0); -+ -+ /* draw back face */ -+ glBegin(GL_QUAD_STRIP); -+ for (i = 0; i <= teeth; i++) { -+ angle = i * 2.0 * M_PI / teeth;