2 * fg_window_blackberry.c
4 * Window management methods for BlackBerry
6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7 * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8 * Copied for Platform code by Evan Felix <karcaw at gmail.com>
9 * Copyright (C) 2012 Sylvain Beucler
10 * Copyright (C) 2013 Vincent Simonetti
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 #define FREEGLUT_BUILDING_LIB
31 #include <GL/freeglut.h>
32 #include "fg_internal.h"
33 #include "egl/fg_window_egl.h"
34 #include <screen/screen.h>
35 #include <bps/screen.h>
38 * Opens a window. Requires a SFG_Window object created and attached
39 * to the freeglut structure. OpenGL context is created here.
41 void fgPlatformOpenWindow( SFG_Window* window, const char* title,
42 GLboolean positionUse, int x, int y,
43 GLboolean sizeUse, int w, int h,
44 GLboolean gameMode, GLboolean isSubWindow )
46 /* TODO: only one full-screen window possible? */
47 if (fgDisplay.pDisplay.single_native_window != NULL) {
48 fgWarning("You can't have more than one window on BlackBerry");
53 screen_window_t sWindow;
54 if (screen_create_window(&sWindow, fgDisplay.pDisplay.screenContext)) {
55 fgError("Could not create window");
58 fgDisplay.pDisplay.single_native_window = sWindow;
60 /* Set window properties */
61 int screenFormat = SCREEN_FORMAT_RGBA8888; //XXX Should this be determined by config?
62 #ifdef GL_ES_VERSION_2_0
63 int screenUsage = SCREEN_USAGE_OPENGL_ES2;
64 #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
65 int screenUsage = SCREEN_USAGE_OPENGL_ES1;
68 screenUsage |= SCREEN_USAGE_DISPLAY; // Physical device copy directly into physical display
70 if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_FORMAT, &screenFormat)) {
71 screen_destroy_window(sWindow);
72 fgError("Could not set window format");
75 if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_USAGE, &screenUsage)) {
76 screen_destroy_window(sWindow);
77 fgError("Could not set window usage");
81 /* Could set size based on what is specified for window. Work on another time
85 if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_BUFFER_SIZE, size)) {
86 screen_destroy_window(sWindow);
87 fgError("Could not set window buffer size");
91 /* Create window buffers */
92 if (screen_create_window_buffers(sWindow, (fgState.DisplayMode & GLUT_DOUBLE) ? 2 : 1)) {
93 screen_destroy_window(sWindow);
94 fgError("Could not create window buffers");
98 /* Save window and set state */
99 window->Window.Handle = fgDisplay.pDisplay.single_native_window;
100 window->State.WorkMask |= GLUT_INIT_WORK;
101 window->State.IsFullscreen = GL_TRUE; //XXX Always fullscreen for now
104 fghChooseConfig(&window->Window.pContext.egl.Config);
105 window->Window.Context = fghCreateNewContextEGL(window);
107 /* Create EGL window */
108 fghPlatformOpenWindowEGL(window);
110 window->State.Visible = GL_TRUE;
114 * Request a window resize
116 void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height )
118 fprintf(stderr, "fgPlatformReshapeWindow: STUB\n");
122 * Closes a window, destroying the frame and OpenGL context
124 void fgPlatformCloseWindow( SFG_Window* window )
126 fghPlatformCloseWindowEGL(window);
128 screen_destroy_window((screen_window_t)window->Window.Handle);
132 * This function makes the specified window visible
134 void fgPlatformShowWindow( void )
136 fprintf(stderr, "fgPlatformShowWindow: STUB\n");
140 * This function hides the specified window
142 void fgPlatformHideWindow( SFG_Window *window )
144 fprintf(stderr, "fgPlatformHideWindow: STUB\n");
148 * Iconify the specified window (top-level windows only)
150 void fgPlatformIconifyWindow( SFG_Window *window )
152 //XXX This is possible via Cascades, but can't seem to find a C-level API
153 fprintf(stderr, "fgPlatformGlutIconifyWindow: STUB\n");
157 * Set the current window's title
159 void fgPlatformGlutSetWindowTitle( const char* title )
161 fprintf(stderr, "fgPlatformGlutSetWindowTitle: STUB\n");
165 * Set the current window's iconified title
167 void fgPlatformGlutSetIconTitle( const char* title )
169 fprintf(stderr, "fgPlatformGlutSetIconTitle: STUB\n");
173 * Change the specified window's position
175 void fgPlatformPositionWindow( SFG_Window *window, int x, int y )
177 fprintf(stderr, "fgPlatformPositionWindow: STUB\n");
181 * Lowers the specified window (by Z order change)
183 void fgPlatformPushWindow( SFG_Window *window )
185 fprintf(stderr, "fgPlatformPushWindow: STUB\n");
189 * Raises the specified window (by Z order change)
191 void fgPlatformPopWindow( SFG_Window *window )
193 fprintf(stderr, "fgPlatformPopWindow: STUB\n");
197 * Toggle the window's full screen state.
199 void fgPlatformFullScreenToggle( SFG_Window *win )
201 fprintf(stderr, "fgPlatformFullScreenToggle: STUB\n");