Updated BlackBerry references to make note of the change from FREEGLUT_GLES2/1 to FREEGLUT_GLES.

Updated BlackBerry toolchain to support building with Dinkum and to support OS 10.3 and GCC 4.8.2
Updated BlackBerry fg_window_blackberry so that window usages aren't hardcoded based on compile information, since it is now controlled by glutInitContextVersion.
EGL window setup now supports EGL 1.5, Renderable type for ES3, and using the minor version from glutInitContextVersion to have more exact control over which version of OpenGL ES is used (requires EGL 1.5)
This commit is contained in:
Rcmaniac25 2014-06-09 22:39:03 -04:00
parent d11c062c72
commit 2dab5a32a6
6 changed files with 94 additions and 33 deletions

View File

@ -6,7 +6,7 @@
# $ source /absolute/path/to/the/bbndk/bbndk-env.sh # $ source /absolute/path/to/the/bbndk/bbndk-env.sh
# $ mkdir build # $ mkdir build
# $ cd build # $ cd build
# $ cmake .. -DCMAKE_TOOLCHAIN_FILE="../blackberry.toolchain.cmake" -DBLACKBERRY_ARCHITECTURE=arm -DFREEGLUT_GLES2=ON -DFREEGLUT_BUILD_DEMOS=NO -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles" # $ cmake .. -DCMAKE_TOOLCHAIN_FILE="../blackberry.toolchain.cmake" -DBLACKBERRY_ARCHITECTURE=arm -DFREEGLUT_GLES=ON -DFREEGLUT_BUILD_DEMOS=NO -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles"
# $ make -j8 # $ make -j8
# #
# Usage Mac: # Usage Mac:
@ -16,6 +16,8 @@
# > /absolute/path/to/the/bbndk/bbndk-env.bat # > /absolute/path/to/the/bbndk/bbndk-env.bat
# > mkdir build # > mkdir build
# > cd build # > cd build
# > cmake .. -DCMAKE_TOOLCHAIN_FILE="../blackberry.toolchain.cmake" -DBLACKBERRY_ARCHITECTURE=arm -DFREEGLUT_GLES2=ON -DFREEGLUT_BUILD_DEMOS=NO -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles" # > cmake .. -DCMAKE_TOOLCHAIN_FILE="../blackberry.toolchain.cmake" -DBLACKBERRY_ARCHITECTURE=arm -DFREEGLUT_GLES=ON -DFREEGLUT_BUILD_DEMOS=NO -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles"
# > make -j8 # > make -j8
# #
To change which version of OpenGL to use, call glutInitContextVersion(1, 0) for OpenGL ES 1.x, glutInitContextVersion(2, 0) for OpenGL ES 2.0, or glutInitContextVersion(3, 0) for OpenGL ES 3.0.

View File

