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