src/video/x11/SDL_x11opengles.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 15 Dec 2009 08:11:06 +0000
changeset 3565 f43c8f688f77
parent 3190 c68d2ca5970f
child 3697 f7b03b6838cb
permissions -rw-r--r--
Fixed bug #906

Added better error reporting for OpenGL context creation failing.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2004 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Library General Public
     7     License as published by the Free Software Foundation; either
     8     version 2 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Library General Public License for more details.
    14 
    15     You should have received a copy of the GNU Library General Public
    16     License along with this library; if not, write to the Free
    17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 
    22     Open Pandora SDL driver
    23     Copyright (C) 2009 David Carré
    24     (cpasjuste@gmail.com)
    25 */
    26 
    27 #include <GLES/gl.h>
    28 #include <GLES/egl.h>
    29 #include <dlfcn.h>
    30 #if defined(__OpenBSD__) && !defined(__ELF__)
    31 #define dlsym(x,y) dlsym(x, "_" y)
    32 #endif
    33 
    34 #include "../SDL_sysvideo.h"
    35 
    36 typedef struct SDL_PrivateGLESData
    37 {
    38     int egl_active;             /* to stop switching drivers while we have a valid context */
    39     XVisualInfo *egl_visualinfo;
    40     EGLDisplay egl_display;
    41     EGLContext egl_context;     /* Current GLES context */
    42     EGLSurface egl_surface;
    43     EGLConfig egl_config;
    44 
    45       EGLDisplay(*eglGetDisplay) (NativeDisplayType display);
    46       EGLBoolean(*eglInitialize) (EGLDisplay dpy, EGLint * major,
    47                                   EGLint * minor);
    48       EGLBoolean(*eglTerminate) (EGLDisplay dpy);
    49 
    50     void *(*eglGetProcAddress) (const GLubyte * procName);
    51 
    52       EGLBoolean(*eglChooseConfig) (EGLDisplay dpy,
    53                                     const EGLint * attrib_list,
    54                                     EGLConfig * configs,
    55                                     EGLint config_size, EGLint * num_config);
    56 
    57       EGLContext(*eglCreateContext) (EGLDisplay dpy,
    58                                      EGLConfig config,
    59                                      EGLContext share_list,
    60                                      const EGLint * attrib_list);
    61 
    62       EGLBoolean(*eglDestroyContext) (EGLDisplay dpy, EGLContext ctx);
    63 
    64       EGLSurface(*eglCreateWindowSurface) (EGLDisplay dpy,
    65                                            EGLConfig config,
    66                                            NativeWindowType window,
    67                                            const EGLint * attrib_list);
    68       EGLBoolean(*eglDestroySurface) (EGLDisplay dpy, EGLSurface surface);
    69 
    70       EGLBoolean(*eglMakeCurrent) (EGLDisplay dpy, EGLSurface draw,
    71                                    EGLSurface read, EGLContext ctx);
    72 
    73       EGLBoolean(*eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw);
    74 
    75     const char *(*eglQueryString) (EGLDisplay dpy, EGLint name);
    76 
    77       EGLBoolean(*eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config,
    78                                        EGLint attribute, EGLint * value);
    79 
    80 } SDL_PrivateGLESData;
    81 
    82 /* OpenGLES functions */
    83 extern SDL_GLContext X11_GLES_CreateContext(_THIS, SDL_Window * window);
    84 extern XVisualInfo *X11_GLES_GetVisual(_THIS, Display * display, int screen);
    85 extern int X11_GLES_MakeCurrent(_THIS, SDL_Window * window,
    86                                 SDL_GLContext context);
    87 extern int X11_GLES_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
    88 extern int X11_GLES_LoadLibrary(_THIS, const char *path);
    89 extern void *X11_GLES_GetProcAddress(_THIS, const char *proc);
    90 extern void X11_GLES_UnloadLibrary(_THIS);
    91 
    92 extern int X11_GLES_SetSwapInterval(_THIS, int interval);
    93 extern int X11_GLES_GetSwapInterval(_THIS);
    94 extern void X11_GLES_SwapWindow(_THIS, SDL_Window * window);
    95 extern void X11_GLES_DeleteContext(_THIS, SDL_GLContext context);