src/video/SDL_egl_c.h
changeset 8021 f96e12e0ade9
child 8062 4fc5f66d63cc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/SDL_egl_c.h	Fri Nov 22 13:24:53 2013 -0300
     1.3 @@ -0,0 +1,127 @@
     1.4 +/*
     1.5 +  Simple DirectMedia Layer
     1.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
     1.7 +
     1.8 +  This software is provided 'as-is', without any express or implied
     1.9 +  warranty.  In no event will the authors be held liable for any damages
    1.10 +  arising from the use of this software.
    1.11 +
    1.12 +  Permission is granted to anyone to use this software for any purpose,
    1.13 +  including commercial applications, and to alter it and redistribute it
    1.14 +  freely, subject to the following restrictions:
    1.15 +
    1.16 +  1. The origin of this software must not be misrepresented; you must not
    1.17 +     claim that you wrote the original software. If you use this software
    1.18 +     in a product, an acknowledgment in the product documentation would be
    1.19 +     appreciated but is not required.
    1.20 +  2. Altered source versions must be plainly marked as such, and must not be
    1.21 +     misrepresented as being the original software.
    1.22 +  3. This notice may not be removed or altered from any source distribution.
    1.23 +*/
    1.24 +#include "SDL_config.h"
    1.25 +
    1.26 +#ifndef _SDL_egl_h
    1.27 +#define _SDL_egl_h
    1.28 +
    1.29 +#if SDL_VIDEO_OPENGL_EGL
    1.30 +
    1.31 +#include "SDL_egl.h"
    1.32 +
    1.33 +#include "SDL_sysvideo.h"
    1.34 +
    1.35 +typedef struct SDL_EGL_VideoData
    1.36 +{
    1.37 +    void *egl_dll_handle, *dll_handle;
    1.38 +    EGLDisplay egl_display;
    1.39 +    EGLConfig egl_config;
    1.40 +    int egl_swapinterval;
    1.41 +    
    1.42 +    EGLDisplay(EGLAPIENTRY *eglGetDisplay) (NativeDisplayType display);
    1.43 +    EGLBoolean(EGLAPIENTRY *eglInitialize) (EGLDisplay dpy, EGLint * major,
    1.44 +                                EGLint * minor);
    1.45 +    EGLBoolean(EGLAPIENTRY  *eglTerminate) (EGLDisplay dpy);
    1.46 +    
    1.47 +    void *(EGLAPIENTRY *eglGetProcAddress) (const char * procName);
    1.48 +    
    1.49 +    EGLBoolean(EGLAPIENTRY *eglChooseConfig) (EGLDisplay dpy,
    1.50 +                                  const EGLint * attrib_list,
    1.51 +                                  EGLConfig * configs,
    1.52 +                                  EGLint config_size, EGLint * num_config);
    1.53 +    
    1.54 +    EGLContext(EGLAPIENTRY *eglCreateContext) (EGLDisplay dpy,
    1.55 +                                   EGLConfig config,
    1.56 +                                   EGLContext share_list,
    1.57 +                                   const EGLint * attrib_list);
    1.58 +    
    1.59 +    EGLBoolean(EGLAPIENTRY *eglDestroyContext) (EGLDisplay dpy, EGLContext ctx);
    1.60 +    
    1.61 +    EGLSurface(EGLAPIENTRY *eglCreateWindowSurface) (EGLDisplay dpy,
    1.62 +                                         EGLConfig config,
    1.63 +                                         NativeWindowType window,
    1.64 +                                         const EGLint * attrib_list);
    1.65 +    EGLBoolean(EGLAPIENTRY *eglDestroySurface) (EGLDisplay dpy, EGLSurface surface);
    1.66 +    
    1.67 +    EGLBoolean(EGLAPIENTRY *eglMakeCurrent) (EGLDisplay dpy, EGLSurface draw,
    1.68 +                                 EGLSurface read, EGLContext ctx);
    1.69 +    
    1.70 +    EGLBoolean(EGLAPIENTRY *eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw);
    1.71 +    
    1.72 +    EGLBoolean(EGLAPIENTRY *eglSwapInterval) (EGLDisplay dpy, EGLint interval);
    1.73 +    
    1.74 +    const char *(EGLAPIENTRY *eglQueryString) (EGLDisplay dpy, EGLint name);
    1.75 +    
    1.76 +    EGLBoolean(EGLAPIENTRY  *eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config,
    1.77 +                                     EGLint attribute, EGLint * value);
    1.78 +    
    1.79 +    EGLBoolean(EGLAPIENTRY *eglWaitNative) (EGLint  engine);
    1.80 +
    1.81 +    EGLBoolean(EGLAPIENTRY *eglWaitGL)(void);
    1.82 +} SDL_EGL_VideoData;
    1.83 +
    1.84 +/* OpenGLES functions */
    1.85 +extern int SDL_EGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
    1.86 +extern int SDL_EGL_LoadLibrary(_THIS, const char *path, NativeDisplayType native_display);
    1.87 +extern void *SDL_EGL_GetProcAddress(_THIS, const char *proc);
    1.88 +extern void SDL_EGL_UnloadLibrary(_THIS);
    1.89 +extern int SDL_EGL_ChooseConfig(_THIS);
    1.90 +extern int SDL_EGL_SetSwapInterval(_THIS, int interval);
    1.91 +extern int SDL_EGL_GetSwapInterval(_THIS);
    1.92 +extern void SDL_EGL_DeleteContext(_THIS, SDL_GLContext context);
    1.93 +extern EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw);
    1.94 +extern void SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface);
    1.95 +
    1.96 +/* These need to be wrapped to get the surface for the window by the platform GLES implementation */
    1.97 +extern SDL_GLContext SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface);
    1.98 +extern int SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context);
    1.99 +extern void SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface);
   1.100 +
   1.101 +/* A few of useful macros */
   1.102 +
   1.103 +#define SDL_EGL_SwapWindow_impl(BACKEND) void \
   1.104 +BACKEND ## _GLES_SwapWindow(_THIS, SDL_Window * window) \
   1.105 +{\
   1.106 +    SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);\
   1.107 +}
   1.108 +
   1.109 +#define SDL_EGL_MakeCurrent_impl(BACKEND) int \
   1.110 +BACKEND ## _GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) \
   1.111 +{\
   1.112 +    if (window && context) { \
   1.113 +        return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context); \
   1.114 +    }\
   1.115 +    else {\
   1.116 +        return SDL_EGL_MakeCurrent(_this, NULL, NULL);\
   1.117 +    }\
   1.118 +}
   1.119 +
   1.120 +#define SDL_EGL_CreateContext_impl(BACKEND) SDL_GLContext \
   1.121 +BACKEND ## _GLES_CreateContext(_THIS, SDL_Window * window) \
   1.122 +{\
   1.123 +    return SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);\
   1.124 +}
   1.125 +
   1.126 +#endif /* SDL_VIDEO_OPENGL_EGL */
   1.127 +
   1.128 +#endif /* _SDL_egl_h */
   1.129 +
   1.130 +/* vi: set ts=4 sw=4 expandtab: */