src/video/SDL_egl.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 14 Jul 2013 11:28:44 -0700
changeset 7776 d4a39491577f
parent 7659 ac4ce59c40e7
child 8541 0041edb891f3
permissions -rw-r--r--
Added the platform specific messagebox function to the video function list
gabomdq@7659
     1
/*
gabomdq@7659
     2
  Simple DirectMedia Layer
gabomdq@7659
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
gabomdq@7659
     4
gabomdq@7659
     5
  This software is provided 'as-is', without any express or implied
gabomdq@7659
     6
  warranty.  In no event will the authors be held liable for any damages
gabomdq@7659
     7
  arising from the use of this software.
gabomdq@7659
     8
gabomdq@7659
     9
  Permission is granted to anyone to use this software for any purpose,
gabomdq@7659
    10
  including commercial applications, and to alter it and redistribute it
gabomdq@7659
    11
  freely, subject to the following restrictions:
gabomdq@7659
    12
gabomdq@7659
    13
  1. The origin of this software must not be misrepresented; you must not
gabomdq@7659
    14
     claim that you wrote the original software. If you use this software
gabomdq@7659
    15
     in a product, an acknowledgment in the product documentation would be
gabomdq@7659
    16
     appreciated but is not required.
gabomdq@7659
    17
  2. Altered source versions must be plainly marked as such, and must not be
gabomdq@7659
    18
     misrepresented as being the original software.
gabomdq@7659
    19
  3. This notice may not be removed or altered from any source distribution.
gabomdq@7659
    20
*/
gabomdq@7659
    21
#include "SDL_config.h"
gabomdq@7659
    22
gabomdq@7659
    23
#ifndef _SDL_egl_h
gabomdq@7659
    24
#define _SDL_egl_h
gabomdq@7659
    25
gabomdq@7659
    26
#if SDL_VIDEO_OPENGL_EGL
gabomdq@7659
    27
gabomdq@7659
    28
#include <EGL/egl.h>
gabomdq@7659
    29
gabomdq@7659
    30
#include <dlfcn.h>
gabomdq@7659
    31
#if defined(__OpenBSD__) && !defined(__ELF__)
gabomdq@7659
    32
#define dlsym(x,y) dlsym(x, "_" y)
gabomdq@7659
    33
#endif
gabomdq@7659
    34
gabomdq@7659
    35
#include "SDL_sysvideo.h"
gabomdq@7659
    36
gabomdq@7659
    37
typedef struct SDL_EGL_VideoData
gabomdq@7659
    38
{
gabomdq@7659
    39
    void *egl_dll_handle;
gabomdq@7659
    40
    EGLDisplay egl_display;
gabomdq@7659
    41
    EGLConfig egl_config;
gabomdq@7659
    42
    int egl_swapinterval;
gabomdq@7659
    43
    
gabomdq@7659
    44
    EGLDisplay(*eglGetDisplay) (NativeDisplayType display);
gabomdq@7659
    45
    EGLBoolean(*eglInitialize) (EGLDisplay dpy, EGLint * major,
gabomdq@7659
    46
                                EGLint * minor);
gabomdq@7659
    47
    EGLBoolean(*eglTerminate) (EGLDisplay dpy);
gabomdq@7659
    48
    
gabomdq@7659
    49
    void *(*eglGetProcAddress) (const char * procName);
gabomdq@7659
    50
    
gabomdq@7659
    51
    EGLBoolean(*eglChooseConfig) (EGLDisplay dpy,
gabomdq@7659
    52
                                  const EGLint * attrib_list,
gabomdq@7659
    53
                                  EGLConfig * configs,
gabomdq@7659
    54
                                  EGLint config_size, EGLint * num_config);
gabomdq@7659
    55
    
gabomdq@7659
    56
    EGLContext(*eglCreateContext) (EGLDisplay dpy,
gabomdq@7659
    57
                                   EGLConfig config,
gabomdq@7659
    58
                                   EGLContext share_list,
gabomdq@7659
    59
                                   const EGLint * attrib_list);
gabomdq@7659
    60
    
gabomdq@7659
    61
    EGLBoolean(*eglDestroyContext) (EGLDisplay dpy, EGLContext ctx);
gabomdq@7659
    62
    
gabomdq@7659
    63
    EGLSurface(*eglCreateWindowSurface) (EGLDisplay dpy,
gabomdq@7659
    64
                                         EGLConfig config,
gabomdq@7659
    65
                                         NativeWindowType window,
gabomdq@7659
    66
                                         const EGLint * attrib_list);
gabomdq@7659
    67
    EGLBoolean(*eglDestroySurface) (EGLDisplay dpy, EGLSurface surface);
gabomdq@7659
    68
    
gabomdq@7659
    69
    EGLBoolean(*eglMakeCurrent) (EGLDisplay dpy, EGLSurface draw,
gabomdq@7659
    70
                                 EGLSurface read, EGLContext ctx);
gabomdq@7659
    71
    
gabomdq@7659
    72
    EGLBoolean(*eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw);
gabomdq@7659
    73
    
gabomdq@7659
    74
    EGLBoolean(*eglSwapInterval) (EGLDisplay dpy, EGLint interval);
gabomdq@7659
    75
    
gabomdq@7659
    76
    const char *(*eglQueryString) (EGLDisplay dpy, EGLint name);
gabomdq@7659
    77
    
gabomdq@7659
    78
    EGLBoolean(*eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config,
gabomdq@7659
    79
                                     EGLint attribute, EGLint * value);
gabomdq@7659
    80
    
gabomdq@7659
    81
    EGLBoolean(*eglWaitNative) (EGLint  engine);
gabomdq@7659
    82
gabomdq@7659
    83
    EGLBoolean(*eglWaitGL)(void);   
gabomdq@7659
    84
} SDL_EGL_VideoData;
gabomdq@7659
    85
