From: Rcmaniac25 Date: Fri, 24 Jan 2014 10:25:10 +0000 (+0000) Subject: Implemented fg_window_blackberry.c to initialize and cleanup windows Implemented... X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=3e7cf561c1470dbee736cd9b371fef14aa5491b1;p=freeglut Implemented fg_window_blackberry.c to initialize and cleanup windows Implemented a BlackBerry specific fg_init so that bps can be started and stopped. git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1646 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/CMakeLists.txt b/CMakeLists.txt index a8cb8b3..4baf592 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,7 +123,6 @@ ELSEIF(ANDROID OR BLACKBERRY) src/android/fg_cursor_android.c src/android/fg_ext_android.c src/android/fg_gamemode_android.c - src/android/fg_init_android.c src/android/fg_input_devices_android.c src/android/fg_joystick_android.c src/android/fg_spaceball_android.c @@ -133,6 +132,7 @@ ELSEIF(ANDROID OR BLACKBERRY) LIST(APPEND FREEGLUT_SRCS src/android/native_app_glue/android_native_app_glue.c src/android/native_app_glue/android_native_app_glue.h + src/android/fg_init_android.c src/android/fg_internal_android.h src/android/fg_main_android.c src/android/fg_main_android.h @@ -143,12 +143,13 @@ ELSEIF(ANDROID OR BLACKBERRY) ELSE() LIST(APPEND FREEGLUT_SRCS # TODO: Anything similar to Android's app_glue? + src/blackberry/fg_init_blackberry.c src/blackberry/fg_internal_blackberry.h # TODO: src/blackberry/fg_main_blackberry.c src/blackberry/fg_main_blackberry.h # TODO: Anything similar to fg_spaceball_android.c needed? src/blackberry/fg_state_blackberry.c - # TODO: src/blackberry/fg_window_blackberry.c + src/blackberry/fg_window_blackberry.c ) ENDIF() ELSE() diff --git a/src/blackberry/fg_init_blackberry.c b/src/blackberry/fg_init_blackberry.c new file mode 100644 index 0000000..4dee11d --- /dev/null +++ b/src/blackberry/fg_init_blackberry.c @@ -0,0 +1,60 @@ +/* + * fg_init_blackberry.c + * + * Various freeglut initialization functions. + * + * Copyright (C) 2012 Sylvain Beucler + * Copyright (C) 2013 Vincent Simonetti + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include "fg_internal.h" +#include "fg_init.h" +#include "egl/fg_init_egl.h" +#include + +void fgPlatformInitialize() +{ + bps_initialize(); + + fghPlatformInitializeEGL(); + + /* Get start time */ + fgState.Time = fgSystemTime(); + + fgState.Initialised = GL_TRUE; +} + +void fgPlatformCloseDisplay() +{ + fghPlatformCloseDisplayEGL(); + + bps_shutdown(); +} + +/** + * Close joystick and serial input devices + */ +void fgPlatformDeinitialiseInputDevices ( void ) +{ + fghCloseInputDevices (); + fgState.JoysticksInitialised = GL_FALSE; + fgState.InputDevsInitialised = GL_FALSE; +} diff --git a/src/blackberry/fg_internal_blackberry.h b/src/blackberry/fg_internal_blackberry.h index 0223144..40e9fda 100644 --- a/src/blackberry/fg_internal_blackberry.h +++ b/src/blackberry/fg_internal_blackberry.h @@ -32,6 +32,7 @@ /* -- PLATFORM-SPECIFIC INCLUDES ------------------------------------------- */ /* BlackBerry OpenGL ES is accessed through EGL */ #include "egl/fg_internal_egl.h" +#include /* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */ /* The structure used by display initialization in freeglut_init.c */ @@ -47,6 +48,7 @@ typedef struct tagSFG_PlatformContext SFG_PlatformContext; struct tagSFG_PlatformContext { struct tagSFG_PlatformContextEGL egl; + screen_context_t screenContext; }; diff --git a/src/blackberry/fg_state_blackberry.c b/src/blackberry/fg_state_blackberry.c index 600a826..a6955e2 100644 --- a/src/blackberry/fg_state_blackberry.c +++ b/src/blackberry/fg_state_blackberry.c @@ -76,7 +76,7 @@ int fgPlatformGlutGet ( GLenum eWhat ) if ( fgStructure.CurrentWindow == NULL ) return 0; int size[2]; - if ( screen_get_window_property_iv(fgStructure.CurrentWindow->Window.Handle, SCREEN_PROPERTY_SIZE, size) != 0 ) + if ( screen_get_window_property_iv(fgStructure.CurrentWindow->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0 ) return 0; switch ( eWhat ) { diff --git a/src/blackberry/fg_window_blackberry.c b/src/blackberry/fg_window_blackberry.c new file mode 100644 index 0000000..1f13b55 --- /dev/null +++ b/src/blackberry/fg_window_blackberry.c @@ -0,0 +1,212 @@ +/* + * fg_window_blackberry.c + * + * Window management methods for BlackBerry + * + * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. + * Written by Pawel W. Olszta, + * Copied for Platform code by Evan Felix + * Copyright (C) 2012 Sylvain Beucler + * Copyright (C) 2013 Vincent Simonetti + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#define FREEGLUT_BUILDING_LIB +#include +#include "fg_internal.h" +#include "egl/fg_window_egl.h" +#include +#include + +/* + * Opens a window. Requires a SFG_Window object created and attached + * to the freeglut structure. OpenGL context is created here. + */ +void fgPlatformOpenWindow( SFG_Window* window, const char* title, + GLboolean positionUse, int x, int y, + GLboolean sizeUse, int w, int h, + GLboolean gameMode, GLboolean isSubWindow ) +{ + /* TODO: only one full-screen window possible? */ + if (fgDisplay.pDisplay.single_native_window != NULL) { + fgWarning("You can't have more than one window on BlackBerry"); + return; + } + + /* Create window */ + if (screen_create_context(&window->Window.pContext.screenContext, 0)) { + fgError("Could not create screen context"); + return; + } + screen_window_t sWindow; + if (screen_create_window(&sWindow, window->Window.pContext.screenContext)) { + screen_destroy_context(window->Window.pContext.screenContext); + fgError("Could not create window"); + return; + } + fgDisplay.pDisplay.single_native_window = sWindow; + + /* Set window properties */ + int screenFormat = SCREEN_FORMAT_RGBA8888; +#ifdef __X86__ + int screenUsage = SCREEN_USAGE_OPENGL_ES2; +#else + int screenUsage = SCREEN_USAGE_DISPLAY | SCREEN_USAGE_OPENGL_ES2; // Physical device copy directly into physical display +#endif + if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_FORMAT, &screenFormat)) { + screen_destroy_window(sWindow); + screen_destroy_context(window->Window.pContext.screenContext); + fgError("Could not set window format"); + return; + } + if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_USAGE, &screenUsage)) { + screen_destroy_window(sWindow); + screen_destroy_context(window->Window.pContext.screenContext); + fgError("Could not set window usage"); + return; + } + + /* Could set size based on what is specified for window. Work on another time + int size[2]; + size[0] = w; + size[1] = h; + if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_BUFFER_SIZE, size)) { + screen_destroy_window(sWindow); + screen_destroy_context(window->Window.pContext.screenContext); + fgError("Could not set window buffer size"); + return; + }*/ + + /* Create window buffers */ + if (screen_create_window_buffers(sWindow, 2)) { + screen_destroy_window(sWindow); + screen_destroy_context(window->Window.pContext.screenContext); + fgError("Could not create window buffers"); + return; + } + + /* Request window events */ + screen_request_events(window->Window.pContext.screenContext); + + /* Save window */ + window->Window.Handle = fgDisplay.pDisplay.single_native_window; + window->State.WorkMask |= GLUT_INIT_WORK; + + /* Create context */ + fghChooseConfig(&window->Window.pContext.egl.Config); + window->Window.Context = fghCreateNewContextEGL(window); + + /* Create EGL window */ + fghPlatformOpenWindowEGL(window); + + window->State.Visible = GL_TRUE; +} + +/* + * Request a window resize + */ +void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ) +{ + fprintf(stderr, "fgPlatformReshapeWindow: STUB\n"); +} + +/* + * Closes a window, destroying the frame and OpenGL context + */ +void fgPlatformCloseWindow( SFG_Window* window ) +{ + fghPlatformCloseWindowEGL(window); + + screen_stop_events(window->Window.pContext.screenContext); + + screen_destroy_window((screen_window_t)window->Window.Handle); + + screen_destroy_context(window->Window.pContext.screenContext); +} + +/* + * This function makes the specified window visible + */ +void fgPlatformShowWindow( void ) +{ + fprintf(stderr, "fgPlatformShowWindow: STUB\n"); +} + +/* + * This function hides the specified window + */ +void fgPlatformHideWindow( SFG_Window *window ) +{ + fprintf(stderr, "fgPlatformHideWindow: STUB\n"); +} + +/* + * Iconify the specified window (top-level windows only) + */ +void fgPlatformIconifyWindow( SFG_Window *window ) +{ + fprintf(stderr, "fgPlatformGlutIconifyWindow: STUB\n"); +} + +/* + * Set the current window's title + */ +void fgPlatformGlutSetWindowTitle( const char* title ) +{ + fprintf(stderr, "fgPlatformGlutSetWindowTitle: STUB\n"); +} + +/* + * Set the current window's iconified title + */ +void fgPlatformGlutSetIconTitle( const char* title ) +{ + fprintf(stderr, "fgPlatformGlutSetIconTitle: STUB\n");} + +/* + * Change the specified window's position + */ +void fgPlatformPositionWindow( SFG_Window *window, int x, int y ) +{ + fprintf(stderr, "fgPlatformPositionWindow: STUB\n"); +} + +/* + * Lowers the specified window (by Z order change) + */ +void fgPlatformPushWindow( SFG_Window *window ) +{ + fprintf(stderr, "fgPlatformPushWindow: STUB\n"); +} + +/* + * Raises the specified window (by Z order change) + */ +void fgPlatformPopWindow( SFG_Window *window ) +{ + fprintf(stderr, "fgPlatformPopWindow: STUB\n"); +} + +/* + * Toggle the window's full screen state. + */ +void fgPlatformFullScreenToggle( SFG_Window *win ) +{ + fprintf(stderr, "fgPlatformFullScreenToggle: STUB\n"); +}