X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fblackberry%2Ffg_window_blackberry.c;h=c0e2ce41df52bc67a5e2d055b9b7a7d353ce1cee;hb=c9c91332b9c0908c943cc10fa5ad073df6f3434e;hp=f18512ee907f8565fe66c23c9cd797bd60b41c47;hpb=4af25b80ace1e391f8886771bdf16c1db2a850f6;p=freeglut diff --git a/src/blackberry/fg_window_blackberry.c b/src/blackberry/fg_window_blackberry.c index f18512e..c0e2ce4 100644 --- a/src/blackberry/fg_window_blackberry.c +++ b/src/blackberry/fg_window_blackberry.c @@ -32,7 +32,6 @@ #include "fg_internal.h" #include "egl/fg_window_egl.h" #include -#include /* * Opens a window. Requires a SFG_Window object created and attached @@ -57,15 +56,25 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, } fgDisplay.pDisplay.single_native_window = sWindow; + /* Choose config and screen format */ + fghChooseConfig(&window->Window.pContext.egl.Config); + int screenFormat = SCREEN_FORMAT_RGBA8888; //Only SCREEN_FORMAT_RGBA8888 and SCREEN_FORMAT_RGB565 are supported. See fg_window_egl for more info + int configAttri; +#define EGL_QUERY_COMP(att, comp) (eglGetConfigAttrib(fgDisplay.pDisplay.egl.Display, window->Window.pContext.egl.Config, att, &configAttri) == GL_TRUE && (configAttri comp)) + if(EGL_QUERY_COMP(EGL_ALPHA_SIZE, <= 0) && EGL_QUERY_COMP(EGL_RED_SIZE, <= 5) && + EGL_QUERY_COMP(EGL_GREEN_SIZE, <= 6) && EGL_QUERY_COMP(EGL_BLUE_SIZE, <= 5)) { + screenFormat = SCREEN_FORMAT_RGB565; + } +#undef EGL_QUERY_COMP + /* Set window properties */ int orientation = atoi(getenv("ORIENTATION")); - int screenFormat = SCREEN_FORMAT_RGBA8888; //XXX Should this be determined by config? #ifdef GL_ES_VERSION_2_0 int screenUsage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION; #elif GL_VERSION_ES_CM_1_0 || GL_VERSION_ES_CL_1_0 || GL_VERSION_ES_CM_1_1 || GL_VERSION_ES_CL_1_1 int screenUsage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION; #endif -#ifndef __X86__ +#if !defined(__X86__) && !defined(__PLAYBOOK__) screenUsage |= SCREEN_USAGE_DISPLAY; // Physical device copy directly into physical display #endif if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_FORMAT, &screenFormat)) { @@ -159,6 +168,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, fgError("Could not set window rotation"); return; } + window->State.pWState.originalRotation = orientation; /* Set buffer sizes */ if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_BUFFER_SIZE, value)) { @@ -180,8 +190,11 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, window->State.IsFullscreen = GL_TRUE; //XXX Always fullscreen for now /* 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); @@ -189,9 +202,18 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, window->State.Visible = GL_TRUE; } +void fgPlatformFlushCommands() +{ + if(screen_flush_context(fgDisplay.pDisplay.screenContext, 0)) { + fgWarning("Could not flush screen context"); + } +} + void fgPlatformRotateWindow(SFG_Window* window, int rotation) { - screen_set_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_ROTATION, &rotation); + if(screen_set_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_ROTATION, &rotation)) { + fgWarning("Could not set window rotation"); + } } /*