X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fegl%2Ffg_init_egl.c;h=3c83fb2a2d7b0e533e896b56025d0ee916f05e12;hb=af47c3f93c7834b4006c49ec9df6a6ffdd3025de;hp=a58812a4e5e8f8f845df594ad5d59afc62ed1423;hpb=7fbb15bc63c7937cab772bd942883e3811acbabf;p=freeglut diff --git a/src/egl/fg_init_egl.c b/src/egl/fg_init_egl.c index a58812a..3c83fb2 100644 --- a/src/egl/fg_init_egl.c +++ b/src/egl/fg_init_egl.c @@ -1,5 +1,5 @@ /* - * freeglut_init_android.c + * fg_init_egl.c * * Various freeglut initialization functions. * @@ -27,46 +27,45 @@ #include #include "fg_internal.h" -#include - /* * A call to this function should initialize all the display stuff... */ -void fgPlatformInitialize( const char* displayName ) +void fghPlatformInitializeEGL() { - fprintf(stderr, "fgPlatformInitialize\n"); - fgState.Initialised = GL_TRUE; - /* CreateDisplay */ /* Using EGL_DEFAULT_DISPLAY, or a specific native display */ +#ifdef FREEGLUT_WAYLAND + fgDisplay.pDisplay.egl.Display = eglGetDisplay( + (EGLNativeDisplayType)fgDisplay.pDisplay.display); +#else EGLNativeDisplayType nativeDisplay = EGL_DEFAULT_DISPLAY; - fgDisplay.pDisplay.eglDisplay = eglGetDisplay(nativeDisplay); + fgDisplay.pDisplay.egl.Display = eglGetDisplay(nativeDisplay); +#endif - FREEGLUT_INTERNAL_ERROR_EXIT(fgDisplay.pDisplay.eglDisplay != EGL_NO_DISPLAY, + FREEGLUT_INTERNAL_ERROR_EXIT(fgDisplay.pDisplay.egl.Display != EGL_NO_DISPLAY, "No display available", "fgPlatformInitialize"); - if (!eglInitialize(fgDisplay.pDisplay.eglDisplay, NULL, NULL)) + if (eglInitialize(fgDisplay.pDisplay.egl.Display, &fgDisplay.pDisplay.egl.MajorVersion, &fgDisplay.pDisplay.egl.MinorVersion) != EGL_TRUE) fgError("eglInitialize: error %x\n", eglGetError()); - /* CreateContext */ - fghCreateContext(); +# ifdef GL_VERSION_1_1 /* or later */ + eglBindAPI(EGL_OPENGL_API); +# else + eglBindAPI(EGL_OPENGL_ES_API); +# endif - // fgDisplay.ScreenWidth = ...; - // fgDisplay.ScreenHeight = ...; - // fgDisplay.ScreenWidthMM = ...; - // fgDisplay.ScreenHeightMM = ...; + /* fgDisplay.ScreenWidth = ...; */ + /* fgDisplay.ScreenHeight = ...; */ + /* fgDisplay.ScreenWidthMM = ...; */ + /* fgDisplay.ScreenHeightMM = ...; */ } -void fgPlatformCloseDisplay ( void ) +void fghPlatformCloseDisplayEGL() { - eglMakeCurrent(fgDisplay.pDisplay.eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - if (fgDisplay.pDisplay.eglContext != EGL_NO_CONTEXT) { - eglDestroyContext(fgDisplay.pDisplay.eglDisplay, fgDisplay.pDisplay.eglContext); - fgDisplay.pDisplay.eglContext = EGL_NO_CONTEXT; - } - - if (fgDisplay.pDisplay.eglDisplay != EGL_NO_DISPLAY) { - eglTerminate(fgDisplay.pDisplay.eglDisplay); - fgDisplay.pDisplay.eglDisplay = EGL_NO_DISPLAY; + if (fgDisplay.pDisplay.egl.Display != EGL_NO_DISPLAY) { + eglTerminate(fgDisplay.pDisplay.egl.Display); + fgDisplay.pDisplay.egl.Display = EGL_NO_DISPLAY; + fgDisplay.pDisplay.egl.MajorVersion = 0; + fgDisplay.pDisplay.egl.MinorVersion = 0; } } @@ -76,5 +75,5 @@ void fgPlatformCloseDisplay ( void ) void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext ) { if (MContext != EGL_NO_CONTEXT) - eglDestroyContext(pDisplay.eglDisplay, MContext); + eglDestroyContext(pDisplay.egl.Display, MContext); }