X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fegl%2Ffg_window_egl.c;h=d83a3eac47e51411403a601f52d9fa5167da97dc;hb=223d39f2318e1724283c50c346843199c81d2e7c;hp=75547baa2c9fdaed0fe92dd166142ccbdeef2f48;hpb=44856885ba35db9526d24d140b84ce492f4871d2;p=freeglut diff --git a/src/egl/fg_window_egl.c b/src/egl/fg_window_egl.c index 75547ba..d83a3ea 100644 --- a/src/egl/fg_window_egl.c +++ b/src/egl/fg_window_egl.c @@ -26,7 +26,7 @@ #include #include "fg_internal.h" -void fghChooseConfigEGL(EGLConfig* config) { +int fghChooseConfig(EGLConfig* config) { const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, #ifdef GL_ES_VERSION_2_0 @@ -49,14 +49,18 @@ void fghChooseConfigEGL(EGLConfig* config) { EGLint num_config; if (!eglChooseConfig(fgDisplay.pDisplay.egl.Display, - attribs, config, 1, &num_config)) - fgError("eglChooseConfig: error %x\n", eglGetError()); + attribs, config, 1, &num_config)) { + fgWarning("eglChooseConfig: error %x\n", eglGetError()); + return 0; + } + + return 1; } /** * Initialize an EGL context for the current display. */ -void fghCreateNewContextEGL( SFG_Window* window ) { +EGLContext fghCreateNewContextEGL( SFG_Window* window ) { EGLContext context; EGLDisplay eglDisplay = fgDisplay.pDisplay.egl.Display; @@ -78,10 +82,14 @@ void fghCreateNewContextEGL( SFG_Window* window ) { } EGLint ver = -1; eglQueryContext(fgDisplay.pDisplay.egl.Display, context, EGL_CONTEXT_CLIENT_VERSION, &ver); +#ifdef GL_ES_VERSION_2_0 if (ver != 2) +#else + if (ver != 1) +#endif fgError("Wrong GLES major version: %d\n", ver); - window->Window.Context = context; + return context; } /* @@ -121,3 +129,13 @@ void fghPlatformCloseWindowEGL( SFG_Window* window ) window->Window.pContext.egl.Surface = EGL_NO_SURFACE; } } + +void fgPlatformSetWindow ( SFG_Window *window ) +{ + if (!eglMakeCurrent( + fgDisplay.pDisplay.egl.Display, + window->Window.pContext.egl.Surface, + window->Window.pContext.egl.Surface, + window->Window.Context)) + fgError("eglMakeCurrent: err=%x\n", eglGetError()); +}