From 2d252401e5ed48358f8fb2d05be8169309d05eda Mon Sep 17 00:00:00 2001 From: Rcmaniac25 Date: Fri, 24 Jan 2014 10:27:43 +0000 Subject: [PATCH] Converted the odd double spaces into 4 space tabs git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1655 7f0cb862-5218-0410-a997-914c9d46530a --- src/blackberry/fg_init_blackberry.c | 20 +- src/blackberry/fg_internal_blackberry.h | 40 +- src/blackberry/fg_main_blackberry.c | 770 +++++++++++++++---------------- src/blackberry/fg_state_blackberry.c | 59 +-- src/blackberry/fg_window_blackberry.c | 176 +++---- 5 files changed, 534 insertions(+), 531 deletions(-) diff --git a/src/blackberry/fg_init_blackberry.c b/src/blackberry/fg_init_blackberry.c index 40b1ed6..5a1a9d9 100644 --- a/src/blackberry/fg_init_blackberry.c +++ b/src/blackberry/fg_init_blackberry.c @@ -33,26 +33,26 @@ void fgPlatformInitialize() { - bps_initialize(); + bps_initialize(); - navigator_request_events(0); - //XXX rotation lock? navigator_rotation_lock(true); + navigator_request_events(0); + //XXX rotation lock? navigator_rotation_lock(true); - fghPlatformInitializeEGL(); + fghPlatformInitializeEGL(); - /* Get start time */ - fgState.Time = fgSystemTime(); + /* Get start time */ + fgState.Time = fgSystemTime(); - fgState.Initialised = GL_TRUE; + fgState.Initialised = GL_TRUE; } void fgPlatformCloseDisplay() { - fghPlatformCloseDisplayEGL(); + fghPlatformCloseDisplayEGL(); - navigator_stop_events(0); + navigator_stop_events(0); - bps_shutdown(); + bps_shutdown(); } /** diff --git a/src/blackberry/fg_internal_blackberry.h b/src/blackberry/fg_internal_blackberry.h index d6b0e3c..229ce05 100644 --- a/src/blackberry/fg_internal_blackberry.h +++ b/src/blackberry/fg_internal_blackberry.h @@ -40,17 +40,17 @@ typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay; struct tagSFG_PlatformDisplay { - struct tagSFG_PlatformDisplayEGL egl; - EGLNativeWindowType single_native_window; + struct tagSFG_PlatformDisplayEGL egl; + EGLNativeWindowType single_native_window; }; typedef struct tagSFG_PlatformContext SFG_PlatformContext; /* SFG_PlatformContext is used for SFG_Window.Window */ struct tagSFG_PlatformContext { - struct tagSFG_PlatformContextEGL egl; - screen_context_t screenContext; - bps_event_t* event; + struct tagSFG_PlatformContextEGL egl; + screen_context_t screenContext; + bps_event_t* event; }; @@ -76,34 +76,34 @@ struct touchscreen { * interspersed */ - /* - * We'll put these values in and that should - * allow the code to at least compile when there is - * no support. The JS open routine should error out - * and shut off all the code downstream anyway and if - * the application doesn't use a joystick we'll be fine. - */ +/* + * We'll put these values in and that should + * allow the code to at least compile when there is + * no support. The JS open routine should error out + * and shut off all the code downstream anyway and if + * the application doesn't use a joystick we'll be fine. + */ - struct JS_DATA_TYPE - { +struct JS_DATA_TYPE +{ int buttons; int x; int y; - }; +}; -# define JS_RETURN (sizeof(struct JS_DATA_TYPE)) +#define JS_RETURN (sizeof(struct JS_DATA_TYPE)) /* XXX It might be better to poll the operating system for the numbers of buttons and * XXX axes and then dynamically allocate the arrays. */ -# define _JS_MAX_AXES 16 +#define _JS_MAX_AXES 16 typedef struct tagSFG_PlatformJoystick SFG_PlatformJoystick; struct tagSFG_PlatformJoystick { - struct JS_DATA_TYPE js; + struct JS_DATA_TYPE js; - char fname [ 128 ]; - int fd; + char fname [ 128 ]; + int fd; }; /* Window's state description. This structure should be kept portable. */ diff --git a/src/blackberry/fg_main_blackberry.c b/src/blackberry/fg_main_blackberry.c index db3f5c6..f7b8f66 100644 --- a/src/blackberry/fg_main_blackberry.c +++ b/src/blackberry/fg_main_blackberry.c @@ -56,87 +56,87 @@ static struct touchscreen touchscreen; unsigned int key_special(int qnxKeycode) { - switch(qnxKeycode) { - case KEYCODE_F1: - return GLUT_KEY_F1; - case KEYCODE_F2: - return GLUT_KEY_F2; - case KEYCODE_F3: - return GLUT_KEY_F3; - case KEYCODE_F4: - return GLUT_KEY_F4; - case KEYCODE_F5: - return GLUT_KEY_F5; - case KEYCODE_F6: - return GLUT_KEY_F6; - case KEYCODE_F7: - return GLUT_KEY_F7; - case KEYCODE_F8: - return GLUT_KEY_F8; - case KEYCODE_F9: - return GLUT_KEY_F9; - case KEYCODE_F10: - return GLUT_KEY_F10; - case KEYCODE_F11: - return GLUT_KEY_F11; - case KEYCODE_F12: - return GLUT_KEY_F12; - case KEYCODE_PG_UP: - return GLUT_KEY_PAGE_UP; - case KEYCODE_PG_DOWN: - return GLUT_KEY_PAGE_DOWN; - case KEYCODE_HOME: - return GLUT_KEY_HOME; - case KEYCODE_END: - return GLUT_KEY_END; - case KEYCODE_INSERT: - return GLUT_KEY_INSERT; - case KEYCODE_UP: - //case KEYCODE_KP_UP: - return GLUT_KEY_UP; - case KEYCODE_DOWN: - //case KEYCODE_KP_DOWN: - return GLUT_KEY_DOWN; - case KEYCODE_LEFT: - //case KEYCODE_KP_LEFT: - return GLUT_KEY_LEFT; - case KEYCODE_RIGHT: - //case KEYCODE_KP_RIGHT: - return GLUT_KEY_RIGHT; - case KEYCODE_NUM_LOCK: - return GLUT_KEY_NUM_LOCK; - case KEYCODE_LEFT_ALT: - return GLUT_KEY_ALT_L; - case KEYCODE_RIGHT_ALT: - return GLUT_KEY_ALT_R; - case KEYCODE_LEFT_SHIFT: - return GLUT_KEY_SHIFT_L; - case KEYCODE_RIGHT_SHIFT: - return GLUT_KEY_SHIFT_R; - case KEYCODE_LEFT_CTRL: - return GLUT_KEY_CTRL_L; - case KEYCODE_RIGHT_CTRL: - return GLUT_KEY_CTRL_R; - } - return 0; + switch(qnxKeycode) { + case KEYCODE_F1: + return GLUT_KEY_F1; + case KEYCODE_F2: + return GLUT_KEY_F2; + case KEYCODE_F3: + return GLUT_KEY_F3; + case KEYCODE_F4: + return GLUT_KEY_F4; + case KEYCODE_F5: + return GLUT_KEY_F5; + case KEYCODE_F6: + return GLUT_KEY_F6; + case KEYCODE_F7: + return GLUT_KEY_F7; + case KEYCODE_F8: + return GLUT_KEY_F8; + case KEYCODE_F9: + return GLUT_KEY_F9; + case KEYCODE_F10: + return GLUT_KEY_F10; + case KEYCODE_F11: + return GLUT_KEY_F11; + case KEYCODE_F12: + return GLUT_KEY_F12; + case KEYCODE_PG_UP: + return GLUT_KEY_PAGE_UP; + case KEYCODE_PG_DOWN: + return GLUT_KEY_PAGE_DOWN; + case KEYCODE_HOME: + return GLUT_KEY_HOME; + case KEYCODE_END: + return GLUT_KEY_END; + case KEYCODE_INSERT: + return GLUT_KEY_INSERT; + case KEYCODE_UP: + //case KEYCODE_KP_UP: + return GLUT_KEY_UP; + case KEYCODE_DOWN: + //case KEYCODE_KP_DOWN: + return GLUT_KEY_DOWN; + case KEYCODE_LEFT: + //case KEYCODE_KP_LEFT: + return GLUT_KEY_LEFT; + case KEYCODE_RIGHT: + //case KEYCODE_KP_RIGHT: + return GLUT_KEY_RIGHT; + case KEYCODE_NUM_LOCK: + return GLUT_KEY_NUM_LOCK; + case KEYCODE_LEFT_ALT: + return GLUT_KEY_ALT_L; + case KEYCODE_RIGHT_ALT: + return GLUT_KEY_ALT_R; + case KEYCODE_LEFT_SHIFT: + return GLUT_KEY_SHIFT_L; + case KEYCODE_RIGHT_SHIFT: + return GLUT_KEY_SHIFT_R; + case KEYCODE_LEFT_CTRL: + return GLUT_KEY_CTRL_L; + case KEYCODE_RIGHT_CTRL: + return GLUT_KEY_CTRL_R; + } + return 0; } unsigned char key_ascii(int qnxKeycode) { - if (qnxKeycode >= KEYCODE_PC_KEYS && qnxKeycode <= UNICODE_PRIVATE_USE_AREA_LAST) { - switch (qnxKeycode) { - case KEYCODE_BACKSPACE: - return 0x0008; - case KEYCODE_TAB: - return 0x0009; - case KEYCODE_KP_ENTER: - case KEYCODE_RETURN: - return 0x000A; - case KEYCODE_ESCAPE: - return 0x001B; - } - } - return qnxKeycode; + if (qnxKeycode >= KEYCODE_PC_KEYS && qnxKeycode <= UNICODE_PRIVATE_USE_AREA_LAST) { + switch (qnxKeycode) { + case KEYCODE_BACKSPACE: + return 0x0008; + case KEYCODE_TAB: + return 0x0009; + case KEYCODE_KP_ENTER: + case KEYCODE_RETURN: + return 0x000A; + case KEYCODE_ESCAPE: + return 0x001B; + } + } + return qnxKeycode; } //From fg_main_x11 @@ -159,326 +159,326 @@ fg_time_t fgPlatformSystemTime ( void ) */ void fgPlatformSleepForEvents( fg_time_t msec ) { - //XXX: Is this right? Is there a more direct way to access the context? - if(bps_get_event(&fgStructure.CurrentWindow->Window.pContext.event, (int)msec) != BPS_SUCCESS) { - LOGW("BPS couldn't get event"); - } + //XXX: Is this right? Is there a more direct way to access the context? + if(bps_get_event(&fgStructure.CurrentWindow->Window.pContext.event, (int)msec) != BPS_SUCCESS) { + LOGW("BPS couldn't get event"); + } } void handle_left_mouse(int x, int y, int height, int eventType, SFG_Window* window) { - bool handled = false; - /* Virtual arrows PAD */ - /* Don't interfere with existing mouse move event */ - if (!touchscreen.in_mmotion) { - struct vpad_state prev_vpad = touchscreen.vpad; - touchscreen.vpad.left = touchscreen.vpad.right = touchscreen.vpad.up = touchscreen.vpad.down = false; - - if (eventType == SCREEN_EVENT_MTOUCH_TOUCH || eventType == SCREEN_EVENT_MTOUCH_MOVE) { - if ((x > 0 && x < 100) && (y > (height - 100) && y < height)) - { - touchscreen.vpad.left = true; - } - if ((x > 200 && x < 300) && (y > (height - 100) && y < height)) - { - touchscreen.vpad.right = true; - } - if ((x > 100 && x < 200) && (y > (height - 100) && y < height)) - { - touchscreen.vpad.down = true; - } - if ((x > 100 && x < 200) && (y > (height - 200) && y < (height - 100))) - { - touchscreen.vpad.up = true; - } - } - - if (eventType == SCREEN_EVENT_MTOUCH_TOUCH && - (touchscreen.vpad.left || touchscreen.vpad.right || touchscreen.vpad.down || touchscreen.vpad.up)) { - touchscreen.vpad.on = true; - } - if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) { - touchscreen.vpad.on = false; - } - - if (prev_vpad.left != touchscreen.vpad.left - || prev_vpad.right != touchscreen.vpad.right - || prev_vpad.up != touchscreen.vpad.up - || prev_vpad.down != touchscreen.vpad.down - || prev_vpad.on != touchscreen.vpad.on) { - if (FETCH_WCB(*window, Special)) { - if (prev_vpad.left == false && touchscreen.vpad.left == true) { - INVOKE_WCB(*window, Special, (GLUT_KEY_LEFT, x, y)); - } - else if (prev_vpad.right == false && touchscreen.vpad.right == true) { - INVOKE_WCB(*window, Special, (GLUT_KEY_RIGHT, x, y)); - } - else if (prev_vpad.up == false && touchscreen.vpad.up == true) { - INVOKE_WCB(*window, Special, (GLUT_KEY_UP, x, y)); - } - else if (prev_vpad.down == false && touchscreen.vpad.down == true) { - INVOKE_WCB(*window, Special, (GLUT_KEY_DOWN, x, y)); - } - } - if (FETCH_WCB(*window, SpecialUp)) { - if (prev_vpad.left == true && touchscreen.vpad.left == false) { - INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_LEFT, x, y)); - } - if (prev_vpad.right == true && touchscreen.vpad.right == false) { - INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_RIGHT, x, y)); - } - if (prev_vpad.up == true && touchscreen.vpad.up == false) { - INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_UP, x, y)); - } - if (prev_vpad.down == true && touchscreen.vpad.down == false) { - INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_DOWN, x, y)); - } - } - handled = true; - } - } - - /* Normal mouse events */ - if (!handled && !touchscreen.vpad.on) { - window->State.MouseX = x; - window->State.MouseY = y; - - if(eventType == SCREEN_EVENT_MTOUCH_MOVE) { - INVOKE_WCB(*window, Motion, (x, y)); - } else if(FETCH_WCB(*window, Mouse)) { - touchscreen.in_mmotion = eventType == SCREEN_EVENT_MTOUCH_TOUCH; - int glutTouchType = eventType == SCREEN_EVENT_MTOUCH_TOUCH ? GLUT_DOWN : GLUT_UP; - INVOKE_WCB(*window, Mouse, (GLUT_LEFT_BUTTON, glutTouchType, x, y)); - } - } + bool handled = false; + /* Virtual arrows PAD */ + /* Don't interfere with existing mouse move event */ + if (!touchscreen.in_mmotion) { + struct vpad_state prev_vpad = touchscreen.vpad; + touchscreen.vpad.left = touchscreen.vpad.right = touchscreen.vpad.up = touchscreen.vpad.down = false; + + if (eventType == SCREEN_EVENT_MTOUCH_TOUCH || eventType == SCREEN_EVENT_MTOUCH_MOVE) { + if ((x > 0 && x < 100) && (y > (height - 100) && y < height)) + { + touchscreen.vpad.left = true; + } + if ((x > 200 && x < 300) && (y > (height - 100) && y < height)) + { + touchscreen.vpad.right = true; + } + if ((x > 100 && x < 200) && (y > (height - 100) && y < height)) + { + touchscreen.vpad.down = true; + } + if ((x > 100 && x < 200) && (y > (height - 200) && y < (height - 100))) + { + touchscreen.vpad.up = true; + } + } + + if (eventType == SCREEN_EVENT_MTOUCH_TOUCH && + (touchscreen.vpad.left || touchscreen.vpad.right || touchscreen.vpad.down || touchscreen.vpad.up)) { + touchscreen.vpad.on = true; + } + if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) { + touchscreen.vpad.on = false; + } + + if (prev_vpad.left != touchscreen.vpad.left + || prev_vpad.right != touchscreen.vpad.right + || prev_vpad.up != touchscreen.vpad.up + || prev_vpad.down != touchscreen.vpad.down + || prev_vpad.on != touchscreen.vpad.on) { + if (FETCH_WCB(*window, Special)) { + if (prev_vpad.left == false && touchscreen.vpad.left == true) { + INVOKE_WCB(*window, Special, (GLUT_KEY_LEFT, x, y)); + } + else if (prev_vpad.right == false && touchscreen.vpad.right == true) { + INVOKE_WCB(*window, Special, (GLUT_KEY_RIGHT, x, y)); + } + else if (prev_vpad.up == false && touchscreen.vpad.up == true) { + INVOKE_WCB(*window, Special, (GLUT_KEY_UP, x, y)); + } + else if (prev_vpad.down == false && touchscreen.vpad.down == true) { + INVOKE_WCB(*window, Special, (GLUT_KEY_DOWN, x, y)); + } + } + if (FETCH_WCB(*window, SpecialUp)) { + if (prev_vpad.left == true && touchscreen.vpad.left == false) { + INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_LEFT, x, y)); + } + if (prev_vpad.right == true && touchscreen.vpad.right == false) { + INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_RIGHT, x, y)); + } + if (prev_vpad.up == true && touchscreen.vpad.up == false) { + INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_UP, x, y)); + } + if (prev_vpad.down == true && touchscreen.vpad.down == false) { + INVOKE_WCB(*window, SpecialUp, (GLUT_KEY_DOWN, x, y)); + } + } + handled = true; + } + } + + /* Normal mouse events */ + if (!handled && !touchscreen.vpad.on) { + window->State.MouseX = x; + window->State.MouseY = y; + + if(eventType == SCREEN_EVENT_MTOUCH_MOVE) { + INVOKE_WCB(*window, Motion, (x, y)); + } else if(FETCH_WCB(*window, Mouse)) { + touchscreen.in_mmotion = eventType == SCREEN_EVENT_MTOUCH_TOUCH; + int glutTouchType = eventType == SCREEN_EVENT_MTOUCH_TOUCH ? GLUT_DOWN : GLUT_UP; + INVOKE_WCB(*window, Mouse, (GLUT_LEFT_BUTTON, glutTouchType, x, y)); + } + } } void fgPlatformProcessSingleEvent ( void ) { - int domain; - bps_event_t** eventPtr = &fgStructure.CurrentWindow->Window.pContext.event; //XXX Is there a more direct way to access the context? - bps_event_t* event; - do - { - if(*eventPtr != NULL) { - SFG_Window* window = fgStructure.CurrentWindow; - if (window != NULL && window->Window.Handle != NULL) { - int size[2]; - screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size); - fghOnReshapeNotify(window,size[0],size[1],GL_FALSE); - } - - event = *eventPtr; - domain = bps_event_get_domain(event); - if (domain == screen_get_domain()) { - int eventType; - screen_event_t screenEvent = screen_event_get_event(event); - screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_TYPE, &eventType); - switch (eventType) { - - //Mostly from fg_main_android - case SCREEN_EVENT_MTOUCH_TOUCH: - case SCREEN_EVENT_MTOUCH_RELEASE: - case SCREEN_EVENT_MTOUCH_MOVE: - { - mtouch_event_t touchEvent; - screen_get_mtouch_event(screenEvent, &touchEvent, 0); - LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_MTOUCH_*: Type: 0x%X, X: %d, Y: %d, Contact Id: %d", SLOG2_FA_SIGNED(eventType), SLOG2_FA_SIGNED(touchEvent.x), SLOG2_FA_SIGNED(touchEvent.y), SLOG2_FA_SIGNED(touchEvent.contact_id)); - if(touchEvent.contact_id == 0) { - int size[2]; - screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size); - handle_left_mouse(touchEvent.x, touchEvent.y, size[1], eventType, window); - } - - //Now handle mutlitouch (adapted from fg_main_windows) - if (eventType == SCREEN_EVENT_MTOUCH_TOUCH) { - INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_ENTERED ) ); - INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_DOWN ) ); - } else if (eventType == SCREEN_EVENT_MTOUCH_MOVE) { - INVOKE_WCB( *window, MultiMotion, ( touchEvent.contact_id, touchEvent.x, touchEvent.y ) ); - //XXX No motion is performed without contact, thus MultiPassive is never used - } else if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) { - INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_UP ) ); - INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_LEFT ) ); - } - break; - } - - case SCREEN_EVENT_POINTER: - { - //Based off/part taken from GamePlay3d PlatformBlackBerry - static int mouse_pressed = 0; - int buttons; - int position[2]; - int wheel; - // A move event will be fired unless a button state changed. - bool move = true; - bool left_move = false; - // This is a mouse move event, it is applicable to a device with a usb mouse or simulator. - screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_BUTTONS, &buttons); - screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_SOURCE_POSITION, position); - screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_MOUSE_WHEEL, &wheel); - int size[2]; - screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size); - - LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_POINTER: Buttons: 0x%X, X: %d, Y: %d, Wheel: %d", SLOG2_FA_SIGNED(buttons), SLOG2_FA_SIGNED(position[0]), SLOG2_FA_SIGNED(position[1]), SLOG2_FA_SIGNED(wheel)); - - //XXX Should multitouch be handled? - - // Handle left mouse. Interpret as touch if the left mouse event is not consumed. - if (buttons & SCREEN_LEFT_MOUSE_BUTTON) { - if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) { - left_move = true; - } else { - move = false; - mouse_pressed |= SCREEN_LEFT_MOUSE_BUTTON; - handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_TOUCH, window); - } - } else if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) { - move = false; - mouse_pressed &= ~SCREEN_LEFT_MOUSE_BUTTON; - handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_RELEASE, window); - } - - // Handle right mouse. - if (buttons & SCREEN_RIGHT_MOUSE_BUTTON) { - if ((mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) == 0) { - move = false; - mouse_pressed |= SCREEN_RIGHT_MOUSE_BUTTON; - INVOKE_WCB(*window, Mouse, (GLUT_RIGHT_BUTTON, GLUT_DOWN, position[0], position[1])); - } - } else if (mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) { - move = false; - mouse_pressed &= ~SCREEN_RIGHT_MOUSE_BUTTON; - INVOKE_WCB(*window, Mouse, (GLUT_RIGHT_BUTTON, GLUT_UP, position[0], position[1])); - } - - // Handle middle mouse. - if (buttons & SCREEN_MIDDLE_MOUSE_BUTTON) { - if ((mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) == 0) { - move = false; - mouse_pressed |= SCREEN_MIDDLE_MOUSE_BUTTON; - INVOKE_WCB(*window, Mouse, (GLUT_MIDDLE_BUTTON, GLUT_DOWN, position[0], position[1])); - } - } else if (mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) { - move = false; - mouse_pressed &= ~SCREEN_MIDDLE_MOUSE_BUTTON; - INVOKE_WCB(*window, Mouse, (GLUT_MIDDLE_BUTTON, GLUT_UP, position[0], position[1])); - } - - // Fire a move event if none of the buttons changed. - if (left_move || move) { - handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_MOVE, window); - } - - if (wheel) { - fgState.MouseWheelTicks -= wheel; - //TODO: Implement wheel support (based on fg_main_mswin... though it seems excessive) - } - break; - } - - //Based off fg_main_android - case SCREEN_EVENT_KEYBOARD: - { - int flags; - int value; - screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_FLAGS, &flags); - screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_SYM, &value); - LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_KEYBOARD. Flags: 0x%X, Sym: 0x%X", SLOG2_FA_SIGNED(flags), SLOG2_FA_SIGNED(value)); - // Suppress key repeats if desired - if ((flags & KEY_REPEAT) == 0 || (fgState.KeyRepeat == GLUT_KEY_REPEAT_ON && !fgStructure.CurrentWindow->State.IgnoreKeyRepeat)) { - unsigned int keypress = 0; - unsigned char ascii = 0; - if ((keypress = key_special(value))) { - if(flags & KEY_DOWN) { - INVOKE_WCB(*window, Special, (keypress, window->State.MouseX, window->State.MouseY)); - } else { - INVOKE_WCB(*window, SpecialUp, (keypress, window->State.MouseX, window->State.MouseY)); - } - } else if((flags & KEY_SYM_VALID) && (ascii = key_ascii(value))) { - if(flags & KEY_DOWN) { - INVOKE_WCB(*window, Keyboard, (ascii, window->State.MouseX, window->State.MouseY)); - } else { - INVOKE_WCB(*window, KeyboardUp, (ascii, window->State.MouseX, window->State.MouseY)); - } - } - } - break; - } - - case SCREEN_EVENT_PROPERTY: - case SCREEN_EVENT_IDLE: - break; - - default: - LOGW("fgPlatformProcessSingleEvent: unknown screen event: 0x%X", SLOG2_FA_SIGNED(eventType)); - break; - } - } else if (domain == navigator_get_domain()) { - int eventType = bps_event_get_code(event); - switch (eventType) { - - case NAVIGATOR_WINDOW_STATE: - { - LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE"); - navigator_window_state_t state = navigator_event_get_window_state(event); - switch (state) - { - case NAVIGATOR_WINDOW_FULLSCREEN: - LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_FULLSCREEN"); - INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_RESUME)); - break; - case NAVIGATOR_WINDOW_THUMBNAIL: - case NAVIGATOR_WINDOW_INVISIBLE: - LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_THUMBNAIL/NAVIGATOR_WINDOW_INVISIBLE"); - INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_PAUSE)); - break; - default: - LOGW("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE unknown: 0x%X", SLOG2_FA_SIGNED(state)); - break; - } - break; - } - - case NAVIGATOR_EXIT: - LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_EXIT"); - /* User closed the application for good, let's kill the window */ - { - SFG_Window* window = fgStructure.CurrentWindow; - if (window != NULL) { - fgDestroyWindow(window); - } else { - LOGW("NAVIGATOR_EXIT: No current window"); - } - } - break; - - case NAVIGATOR_SWIPE_DOWN: - case NAVIGATOR_BACK: - case NAVIGATOR_WINDOW_ACTIVE: - case NAVIGATOR_DEVICE_LOCK_STATE: - case NAVIGATOR_WINDOW_COVER: - case NAVIGATOR_WINDOW_COVER_ENTER: - case NAVIGATOR_WINDOW_COVER_EXIT: - //XXX Should probably do something with these - break; - - default: - LOGW("fgPlatformProcessSingleEvent: unknown navigator event: 0x%X", SLOG2_FA_SIGNED(eventType)); - break; - } - } - } - } while(bps_get_event(eventPtr, 1) == BPS_SUCCESS && *eventPtr != NULL); - - /* Reset event to reduce chances of triggering something */ - *eventPtr = NULL; + int domain; + bps_event_t** eventPtr = &fgStructure.CurrentWindow->Window.pContext.event; //XXX Is there a more direct way to access the context? + bps_event_t* event; + do + { + if(*eventPtr != NULL) { + SFG_Window* window = fgStructure.CurrentWindow; + if (window != NULL && window->Window.Handle != NULL) { + int size[2]; + screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size); + fghOnReshapeNotify(window,size[0],size[1],GL_FALSE); + } + + event = *eventPtr; + domain = bps_event_get_domain(event); + if (domain == screen_get_domain()) { + int eventType; + screen_event_t screenEvent = screen_event_get_event(event); + screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_TYPE, &eventType); + switch (eventType) { + + //Mostly from fg_main_android + case SCREEN_EVENT_MTOUCH_TOUCH: + case SCREEN_EVENT_MTOUCH_RELEASE: + case SCREEN_EVENT_MTOUCH_MOVE: + { + mtouch_event_t touchEvent; + screen_get_mtouch_event(screenEvent, &touchEvent, 0); + LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_MTOUCH_*: Type: 0x%X, X: %d, Y: %d, Contact Id: %d", SLOG2_FA_SIGNED(eventType), SLOG2_FA_SIGNED(touchEvent.x), SLOG2_FA_SIGNED(touchEvent.y), SLOG2_FA_SIGNED(touchEvent.contact_id)); + if(touchEvent.contact_id == 0) { + int size[2]; + screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size); + handle_left_mouse(touchEvent.x, touchEvent.y, size[1], eventType, window); + } + + //Now handle mutlitouch (adapted from fg_main_windows) + if (eventType == SCREEN_EVENT_MTOUCH_TOUCH) { + INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_ENTERED ) ); + INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_DOWN ) ); + } else if (eventType == SCREEN_EVENT_MTOUCH_MOVE) { + INVOKE_WCB( *window, MultiMotion, ( touchEvent.contact_id, touchEvent.x, touchEvent.y ) ); + //XXX No motion is performed without contact, thus MultiPassive is never used + } else if (eventType == SCREEN_EVENT_MTOUCH_RELEASE) { + INVOKE_WCB( *window, MultiButton, ( touchEvent.contact_id, touchEvent.x, touchEvent.y, 0, GLUT_UP ) ); + INVOKE_WCB( *window, MultiEntry, ( touchEvent.contact_id, GLUT_LEFT ) ); + } + break; + } + + case SCREEN_EVENT_POINTER: + { + //Based off/part taken from GamePlay3d PlatformBlackBerry + static int mouse_pressed = 0; + int buttons; + int position[2]; + int wheel; + // A move event will be fired unless a button state changed. + bool move = true; + bool left_move = false; + // This is a mouse move event, it is applicable to a device with a usb mouse or simulator. + screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_BUTTONS, &buttons); + screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_SOURCE_POSITION, position); + screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_MOUSE_WHEEL, &wheel); + int size[2]; + screen_get_window_property_iv(window->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size); + + LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_POINTER: Buttons: 0x%X, X: %d, Y: %d, Wheel: %d", SLOG2_FA_SIGNED(buttons), SLOG2_FA_SIGNED(position[0]), SLOG2_FA_SIGNED(position[1]), SLOG2_FA_SIGNED(wheel)); + + //XXX Should multitouch be handled? + + // Handle left mouse. Interpret as touch if the left mouse event is not consumed. + if (buttons & SCREEN_LEFT_MOUSE_BUTTON) { + if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) { + left_move = true; + } else { + move = false; + mouse_pressed |= SCREEN_LEFT_MOUSE_BUTTON; + handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_TOUCH, window); + } + } else if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON) { + move = false; + mouse_pressed &= ~SCREEN_LEFT_MOUSE_BUTTON; + handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_RELEASE, window); + } + + // Handle right mouse. + if (buttons & SCREEN_RIGHT_MOUSE_BUTTON) { + if ((mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) == 0) { + move = false; + mouse_pressed |= SCREEN_RIGHT_MOUSE_BUTTON; + INVOKE_WCB(*window, Mouse, (GLUT_RIGHT_BUTTON, GLUT_DOWN, position[0], position[1])); + } + } else if (mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) { + move = false; + mouse_pressed &= ~SCREEN_RIGHT_MOUSE_BUTTON; + INVOKE_WCB(*window, Mouse, (GLUT_RIGHT_BUTTON, GLUT_UP, position[0], position[1])); + } + + // Handle middle mouse. + if (buttons & SCREEN_MIDDLE_MOUSE_BUTTON) { + if ((mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) == 0) { + move = false; + mouse_pressed |= SCREEN_MIDDLE_MOUSE_BUTTON; + INVOKE_WCB(*window, Mouse, (GLUT_MIDDLE_BUTTON, GLUT_DOWN, position[0], position[1])); + } + } else if (mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) { + move = false; + mouse_pressed &= ~SCREEN_MIDDLE_MOUSE_BUTTON; + INVOKE_WCB(*window, Mouse, (GLUT_MIDDLE_BUTTON, GLUT_UP, position[0], position[1])); + } + + // Fire a move event if none of the buttons changed. + if (left_move || move) { + handle_left_mouse(position[0], position[1], size[1], SCREEN_EVENT_MTOUCH_MOVE, window); + } + + if (wheel) { + fgState.MouseWheelTicks -= wheel; + //TODO: Implement wheel support (based on fg_main_mswin... though it seems excessive) + } + break; + } + + //Based off fg_main_android + case SCREEN_EVENT_KEYBOARD: + { + int flags; + int value; + screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_FLAGS, &flags); + screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_KEY_SYM, &value); + LOGI("fgPlatformProcessSingleEvent: SCREEN_EVENT_KEYBOARD. Flags: 0x%X, Sym: 0x%X", SLOG2_FA_SIGNED(flags), SLOG2_FA_SIGNED(value)); + // Suppress key repeats if desired + if ((flags & KEY_REPEAT) == 0 || (fgState.KeyRepeat == GLUT_KEY_REPEAT_ON && !fgStructure.CurrentWindow->State.IgnoreKeyRepeat)) { + unsigned int keypress = 0; + unsigned char ascii = 0; + if ((keypress = key_special(value))) { + if(flags & KEY_DOWN) { + INVOKE_WCB(*window, Special, (keypress, window->State.MouseX, window->State.MouseY)); + } else { + INVOKE_WCB(*window, SpecialUp, (keypress, window->State.MouseX, window->State.MouseY)); + } + } else if((flags & KEY_SYM_VALID) && (ascii = key_ascii(value))) { + if(flags & KEY_DOWN) { + INVOKE_WCB(*window, Keyboard, (ascii, window->State.MouseX, window->State.MouseY)); + } else { + INVOKE_WCB(*window, KeyboardUp, (ascii, window->State.MouseX, window->State.MouseY)); + } + } + } + break; + } + + case SCREEN_EVENT_PROPERTY: + case SCREEN_EVENT_IDLE: + break; + + default: + LOGW("fgPlatformProcessSingleEvent: unknown screen event: 0x%X", SLOG2_FA_SIGNED(eventType)); + break; + } + } else if (domain == navigator_get_domain()) { + int eventType = bps_event_get_code(event); + switch (eventType) { + + case NAVIGATOR_WINDOW_STATE: + { + LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE"); + navigator_window_state_t state = navigator_event_get_window_state(event); + switch (state) + { + case NAVIGATOR_WINDOW_FULLSCREEN: + LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_FULLSCREEN"); + INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_RESUME)); + break; + case NAVIGATOR_WINDOW_THUMBNAIL: + case NAVIGATOR_WINDOW_INVISIBLE: + LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE-NAVIGATOR_WINDOW_THUMBNAIL/NAVIGATOR_WINDOW_INVISIBLE"); + INVOKE_WCB(*window, AppStatus, (GLUT_APPSTATUS_PAUSE)); + break; + default: + LOGW("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE unknown: 0x%X", SLOG2_FA_SIGNED(state)); + break; + } + break; + } + + case NAVIGATOR_EXIT: + { + LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_EXIT"); + /* User closed the application for good, let's kill the window */ + SFG_Window* window = fgStructure.CurrentWindow; + if (window != NULL) { + fgDestroyWindow(window); + } else { + LOGW("NAVIGATOR_EXIT: No current window"); + } + break; + } + + case NAVIGATOR_SWIPE_DOWN: + case NAVIGATOR_BACK: + case NAVIGATOR_WINDOW_ACTIVE: + case NAVIGATOR_DEVICE_LOCK_STATE: + case NAVIGATOR_WINDOW_COVER: + case NAVIGATOR_WINDOW_COVER_ENTER: + case NAVIGATOR_WINDOW_COVER_EXIT: + //XXX Should probably do something with these + break; + + default: + LOGW("fgPlatformProcessSingleEvent: unknown navigator event: 0x%X", SLOG2_FA_SIGNED(eventType)); + break; + } + } + } + } while(bps_get_event(eventPtr, 1) == BPS_SUCCESS && *eventPtr != NULL); + + /* Reset event to reduce chances of triggering something */ + *eventPtr = NULL; } void fgPlatformMainLoopPreliminaryWork ( void ) { - LOGI("fgPlatformMainLoopPreliminaryWork"); + LOGI("fgPlatformMainLoopPreliminaryWork"); } diff --git a/src/blackberry/fg_state_blackberry.c b/src/blackberry/fg_state_blackberry.c index a6955e2..27f4968 100644 --- a/src/blackberry/fg_state_blackberry.c +++ b/src/blackberry/fg_state_blackberry.c @@ -62,38 +62,39 @@ int fgPlatformGlutDeviceGet ( GLenum eWhat ) int fgPlatformGlutGet ( GLenum eWhat ) { - switch (eWhat) { - /* One full-screen window only */ - case GLUT_WINDOW_X: - case GLUT_WINDOW_Y: - case GLUT_WINDOW_BORDER_WIDTH: - case GLUT_WINDOW_HEADER_HEIGHT: - return 0; + switch (eWhat) { + /* One full-screen window only */ + case GLUT_WINDOW_X: + case GLUT_WINDOW_Y: + case GLUT_WINDOW_BORDER_WIDTH: + case GLUT_WINDOW_HEADER_HEIGHT: + return 0; - case GLUT_WINDOW_WIDTH: - case GLUT_WINDOW_HEIGHT: + case GLUT_WINDOW_WIDTH: + case GLUT_WINDOW_HEIGHT: { - if ( fgStructure.CurrentWindow == NULL ) - return 0; - int size[2]; - if ( screen_get_window_property_iv(fgStructure.CurrentWindow->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0 ) - return 0; - switch ( eWhat ) - { - case GLUT_WINDOW_WIDTH: - return size[0]; - case GLUT_WINDOW_HEIGHT: - return size[1]; - } + if ( fgStructure.CurrentWindow == NULL ) + return 0; + int size[2]; + if ( screen_get_window_property_iv(fgStructure.CurrentWindow->Window.Handle, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0 ) + return 0; + switch ( eWhat ) + { + case GLUT_WINDOW_WIDTH: + return size[0]; + case GLUT_WINDOW_HEIGHT: + return size[1]; + } + break; } - case GLUT_WINDOW_COLORMAP_SIZE: - /* 0 for RGBA/non-indexed mode */ - /* Under BlackBerry and GLES more generally, no indexed-mode */ - return 0; + case GLUT_WINDOW_COLORMAP_SIZE: + /* 0 for RGBA/non-indexed mode */ + /* Under BlackBerry and GLES more generally, no indexed-mode */ + return 0; - default: - return fghPlatformGlutGetEGL(eWhat); - } - return -1; + default: + return fghPlatformGlutGetEGL(eWhat); + } + return -1; } diff --git a/src/blackberry/fg_window_blackberry.c b/src/blackberry/fg_window_blackberry.c index 8c1a121..d435dfb 100644 --- a/src/blackberry/fg_window_blackberry.c +++ b/src/blackberry/fg_window_blackberry.c @@ -43,84 +43,84 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, 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; - } - window->Window.pContext.event = NULL; //XXX Should probably be done elsewhere. Done here so there is no event at the moment - - /* 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; //XXX Should this be determined by config? + /* 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; + } + window->Window.pContext.event = NULL; //XXX Should probably be done elsewhere. Done here so there is no event at the moment + + /* 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; //XXX Should this be determined by config? #ifdef GL_ES_VERSION_2_0 - int screenUsage = SCREEN_USAGE_OPENGL_ES2; + int screenUsage = SCREEN_USAGE_OPENGL_ES2; #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; + int screenUsage = SCREEN_USAGE_OPENGL_ES1; #endif #ifndef __X86__ - screenUsage |= SCREEN_USAGE_DISPLAY; // Physical device copy directly into physical display + screenUsage |= SCREEN_USAGE_DISPLAY; // 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, (fgState.DisplayMode & GLUT_DOUBLE) ? 2 : 1)) { - 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 and set state */ - window->Window.Handle = fgDisplay.pDisplay.single_native_window; - window->State.WorkMask |= GLUT_INIT_WORK; - window->State.IsFullscreen = GL_TRUE; //XXX Always fullscreen for now - - /* Create context */ - fghChooseConfig(&window->Window.pContext.egl.Config); - window->Window.Context = fghCreateNewContextEGL(window); - - /* Create EGL window */ - fghPlatformOpenWindowEGL(window); - - window->State.Visible = GL_TRUE; + 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, (fgState.DisplayMode & GLUT_DOUBLE) ? 2 : 1)) { + 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 and set state */ + window->Window.Handle = fgDisplay.pDisplay.single_native_window; + window->State.WorkMask |= GLUT_INIT_WORK; + window->State.IsFullscreen = GL_TRUE; //XXX Always fullscreen for now + + /* Create context */ + fghChooseConfig(&window->Window.pContext.egl.Config); + window->Window.Context = fghCreateNewContextEGL(window); + + /* Create EGL window */ + fghPlatformOpenWindowEGL(window); + + window->State.Visible = GL_TRUE; } /* @@ -128,7 +128,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, */ void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ) { - fprintf(stderr, "fgPlatformReshapeWindow: STUB\n"); + fprintf(stderr, "fgPlatformReshapeWindow: STUB\n"); } /* @@ -136,13 +136,13 @@ void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ) */ void fgPlatformCloseWindow( SFG_Window* window ) { - fghPlatformCloseWindowEGL(window); + fghPlatformCloseWindowEGL(window); - screen_stop_events(window->Window.pContext.screenContext); + screen_stop_events(window->Window.pContext.screenContext); - screen_destroy_window((screen_window_t)window->Window.Handle); + screen_destroy_window((screen_window_t)window->Window.Handle); - screen_destroy_context(window->Window.pContext.screenContext); + screen_destroy_context(window->Window.pContext.screenContext); } /* @@ -150,7 +150,7 @@ void fgPlatformCloseWindow( SFG_Window* window ) */ void fgPlatformShowWindow( void ) { - fprintf(stderr, "fgPlatformShowWindow: STUB\n"); + fprintf(stderr, "fgPlatformShowWindow: STUB\n"); } /* @@ -158,7 +158,7 @@ void fgPlatformShowWindow( void ) */ void fgPlatformHideWindow( SFG_Window *window ) { - fprintf(stderr, "fgPlatformHideWindow: STUB\n"); + fprintf(stderr, "fgPlatformHideWindow: STUB\n"); } /* @@ -166,7 +166,8 @@ void fgPlatformHideWindow( SFG_Window *window ) */ void fgPlatformIconifyWindow( SFG_Window *window ) { - fprintf(stderr, "fgPlatformGlutIconifyWindow: STUB\n"); + //XXX This is possible via Cascades, but can't seem to find a C-level API + fprintf(stderr, "fgPlatformGlutIconifyWindow: STUB\n"); } /* @@ -174,7 +175,7 @@ void fgPlatformIconifyWindow( SFG_Window *window ) */ void fgPlatformGlutSetWindowTitle( const char* title ) { - fprintf(stderr, "fgPlatformGlutSetWindowTitle: STUB\n"); + fprintf(stderr, "fgPlatformGlutSetWindowTitle: STUB\n"); } /* @@ -182,14 +183,15 @@ void fgPlatformGlutSetWindowTitle( const char* title ) */ void fgPlatformGlutSetIconTitle( const char* title ) { - fprintf(stderr, "fgPlatformGlutSetIconTitle: STUB\n");} + 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"); + fprintf(stderr, "fgPlatformPositionWindow: STUB\n"); } /* @@ -197,7 +199,7 @@ void fgPlatformPositionWindow( SFG_Window *window, int x, int y ) */ void fgPlatformPushWindow( SFG_Window *window ) { - fprintf(stderr, "fgPlatformPushWindow: STUB\n"); + fprintf(stderr, "fgPlatformPushWindow: STUB\n"); } /* @@ -205,7 +207,7 @@ void fgPlatformPushWindow( SFG_Window *window ) */ void fgPlatformPopWindow( SFG_Window *window ) { - fprintf(stderr, "fgPlatformPopWindow: STUB\n"); + fprintf(stderr, "fgPlatformPopWindow: STUB\n"); } /* @@ -213,5 +215,5 @@ void fgPlatformPopWindow( SFG_Window *window ) */ void fgPlatformFullScreenToggle( SFG_Window *win ) { - fprintf(stderr, "fgPlatformFullScreenToggle: STUB\n"); + fprintf(stderr, "fgPlatformFullScreenToggle: STUB\n"); } -- 1.7.10.4