From e8a7a152c9635b312550dca649f0cda3a1aa098f Mon Sep 17 00:00:00 2001 From: Rcmaniac25 Date: Fri, 24 Jan 2014 10:24:45 +0000 Subject: [PATCH] Android and BlackBerry have a fair amount of overlap, for now. git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1645 7f0cb862-5218-0410-a997-914c9d46530a --- CMakeLists.txt | 46 ++++++++++------ src/blackberry/fg_state_blackberry.c | 99 ++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 17 deletions(-) create mode 100644 src/blackberry/fg_state_blackberry.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bc9b2b..a8cb8b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,30 +118,39 @@ IF(WIN32) ) ENDIF() -ELSEIF(ANDROID) +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_internal_android.h 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_main_android.c - src/android/fg_main_android.h - src/android/fg_runtime_android.c src/android/fg_spaceball_android.c - src/android/fg_state_android.c src/android/fg_structure_android.c - src/android/fg_window_android.c - ) -ELSEIF(BLACKBERRY) - LIST(APPEND FREEGLUT_SRCS - src/blackberry/fg_internal_blackberry.h - src/blackberry/fg_main_blackberry.h ) + IF(ANDROID) + 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_internal_android.h + src/android/fg_main_android.c + src/android/fg_main_android.h + src/android/fg_runtime_android.c + src/android/fg_state_android.c + src/android/fg_window_android.c + ) + ELSE() + LIST(APPEND FREEGLUT_SRCS + # TODO: Anything similar to Android's app_glue? + 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 + ) + ENDIF() ELSE() LIST(APPEND FREEGLUT_SRCS src/x11/fg_cursor_x11.c @@ -257,7 +266,10 @@ IF(ANDROID) # -llog for native Android logging LIST(APPEND LIBS android log) ELSEIF(BLACKBERRY) - LIST(APPEND LIBS bps slog2) + # -lbps for event loop + # -lslog2 for logging + # -screen for native screen + LIST(APPEND LIBS bps slog2 screen) ENDIF() INCLUDE(CheckFunctionExists) @@ -472,7 +484,7 @@ ELSEIF(FREEGLUT_GLES2) IF(ANDROID) SET(PC_LIBS_PRIVATE "-llog -landroid -lGLESv2 -lEGL -lm") ELSEIF(BLACKBERRY) - SET(PC_LIBS_PRIVATE "-lbps -lslog2 -lGLESv2 -lEGL -lm") + SET(PC_LIBS_PRIVATE "-lbps -lslog2 -lscreen -lGLESv2 -lEGL -lm") ELSE() SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lEGL -lm") ENDIF() @@ -480,7 +492,7 @@ ELSEIF(FREEGLUT_GLES1) IF(ANDROID) SET(PC_LIBS_PRIVATE "-llog -landroid -lGLESv1_CM -lEGL -lm") ELSEIF(BLACKBERRY) - SET(PC_LIBS_PRIVATE "-lbps -lslog2 -lGLESv1_CM -lEGL -lm") + SET(PC_LIBS_PRIVATE "-lbps -lslog2 -lscreen -lGLESv1_CM -lEGL -lm") ELSE() SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv1_CM -lEGL -lm") ENDIF() diff --git a/src/blackberry/fg_state_blackberry.c b/src/blackberry/fg_state_blackberry.c new file mode 100644 index 0000000..600a826 --- /dev/null +++ b/src/blackberry/fg_state_blackberry.c @@ -0,0 +1,99 @@ +/* + * fg_state_blackberry.c + * + * BlackBerry-specific freeglut state query methods. + * + * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved. + * Written by John F. Fay, + * 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 +#include +#include "fg_internal.h" +#include "egl/fg_state_egl.h" + +//From fg_state_android.c +int fgPlatformGlutDeviceGet ( GLenum eWhat ) +{ + switch( eWhat ) + { + case GLUT_HAS_KEYBOARD: + /* BlackBerry has a keyboard, though it may be virtual. */ + return 1; + + case GLUT_HAS_MOUSE: + /* BlackBerry has a touchscreen; until we get proper touchscreen + support, consider it as a mouse. */ + return 1 ; + + case GLUT_NUM_MOUSE_BUTTONS: + /* BlackBerry has a touchscreen; until we get proper touchscreen + support, consider it as a 1-button mouse. */ + return 1; + + default: + fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat ); + break; + } + + /* And now -- the failure. */ + return -1; +} + +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; + + 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_SIZE, size) != 0 ) + return 0; + switch ( eWhat ) + { + case GLUT_WINDOW_WIDTH: + return size[0]; + case GLUT_WINDOW_HEIGHT: + return size[1]; + } + } + + 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; +} -- 1.7.10.4