#include "egl/fg_window_egl.h"
#include <slog2.h>
+#ifdef NDEBUG
+#define LOGI(...)
+#else
#define LOGI(...) ((void)slog2fa(NULL, 1337, SLOG2_INFO, __VA_ARGS__, SLOG2_FA_END))
+#endif
#define LOGW(...) ((void)slog2fa(NULL, 1337, SLOG2_WARNING, __VA_ARGS__, SLOG2_FA_END))
#include <sys/keycodes.h>
#include <input/screen_helpers.h>
*/
void fgPlatformSleepForEvents( fg_time_t msec )
{
- if(fgStructure.CurrentWindow && fgDisplay.pDisplay.event == NULL && bps_get_event(&fgDisplay.pDisplay.event, (int)msec) != BPS_SUCCESS) {
+ if(fgStructure.CurrentWindow && fgDisplay.pDisplay.event == NULL &&
+ bps_get_event(&fgDisplay.pDisplay.event, (int)msec) != BPS_SUCCESS) {
LOGW("BPS couldn't get event");
}
}
/* Create context */
fghChooseConfig(&window->Window.pContext.egl.Config);
- window->Window.Context = fghCreateNewContextEGL(window);
+ window->Window.Context = EGL_NO_CONTEXT;
+ if( fgState.UseCurrentContext == GL_TRUE )
+ window->Window.Context = eglGetCurrentContext();
+ if( window->Window.Context == EGL_NO_CONTEXT )
+ window->Window.Context = fghCreateNewContextEGL(window);
/* Create EGL window */
fghPlatformOpenWindowEGL(window);
http://qt.gitorious.org/qt/qtbase/source/893deb1a93021cdfabe038cdf1869de33a60cbc9:src/plugins/platforms/qnx/qqnxglcontext.cpp
That's all that is used, and that's what BlackBerry uses for their own internal OpenGL setup, so unless something else is determined, use it */
EGL_BLUE_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_RED_SIZE, 8,
#else
EGL_BLUE_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGLint num_config;
if (!eglChooseConfig(fgDisplay.pDisplay.egl.Display,
- attribs, config, 1, &num_config)) {
+ attribs, config, 1, &num_config)) {
fgWarning("eglChooseConfig: error %x\n", eglGetError());
return 0;
}
{
if ( window != fgStructure.CurrentWindow && window) {
if (eglMakeCurrent(fgDisplay.pDisplay.egl.Display,
- window->Window.pContext.egl.Surface,
- window->Window.pContext.egl.Surface,
- window->Window.Context) == EGL_FALSE)
+ window->Window.pContext.egl.Surface,
+ window->Window.pContext.egl.Surface,
+ window->Window.Context) == EGL_FALSE)
fgError("eglMakeCurrent: err=%x\n", eglGetError());
}
}
*/
void fghPlatformCloseWindowEGL( SFG_Window* window )
{
- eglMakeCurrent(fgDisplay.pDisplay.egl.Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ /* Based on fg_window_mswin fgPlatformCloseWindow */
+ if( fgStructure.CurrentWindow == window )
+ eglMakeCurrent(fgDisplay.pDisplay.egl.Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+
if (window->Window.Context != EGL_NO_CONTEXT) {
- eglDestroyContext(fgDisplay.pDisplay.egl.Display, window->Window.Context);
+ /* Step through the list of windows. If the rendering context is not being used by another window, then delete it */
+ {
+ GLboolean used = GL_FALSE;
+ SFG_Window *iter;
+
+ for( iter = (SFG_Window*)fgStructure.Windows.First;
+ iter && used == GL_FALSE;
+ iter = (SFG_Window*)iter->Node.Next)
+ {
+ if( (iter->Window.Context == window->Window.Context) &&
+ (iter != window) )
+ used = GL_TRUE;
+ }
+
+ if( !used )
+ eglDestroyContext(fgDisplay.pDisplay.egl.Display, window->Window.Context);
+ }
window->Window.Context = EGL_NO_CONTEXT;
}
int i, j, argc = *pargc;
{
- /* check if GLUT_FPS env var is set */
+ /* check if GLUT_FPS env var is set */
const char *fps = getenv( "GLUT_FPS" );
if( fps )
return;
}
- /* If we're in game mode, we want to leave game mode */
+ /* If we're in game mode, we want to leave game mode */
if( fgStructure.GameModeWindow ) {
glutLeaveGameMode();
}
/* If there was a menu created, destroy the rendering context */
if( fgStructure.MenuContext )
{
- fgPlatformDestroyContext (fgDisplay.pDisplay, fgStructure.MenuContext->MContext );
+ fgPlatformDestroyContext (fgDisplay.pDisplay, fgStructure.MenuContext->MContext );
free( fgStructure.MenuContext );
fgStructure.MenuContext = NULL;
}
free( timer );
}
- fgPlatformDeinitialiseInputDevices ();
+ fgPlatformDeinitialiseInputDevices ();
- fgState.MouseWheelTicks = 0;
+ fgState.MouseWheelTicks = 0;
fgState.MajorVersion = 1;
fgState.MinorVersion = 0;
fgState.ProgramName = NULL;
}
- fgPlatformCloseDisplay ();
+ fgPlatformCloseDisplay ();
fgState.Initialised = GL_FALSE;
}
fgCreateStructure( );
- fghParseCommandLineArguments ( pargc, argv, &displayName, &geometry );
+ fghParseCommandLineArguments ( pargc, argv, &displayName, &geometry );
/*
* Have the display created now. If there wasn't a "-display"
*/
void fgSetWindow ( SFG_Window *window )
{
- fgPlatformSetWindow ( window );
+ fgPlatformSetWindow ( window );
fgStructure.CurrentWindow = window;
}
if (fgStructure.GameModeWindow != NULL && fgStructure.GameModeWindow->ID==window->ID)
glutLeaveGameMode();
- fgPlatformCloseWindow ( window );
+ fgPlatformCloseWindow ( window );
}
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetWindowTitle" );
if( ! fgStructure.CurrentWindow->Parent )
{
- fgPlatformGlutSetWindowTitle ( title );
+ fgPlatformGlutSetWindowTitle ( title );
}
}
if( ! fgStructure.CurrentWindow->Parent )
{
- fgPlatformGlutSetIconTitle ( title );
+ fgPlatformGlutSetIconTitle ( title );
}
}
}
if (!win->State.IsFullscreen)
- win->State.WorkMask |= GLUT_FULL_SCREEN_WORK;
+ win->State.WorkMask |= GLUT_FULL_SCREEN_WORK;
}
/*