X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fblackberry%2Ffg_window_blackberry.c;h=86668af1d865911a95ebaf44d3d24635acbb7355;hb=421588fbbc5a989c5722a0eae212917cb86e8f26;hp=0cc14c97053dc24464cd3bf7659826aabc7ebc1f;hpb=5f89d95bd3ce9d96f28b457afe53e68098a8380e;p=freeglut diff --git a/src/blackberry/fg_window_blackberry.c b/src/blackberry/fg_window_blackberry.c index 0cc14c9..86668af 100644 --- a/src/blackberry/fg_window_blackberry.c +++ b/src/blackberry/fg_window_blackberry.c @@ -31,8 +31,7 @@ #include #include "fg_internal.h" #include "egl/fg_window_egl.h" -#include -#include +#include /* * Opens a window. Requires a SFG_Window object created and attached @@ -57,15 +56,31 @@ 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; + int screenUsage = SCREEN_USAGE_ROTATION; +#ifdef SCREEN_USAGE_OPENGL_ES3 + if (fgState.MajorVersion >= 3) { + screenUsage |= SCREEN_USAGE_OPENGL_ES3; + } else #endif -#ifndef __X86__ + if (fgState.MajorVersion >= 2) { + screenUsage |= SCREEN_USAGE_OPENGL_ES2; + } else { + screenUsage |= SCREEN_USAGE_OPENGL_ES1; + } +#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)) { @@ -181,8 +196,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); @@ -243,9 +261,20 @@ void fgPlatformHideWindow( SFG_Window *window ) */ void fgPlatformIconifyWindow( SFG_Window *window ) { - //XXX This is possible via Cascades, but can't seem to find a C-level API - //XXX bb::Application::instance()->minimize(); +#ifndef __PLAYBOOK__ + pps_encoder_t encoder; + + pps_encoder_initialize(&encoder, false); + pps_encoder_add_string(&encoder, "msg", "minimizeWindow"); + + if (navigator_raw_write(pps_encoder_buffer(&encoder), pps_encoder_length(&encoder)) != BPS_SUCCESS) { + fgWarning("Could not iconify window on BlackBerry"); + } + + pps_encoder_cleanup(&encoder); +#else fprintf(stderr, "fgPlatformGlutIconifyWindow: STUB\n"); +#endif } /* @@ -261,6 +290,7 @@ void fgPlatformGlutSetWindowTitle( const char* title ) */ void fgPlatformGlutSetIconTitle( const char* title ) { + //XXX Possibly a window cover label? fprintf(stderr, "fgPlatformGlutSetIconTitle: STUB\n"); }