]> git.cworth.org Git - fips/blobdiff - test/glx-dlopen-dlsym.c
test: Reduce code duplication in test-suite programs
[fips] / test / glx-dlopen-dlsym.c
index b4f8c3e7f9ac7afc9c2901bc2a1d8cee28b724e7..a2a6f5dcfd5eb2ac030646e0d42238faf8b2b4f8 100644 (file)
@@ -48,98 +48,8 @@ void (*my_glXDestroyContext) (Display *, GLXContext);
 Bool (*my_glXMakeCurrent) (Display *, GLXDrawable, GLXContext);
 void (*my_glXSwapBuffers) (Display *, GLXDrawable);
 
-static void
-set_2d_projection (int width, int height)
-{
-       my_glMatrixMode (GL_PROJECTION);
-       my_glLoadIdentity ();
-       my_glOrtho (0, width, height, 0, 0, 1);
-       my_glMatrixMode (GL_MODELVIEW);
-}
-
-static void
-paint_rgb_using_clear (double r, double g, double b)
-{
-        my_glClearColor(r, g, b, 1.0);
-        my_glClear(GL_COLOR_BUFFER_BIT);
-}
-
-static void
-draw (Display *dpy, Window window, int width, int height)
-{
-       int i;
-        int visual_attr[] = {
-                GLX_RGBA,
-                GLX_RED_SIZE,          8,
-                GLX_GREEN_SIZE,        8,
-                GLX_BLUE_SIZE,         8,
-                GLX_ALPHA_SIZE,        8,
-                GLX_DOUBLEBUFFER,
-                GLX_DEPTH_SIZE,                24,
-                GLX_STENCIL_SIZE,      8,
-                GLX_X_VISUAL_TYPE,     GLX_DIRECT_COLOR,
-                None
-        };
-
-       /* Window and context setup. */
-        XVisualInfo *visual_info = my_glXChooseVisual(dpy, 0, visual_attr);
-        GLXContext ctx = my_glXCreateContext(dpy, visual_info, NULL, True);
-        my_glXMakeCurrent(dpy, window, ctx);
-
-        my_glViewport(0, 0, width, height);
-
-       set_2d_projection (width, height);
-
-/* Simply count through some colors, frame by frame. */
-#define RGB(frame) (((frame+1)/4) % 2), (((frame+1)/2) % 2), ((frame+1) % 2)
-
-       int frame = 0;
-       for (i = 0; i < 2; i++) {
-               /* Frame: Draw a solid (magenta) frame */
-               paint_rgb_using_clear (RGB(frame));
-               my_glXSwapBuffers (dpy, window);
-               frame++;
-
-               /* Frame: Draw a solid (yellow) frame */
-               paint_rgb_using_clear (RGB(frame));
-               my_glXSwapBuffers (dpy, window);
-               frame++;
-
-               /* Frame: Draw a solid (cyan) frame */
-               paint_rgb_using_clear (RGB(frame));
-               my_glXSwapBuffers (dpy, window);
-               frame++;
-       }
-
-       /* Cleanup */
-        my_glXDestroyContext (dpy, ctx);
-}
-
-static void
-handle_events(Display *dpy, Window window)
-{
-        XEvent xev;
-       int width = 0;
-       int height = 0;
-
-        XNextEvent (dpy, &xev);
-
-        while (1) {
-                XNextEvent (dpy, &xev);
-                switch (xev.type) {
-                case ConfigureNotify:
-                        width = xev.xconfigure.width;
-                        height = xev.xconfigure.height;
-                        break;
-                case Expose:
-                        if (xev.xexpose.count == 0) {
-                                draw (dpy, window, width, height);
-                                return;
-                        }
-                        break;
-                }
-        }
-}
+#define HANDLE_EVENTS_GL_PREFIX my_
+#include "handle-events.c"
 
 static void
 resolve_symbols (void)