X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fxlock-gl-utils.c;h=36d724c9e675004f9ffa08d18b7f60953903a3da;hb=39809ded547bdbb08207d3e514950425215b4410;hp=d72b4ebdd4aa4ad0d4884893441d05c3e4aecec0;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/glx/xlock-gl-utils.c b/hacks/glx/xlock-gl-utils.c index d72b4ebd..36d724c9 100644 --- a/hacks/glx/xlock-gl-utils.c +++ b/hacks/glx/xlock-gl-utils.c @@ -1,5 +1,5 @@ /* xlock-gl.c --- xscreensaver compatibility layer for xlockmore GL modules. - * xscreensaver, Copyright (c) 1997-2008 Jamie Zawinski + * xscreensaver, Copyright (c) 1997-2015 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -16,11 +16,7 @@ #include #include "xlockmoreI.h" -#include "glxfonts.h" - -#include -#include -#include +#include "texfont.h" #ifndef isupper # define isupper(c) ((c) >= 'A' && (c) <= 'Z') @@ -56,10 +52,18 @@ init_GL(ModeInfo * mi) Window window = mi->window; Screen *screen = mi->xgwa.screen; Visual *visual = mi->xgwa.visual; - GLXContext glx_context = 0; XVisualInfo vi_in, *vi_out; int out_count; + if (mi->glx_context) { + glXMakeCurrent (dpy, window, mi->glx_context); + return &mi->glx_context; + } + +# ifdef HAVE_JWZGLES + jwzgles_make_current(jwzgles_make_state(state)); +# endif + vi_in.screen = screen_number (screen); vi_in.visualid = XVisualIDFromVisual (visual); vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask, @@ -69,23 +73,23 @@ init_GL(ModeInfo * mi) { XSync (dpy, False); orig_ehandler = XSetErrorHandler (BadValue_ehandler); - glx_context = glXCreateContext (dpy, vi_out, 0, GL_TRUE); + mi->glx_context = glXCreateContext (dpy, vi_out, 0, GL_TRUE); XSync (dpy, False); XSetErrorHandler (orig_ehandler); if (got_error) - glx_context = 0; + mi->glx_context = 0; } XFree((char *) vi_out); - if (!glx_context) + if (!mi->glx_context) { fprintf(stderr, "%s: couldn't create GL context for visual 0x%x.\n", progname, (unsigned int) XVisualIDFromVisual (visual)); exit(1); } - glXMakeCurrent (dpy, window, glx_context); + glXMakeCurrent (dpy, window, mi->glx_context); { GLboolean rgba_mode = 0; @@ -118,18 +122,30 @@ init_GL(ModeInfo * mi) glDrawBuffer (GL_FRONT); } + /* Sometimes glDrawBuffer() throws "invalid op". Dunno why. Ignore. */ + clear_gl_error (); + + /* Process the -background argument. */ + { + char *s = get_string_resource(mi->dpy, "background", "Background"); + XColor c = { 0, }; + if (! XParseColor (dpy, mi->xgwa.colormap, s, &c)) + fprintf (stderr, "%s: can't parse color %s; using black.\n", + progname, s); + glClearColor (c.red / 65535.0, + c.green / 65535.0, + c.blue / 65535.0, + 1.0); + } + + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* GLXContext is already a pointer type. Why this function returns a pointer to a pointer, I have no idea... */ - { - GLXContext *ptr = (GLXContext *) malloc(sizeof(GLXContext)); - *ptr = glx_context; - return ptr; - } + return &mi->glx_context; } - /* clear away any lingering error codes */ @@ -155,6 +171,11 @@ check_gl_error (const char *type) case GL_STACK_OVERFLOW: e = "stack overflow"; break; case GL_STACK_UNDERFLOW: e = "stack underflow"; break; case GL_OUT_OF_MEMORY: e = "out of memory"; break; +#ifdef GL_INVALID_FRAMEBUFFER_OPERATION + case GL_INVALID_FRAMEBUFFER_OPERATION: + e = "invalid framebuffer operation"; + break; +#endif #ifdef GL_TABLE_TOO_LARGE_EXT case GL_TABLE_TOO_LARGE_EXT: e = "table too large"; break; #endif