@ -6,7 +6,7 @@
# $ source /absolute/path/to/the/bbndk/bbndk-env.sh # $ source /absolute/path/to/the/bbndk/bbndk-env.sh
# $ mkdir build # $ mkdir build
# $ cd build # $ cd build
# $ cmake .. -DCMAKE_TOOLCHAIN_FILE="../blackberry.toolchain.cmake" -DBLACKBERRY_ARCHITECTURE=arm -DFREEGLUT_GLES2=ON -DFREEGLUT_BUILD_DEMOS=NO -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles" # $ cmake .. -DCMAKE_TOOLCHAIN_FILE="../blackberry.toolchain.cmake" -DBLACKBERRY_ARCHITECTURE=arm -DFREEGLUT_GLES=ON -DFREEGLUT_BUILD_DEMOS=NO -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles"
# $ make -j8 # $ make -j8
# #
# Usage Mac: # Usage Mac:
@ -16,7 +16,7 @@
# > /absolute/path/to/the/bbndk/bbndk-env.bat # > /absolute/path/to/the/bbndk/bbndk-env.bat
# > mkdir build # > mkdir build
# > cd build # > cd build
# > cmake .. -DCMAKE_TOOLCHAIN_FILE="../blackberry.toolchain.cmake" -DBLACKBERRY_ARCHITECTURE=arm -DFREEGLUT_GLES2=ON -DFREEGLUT_BUILD_DEMOS=NO -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles" # > cmake .. -DCMAKE_TOOLCHAIN_FILE="../blackberry.toolchain.cmake" -DBLACKBERRY_ARCHITECTURE=arm -DFREEGLUT_GLES=ON -DFREEGLUT_BUILD_DEMOS=NO -DCMAKE_VERBOSE_MAKEFILE=TRUE -G "Eclipse CDT4 - Unix Makefiles"
# > make -j8 # > make -j8
# #
@ -37,6 +37,11 @@ if( EXISTS "${BLACKBERRY_TARGET_ROOT}/x86/lib/gcc/4.4.2" )
set( PLAYBOOK True ) set( PLAYBOOK True )
endif() endif()
# Check for for GCC 4.8.2
if( EXISTS "${BLACKBERRY_TARGET_ROOT}/x86/lib/gcc/4.8.2" )
set( BB_GCC_482 True )
endif()
# STL version: by default gnustl_static will be used # STL version: by default gnustl_static will be used
set( BLACKBERRY_USE_STLPORT FALSE CACHE BOOL "Experimental: use stlport_static instead of gnustl_static") set( BLACKBERRY_USE_STLPORT FALSE CACHE BOOL "Experimental: use stlport_static instead of gnustl_static")
mark_as_advanced( BLACKBERRY_USE_STLPORT ) mark_as_advanced( BLACKBERRY_USE_STLPORT )
@ -103,28 +108,52 @@ else()
endif() endif()
# Flags and preprocessor definitions # Flags and preprocessor definitions
set( BB_USING_GCC_482 False )
if( PLAYBOOK )
set( BLACKBERRY_COMP_DEF "-D__PLAYBOOK__" )
set( BLACKBERRY_COMP_VERSION "4.4.2" )
else()
set( BLACKBERRY_COMP_DEF "-D__QNX__" )
if( BB_GCC_482 AND BLACKBERRY_USE_GCC_4_8 )
set( BLACKBERRY_COMP_VERSION "4.8.2" )
set( BB_USING_GCC_482 True )
else()
set( BLACKBERRY_COMP_VERSION "4.6.3" )
endif()
endif()
if( BLACKBERRY_ARCHITECTURE STREQUAL "arm" ) if( BLACKBERRY_ARCHITECTURE STREQUAL "arm" )
if( PLAYBOOK ) set( BLACKBERRY_COMP_TARGET "gcc_ntoarmv7le" )
set( BLACKBERRY_CC_FLAGS " -V4.4.2,gcc_ntoarmv7le -D__PLAYBOOK__" )
set( BLACKBERRY_CXX_FLAGS " -V4.4.2,gcc_ntoarmv7le -Y_gpp -D__PLAYBOOK__" )
else() else()
set( BLACKBERRY_CC_FLAGS " -V4.6.3,gcc_ntoarmv7le -D__QNX__" ) set( BLACKBERRY_COMP_TARGET "gcc_ntox86" )
set( BLACKBERRY_CXX_FLAGS " -V4.6.3,gcc_ntoarmv7le -Y_gpp -D__QNX__" ) endif()
set( BLACKBERRY_CXX_COMP_LIB "" )
if( BLACKBERRY_DINKUM )
set( DINKUM 1 )
if( BB_USING_GCC_482 )
set( BLACKBERRY_COMP_TARGET "${BLACKBERRY_COMP_TARGET}_cpp" )
else()
set( BLACKBERRY_CXX_COMP_LIB "-Y_cpp" )
endif() endif()
else() else()
if( PLAYBOOK ) set( DINKUM 0 )
set( BLACKBERRY_CC_FLAGS " -V4.4.2,gcc_ntox86 -D__PLAYBOOK__" ) if( BB_USING_GCC_482 )
set( BLACKBERRY_CXX_FLAGS " -V4.4.2,gcc_ntox86 -Y_gpp -D__PLAYBOOK__" ) set( BLACKBERRY_COMP_TARGET "${BLACKBERRY_COMP_TARGET}_gpp" )
else() else()
set( BLACKBERRY_CC_FLAGS " -V4.6.3,gcc_ntox86 -D__QNX__" ) set( BLACKBERRY_CXX_COMP_LIB "-Y_gpp" )
set( BLACKBERRY_CXX_FLAGS " -V4.6.3,gcc_ntox86 -Y_gpp -D__QNX__" )
endif() endif()
endif() endif()
set( BLACKBERRY_CC_FLAGS " -V${BLACKBERRY_COMP_VERSION},${BLACKBERRY_COMP_TARGET} ${BLACKBERRY_COMP_DEF}" )
set( BLACKBERRY_CXX_FLAGS " -V${BLACKBERRY_COMP_VERSION},${BLACKBERRY_COMP_TARGET} ${BLACKBERRY_CXX_COMP_LIB} ${BLACKBERRY_COMP_DEF}" )
set( BLACKBERRY 1 ) set( BLACKBERRY 1 )
# NDK flags # NDK flags
if( DINKUM )
set( CMAKE_CXX_FLAGS "${BLACKBERRY_CXX_FLAGS} -DBLACKBERRY_DINKUM=1" )
set( CMAKE_C_FLAGS "${BLACKBERRY_CC_FLAGS} -DBLACKBERRY_DINKUM=1" )
else()
set( CMAKE_CXX_FLAGS "${BLACKBERRY_CXX_FLAGS}" ) set( CMAKE_CXX_FLAGS "${BLACKBERRY_CXX_FLAGS}" )
set( CMAKE_C_FLAGS "${BLACKBERRY_CC_FLAGS}" ) set( CMAKE_C_FLAGS "${BLACKBERRY_CC_FLAGS}" )
endif()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" ) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )

