From Jorge Ciges, "1rst - Changes in Cmake: They make possible "make install" with the android building.
2nd - Script to use a 3rd party directory with basic libraries: libjpeg,libpng,libtiff,giflib,freetype,curl,gdal. 3rd - Change in the GLES library loading for Android. That should make GLES2 work properly. 4rth- Included two defines RGB8_OES and RGBA8_OES as a substitute in GLES for RGB8 and RGBA8 5th - OpenGL and GLSL version identification changed to recognize GLES versions properly "
This commit is contained in:
@@ -85,6 +85,15 @@ IF(OSG_BUILD_PLATFORM_ANDROID)
|
||||
ADD_CUSTOM_TARGET(ndk ALL echo
|
||||
DEPENDS Android-OpenSceneGraph
|
||||
)
|
||||
install(DIRECTORY include/ DESTINATION include/
|
||||
PATTERN ".svn" EXCLUDE
|
||||
)
|
||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/include/ DESTINATION include/
|
||||
)
|
||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/obj/ DESTINATION obj/
|
||||
PATTERN ".svn" EXCLUDE
|
||||
PATTERN "objs" EXCLUDE
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(-DANDROID)
|
||||
|
||||
@@ -434,7 +443,7 @@ IF(WIN32 AND NOT ANDROID)
|
||||
ENDIF()
|
||||
|
||||
IF(ANDROID)
|
||||
# FIXME: add here any platform find
|
||||
ANDROID_3RD_PARTY()
|
||||
ELSE()
|
||||
# Common to all platforms except android:
|
||||
FIND_PACKAGE(FreeType)
|
||||
|
||||
@@ -9,7 +9,7 @@ MACRO(SETUP_ANDROID_LIBRARY LIB_NAME)
|
||||
set(MODULE_SOURCES "${MODULE_SOURCES} ${n_f}")
|
||||
endforeach(arg ${TARGET_SRC})
|
||||
|
||||
#SET(MODULE_INCLUDES "${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include")
|
||||
#SET(MODULE_INCLUDES "${CMAKE_SOURCE_DIR}/include include")
|
||||
GET_DIRECTORY_PROPERTY(loc_includes INCLUDE_DIRECTORIES)
|
||||
foreach(arg ${loc_includes})
|
||||
IF(NOT "${arg}" MATCHES "/usr/include" AND NOT "${arg}" MATCHES "/usr/local/include")
|
||||
@@ -53,3 +53,128 @@ MACRO(SETUP_ANDROID_LIBRARY LIB_NAME)
|
||||
configure_file("${OSG_ANDROID_TEMPLATES}/Android.mk.modules.in" "${CMAKE_CURRENT_BINARY_DIR}/Android.mk")
|
||||
|
||||
ENDMACRO()
|
||||
|
||||
MACRO(ANDROID_3RD_PARTY)
|
||||
################################################
|
||||
#JPEG
|
||||
################################################
|
||||
FIND_PATH(JPEG_INCLUDE_DIR Android.mk
|
||||
${CMAKE_SOURCE_DIR}/3rdparty/libjpeg
|
||||
)
|
||||
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libjpeg")
|
||||
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${JPEG_INCLUDE_DIR}/Android.mk \n")
|
||||
if(JPEG_INCLUDE_DIR)
|
||||
message(STATUS "Jpeg found ${JPEG_INCLUDE_DIR}" )
|
||||
set(JPEG_FOUND "Yes")
|
||||
install(DIRECTORY 3rdparty/build/libjpeg/ DESTINATION ./ )
|
||||
else(JPEG_INCLUDE_DIR)
|
||||
message(STATUS "Jpeg missing" )
|
||||
endif()
|
||||
################################################
|
||||
#PNG
|
||||
################################################
|
||||
FIND_PATH(PNG_INCLUDE_DIR Android.mk
|
||||
${CMAKE_SOURCE_DIR}/3rdparty/libpng
|
||||
)
|
||||
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libpng")
|
||||
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${PNG_INCLUDE_DIR}/Android.mk \n")
|
||||
if(PNG_INCLUDE_DIR)
|
||||
message(STATUS "PNG found ${PNG_INCLUDE_DIR}" )
|
||||
set(PNG_FOUND "Yes")
|
||||
install(DIRECTORY 3rdparty/build/libpng/ DESTINATION ./ )
|
||||
else(PNG_INCLUDE_DIR)
|
||||
message(STATUS "PNG missing" )
|
||||
endif()
|
||||
################################################
|
||||
#GIF
|
||||
################################################
|
||||
FIND_PATH(GIFLIB_INCLUDE_DIR Android.mk
|
||||
${CMAKE_SOURCE_DIR}/3rdparty/giflib
|
||||
)
|
||||
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libgif")
|
||||
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${GIFLIB_INCLUDE_DIR}/Android.mk \n")
|
||||
if(GIFLIB_INCLUDE_DIR)
|
||||
message(STATUS "GIF found ${GIFLIB_INCLUDE_DIR}" )
|
||||
set(GIFLIB_FOUND "Yes")
|
||||
install(DIRECTORY 3rdparty/build/giflib/ DESTINATION ./ )
|
||||
else(GIFLIB_INCLUDE_DIR)
|
||||
message(STATUS "GIF missing" )
|
||||
endif()
|
||||
################################################
|
||||
#TIF
|
||||
################################################
|
||||
FIND_PATH(TIFF_INCLUDE_DIR Android.mk
|
||||
${CMAKE_SOURCE_DIR}/3rdparty/libtiff
|
||||
)
|
||||
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libtiff")
|
||||
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${TIFF_INCLUDE_DIR}/Android.mk \n")
|
||||
if(TIFF_INCLUDE_DIR)
|
||||
message(STATUS "TIF found ${TIFF_INCLUDE_DIR}" )
|
||||
set(TIFF_FOUND "Yes")
|
||||
install(DIRECTORY 3rdparty/build/libtiff/ DESTINATION ./ )
|
||||
else(TIFF_INCLUDE_DIR)
|
||||
message(STATUS "TIF missing" )
|
||||
endif()
|
||||
################################################
|
||||
#ZLIB
|
||||
################################################
|
||||
#FIND_PATH(ZLIB_INCLUDE_DIR Android.mk
|
||||
# ${CMAKE_SOURCE_DIR}/3rdparty/zlib
|
||||
#)
|
||||
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} zlib")
|
||||
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${ZLIB_INCLUDE_DIR}/Android.mk \n")
|
||||
#if(ZLIB_INCLUDE_DIR)
|
||||
# message(STATUS "ZLIB found ${ZLIB_INCLUDE_DIR}" )
|
||||
# set(ZLIB_FOUND "Yes")
|
||||
# install(DIRECTORY 3rdparty/build/libjpeg/ DESTINATION ./ )
|
||||
#else(ZLIB_INCLUDE_DIR)
|
||||
# message(STATUS "ZLIB missing" )
|
||||
#endif()
|
||||
################################################
|
||||
#CURL
|
||||
################################################
|
||||
FIND_PATH(CURL_DIR Android.mk
|
||||
${CMAKE_SOURCE_DIR}/3rdparty/curl
|
||||
)
|
||||
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libcurl")
|
||||
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${CURL_DIR}/Android.mk \n")
|
||||
set(CURL_INCLUDE_DIR ${CURL_DIR}/include)
|
||||
set(CURL_INCLUDE_DIRS ${CURL_DIR}/include) #Both are defined in FindCurl
|
||||
if(CURL_DIR)
|
||||
message(STATUS "Curl found ${CURL_DIR}" )
|
||||
set(CURL_FOUND "Yes")
|
||||
install(DIRECTORY 3rdparty/build/curl/ DESTINATION ./ )
|
||||
else(CURL_DIR)
|
||||
message(STATUS "Curl missing" )
|
||||
endif()
|
||||
################################################
|
||||
#FREETYPE
|
||||
################################################
|
||||
FIND_PATH(FREETYPE_DIR Android.mk
|
||||
${CMAKE_SOURCE_DIR}/3rdparty/freetype
|
||||
)
|
||||
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libft2")
|
||||
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${FREETYPE_DIR}/Android.mk \n")
|
||||
set(FREETYPE_INCLUDE_DIRS "${FREETYPE_DIR}/include ${FREETYPE_DIR}/include/freetype/config")
|
||||
if(FREETYPE_DIR)
|
||||
message(STATUS "FREETYPE found ${FREETYPE_DIR}" )
|
||||
set(FREETYPE_FOUND "Yes")
|
||||
install(DIRECTORY 3rdparty/build/freetype/ DESTINATION ./ )
|
||||
else(FREETYPE_DIR)
|
||||
message(STATUS "FREETYPE missing" )
|
||||
endif()
|
||||
################################################
|
||||
#GDAL
|
||||
################################################
|
||||
FIND_PATH(GDAL_DIR gdal.h
|
||||
${CMAKE_SOURCE_DIR}/3rdparty/gdal/include
|
||||
)
|
||||
set(GDAL_INCLUDE_DIR "${GDAL_DIR}")
|
||||
if(GDAL_DIR)
|
||||
message(STATUS "GDAL found ${GDAL_DIR}" )
|
||||
set(GDAL_FOUND "Yes")
|
||||
install(DIRECTORY 3rdparty/build/gdal/ DESTINATION ./ )
|
||||
else(GDAL_DIR)
|
||||
message(STATUS "GDAL missing" )
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
@@ -170,6 +170,12 @@
|
||||
#define GL_NONE 0x0
|
||||
#endif
|
||||
|
||||
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
|
||||
//GLES defines (OES)
|
||||
#define GL_RGB8_OES 0x8051
|
||||
#define GL_RGBA8_OES 0x8058
|
||||
#endif
|
||||
|
||||
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GL3_AVAILABLE)
|
||||
#define GL_POLYGON 0x0009
|
||||
#define GL_QUADS 0x0007
|
||||
|
||||
@@ -377,9 +377,17 @@ void GL2Extensions::setupGL2Extensions(unsigned int contextID)
|
||||
{
|
||||
// If glGetString raises an error, assume initial release "1.00"
|
||||
while(glGetError() != GL_NO_ERROR) {} // reset error flag
|
||||
|
||||
const char* langVerStr = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
|
||||
if( (glGetError() == GL_NO_ERROR) && langVerStr )
|
||||
_glslLanguageVersion = asciiToFloat( langVerStr );
|
||||
{
|
||||
std::string glslvs( langVerStr );
|
||||
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
|
||||
_glslLanguageVersion = ( asciiToFloat( glslvs.substr( glslvs.find( "GLSL ES " )+8 ).c_str() ) );
|
||||
#else
|
||||
_glslLanguageVersion = ( asciiToFloat( glslvs.substr( glslvs.find( "GLSL "+5 ) ).c_str() ) );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
_glslLanguageVersion = 1.0f;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,11 @@ float osg::getGLVersionNumber()
|
||||
if (!versionstring) return 0.0;
|
||||
|
||||
std::string vs( versionstring );
|
||||
return( asciiToFloat( vs.substr( 0, vs.find( " " ) ).c_str() ) );
|
||||
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
|
||||
return( asciiToFloat( vs.substr( vs.find( "ES " )+3 ).c_str() ) );
|
||||
#else
|
||||
return( asciiToFloat( vs.substr( vs.find( " " )+1 ).c_str() ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
bool osg::isExtensionInExtensionString(const char *extension, const char *extensionString)
|
||||
@@ -319,8 +323,15 @@ std::string& osg::getGLExtensionDisableString()
|
||||
void* osg::getGLExtensionFuncPtr(const char *funcName)
|
||||
{
|
||||
// OSG_NOTICE<<"osg::getGLExtensionFuncPtr("<<funcName<<")"<<std::endl;
|
||||
#if defined(ANDROID)
|
||||
#if defined(OSG_GLES1_AVAILABLE)
|
||||
static void *handle = dlopen("libGLESv1_CM.so", RTLD_NOW);
|
||||
#elif defined(OSG_GLES2_AVAILABLE)
|
||||
static void *handle = dlopen("libGLESv2.so", RTLD_NOW);
|
||||
#endif
|
||||
return dlsym(handle, funcName);
|
||||
|
||||
#if defined(WIN32)
|
||||
#elif defined(WIN32)
|
||||
|
||||
#if defined(OSG_GLES2_AVAILABLE)
|
||||
static HMODULE hmodule = GetModuleHandle(TEXT("libGLESv2.dll"));
|
||||
|
||||
Reference in New Issue
Block a user