21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_EMSCRIPTEN && SDL_VIDEO_OPENGL_EGL 25 #include <emscripten/emscripten.h> 26 #include <GLES2/gl2.h> 31 #define LOAD_FUNC(NAME) _this->egl_data->NAME = NAME; 36 Emscripten_GLES_LoadLibrary(
_THIS,
const char *
path) {
38 _this->egl_data = (
struct SDL_EGL_VideoData *)
SDL_calloc(1,
sizeof(SDL_EGL_VideoData));
39 if (!
_this->egl_data) {
43 LOAD_FUNC(eglGetDisplay);
44 LOAD_FUNC(eglInitialize);
45 LOAD_FUNC(eglTerminate);
46 LOAD_FUNC(eglGetProcAddress);
47 LOAD_FUNC(eglChooseConfig);
48 LOAD_FUNC(eglGetConfigAttrib);
49 LOAD_FUNC(eglCreateContext);
50 LOAD_FUNC(eglDestroyContext);
51 LOAD_FUNC(eglCreateWindowSurface);
52 LOAD_FUNC(eglDestroySurface);
53 LOAD_FUNC(eglMakeCurrent);
54 LOAD_FUNC(eglSwapBuffers);
55 LOAD_FUNC(eglSwapInterval);
56 LOAD_FUNC(eglWaitNative);
58 LOAD_FUNC(eglBindAPI);
60 _this->egl_data->egl_display =
_this->egl_data->eglGetDisplay(EGL_DEFAULT_DISPLAY);
61 if (!
_this->egl_data->egl_display) {
65 if (
_this->egl_data->eglInitialize(
_this->egl_data->egl_display,
NULL,
NULL) != EGL_TRUE) {
90 SDL_EGL_DeleteContext(
_this, context);
93 SDL_EGL_CreateContext_impl(Emscripten)
94 SDL_EGL_SwapWindow_impl(Emscripten)
95 SDL_EGL_MakeCurrent_impl(Emscripten)
101 if (window->driverdata) {
#define GL_STENCIL_BUFFER_BIT
static SDL_Window * window
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
#define GL_DEPTH_BUFFER_BIT
static SDL_VideoDevice * _this
void * SDL_calloc(size_t nmemb, size_t size)
void * SDL_GLContext
An opaque handle to an OpenGL context.
GLAPI void GLAPIENTRY glClear(GLbitfield mask)
#define GL_COLOR_BUFFER_BIT
#define SDL_OutOfMemory()
The type used to identify a window.
struct SDL_VideoDevice::@28 gl_config
GLsizei const GLchar *const * path
GLubyte GLubyte GLubyte GLubyte w
GLfloat GLfloat GLfloat GLfloat h