gabomdq@7659
    86
/* OpenGLES functions */
gabomdq@7659
    87
extern int SDL_EGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
gabomdq@7659
    88
extern int SDL_EGL_LoadLibrary(_THIS, const char *path, NativeDisplayType native_display);
gabomdq@7659
    89
extern void *SDL_EGL_GetProcAddress(_THIS, const char *proc);
gabomdq@7659
    90
extern void SDL_EGL_UnloadLibrary(_THIS);
gabomdq@7659
    91
extern int SDL_EGL_ChooseConfig(_THIS);
gabomdq@7659
    92
extern int SDL_EGL_SetSwapInterval(_THIS, int interval);
gabomdq@7659
    93
extern int SDL_EGL_GetSwapInterval(_THIS);
gabomdq@7659
    94
extern void SDL_EGL_DeleteContext(_THIS, SDL_GLContext context);
gabomdq@7659
    95
extern EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw);
gabomdq@7659
    96
extern void SDL_EGL_DestroySurface(_THIS, EGLSurface egl_surface);
gabomdq@7659
    97
gabomdq@7659
    98
/* These need to be wrapped to get the surface for the window by the platform GLES implementation */
gabomdq@7659
    99
extern SDL_GLContext SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface);
gabomdq@7659
   100
extern int SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context);
gabomdq@7659
   101
extern void SDL_EGL_SwapBuffers(_THIS, EGLSurface egl_surface);
gabomdq@7659
   102
gabomdq@7659
   103
/* A few of useful macros */
gabomdq@7659
   104
gabomdq@7659
   105
#define SDL_EGL_SwapWindow_impl(BACKEND) void \
gabomdq@7659
   106
BACKEND ## _GLES_SwapWindow(_THIS, SDL_Window * window) \
gabomdq@7659
   107
{\
gabomdq@7659
   108
    SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);\
gabomdq@7659
   109
}
gabomdq@7659
   110
gabomdq@7659
   111
#define SDL_EGL_MakeCurrent_impl(BACKEND) int \
gabomdq@7659
   112
BACKEND ## _GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) \
gabomdq@7659
   113
{\
gabomdq@7659
   114
    if (window && context) { \
gabomdq@7659
   115
        return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context); \
gabomdq@7659
   116
    }\
gabomdq@7659
   117
    else {\
gabomdq@7659
   118
        return SDL_EGL_MakeCurrent(_this, NULL, NULL);\
gabomdq@7659
   119
    }\
gabomdq@7659
   120
}
gabomdq@7659
   121
gabomdq@7659
   122
#define SDL_EGL_CreateContext_impl(BACKEND) SDL_GLContext \
gabomdq@7659
   123
BACKEND ## _GLES_CreateContext(_THIS, SDL_Window * window) \
gabomdq@7659
   124
{\
gabomdq@7659
   125
    return SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);\
gabomdq@7659
   126
}
gabomdq@7659
   127
gabomdq@7659
   128
#endif /* SDL_VIDEO_OPENGL_EGL */
gabomdq@7659
   129
gabomdq@7659
   130
#endif /* _SDL_egl_h */
gabomdq@7659
   131
gabomdq@7659
   132
/* vi: set ts=4 sw=4 expandtab: */