Info logging only shows in debug compilation Added support for UseCurrentContext flag Updated fghPlatformCloseWindowEGL for performance so that eglMakeCurrent isn't invoked unless it's the current window and that the EGL context isn't destroyed unless no other windows uses

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1673 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2014-01-24 10:34:49 +00:00
parent c5201e73ef
commit e8cc20621f
5 changed files with 50 additions and 22 deletions

View File

@ -32,7 +32,11 @@
#include "egl/fg_window_egl.h" #include "egl/fg_window_egl.h"
#include <slog2.h> #include <slog2.h>
#ifdef NDEBUG
#define LOGI(...)
#else
#define LOGI(...) ((void)slog2fa(NULL, 1337, SLOG2_INFO, __VA_ARGS__, SLOG2_FA_END)) #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)) #define LOGW(...) ((void)slog2fa(NULL, 1337, SLOG2_WARNING, __VA_ARGS__, SLOG2_FA_END))
#include <sys/keycodes.h> #include <sys/keycodes.h>
#include <input/screen_helpers.h> #include <input/screen_helpers.h>
@ -165,7 +169,8 @@ fg_time_t fgPlatformSystemTime ( void )
*/ */
void fgPlatformSleepForEvents( fg_time_t msec ) 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"); LOGW("BPS couldn't get event");
} }
} }

View File

@ -182,6 +182,10 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
/* Create context */ /* Create context */
fghChooseConfig(&window->Window.pContext.egl.Config); fghChooseConfig(&window->Window.pContext.egl.Config);
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); window->Window.Context = fghCreateNewContextEGL(window);
/* Create EGL window */ /* Create EGL window */

View File

@ -138,9 +138,28 @@ void fghPlatformOpenWindowEGL( SFG_Window* window )
*/ */
void fghPlatformCloseWindowEGL( SFG_Window* window ) void fghPlatformCloseWindowEGL( SFG_Window* window )
{ {
/* Based on fg_window_mswin fgPlatformCloseWindow */
if( fgStructure.CurrentWindow == window )
eglMakeCurrent(fgDisplay.pDisplay.egl.Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(fgDisplay.pDisplay.egl.Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (window->Window.Context != EGL_NO_CONTEXT) { if (window->Window.Context != EGL_NO_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); eglDestroyContext(fgDisplay.pDisplay.egl.Display, window->Window.Context);
}
window->Window.Context = EGL_NO_CONTEXT; window->Window.Context = EGL_NO_CONTEXT;
} }