# $ source /absolute/path/to/the/bbndk/bbndk-env.sh
# $ mkdir 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
#
# Usage Mac:
# > /absolute/path/to/the/bbndk/bbndk-env.bat
# > mkdir 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
-#
\ No newline at end of file
+#
+
+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.
\ No newline at end of file
# $ source /absolute/path/to/the/bbndk/bbndk-env.sh
# $ mkdir 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
#
# Usage Mac:
# > /absolute/path/to/the/bbndk/bbndk-env.bat
# > mkdir 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
#
# Check for PlayBook
if( EXISTS "${BLACKBERRY_TARGET_ROOT}/x86/lib/gcc/4.4.2" )
-set( PLAYBOOK True )
+ set( PLAYBOOK True )
+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
endif()
# 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( PLAYBOOK )
- 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()
- set( BLACKBERRY_CC_FLAGS " -V4.6.3,gcc_ntoarmv7le -D__QNX__" )
- set( BLACKBERRY_CXX_FLAGS " -V4.6.3,gcc_ntoarmv7le -Y_gpp -D__QNX__" )
- endif()
+ set( BLACKBERRY_COMP_TARGET "gcc_ntoarmv7le" )
else()
- if( PLAYBOOK )
- set( BLACKBERRY_CC_FLAGS " -V4.4.2,gcc_ntox86 -D__PLAYBOOK__" )
- set( BLACKBERRY_CXX_FLAGS " -V4.4.2,gcc_ntox86 -Y_gpp -D__PLAYBOOK__" )
- else()
- set( BLACKBERRY_CC_FLAGS " -V4.6.3,gcc_ntox86 -D__QNX__" )
- set( BLACKBERRY_CXX_FLAGS " -V4.6.3,gcc_ntox86 -Y_gpp -D__QNX__" )
- endif()
+ set( BLACKBERRY_COMP_TARGET "gcc_ntox86" )
+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()
+else()
+ set( DINKUM 0 )
+ if( BB_USING_GCC_482 )
+ set( BLACKBERRY_COMP_TARGET "${BLACKBERRY_COMP_TARGET}_gpp" )
+ else()
+ set( BLACKBERRY_CXX_COMP_LIB "-Y_gpp" )
+ 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 )
# NDK flags
-set( CMAKE_CXX_FLAGS "${BLACKBERRY_CXX_FLAGS}" )
-set( CMAKE_C_FLAGS "${BLACKBERRY_CC_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_C_FLAGS "${BLACKBERRY_CC_FLAGS}" )
+endif()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )
int screenFormat = SCREEN_FORMAT_RGBA8888; //Only SCREEN_FORMAT_RGBA8888 and SCREEN_FORMAT_RGB565 are supported. See fg_window_egl for more info
int configAttri;
#define EGL_QUERY_COMP(att, comp) (eglGetConfigAttrib(fgDisplay.pDisplay.egl.Display, window->Window.pContext.egl.Config, att, &configAttri) == GL_TRUE && (configAttri comp))
- if(EGL_QUERY_COMP(EGL_ALPHA_SIZE, <= 0) && EGL_QUERY_COMP(EGL_RED_SIZE, <= 5) &&
+ if (EGL_QUERY_COMP(EGL_ALPHA_SIZE, <= 0) && EGL_QUERY_COMP(EGL_RED_SIZE, <= 5) &&
EGL_QUERY_COMP(EGL_GREEN_SIZE, <= 6) && EGL_QUERY_COMP(EGL_BLUE_SIZE, <= 5)) {
screenFormat = SCREEN_FORMAT_RGB565;
}
/* Set window properties */
int orientation = atoi(getenv("ORIENTATION"));
-#ifdef GL_ES_VERSION_2_0
- int screenUsage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
-#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 | SCREEN_USAGE_ROTATION;
+ int screenUsage = SCREEN_USAGE_ROTATION;
+#ifdef SCREEN_USAGE_OPENGL_ES3
+ if (fgState.MajorVersion >= 3) {
+ screenUsage |= SCREEN_USAGE_OPENGL_ES3;
+ } else
#endif
+ if (fgState.MajorVersion >= 2) {
+ screenUsage |= SCREEN_USAGE_OPENGL_ES2;
+ } else {
+ screenUsage |= SCREEN_USAGE_OPENGL_ES1;
+ }
#if !defined(__X86__) && !defined(__PLAYBOOK__)
screenUsage |= SCREEN_USAGE_DISPLAY; // Physical device copy directly into physical display
#endif
FREEGLUT_INTERNAL_ERROR_EXIT(fgDisplay.pDisplay.egl.Display != EGL_NO_DISPLAY,
"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());
# ifdef GL_VERSION_1_1 /* or later */
if (fgDisplay.pDisplay.egl.Display != EGL_NO_DISPLAY) {
eglTerminate(fgDisplay.pDisplay.egl.Display);
fgDisplay.pDisplay.egl.Display = EGL_NO_DISPLAY;
+ fgDisplay.pDisplay.egl.MajorVersion = 0;
+ fgDisplay.pDisplay.egl.MinorVersion = 0;
}
}
{
/* Used to initialize and deinitialize EGL */
EGLDisplay Display;
+ EGLint MajorVersion;
+ EGLint MinorVersion;
};
EGLint attributes[32];
int where = 0;
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) {
/*
- * 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
- * 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
- * any references to OpenGL ES 3.0. Tests have shown that EGL_OPENGL_ES2_BIT will work with ES 3.0.
+ * 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
+ * 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
+ * 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);
} else {
EGLint attributes[32];
int where = 0;
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);
context = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, attributes);
}
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);
+ }
+#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;
}