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)

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1694 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2014-06-24 07:03:16 +00:00
parent 89cfab41fc
commit c12f6173db
6 changed files with 94 additions and 33 deletions

View File

@ -6,7 +6,7 @@
# $ 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:
@ -16,6 +16,8 @@
# > /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
#
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
# $ 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:
@ -16,7 +16,7 @@
# > /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
#
@ -34,7 +34,12 @@ set( CMAKE_SYSTEM_VERSION 1 )
# 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
@ -103,28 +108,52 @@ else()
endif()
# Flags and preprocessor definitions
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( BB_USING_GCC_482 False )
if( PLAYBOOK )
set( BLACKBERRY_COMP_DEF "-D__PLAYBOOK__" )
set( BLACKBERRY_COMP_VERSION "4.4.2" )
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__" )
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_CC_FLAGS " -V4.6.3,gcc_ntox86 -D__QNX__" )
set( BLACKBERRY_CXX_FLAGS " -V4.6.3,gcc_ntox86 -Y_gpp -D__QNX__" )
set( BLACKBERRY_COMP_VERSION "4.6.3" )
endif()
endif()
if( BLACKBERRY_ARCHITECTURE STREQUAL "arm" )
set( BLACKBERRY_COMP_TARGET "gcc_ntoarmv7le" )
else()
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" )

View File

@ -61,7 +61,7 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
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;
}
@ -69,11 +69,17 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
/* 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

View File

@ -39,7 +39,7 @@ void fghPlatformInitializeEGL()
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 */
@ -59,6 +59,8 @@ void fghPlatformCloseDisplayEGL()
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;
}
}

View File

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

View File

@ -30,11 +30,16 @@ int fghChooseConfig(EGLConfig* config) {
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 {
@ -87,6 +92,12 @@ EGLContext fghCreateNewContextEGL( SFG_Window* window ) {
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);
@ -96,8 +107,17 @@ EGLContext fghCreateNewContextEGL( SFG_Window* window ) {
}
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;
}