View File

@ -69,11 +69,17 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
/* Set window properties */ /* Set window properties */
int orientation = atoi(getenv("ORIENTATION")); int orientation = atoi(getenv("ORIENTATION"));
#ifdef GL_ES_VERSION_2_0 int screenUsage = SCREEN_USAGE_ROTATION;
int screenUsage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION; #ifdef SCREEN_USAGE_OPENGL_ES3
#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 if (fgState.MajorVersion >= 3) {
int screenUsage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION; screenUsage |= SCREEN_USAGE_OPENGL_ES3;
} else
#endif #endif
if (fgState.MajorVersion >= 2) {
screenUsage |= SCREEN_USAGE_OPENGL_ES2;
} else {
screenUsage |= SCREEN_USAGE_OPENGL_ES1;
}
#if !defined(__X86__) && !defined(__PLAYBOOK__) #if !defined(__X86__) && !defined(__PLAYBOOK__)
screenUsage |= SCREEN_USAGE_DISPLAY; // Physical device copy directly into physical display screenUsage |= SCREEN_USAGE_DISPLAY; // Physical device copy directly into physical display
#endif #endif

View File

@ -39,7 +39,7 @@ void fghPlatformInitializeEGL()
FREEGLUT_INTERNAL_ERROR_EXIT(fgDisplay.pDisplay.egl.Display != EGL_NO_DISPLAY, FREEGLUT_INTERNAL_ERROR_EXIT(fgDisplay.pDisplay.egl.Display != EGL_NO_DISPLAY,
"No display available", "fgPlatformInitialize"); "No display available", "fgPlatformInitialize");
if (eglInitialize(fgDisplay.pDisplay.egl.Display, NULL, NULL) != EGL_TRUE) if (eglInitialize(fgDisplay.pDisplay.egl.Display, &fgDisplay.pDisplay.egl.MajorVersion, &fgDisplay.pDisplay.egl.MinorVersion) != EGL_TRUE)
fgError("eglInitialize: error %x\n", eglGetError()); fgError("eglInitialize: error %x\n", eglGetError());
# ifdef GL_VERSION_1_1 /* or later */ # ifdef GL_VERSION_1_1 /* or later */
@ -59,6 +59,8 @@ void fghPlatformCloseDisplayEGL()
if (fgDisplay.pDisplay.egl.Display != EGL_NO_DISPLAY) { if (fgDisplay.pDisplay.egl.Display != EGL_NO_DISPLAY) {
eglTerminate(fgDisplay.pDisplay.egl.Display); eglTerminate(fgDisplay.pDisplay.egl.Display);
fgDisplay.pDisplay.egl.Display = EGL_NO_DISPLAY; fgDisplay.pDisplay.egl.Display = EGL_NO_DISPLAY;
fgDisplay.pDisplay.egl.MajorVersion = 0;
fgDisplay.pDisplay.egl.MinorVersion = 0;
} }
} }

