1 #include <android/log.h>
2 #include "screenhackI.h"
3 #include "xlockmoreI.h"
5 #if defined(USE_IPHONE) || (HAVE_ANDROID)
8 # include <OpenGL/OpenGL.h>
11 /* used by the OpenGL screen savers
13 extern GLXContext *init_GL (ModeInfo *);
14 extern void glXSwapBuffers (Display *, Window);
15 extern void glXMakeCurrent (Display *, Window, GLXContext);
16 extern void clear_gl_error (void);
17 extern void check_gl_error (const char *type);
19 /* Does nothing - prepareContext already did the work.
22 glXMakeCurrent (Display *dpy, Window window, GLXContext context)
27 /* clear away any lingering error codes */
31 while (glGetError() != GL_NO_ERROR)
36 // needs to be implemented in Android...
37 /* Copy the back buffer to the front buffer.
40 glXSwapBuffers (Display *dpy, Window window)
45 /* Called by OpenGL savers using the XLockmore API.
48 init_GL (ModeInfo *mi)
50 Window win = mi->window;
52 // Caller expects a pointer to an opaque struct... which it dereferences.
53 // Don't ask me, it's historical...
54 static int blort = -1;
55 return (void *) &blort;
58 /* report a GL error. */
60 check_gl_error (const char *type)
65 switch ((i = glGetError())) {
66 case GL_NO_ERROR: return;
67 case GL_INVALID_ENUM: e = "invalid enum"; break;
68 case GL_INVALID_VALUE: e = "invalid value"; break;
69 case GL_INVALID_OPERATION: e = "invalid operation"; break;
70 case GL_STACK_OVERFLOW: e = "stack overflow"; break;
71 case GL_STACK_UNDERFLOW: e = "stack underflow"; break;
72 case GL_OUT_OF_MEMORY: e = "out of memory"; break;
73 #ifdef GL_TABLE_TOO_LARGE_EXT
74 case GL_TABLE_TOO_LARGE_EXT: e = "table too large"; break;
76 #ifdef GL_TEXTURE_TOO_LARGE_EXT
77 case GL_TEXTURE_TOO_LARGE_EXT: e = "texture too large"; break;
80 e = buf; sprintf (buf, "unknown GL error %d", (int) i); break;
82 __android_log_write(ANDROID_LOG_ERROR, "xscreensaver", e);