diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2010-06-20 21:14:22 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2010-06-20 21:14:22 +0200 |
commit | 7695ce447acb41050295fd205e14ba55c378cdd2 (patch) | |
tree | 08ae0b84457071688c45f72a49150c4807006c33 /package | |
parent | 9cef6f4deb8f736d63bb41dc7e34793ad60db482 (diff) | |
parent | 19d35b947f30b2b3ac98ff039832ae46df7fee8c (diff) |
Merge branch 'upstream'
Diffstat (limited to 'package')
38 files changed, 15382 insertions, 25 deletions
diff --git a/package/Config.in b/package/Config.in index 2f7aecaa4..8922d7900 100644 --- a/package/Config.in +++ b/package/Config.in @@ -174,6 +174,8 @@ source "package/cxxtools/Config.in" source "package/dbus/Config.in" source "package/dbus-glib/Config.in" source "package/dbus-glib/Config.in.lib" +source "package/DirectFB/Config.in" +source "package/DirectFB/Config.in.lib" source "package/e2fsprogs/Config.in.lib" source "package/fltk/Config.in" source "package/fltk/Config.in.lib" @@ -184,6 +186,7 @@ source "package/glib/Config.in" source "package/gtk+/Config.in" source "package/heimdal/Config.in.lib" source "package/id3lib/Config.in" +source "package/imlib2/Config.in" source "package/libao/Config.in" source "package/libao/Config.in.lib" source "package/libaudiofile/Config.in" @@ -627,12 +630,16 @@ menu "X applications" source "package/dillo/Config.in" source "package/evilwm/Config.in" source "package/firefox/Config.in" +source "package/fluxbox/Config.in" source "package/font-util/Config.in" +source "package/qingy/Config.in" source "package/rxvt-unicode/Config.in" source "package/twm/Config.in" source "package/xauth/Config.in" source "package/xinit/Config.in" source "package/xlsfonts/Config.in" +source "package/xterm/Config.in" +source "package/xvinfo/Config.in" endmenu menu "X fonts" @@ -690,6 +697,8 @@ source "package/libXpm/Config.in" source "package/libXpm/Config.in.lib" source "package/libXrender/Config.in" source "package/libXrender/Config.in.lib" +source "package/libXScrnSaver/Config.in" +source "package/libXScrnSaver/Config.in.lib" source "package/libXt/Config.in" source "package/libXt/Config.in.lib" source "package/libXft/Config.in" diff --git a/package/DirectFB/Makefile b/package/DirectFB/Makefile new file mode 100644 index 000000000..e6da5984a --- /dev/null +++ b/package/DirectFB/Makefile @@ -0,0 +1,55 @@ +# This file is part of the OpenADK project. OpenADK is copyrighted +# material, please see the LICENCE file in the top-level directory. + +include $(TOPDIR)/rules.mk + +PKG_NAME:= DirectFB +PKG_VERSION:= 1.4.3 +PKG_RELEASE:= 1 +PKG_MD5SUM:= 223e036da906ceb4bd44708026839ff1 +PKG_DESCR:= Thin library on top of the Linux framebuffer devices +PKG_SECTION:= libs +PKG_BUILDDEP:= libpng +PKG_DEPENDS:= libpng +PKG_URL:= http://www.directfb.org/ +PKG_SITES:= http://directfb.org/downloads/Core/DirectFB-1.4/ + +include $(TOPDIR)/mk/package.mk + +$(eval $(call PKG_template,DIRECTFB,$(PKG_NAME),$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION})) + +CONFIGURE_ARGS+= --with-inputdrivers=linuxinput,keyboard,ps2mouse \ + --with-gfxdrivers=none \ + --disable-osx + +# This is to overcome libtool fuckup - when building without, +# libtool calls (the correct) ld directly without parameters, +# which then chooses the wrong default emulation (which is +# probably the real problem here). LDEMULATION overrides ld's +# wrong choice. +ifeq (${ADK_LINUX_MIPS64_LEMOTE},y) +XAKE_FLAGS+= LDEMULATION=elf64ltsmip +endif + +post-install: + ${INSTALL_DIR} ${IDIR_DIRECTFB}/etc + ${INSTALL_DATA} ./files/directfbrc ${IDIR_DIRECTFB}/etc/ + $(INSTALL_DIR) $(IDIR_DIRECTFB)/usr/lib/directfb-1.4-0/{inputdrivers,systems,wm} + ${CP} $(WRKINST)/usr/lib/lib{direct,fusion}*.so* \ + $(IDIR_DIRECTFB)/usr/lib/ + ${CP} ${WRKINST}/usr/lib/directfb-1.4-0/inputdrivers/libdirectfb_linux_input.so \ + ${IDIR_DIRECTFB}/usr/lib/directfb-1.4-0/inputdrivers/ + ${CP} ${WRKINST}/usr/lib/directfb-1.4-0/systems/*.so \ + ${IDIR_DIRECTFB}/usr/lib/directfb-1.4-0/systems/ + ${CP} ${WRKINST}/usr/lib/directfb-1.4-0/wm/*.so \ + ${IDIR_DIRECTFB}/usr/lib/directfb-1.4-0/wm/ + $(INSTALL_DIR) $(IDIR_DIRECTFB)/usr/lib/directfb-1.4-0/interfaces/IDirectFB{Font,ImageProvider,VideoProvider} + ${CP} ${WRKINST}/usr/lib/directfb-1.4-0/interfaces/IDirectFBFont/*.so \ + ${IDIR_DIRECTFB}/usr/lib/directfb-1.4-0/interfaces/IDirectFBFont/ + ${CP} ${WRKINST}/usr/lib/directfb-1.4-0/interfaces/IDirectFBImageProvider/*.so \ + ${IDIR_DIRECTFB}/usr/lib/directfb-1.4-0/interfaces/IDirectFBImageProvider/ + ${CP} ${WRKINST}/usr/lib/directfb-1.4-0/interfaces/IDirectFBVideoProvider/*.so \ + ${IDIR_DIRECTFB}/usr/lib/directfb-1.4-0/interfaces/IDirectFBVideoProvider/ + + +include ${TOPDIR}/mk/pkg-bottom.mk diff --git a/package/DirectFB/files/DirectFB.conffiles b/package/DirectFB/files/DirectFB.conffiles new file mode 100644 index 000000000..d4d8e0024 --- /dev/null +++ b/package/DirectFB/files/DirectFB.conffiles @@ -0,0 +1 @@ +/etc/directfbrc diff --git a/package/DirectFB/files/directfbrc b/package/DirectFB/files/directfbrc new file mode 100644 index 000000000..c0e563e86 --- /dev/null +++ b/package/DirectFB/files/directfbrc @@ -0,0 +1,4 @@ +#mode=1024x600 +#depth=16 +mouse-protocol=IMPS/2 +mouse-source=/dev/psaux diff --git a/package/MesaLib/Makefile b/package/MesaLib/Makefile index 0a4ff3b9a..043034947 100644 --- a/package/MesaLib/Makefile +++ b/package/MesaLib/Makefile @@ -15,6 +15,11 @@ PKG_BUILDDEP+= dri2proto glproto expat PKG_URL:= http://www.mesa3d.org/ PKG_SITES:= ftp://ftp.freedesktop.org/pub/mesa/7.8.1/ +PKG_DESCR_GLXINFO:= Display various GLX information +PKG_SECT_GLXINFO:= x11 +PKG_DESCR_GLXGEARS:= Nice little OpenGL demo application +PKG_SECT_GLXGEARS:= x11 + WRKDIST= ${WRKDIR}/Mesa-${PKG_VERSION} PKG_TARGET_DEPENDS:= ibmx40 lemote @@ -22,13 +27,26 @@ PKG_TARGET_DEPENDS:= ibmx40 lemote 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,GLXINFO,glxinfo,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR_GLXINFO},${PKG_SECT_GLXINFO})) +$(eval $(call PKG_template,GLXGEARS,glxgears,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR_GLXGEARS},${PKG_SECT_GLXGEARS})) + +ifeq (${ADK_LINUX_X86_IBMX40},y) +DRI_DRIVERS:=i810 +endif + +# Lemote's SMI712 is not directly supported by Mesa, +# and at least some SIS driver fails to build when +# keeping the driver auto-selection intact. +ifeq (${ADK_LINUX_MIPS64_LEMOTE},y) +DRI_DRIVERS:=swrast +endif CONFIGURE_ARGS+= --disable-static \ --disable-gallium \ --disable-glw \ --with-driver=dri \ - --with-dri-drivers=i810 \ - --without-demos + --with-dri-drivers=${DRI_DRIVERS} \ + --with-demos=xdemos XAKE_FLAGS+= APP_CC=${HOSTCC} HOST_CC=${HOSTCC} @@ -39,17 +57,27 @@ pre-configure: --disable-glw \ --disable-gallium \ --with-driver=xlib \ - --without-demos \ + --with-demos=xdemos \ ); ${MAKE} -C ${WRKBUILD}/src/glsl ${MAKE} -C ${WRKBUILD}/src/glsl/apps - cp ${WRKBUILD}/src/glsl/apps/compile \ + ${CP} ${WRKBUILD}/src/glsl/apps/compile \ ${STAGING_TOOLS}/bin ${MAKE} -C ${WRKBUILD}/src/glsl clean post-install: - $(INSTALL_DIR) $(IDIR_MESALIB)/usr/lib + $(INSTALL_DIR) $(IDIR_MESALIB)/usr/lib/dri $(CP) $(WRKINST)/usr/lib/libGL*.so* \ $(IDIR_MESALIB)/usr/lib +ifeq (${ADK_LINUX_MIPS64_LEMOTE},y) + ${CP} $(WRKINST)/usr/lib/dri/swrast_dri.so \ + ${IDIR_MESALIB}/usr/lib/dri/ +endif + ${INSTALL_DIR} ${IDIR_GLXINFO}/usr/bin + ${INSTALL_BIN} ${WRKBUILD}/progs/xdemos/glxinfo \ + ${IDIR_GLXINFO}/usr/bin/ + ${INSTALL_DIR} ${IDIR_GLXGEARS}/usr/bin + ${INSTALL_BIN} ${WRKBUILD}/progs/xdemos/glxgears \ + ${IDIR_GLXGEARS}/usr/bin/ include ${TOPDIR}/mk/pkg-bottom.mk diff --git a/package/MesaLib/patches/000-mesalib-xdemos.patch b/package/MesaLib/patches/000-mesalib-xdemos.patch new file mode 100644 index 000000000..866e68c2e --- /dev/null +++ b/package/MesaLib/patches/000-mesalib-xdemos.patch @@ -0,0 +1,14774 @@ +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 <GL/gl.h> ++#include <GL/glx.h> ++#include <assert.h> ++#include <math.h> ++#include <stdio.h> ++#include <stdlib.h> ++#include <X11/keysym.h> ++#include <unistd.h> ++#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 <jesse.barnes@intel.com> ++ * ++ */ ++ ++/** @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 <width>' and '-h <height' to set the ++ * window size. ++ */ ++#include <stdio.h> ++#include <stdlib.h> ++#include <string.h> ++#include <unistd.h> ++#include <GL/gl.h> ++#include <GL/glu.h> ++#include <GL/glx.h> ++#include <GL/glxext.h> ++#include <X11/X.h> ++#include <X11/Xlib.h> ++#include <X11/Xutil.h> ++ ++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 <width>] [-h <height>] [-s<sync method>] " ++ "[-v]\n", name); ++ printf("\t-s<sync method>:\n"); ++ printf("\t\tn: none\n"); ++ printf("\t\ts: SGI video sync extension\n"); ++ printf("\t\tb: buffer swap\n"); ++ printf("\t-i<swap interval>\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, |