View File

@ -35,6 +35,8 @@ struct tagSFG_PlatformDisplayEGL
{ {
/* Used to initialize and deinitialize EGL */ /* Used to initialize and deinitialize EGL */
EGLDisplay Display; EGLDisplay Display;
EGLint MajorVersion;
EGLint MinorVersion;
}; };

View File

@ -30,11 +30,16 @@ int fghChooseConfig(EGLConfig* config) {
EGLint attributes[32]; EGLint attributes[32];
int where = 0; int where = 0;
ATTRIB_VAL(EGL_SURFACE_TYPE, EGL_WINDOW_BIT); ATTRIB_VAL(EGL_SURFACE_TYPE, EGL_WINDOW_BIT);
#ifdef EGL_OPENGL_ES3_BIT
if (fgDisplay.pDisplay.egl.MinorVersion >= 5 && fgState.MajorVersion >= 3) {
ATTRIB_VAL(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT);
} else
#endif
if (fgState.MajorVersion >= 2) { if (fgState.MajorVersion >= 2) {
/* /*
* Khronos does not specify a EGL_OPENGL_ES3_BIT outside of the OpenGL extension "EGL_KHR_create_context". There are numerous references on the internet that * Khronos does not specify a EGL_OPENGL_ES3_BIT outside of the OpenGL extension "EGL_KHR_create_context" and EGL 1.5. There are numerous references on the internet
* say to use EGL_OPENGL_ES3_BIT, followed by many saying they can't find it in any headers. In fact, the offical updated specification for EGL does not have * that say to use EGL_OPENGL_ES3_BIT (pre-EGL 1.5), followed by many saying they can't find it in any headers. In fact, the offical updated specification for EGL
* any references to OpenGL ES 3.0. Tests have shown that EGL_OPENGL_ES2_BIT will work with ES 3.0. * does not have any references to OpenGL ES 3.x. Tests have shown that EGL_OPENGL_ES2_BIT will work with ES 3.x.
*/ */
ATTRIB_VAL(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT); ATTRIB_VAL(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT);
} else { } else {
@ -87,6 +92,12 @@ EGLContext fghCreateNewContextEGL( SFG_Window* window ) {
EGLint attributes[32]; EGLint attributes[32];
int where = 0; int where = 0;
ATTRIB_VAL(EGL_CONTEXT_CLIENT_VERSION, fgState.MajorVersion); ATTRIB_VAL(EGL_CONTEXT_CLIENT_VERSION, fgState.MajorVersion);
#ifdef EGL_CONTEXT_MINOR_VERSION
if (fgDisplay.pDisplay.egl.MinorVersion >= 5) {
// EGL_CONTEXT_CLIENT_VERSION == EGL_CONTEXT_MAJOR_VERSION
ATTRIB_VAL(EGL_CONTEXT_MINOR_VERSION, fgState.MinorVersion);
}
#endif
ATTRIB(EGL_NONE); ATTRIB(EGL_NONE);
context = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, attributes); context = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, attributes);
@ -96,8 +107,17 @@ EGLContext fghCreateNewContextEGL( SFG_Window* window ) {
} }
eglQueryContext(fgDisplay.pDisplay.egl.Display, context, EGL_CONTEXT_CLIENT_VERSION, &ver); eglQueryContext(fgDisplay.pDisplay.egl.Display, context, EGL_CONTEXT_CLIENT_VERSION, &ver);
if (ver != fgState.MajorVersion) if (ver != fgState.MajorVersion) {
fgError("Wrong GLES major version: %d\n", ver); fgError("Wrong GLES major version: %d\n", ver);
}
#ifdef EGL_CONTEXT_MINOR_VERSION
if (fgDisplay.pDisplay.egl.MinorVersion >= 5) {
eglQueryContext(fgDisplay.pDisplay.egl.Display, context, EGL_CONTEXT_MINOR_VERSION, &ver);
if (ver != fgState.MinorVersion) {
fgError("Wrong GLES minor version: %d\n", ver);
}
}
#endif
return context; return context;
} }