Merge orphaned zone painter changes.

This commit is contained in:
sfb 2011-12-19 07:58:09 -06:00
commit 54804ab31f
1017 changed files with 55868 additions and 5528 deletions

View file

@ -41,10 +41,6 @@ INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
# Force out of source builds. # Force out of source builds.
CHECK_OUT_OF_SOURCE() CHECK_OUT_OF_SOURCE()
# Variables which must be set before PROJECT
NL_SETUP_BUILD()
NL_SETUP_BUILD_FLAGS()
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(RyzomCore CXX C) PROJECT(RyzomCore CXX C)
SET(NL_VERSION_MAJOR 0) SET(NL_VERSION_MAJOR 0)
@ -52,6 +48,9 @@ SET(NL_VERSION_MINOR 8)
SET(NL_VERSION_PATCH 0) SET(NL_VERSION_PATCH 0)
SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}") SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}")
NL_SETUP_BUILD()
NL_SETUP_BUILD_FLAGS()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Redirect output files # Redirect output files
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@ -91,20 +90,11 @@ NL_CONFIGURE_CHECKS()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
#Platform specifics #Platform specifics
SETUP_EXTERNAL()
IF(WIN32) IF(WIN32)
INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
SET(WINSOCK2_LIB ws2_32.lib) SET(WINSOCK2_LIB ws2_32.lib)
FIND_PACKAGE(External REQUIRED)
IF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/IDE/.+" "VC" VC_DIR ${CMAKE_MAKE_PROGRAM})
ELSE(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
# convert compiler fullpath to VC++ path
STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER})
ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
IF(WITH_MFC) IF(WITH_MFC)
FIND_PACKAGE(CustomMFC REQUIRED) FIND_PACKAGE(CustomMFC REQUIRED)
ENDIF(WITH_MFC) ENDIF(WITH_MFC)
@ -119,20 +109,15 @@ IF(WITH_STATIC)
# libxml2 could need winsock2 library # libxml2 could need winsock2 library
SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC) SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC)
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB}) SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB})
# on Mac OS X libxml2 requieres iconv
IF(APPLE)
FIND_PACKAGE(Iconv REQUIRED)
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES})
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
ENDIF(APPLE)
ENDIF(WITH_STATIC) ENDIF(WITH_STATIC)
IF(WITH_STLPORT)
FIND_PACKAGE(STLport REQUIRED)
INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR})
IF(WIN32)
SET(VC_INCLUDE_DIR "${VC_DIR}/include")
FIND_PACKAGE(WindowsSDK REQUIRED)
# use VC++ and Windows SDK include paths
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIR})
ENDIF(WIN32)
ENDIF(WITH_STLPORT)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/PCHSupport.cmake) INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/PCHSupport.cmake)
IF(FINAL_VERSION) IF(FINAL_VERSION)
@ -158,11 +143,11 @@ IF(WITH_RYZOM)
ENDIF(WITH_RYZOM) ENDIF(WITH_RYZOM)
IF(WITH_NELNS) IF(WITH_NELNS)
# ADD_SUBDIRECTORY(nelns) ADD_SUBDIRECTORY(nelns)
ENDIF(WITH_NELNS) ENDIF(WITH_NELNS)
IF(WITH_SNOWBALLS) IF(WITH_SNOWBALLS)
# ADD_SUBDIRECTORY(snowballs2) ADD_SUBDIRECTORY(snowballs2)
ENDIF(WITH_SNOWBALLS) ENDIF(WITH_SNOWBALLS)
IF(WITH_TOOLS) IF(WITH_TOOLS)

View file

@ -48,6 +48,10 @@ MACRO(NL_CONFIGURE_CHECKS)
SET(NL_OPENGL_AVAILABLE 1) SET(NL_OPENGL_AVAILABLE 1)
ENDIF(WITH_DRIVER_OPENGL) ENDIF(WITH_DRIVER_OPENGL)
IF(WITH_DRIVER_OPENGLES)
SET(NL_OPENGLES_AVAILABLE 1)
ENDIF(WITH_DRIVER_OPENGLES)
IF(WITH_DRIVER_DIRECT3D) IF(WITH_DRIVER_DIRECT3D)
SET(NL_DIRECT3D_AVAILABLE 1) SET(NL_DIRECT3D_AVAILABLE 1)
ENDIF(WITH_DRIVER_DIRECT3D) ENDIF(WITH_DRIVER_DIRECT3D)

View file

@ -12,31 +12,34 @@ endif(MAXSDK_INCLUDE_DIR)
find_path(MAXSDK_INCLUDE_DIR max.h find_path(MAXSDK_INCLUDE_DIR max.h
PATHS PATHS
"$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk/include"
"$ENV{3DSMAX_2011_SDK_PATH}/maxsdk/include"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk/include" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk/include"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk/include" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk/include"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk/include" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk/include"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk/include" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk/include"
"$ENV{3DSMAX_2011_SDK_PATH}/maxsdk/include"
) )
find_path(MAXSDK_CS_INCLUDE_DIR bipexp.h find_path(MAXSDK_CS_INCLUDE_DIR bipexp.h
PATHS PATHS
"$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk/include/CS"
"$ENV{3DSMAX_2011_SDK_PATH}/maxsdk/include/CS"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk/include/CS" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk/include/CS"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk/include/CS" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk/include/CS"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk/include/CS" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk/include/CS"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk/include/CS" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk/include/CS"
"$ENV{3DSMAX_2011_SDK_PATH}/maxsdk/include/CS"
) )
MACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME) MACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME)
FIND_LIBRARY(${MYLIBRARY} FIND_LIBRARY(${MYLIBRARY}
NAMES ${MYLIBRARYNAME} NAMES ${MYLIBRARYNAME}
PATHS PATHS
"$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk/lib"
"$ENV{3DSMAX_2011_SDK_PATH}/maxsdk/lib"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk/lib" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk/lib"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk/lib" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk/lib"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk/lib" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk/lib"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk/lib" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 9 SDK/maxsdk/lib"
"$ENV{3DSMAX_2011_SDK_PATH}/maxsdk/lib"
) )
ENDMACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME) ENDMACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME)

View file

@ -40,17 +40,12 @@ ENDIF(WITH_STLPORT OR NOT MFC_FOUND)
# Only if using a custom path # Only if using a custom path
IF(CUSTOM_MFC_DIR) IF(CUSTOM_MFC_DIR)
IF(NOT CMAKE_SIZEOF_VOID_P)
INCLUDE (CheckTypeSize)
CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
ENDIF(NOT CMAKE_SIZEOF_VOID_P)
# Using 32 or 64 bits libraries # Using 32 or 64 bits libraries
IF(CMAKE_SIZEOF_VOID_P EQUAL 8) IF(TARGET_X64)
SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64") SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib/amd64")
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) ELSE(TARGET_X64)
SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib") SET(MFC_LIBRARY_DIR "${MFC_DIR}/lib")
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) ENDIF(TARGET_X64)
# Add MFC libraries directory to default library path # Add MFC libraries directory to default library path
LINK_DIRECTORIES(${MFC_LIBRARY_DIR}) LINK_DIRECTORIES(${MFC_LIBRARY_DIR})

View file

@ -30,16 +30,11 @@ ENDMACRO(FIND_DXSDK_LIBRARY MYLIBRARY MYLIBRARYNAME)
IF(DXSDK_DIR) IF(DXSDK_DIR)
SET(DXSDK_INCLUDE_DIR "${DXSDK_DIR}/Include") SET(DXSDK_INCLUDE_DIR "${DXSDK_DIR}/Include")
IF(NOT CMAKE_SIZEOF_VOID_P) IF(TARGET_X64)
INCLUDE (CheckTypeSize)
CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
ENDIF(NOT CMAKE_SIZEOF_VOID_P)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(DXSDK_LIBRARY_DIR "${DXSDK_DIR}/Lib/x64") SET(DXSDK_LIBRARY_DIR "${DXSDK_DIR}/Lib/x64")
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) ELSE(TARGET_X64)
SET(DXSDK_LIBRARY_DIR "${DXSDK_DIR}/Lib/x86") SET(DXSDK_LIBRARY_DIR "${DXSDK_DIR}/Lib/x86")
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) ENDIF(TARGET_X64)
FIND_DXSDK_LIBRARY(DXSDK_GUID_LIBRARY dxguid) FIND_DXSDK_LIBRARY(DXSDK_GUID_LIBRARY dxguid)
FIND_DXSDK_LIBRARY(DXSDK_DINPUT_LIBRARY dinput8) FIND_DXSDK_LIBRARY(DXSDK_DINPUT_LIBRARY dinput8)
@ -59,7 +54,7 @@ ENDIF(DXSDK_DIR)
# all listed variables are TRUE. # all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs) INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DIRECTXSDK DEFAULT_MSG DXSDK_DIR DXSDK_GUID_LIBRARY DXSDK_DINPUT_LIBRARY) FIND_PACKAGE_HANDLE_STANDARD_ARGS(DirectXSDK DEFAULT_MSG DXSDK_DIR DXSDK_GUID_LIBRARY DXSDK_DINPUT_LIBRARY)
MARK_AS_ADVANCED(DXSDK_INCLUDE_DIR MARK_AS_ADVANCED(DXSDK_INCLUDE_DIR
DXSDK_GUID_LIBRARY DXSDK_GUID_LIBRARY

View file

@ -3,11 +3,12 @@
# The following values are defined # The following values are defined
# EXTERNAL_PATH - where to find external # EXTERNAL_PATH - where to find external
# EXTERNAL_INCLUDE_PATH - where to find external includes # EXTERNAL_INCLUDE_PATH - where to find external includes
# EXTERNAL_BINARY_PATH - where to find external binaries
# EXTERNAL_LIBRARY_PATH - where to find external libraries # EXTERNAL_LIBRARY_PATH - where to find external libraries
# EXTERNAL_FOUND - True if the external libraries are available # EXTERNAL_FOUND - True if the external libraries are available
SET(EXTERNAL_TEMP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/../external ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty ${EXTERNAL_PATH}) SET(EXTERNAL_TEMP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/../external ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty ${EXTERNAL_PATH})
SET(EXTERNAL_TEMP_FILE "include/png.h") SET(EXTERNAL_TEMP_FILE "include/wwwconf.h")
SET(EXTERNAL_NAME "external") SET(EXTERNAL_NAME "external")
# If using STLport preprend external_stlport # If using STLport preprend external_stlport
@ -17,36 +18,42 @@ IF(WITH_STLPORT)
SET(EXTERNAL_NAME "external with STLport") SET(EXTERNAL_NAME "external with STLport")
ENDIF(WITH_STLPORT) ENDIF(WITH_STLPORT)
SET(EXTERNAL_FOUND FALSE) FIND_PATH(EXTERNAL_PATH
FOREACH(ITEM ${EXTERNAL_TEMP_PATH}) ${EXTERNAL_TEMP_FILE}
IF(EXISTS "${ITEM}/${EXTERNAL_TEMP_FILE}" AND NOT EXTERNAL_FOUND) PATHS
SET(EXTERNAL_FOUND TRUE) $ENV{EXTERNAL_PATH}
# Get absolute path to avoid .. ${EXTERNAL_TEMP_PATH}
GET_FILENAME_COMPONENT(ITEM ${ITEM} ABSOLUTE) /usr/local
SET(EXTERNAL_PATH ${ITEM} CACHE PATH "" FORCE) /usr
ENDIF(EXISTS "${ITEM}/${EXTERNAL_TEMP_FILE}" AND NOT EXTERNAL_FOUND) /sw
ENDFOREACH(ITEM ${EXTERNAL_TEMP_PATH}) /opt/local
/opt/csw
/opt
)
IF(EXTERNAL_FOUND) IF(EXTERNAL_PATH)
SET(EXTERNAL_FOUND TRUE)
SET(EXTERNAL_INCLUDE_PATH "${EXTERNAL_PATH}/include") SET(EXTERNAL_INCLUDE_PATH "${EXTERNAL_PATH}/include")
IF(NOT CMAKE_SIZEOF_VOID_P) # Using 32 or 64 bits binaries
INCLUDE (CheckTypeSize) IF(TARGET_X64 AND WIN32)
CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P) SET(EXTERNAL_BINARY_PATH "${EXTERNAL_PATH}/bin64")
ENDIF(NOT CMAKE_SIZEOF_VOID_P) ELSE(TARGET_X64 AND WIN32)
SET(EXTERNAL_BINARY_PATH "${EXTERNAL_PATH}/bin")
ENDIF(TARGET_X64 AND WIN32)
# Using 32 or 64 bits libraries # Using 32 or 64 bits libraries
IF(CMAKE_SIZEOF_VOID_P EQUAL 8) IF(TARGET_X64 AND WIN32)
SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib64") SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib64")
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) ELSE(TARGET_X64 AND WIN32)
SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib") SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib")
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) ENDIF(TARGET_X64 AND WIN32)
SET(CMAKE_INCLUDE_PATH "${EXTERNAL_INCLUDE_PATH};${CMAKE_INCLUDE_PATH}") SET(CMAKE_INCLUDE_PATH "${EXTERNAL_INCLUDE_PATH};${CMAKE_INCLUDE_PATH}")
# Stupid hack for FindOpenAL.cmake # Stupid hack for FindOpenAL.cmake
SET(CMAKE_INCLUDE_PATH "${EXTERNAL_PATH};${CMAKE_INCLUDE_PATH}") SET(CMAKE_INCLUDE_PATH "${EXTERNAL_PATH};${CMAKE_INCLUDE_PATH}")
SET(CMAKE_LIBRARY_PATH "${EXTERNAL_LIBRARY_PATH};${CMAKE_LIBRARY_PATH}") SET(CMAKE_LIBRARY_PATH "${EXTERNAL_LIBRARY_PATH};${CMAKE_LIBRARY_PATH}")
ENDIF(EXTERNAL_FOUND) ENDIF(EXTERNAL_PATH)
IF(EXTERNAL_FOUND) IF(EXTERNAL_FOUND)
IF(NOT External_FIND_QUIETLY) IF(NOT External_FIND_QUIETLY)
@ -62,4 +69,4 @@ ELSE(EXTERNAL_FOUND)
ENDIF(External_FIND_REQUIRED) ENDIF(External_FIND_REQUIRED)
ENDIF(EXTERNAL_FOUND) ENDIF(EXTERNAL_FOUND)
MARK_AS_ADVANCED(EXTERNAL_INCLUDE_PATH EXTERNAL_LIBRARY_PATH) MARK_AS_ADVANCED(EXTERNAL_INCLUDE_PATH EXTERNAL_BINARY_PATH EXTERNAL_LIBRARY_PATH)

View file

@ -41,7 +41,7 @@ IF(FREETYPE_ADDITIONAL_INCLUDE_DIR)
ENDIF(FREETYPE_ADDITIONAL_INCLUDE_DIR) ENDIF(FREETYPE_ADDITIONAL_INCLUDE_DIR)
FIND_LIBRARY(FREETYPE_LIBRARY FIND_LIBRARY(FREETYPE_LIBRARY
NAMES freetype libfreetype freetype219 NAMES freetype libfreetype freetype219 freetype246
PATHS PATHS
$ENV{FREETYPE_DIR}/lib $ENV{FREETYPE_DIR}/lib
/usr/local/lib /usr/local/lib

View file

@ -0,0 +1,83 @@
# - Try to find Iconv on Mac OS X
# Once done this will define
#
# ICONV_FOUND - system has Iconv
# ICONV_INCLUDE_DIR - the Iconv include directory
# ICONV_LIBRARIES - Link these to use Iconv
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
#
IF(APPLE)
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
# Already in cache, be silent
SET(ICONV_FIND_QUIETLY TRUE)
ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
IF(APPLE)
FIND_PATH(ICONV_INCLUDE_DIR iconv.h
PATHS
/opt/local/include/
NO_CMAKE_SYSTEM_PATH
)
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c
PATHS
/opt/local/lib/
NO_CMAKE_SYSTEM_PATH
)
ENDIF(APPLE)
FIND_PATH(ICONV_INCLUDE_DIR iconv.h PATHS /opt/local/include /sw/include)
string(REGEX REPLACE "(.*)/include/?" "\\1" ICONV_INCLUDE_BASE_DIR "${ICONV_INCLUDE_DIR}")
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv c HINTS "${ICONV_INCLUDE_BASE_DIR}/lib" PATHS /opt/local/lib)
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
SET(ICONV_FOUND TRUE)
ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
IF(ICONV_FOUND)
check_c_compiler_flag("-Werror" ICONV_HAVE_WERROR)
set (CMAKE_C_FLAGS_BACKUP "${CMAKE_C_FLAGS}")
if(ICONV_HAVE_WERROR)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif(ICONV_HAVE_WERROR)
check_c_source_compiles("
#include <iconv.h>
int main(){
iconv_t conv = 0;
const char* in = 0;
size_t ilen = 0;
char* out = 0;
size_t olen = 0;
iconv(conv, &in, &ilen, &out, &olen);
return 0;
}
" ICONV_SECOND_ARGUMENT_IS_CONST )
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BACKUP}")
ENDIF(ICONV_FOUND)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
IF(ICONV_FOUND)
IF(NOT ICONV_FIND_QUIETLY)
MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
ENDIF(NOT ICONV_FIND_QUIETLY)
ELSE(ICONV_FOUND)
IF(Iconv_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Iconv")
ENDIF(Iconv_FIND_REQUIRED)
ENDIF(ICONV_FOUND)
MARK_AS_ADVANCED(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
ICONV_SECOND_ARGUMENT_IS_CONST
)
ENDIF(APPLE)

View file

@ -6,6 +6,8 @@
# LIBWWW_LIBRARY, where to find the LibWWW library. # LIBWWW_LIBRARY, where to find the LibWWW library.
# LIBWWW_FOUND, If false, do not try to use LibWWW. # LIBWWW_FOUND, If false, do not try to use LibWWW.
OPTION(WITH_LIBWWW_STATIC "Use only static libraries for libwww" OFF)
SET(LIBWWW_FIND_QUIETLY ${Libwww_FIND_QUIETLY}) SET(LIBWWW_FIND_QUIETLY ${Libwww_FIND_QUIETLY})
# also defined, but not for general use are # also defined, but not for general use are
@ -46,6 +48,11 @@ ENDIF(LIBWWW_ADDITIONAL_INCLUDE_DIR)
# helper to find all the libwww sub libraries # helper to find all the libwww sub libraries
MACRO(FIND_WWW_LIBRARY MYLIBRARY OPTION) MACRO(FIND_WWW_LIBRARY MYLIBRARY OPTION)
IF(WITH_LIBWWW_STATIC AND UNIX AND NOT APPLE AND NOT WITH_STATIC_EXTERNAL)
SET(CMAKE_FIND_LIBRARY_SUFFIXES_OLD ${CMAKE_FIND_LIBRARY_SUFFIXES})
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
ENDIF(WITH_LIBWWW_STATIC AND UNIX AND NOT APPLE AND NOT WITH_STATIC_EXTERNAL)
FIND_LIBRARY(${MYLIBRARY} FIND_LIBRARY(${MYLIBRARY}
NAMES ${ARGN} NAMES ${ARGN}
PATHS PATHS
@ -60,21 +67,27 @@ MACRO(FIND_WWW_LIBRARY MYLIBRARY OPTION)
/usr/freeware/lib64 /usr/freeware/lib64
) )
IF(CMAKE_FIND_LIBRARY_SUFFIXES_OLD)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_OLD})
ENDIF(CMAKE_FIND_LIBRARY_SUFFIXES_OLD)
IF(${MYLIBRARY}) IF(${MYLIBRARY})
IF(${OPTION} STREQUAL REQUIRED OR WITH_STATIC) IF(${OPTION} STREQUAL REQUIRED OR WITH_STATIC OR WITH_LIBWWW_STATIC)
SET(LIBWWW_LIBRARIES ${LIBWWW_LIBRARIES} ${${MYLIBRARY}}) SET(LIBWWW_LIBRARIES ${LIBWWW_LIBRARIES} ${${MYLIBRARY}})
ENDIF(${OPTION} STREQUAL REQUIRED OR WITH_STATIC) ENDIF(${OPTION} STREQUAL REQUIRED OR WITH_STATIC OR WITH_LIBWWW_STATIC)
ELSE(${MYLIBRARY}) ELSE(${MYLIBRARY})
IF(NOT LIBWWW_FIND_QUIETLY) IF(NOT LIBWWW_FIND_QUIETLY AND NOT WIN32)
MESSAGE(STATUS "Warning: Libwww: Library not found: ${MYLIBRARY}") MESSAGE(STATUS "Warning: Libwww: Library not found: ${MYLIBRARY}")
ENDIF(NOT LIBWWW_FIND_QUIETLY) ENDIF(NOT LIBWWW_FIND_QUIETLY AND NOT WIN32)
ENDIF(${MYLIBRARY}) ENDIF(${MYLIBRARY})
MARK_AS_ADVANCED(${MYLIBRARY}) MARK_AS_ADVANCED(${MYLIBRARY})
ENDMACRO(FIND_WWW_LIBRARY) ENDMACRO(FIND_WWW_LIBRARY)
MACRO(LINK_WWW_LIBRARY MYLIBRARY OTHERLIBRARY SYMBOL) MACRO(LINK_WWW_LIBRARY MYLIBRARY OTHERLIBRARY SYMBOL)
LINK_DEPENDS(LIBWWW_LIBRARIES ${MYLIBRARY} ${OTHERLIBRARY} ${SYMBOL}) IF(NOT WITH_LIBWWW_STATIC AND NOT WITH_STATIC_EXTERNAL)
LINK_DEPENDS(LIBWWW_LIBRARIES ${MYLIBRARY} ${OTHERLIBRARY} ${SYMBOL})
ENDIF(NOT WITH_LIBWWW_STATIC AND NOT WITH_STATIC_EXTERNAL)
ENDMACRO(LINK_WWW_LIBRARY) ENDMACRO(LINK_WWW_LIBRARY)
# Find and link required libs for static or dynamic # Find and link required libs for static or dynamic

View file

@ -6,7 +6,7 @@
IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR) IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
# in cache already # in cache already
SET(LUABIND_FIND_QUIETLY TRUE) SET(Luabind_FIND_QUIETLY TRUE)
ENDIF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR) ENDIF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
FIND_PATH(LUABIND_INCLUDE_DIR FIND_PATH(LUABIND_INCLUDE_DIR
@ -22,7 +22,7 @@ FIND_PATH(LUABIND_INCLUDE_DIR
) )
SET(LIBRARY_NAME_RELEASE luabind libluabind) SET(LIBRARY_NAME_RELEASE luabind libluabind)
SET(LIBRARY_NAME_DEBUG luabind_d libluabind_d libluabindd) SET(LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd)
IF(WITH_STLPORT) IF(WITH_STLPORT)
SET(LIBRARY_NAME_RELEASE luabind_stlport ${LIBRARY_NAME_RELEASE}) SET(LIBRARY_NAME_RELEASE luabind_stlport ${LIBRARY_NAME_RELEASE})
@ -62,30 +62,35 @@ FIND_LIBRARY(LUABIND_LIBRARY_DEBUG
FIND_PACKAGE(Boost REQUIRED) FIND_PACKAGE(Boost REQUIRED)
IF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR) IF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR)
IF(LUABIND_LIBRARY_RELEASE) IF(LUABIND_LIBRARY_RELEASE AND LUABIND_LIBRARY_DEBUG)
# Case where both Release and Debug versions are provided
SET(LUABIND_FOUND TRUE) SET(LUABIND_FOUND TRUE)
SET(LUABIND_INCLUDE_DIR ${LUABIND_INCLUDE_DIR} ${Boost_INCLUDE_DIR}) SET(LUABIND_LIBRARIES optimized ${LUABIND_LIBRARY_RELEASE} debug ${LUABIND_LIBRARY_DEBUG})
IF(LUABIND_LIBRARY_DEBUG) ELSEIF(LUABIND_LIBRARY_RELEASE)
SET(LUABIND_LIBRARIES "optimized;${LUABIND_LIBRARY_RELEASE};debug;${LUABIND_LIBRARY_DEBUG}") # Normal case
ELSE(LUABIND_LIBRARY_DEBUG) SET(LUABIND_FOUND TRUE)
SET(LUABIND_LIBRARIES "${LUABIND_LIBRARY_RELEASE}") SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_RELEASE})
ENDIF(LUABIND_LIBRARY_DEBUG) ELSEIF(LUABIND_LIBRARY_DEBUG)
ENDIF(LUABIND_LIBRARY_RELEASE) # Case where Luabind is compiled from sources (debug version is compiled by default)
SET(LUABIND_FOUND TRUE)
SET(LUABIND_LIBRARIES ${LUABIND_LIBRARY_DEBUG})
ENDIF(LUABIND_LIBRARY_RELEASE AND LUABIND_LIBRARY_DEBUG)
ENDIF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR) ENDIF(LUABIND_INCLUDE_DIR AND Boost_INCLUDE_DIR)
IF(LUABIND_FOUND) IF(LUABIND_FOUND)
SET(LUABIND_INCLUDE_DIR ${LUABIND_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
# Check if luabind/version.hpp exists # Check if luabind/version.hpp exists
FIND_FILE(LUABIND_VERSION_FILE luabind/version.hpp PATHS ${LUABIND_INCLUDE_DIR}) FIND_FILE(LUABIND_VERSION_FILE luabind/version.hpp PATHS ${LUABIND_INCLUDE_DIR})
IF(LUABIND_VERSION_FILE) IF(LUABIND_VERSION_FILE)
SET(LUABIND_DEFINITIONS "-DHAVE_LUABIND_VERSION") SET(LUABIND_DEFINITIONS "-DHAVE_LUABIND_VERSION")
ENDIF(LUABIND_VERSION_FILE) ENDIF(LUABIND_VERSION_FILE)
IF(NOT LUABIND_FIND_QUIETLY) IF(NOT Luabind_FIND_QUIETLY)
MESSAGE(STATUS "Found Luabind: ${LUABIND_LIBRARIES}") MESSAGE(STATUS "Found Luabind: ${LUABIND_LIBRARIES}")
ENDIF(NOT LUABIND_FIND_QUIETLY) ENDIF(NOT Luabind_FIND_QUIETLY)
ELSE(LUABIND_FOUND) ELSE(LUABIND_FOUND)
IF(NOT LUABIND_FIND_QUIETLY) IF(NOT Luabind_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Luabind!") MESSAGE(STATUS "Warning: Unable to find Luabind!")
ENDIF(NOT LUABIND_FIND_QUIETLY) ENDIF(NOT Luabind_FIND_QUIETLY)
ENDIF(LUABIND_FOUND) ENDIF(LUABIND_FOUND)
MARK_AS_ADVANCED(LUABIND_LIBRARY_RELEASE LUABIND_LIBRARY_DEBUG Boost_LIB_DIAGNOSTIC_DEFINITIONS) MARK_AS_ADVANCED(LUABIND_LIBRARY_RELEASE LUABIND_LIBRARY_DEBUG Boost_LIB_DIAGNOSTIC_DEFINITIONS)

View file

@ -71,9 +71,9 @@ IF(STLPORT_INCLUDE_DIR)
IF(STLPORT_LIBRARY_RELEASE) IF(STLPORT_LIBRARY_RELEASE)
SET(STLPORT_FOUND TRUE) SET(STLPORT_FOUND TRUE)
SET(STLPORT_LIBRARIES "optimized;${STLPORT_LIBRARY_RELEASE}") SET(STLPORT_LIBRARIES ${STLPORT_LIBRARY_RELEASE})
IF(STLPORT_LIBRARY_DEBUG) IF(STLPORT_LIBRARY_DEBUG)
SET(STLPORT_LIBRARIES "${STLPORT_LIBRARIES};debug;${STLPORT_LIBRARY_DEBUG}") SET(STLPORT_LIBRARIES optimized ${STLPORT_LIBRARIES} debug ${STLPORT_LIBRARY_DEBUG})
ENDIF(STLPORT_LIBRARY_DEBUG) ENDIF(STLPORT_LIBRARY_DEBUG)
ENDIF(STLPORT_LIBRARY_RELEASE) ENDIF(STLPORT_LIBRARY_RELEASE)
ENDIF(STLPORT_INCLUDE_DIR) ENDIF(STLPORT_INCLUDE_DIR)

View file

@ -9,17 +9,38 @@ IF(WINSDK_INCLUDE_DIR)
SET(WINSDK_FIND_QUIETLY TRUE) SET(WINSDK_FIND_QUIETLY TRUE)
ENDIF(WINSDK_INCLUDE_DIR) ENDIF(WINSDK_INCLUDE_DIR)
GET_FILENAME_COMPONENT(WINSDK71_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;InstallationFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDK71_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;ProductVersion]" NAME)
IF(WINSDK71_DIR)
IF(NOT WINSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDK71_VERSION} in ${WINSDK71_DIR}")
ENDIF(NOT WINSDK_FIND_QUIETLY)
ENDIF(WINSDK71_DIR)
GET_FILENAME_COMPONENT(WINSDKCURRENT_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDKCURRENT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentVersion]" NAME)
IF(WINSDKCURRENT_DIR)
IF(NOT WINSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDKCURRENT_VERSION} in ${WINSDKCURRENT_DIR}")
ENDIF(NOT WINSDK_FIND_QUIETLY)
ENDIF(WINSDKCURRENT_DIR)
FIND_PATH(WINSDK_INCLUDE_DIR Windows.h FIND_PATH(WINSDK_INCLUDE_DIR Windows.h
PATHS PATHS
"[HKEY_CURRENT_USER\\Software\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]/Include" ${WINSDK71_DIR}/Include
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]/Include" ${WINSDKCURRENT_DIR}/Include
)
FIND_PROGRAM(WINSDK_SIGNTOOL signtool
PATHS
${WINSDK71_DIR}/Bin
${WINSDKCURRENT_DIR}/Bin
) )
IF(WINSDK_INCLUDE_DIR) IF(WINSDK_INCLUDE_DIR)
SET(WINSDK_FOUND TRUE) SET(WINSDK_FOUND TRUE)
IF(NOT WINSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK.")
ENDIF(NOT WINSDK_FIND_QUIETLY)
ELSE(WINSDK_INCLUDE_DIR) ELSE(WINSDK_INCLUDE_DIR)
IF(NOT WINSDK_FIND_QUIETLY) IF(NOT WINSDK_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Windows SDK!") MESSAGE(STATUS "Warning: Unable to find Windows SDK!")

View file

@ -1,39 +0,0 @@
# - Find zlib
# Find the native ZLIB includes and library
#
# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
# ZLIB_LIBRARIES - List of libraries when using zlib.
# ZLIB_FOUND - True if zlib found.
#=============================================================================
# Copyright 2001-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distributed this file outside of CMake, substitute the full
# License text for the above reference.)
IF (ZLIB_INCLUDE_DIR)
# Already in cache, be silent
SET(ZLIB_FIND_QUIETLY TRUE)
ENDIF (ZLIB_INCLUDE_DIR)
FIND_PATH(ZLIB_INCLUDE_DIR zlib.h)
SET(ZLIB_NAMES z zlib zdll)
FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} )
MARK_AS_ADVANCED( ZLIB_LIBRARY ZLIB_INCLUDE_DIR )
# Per-recommendation
SET(ZLIB_INCLUDE_DIRS "${ZLIB_INCLUDE_DIR}")
SET(ZLIB_LIBRARIES "${ZLIB_LIBRARY}")
# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS)

View file

@ -45,8 +45,6 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
LIST(APPEND ${_out_compile_flags} "-fPIC") LIST(APPEND ${_out_compile_flags} "-fPIC")
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
ELSE(CMAKE_COMPILER_IS_GNUCXX)
## TODO ... ? or does it work out of the box
ENDIF(CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_COMPILER_IS_GNUCXX)
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES ) GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES )
@ -54,13 +52,23 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
LIST(APPEND ${_out_compile_flags} " ${_PCH_include_prefix}\"${item}\"") LIST(APPEND ${_out_compile_flags} " ${_PCH_include_prefix}\"${item}\"")
ENDFOREACH(item) ENDFOREACH(item)
# Required for CMake 2.6
SET(GLOBAL_DEFINITIONS "")
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS -D${item})
ENDFOREACH(item)
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
GET_DIRECTORY_PROPERTY(_global_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS) GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
LIST(APPEND ${_out_compile_flags} ${GLOBAL_DEFINITIONS})
LIST(APPEND ${_out_compile_flags} ${_directory_flags}) LIST(APPEND ${_out_compile_flags} ${_directory_flags})
LIST(APPEND ${_out_compile_flags} ${_global_definitions}) LIST(APPEND ${_out_compile_flags} ${_directory_definitions})
LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS}) LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS})
# Format definitions and remove duplicates
SEPARATE_ARGUMENTS(${_out_compile_flags}) SEPARATE_ARGUMENTS(${_out_compile_flags})
LIST(REMOVE_DUPLICATES ${_out_compile_flags})
ENDMACRO(_PCH_GET_COMPILE_FLAGS) ENDMACRO(_PCH_GET_COMPILE_FLAGS)
MACRO(_PCH_GET_PDB_FILENAME out_filename _target) MACRO(_PCH_GET_PDB_FILENAME out_filename _target)
@ -115,6 +123,11 @@ MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input) ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use ) MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND)
IF(CMAKE_COMPILER_IS_GNUCXX) IF(CMAKE_COMPILER_IS_GNUCXX)
# to do: test whether compiler flags match between target _targetName # to do: test whether compiler flags match between target _targetName
# and _pch_output_to_use # and _pch_output_to_use
@ -123,19 +136,17 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
# for use with distcc and gcc >4.0.1 if preprocessed files are accessible # for use with distcc and gcc >4.0.1 if preprocessed files are accessible
# on all remote machines set # on all remote machines set
# PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess # PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
SET(_target_cflags "${PCH_ADDITIONAL_COMPILER_FLAGS}-include ${_input} -Winvalid-pch") SET(_target_cflags "${oldProps} ${PCH_ADDITIONAL_COMPILER_FLAGS}-include ${_input} -Winvalid-pch")
ELSE(CMAKE_COMPILER_IS_GNUCXX) ELSE(CMAKE_COMPILER_IS_GNUCXX)
IF(MSVC) IF(MSVC)
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND)
SET(_target_cflags "${oldProps} /Yu\"${_input}\" /FI\"${_input}\" /Fp\"${_pch_output_to_use}\"") SET(_target_cflags "${oldProps} /Yu\"${_input}\" /FI\"${_input}\" /Fp\"${_pch_output_to_use}\"")
ENDIF(MSVC) ENDIF(MSVC)
ENDIF(CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_COMPILER_IS_GNUCXX)
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_target_cflags}) SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_target_cflags})
IF(oldProps)
SET_TARGET_PROPERTIES(${_targetName}_pch_dephelp PROPERTIES COMPILE_FLAGS ${oldProps})
ENDIF(oldProps)
ADD_CUSTOM_TARGET(pch_Generate_${_targetName} DEPENDS ${_pch_output_to_use}) ADD_CUSTOM_TARGET(pch_Generate_${_targetName} DEPENDS ${_pch_output_to_use})
ADD_DEPENDENCIES(${_targetName} pch_Generate_${_targetName}) ADD_DEPENDENCIES(${_targetName} pch_Generate_${_targetName})
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET) ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)

View file

@ -3,10 +3,10 @@
# Argument: name - the name of the .pc package, e.g. "nel-pacs.pc" # Argument: name - the name of the .pc package, e.g. "nel-pacs.pc"
### ###
MACRO(NL_GEN_PC name) MACRO(NL_GEN_PC name)
IF(NOT WIN32) IF(NOT WIN32 AND WITH_INSTALL_LIBRARIES)
CONFIGURE_FILE(${name}.in "${CMAKE_CURRENT_BINARY_DIR}/${name}") CONFIGURE_FILE(${name}.in "${CMAKE_CURRENT_BINARY_DIR}/${name}")
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION lib/pkgconfig) INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION lib/pkgconfig)
ENDIF(NOT WIN32) ENDIF(NOT WIN32 AND WITH_INSTALL_LIBRARIES)
ENDMACRO(NL_GEN_PC) ENDMACRO(NL_GEN_PC)
### ###
@ -37,17 +37,25 @@ ENDMACRO(NL_TARGET_DRIVER)
# Argument: # Argument:
### ###
MACRO(NL_DEFAULT_PROPS name label) MACRO(NL_DEFAULT_PROPS name label)
SET_TARGET_PROPERTIES(${name} PROPERTIES PROJECT_LABEL ${label})
GET_TARGET_PROPERTY(type ${name} TYPE) GET_TARGET_PROPERTY(type ${name} TYPE)
IF(${type} STREQUAL SHARED_LIBRARY) IF(${type} STREQUAL SHARED_LIBRARY)
# Set versions only if target is a shared library # Set versions only if target is a shared library
SET_TARGET_PROPERTIES(${name} PROPERTIES SET_TARGET_PROPERTIES(${name} PROPERTIES
VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR} VERSION ${NL_VERSION} SOVERSION ${NL_VERSION_MAJOR})
INSTALL_NAME_DIR ${NL_LIB_PREFIX} IF(NL_LIB_PREFIX)
PROJECT_LABEL ${label}) SET_TARGET_PROPERTIES(${name} PROPERTIES INSTALL_NAME_DIR ${NL_LIB_PREFIX})
ELSE(${type} STREQUAL SHARED_LIBRARY) ENDIF(NL_LIB_PREFIX)
SET_TARGET_PROPERTIES(${name} PROPERTIES
PROJECT_LABEL ${label})
ENDIF(${type} STREQUAL SHARED_LIBRARY) ENDIF(${type} STREQUAL SHARED_LIBRARY)
IF(${type} STREQUAL EXECUTABLE AND WIN32)
SET_TARGET_PROPERTIES(${name} PROPERTIES
VERSION ${NL_VERSION}
SOVERSION ${NL_VERSION_MAJOR}
COMPILE_FLAGS "/GA"
LINK_FLAGS "/VERSION:${NL_VERSION}")
ENDIF(${type} STREQUAL EXECUTABLE AND WIN32)
IF(WITH_STLPORT AND WIN32) IF(WITH_STLPORT AND WIN32)
SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "/X") SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "/X")
ENDIF(WITH_STLPORT AND WIN32) ENDIF(WITH_STLPORT AND WIN32)
@ -93,6 +101,14 @@ MACRO(NL_ADD_STATIC_VID_DRIVERS name)
TARGET_LINK_LIBRARIES(${name} nel_drv_opengl) TARGET_LINK_LIBRARIES(${name} nel_drv_opengl)
ENDIF(WIN32) ENDIF(WIN32)
ENDIF(WITH_DRIVER_OPENGL) ENDIF(WITH_DRIVER_OPENGL)
IF(WITH_DRIVER_OPENGLES)
IF(WIN32)
TARGET_LINK_LIBRARIES(${name} nel_drv_opengles_win)
ELSE(WIN32)
TARGET_LINK_LIBRARIES(${name} nel_drv_opengles)
ENDIF(WIN32)
ENDIF(WITH_DRIVER_OPENGLES)
ENDIF(WITH_STATIC_DRIVERS) ENDIF(WITH_STATIC_DRIVERS)
ENDMACRO(NL_ADD_STATIC_VID_DRIVERS) ENDMACRO(NL_ADD_STATIC_VID_DRIVERS)
@ -162,6 +178,13 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
OPTION(WITH_STATIC "With static libraries." OFF) OPTION(WITH_STATIC "With static libraries." OFF)
ENDIF(WIN32) ENDIF(WIN32)
OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF) OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF)
IF(WIN32)
OPTION(WITH_EXTERNAL "With provided external." ON )
ELSE(WIN32)
OPTION(WITH_EXTERNAL "With provided external." OFF)
ENDIF(WIN32)
OPTION(WITH_STATIC_EXTERNAL "With static external libraries" OFF)
OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON )
### ###
# GUI toolkits # GUI toolkits
@ -186,10 +209,10 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
OPTION(BUILD_DASHBOARD "Build to the CDash dashboard" OFF) OPTION(BUILD_DASHBOARD "Build to the CDash dashboard" OFF)
OPTION(WITH_NEL "Build NeL (nearly always required)." ON ) OPTION(WITH_NEL "Build NeL (nearly always required)." ON )
OPTION(WITH_NELNS "Build NeL Network Services." OFF) OPTION(WITH_NELNS "Build NeL Network Services." OFF)
OPTION(WITH_RYZOM "Build Ryzom Core." ON ) OPTION(WITH_RYZOM "Build Ryzom Core." ON )
OPTION(WITH_SNOWBALLS "Build Snowballs." OFF) OPTION(WITH_SNOWBALLS "Build Snowballs." OFF)
ENDMACRO(NL_SETUP_DEFAULT_OPTIONS) ENDMACRO(NL_SETUP_DEFAULT_OPTIONS)
MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
@ -208,6 +231,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
# Drivers Support # Drivers Support
### ###
OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON ) OPTION(WITH_DRIVER_OPENGL "Build OpenGL Driver (3D)" ON )
OPTION(WITH_DRIVER_OPENGLES "Build OpenGL ES Driver (3D)" OFF)
OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF) OPTION(WITH_DRIVER_DIRECT3D "Build Direct3D Driver (3D)" OFF)
OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON ) OPTION(WITH_DRIVER_OPENAL "Build OpenAL Driver (Sound)" ON )
OPTION(WITH_DRIVER_FMOD "Build FMOD Driver (Sound)" OFF) OPTION(WITH_DRIVER_FMOD "Build FMOD Driver (Sound)" OFF)
@ -278,20 +302,64 @@ MACRO(NL_SETUP_BUILD)
ENDIF(CMAKE_BUILD_TYPE MATCHES "Release") ENDIF(CMAKE_BUILD_TYPE MATCHES "Release")
ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug") ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug")
# Determine target CPU
# IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
IF(NOT CMAKE_SIZEOF_VOID_P)
INCLUDE (CheckTypeSize)
CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
ENDIF(NOT CMAKE_SIZEOF_VOID_P)
# Using 32 or 64 bits libraries
SET(TARGET_X86 1)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(ARCH "x86_64")
SET(TARGET_X64 1)
ADD_DEFINITIONS(-DHAVE_X86_64)
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(ARCH "x86")
ADD_DEFINITIONS(-DHAVE_X86)
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
# ADD_DEFINITIONS(-DHAVE_IA64)
# ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
IF(WIN32) IF(WIN32)
# don't use a /O[012x] flag if you want custom optimizations IF(MSVC10)
SET(SPEED_OPTIMIZATIONS "/Ob2 /Oi /Ot /Oy /GT /GF /GS-") # /Ox is working with VC++ 2010, but custom optimizations don't exist
# without inlining it's unusable, use custom optimizations again SET(SPEED_OPTIMIZATIONS "/Ox /GF /GS-")
SET(MIN_OPTIMIZATIONS "/Ob1") # without inlining it's unusable, use custom optimizations again
SET(MIN_OPTIMIZATIONS "/Od /Ob1")
ELSEIF(MSVC90)
# don't use a /O[012x] flag if you want custom optimizations
SET(SPEED_OPTIMIZATIONS "/Ob2 /Oi /Ot /Oy /GT /GF /GS-")
# without inlining it's unusable, use custom optimizations again
SET(MIN_OPTIMIZATIONS "/Ob1")
ELSEIF(MSVC80)
# don't use a /O[012x] flag if you want custom optimizations
SET(SPEED_OPTIMIZATIONS "/Ox /GF /GS-")
# without inlining it's unusable, use custom optimizations again
SET(MIN_OPTIMIZATIONS "/Od /Ob1")
ELSE(MSVC10)
MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
ENDIF(MSVC10)
SET(PLATFORM_CFLAGS "/D_CRT_SECURE_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zi /Zm1000") SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zi /Zm1000 /MP /Gy-")
# Exceptions are only set for C++
SET(PLATFORM_CXXFLAGS "${PLATFORM_CFLAGS} /EHa")
# Common link flags # Common link flags
SET(PLATFORM_LINKFLAGS "-DEBUG") SET(PLATFORM_LINKFLAGS "-DEBUG")
IF(TARGET_X64)
# Fix a bug with Intellisense
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /D_WIN64")
# Fix a compilation error for some big C++ files
SET(MIN_OPTIMIZATIONS "${MIN_OPTIMIZATIONS} /bigobj")
ELSE(TARGET_X64)
# Allows 32 bits applications to use 3 GB of RAM
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /LARGEADDRESSAWARE")
ENDIF(TARGET_X64)
# Exceptions are only set for C++
SET(PLATFORM_CXXFLAGS "${PLATFORM_CFLAGS} /EHa")
SET(NL_DEBUG_CFLAGS "/MDd /RTC1 /D_DEBUG ${MIN_OPTIMIZATIONS}") SET(NL_DEBUG_CFLAGS "/MDd /RTC1 /D_DEBUG ${MIN_OPTIMIZATIONS}")
SET(NL_RELEASE_CFLAGS "/MD /D NDEBUG ${SPEED_OPTIMIZATIONS}") SET(NL_RELEASE_CFLAGS "/MD /D NDEBUG ${SPEED_OPTIMIZATIONS}")
SET(NL_DEBUG_LINKFLAGS "/NODEFAULTLIB:msvcrt /INCREMENTAL:YES") SET(NL_DEBUG_LINKFLAGS "/NODEFAULTLIB:msvcrt /INCREMENTAL:YES")
@ -306,6 +374,11 @@ MACRO(NL_SETUP_BUILD)
SET(PLATFORM_CFLAGS "-gdwarf-2 ${PLATFORM_CFLAGS}") SET(PLATFORM_CFLAGS "-gdwarf-2 ${PLATFORM_CFLAGS}")
ENDIF(APPLE) ENDIF(APPLE)
# Fix "relocation R_X86_64_32 against.." error on x64 platforms
IF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS)
SET(PLATFORM_CFLAGS "-fPIC ${PLATFORM_CFLAGS}")
ENDIF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS)
SET(PLATFORM_CXXFLAGS ${PLATFORM_CFLAGS}) SET(PLATFORM_CXXFLAGS ${PLATFORM_CFLAGS})
IF(NOT APPLE) IF(NOT APPLE)
@ -314,33 +387,10 @@ MACRO(NL_SETUP_BUILD)
SET(NL_DEBUG_CFLAGS "-DNL_DEBUG -D_DEBUG") SET(NL_DEBUG_CFLAGS "-DNL_DEBUG -D_DEBUG")
SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O6") SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O6")
ENDIF(WIN32) ENDIF(WIN32)
# Determine host CPU
IF(UNIX AND NOT WIN32)
FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
IF(CMAKE_UNAME)
EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
SET(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "processor type (i386 and x86_64)")
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
ADD_DEFINITIONS(-DHAVE_X86_64)
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
ADD_DEFINITIONS(-DHAVE_IA64)
ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
ADD_DEFINITIONS(-DHAVE_X86)
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
ELSE(CMAKE_UNAME) # Assume that if uname is not found that we're x86.
ADD_DEFINITIONS(-DHAVE_X86)
ENDIF(CMAKE_UNAME)
ENDIF(UNIX AND NOT WIN32)
ENDMACRO(NL_SETUP_BUILD) ENDMACRO(NL_SETUP_BUILD)
MACRO(NL_SETUP_BUILD_FLAGS) MACRO(NL_SETUP_BUILD_FLAGS)
#SET(CMAKE_DEBUG_POSTFIX "_d")
#SET(CMAKE_RELEASE_POSTFIX "_r")
SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE) SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE)
SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE) SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE)
@ -431,44 +481,98 @@ MACRO(RYZOM_SETUP_PREFIX_PATHS)
IF(WIN32) IF(WIN32)
SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations") SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
ELSE(WIN32) ELSE(WIN32)
SET(RYZOM_ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc/ryzom" CACHE PATH "Installation path for configurations") SET(RYZOM_ETC_PREFIX "${RYZOM_PREFIX}/etc/ryzom" CACHE PATH "Installation path for configurations")
ENDIF(WIN32) ENDIF(WIN32)
ENDIF(NOT RYZOM_ETC_PREFIX) ENDIF(NOT RYZOM_ETC_PREFIX)
## Allow override of install_prefix/share path. ## Allow override of install_prefix/share path.
IF(NOT RYZOM_SHARE_PREFIX) IF(NOT RYZOM_SHARE_PREFIX)
IF(WIN32) IF(WIN32)
SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.") SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
ELSE(WIN32) ELSE(WIN32)
SET(RYZOM_SHARE_PREFIX "${CMAKE_INSTALL_PREFIX}/share/ryzom" CACHE PATH "Installation path for data.") SET(RYZOM_SHARE_PREFIX "${RYZOM_PREFIX}/share/ryzom" CACHE PATH "Installation path for data.")
ENDIF(WIN32) ENDIF(WIN32)
ENDIF(NOT RYZOM_SHARE_PREFIX) ENDIF(NOT RYZOM_SHARE_PREFIX)
## Allow override of install_prefix/sbin path. ## Allow override of install_prefix/sbin path.
IF(NOT RYZOM_SBIN_PREFIX) IF(NOT RYZOM_SBIN_PREFIX)
IF(WIN32) IF(WIN32)
SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.") SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
ELSE(WIN32) ELSE(WIN32)
SET(RYZOM_SBIN_PREFIX "${CMAKE_INSTALL_PREFIX}/sbin" CACHE PATH "Installation path for admin tools and services.") SET(RYZOM_SBIN_PREFIX "${RYZOM_PREFIX}/sbin" CACHE PATH "Installation path for admin tools and services.")
ENDIF(WIN32) ENDIF(WIN32)
ENDIF(NOT RYZOM_SBIN_PREFIX) ENDIF(NOT RYZOM_SBIN_PREFIX)
## Allow override of install_prefix/bin path. ## Allow override of install_prefix/bin path.
IF(NOT RYZOM_BIN_PREFIX) IF(NOT RYZOM_BIN_PREFIX)
IF(WIN32) IF(WIN32)
SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.") SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ELSE(WIN32) ELSE(WIN32)
SET(RYZOM_BIN_PREFIX "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation path for tools.") SET(RYZOM_BIN_PREFIX "${RYZOM_PREFIX}/bin" CACHE PATH "Installation path for tools.")
ENDIF(WIN32) ENDIF(WIN32)
ENDIF(NOT RYZOM_BIN_PREFIX) ENDIF(NOT RYZOM_BIN_PREFIX)
## Allow override of install_prefix/games path. ## Allow override of install_prefix/games path.
IF(NOT RYZOM_GAMES_PREFIX) IF(NOT RYZOM_GAMES_PREFIX)
IF(WIN32) IF(WIN32)
SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.") SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ELSE(WIN32) ELSE(WIN32)
SET(RYZOM_GAMES_PREFIX "${CMAKE_INSTALL_PREFIX}/games" CACHE PATH "Installation path for client.") SET(RYZOM_GAMES_PREFIX "${RYZOM_PREFIX}/games" CACHE PATH "Installation path for client.")
ENDIF(WIN32) ENDIF(WIN32)
ENDIF(NOT RYZOM_GAMES_PREFIX) ENDIF(NOT RYZOM_GAMES_PREFIX)
ENDMACRO(RYZOM_SETUP_PREFIX_PATHS) ENDMACRO(RYZOM_SETUP_PREFIX_PATHS)
MACRO(SETUP_EXTERNAL)
IF(WITH_EXTERNAL)
FIND_PACKAGE(External REQUIRED)
ENDIF(WITH_EXTERNAL)
IF(WIN32)
INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
IF(MSVC10)
IF(NOT MSVC10_REDIST_DIR)
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC10_REDIST_DIR)
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0_Config;InstallDir]" ABSOLUTE)
# VC_ROOT_DIR is set to "registry" when a key is not found
IF(VC_ROOT_DIR MATCHES "registry")
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VCExpress\\10.0_Config;InstallDir]" ABSOLUTE)
IF(VC_ROOT_DIR MATCHES "registry")
MESSAGE(FATAL_ERROR "Unable to find VC++ 2010 directory!")
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(VC_ROOT_DIR MATCHES "registry")
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR})
ELSE(MSVC10)
IF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${CMAKE_MAKE_PROGRAM})
ELSE(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
# convert compiler fullpath to VC++ path
STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER})
ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
ENDIF(MSVC10)
ELSE(WIN32)
IF(CMAKE_FIND_LIBRARY_SUFFIXES AND NOT APPLE)
IF(WITH_STATIC_EXTERNAL)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
ELSE(WITH_STATIC_EXTERNAL)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
ENDIF(WITH_STATIC_EXTERNAL)
ENDIF(CMAKE_FIND_LIBRARY_SUFFIXES AND NOT APPLE)
ENDIF(WIN32)
IF(WITH_STLPORT)
FIND_PACKAGE(STLport REQUIRED)
INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR})
IF(WIN32)
SET(VC_INCLUDE_DIR "${VC_DIR}/include")
FIND_PACKAGE(WindowsSDK REQUIRED)
# use VC++ and Windows SDK include paths
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIR})
ENDIF(WIN32)
ENDIF(WITH_STLPORT)
ENDMACRO(SETUP_EXTERNAL)

View file

@ -29,4 +29,4 @@ file for for more details on license terms and other legal issues.
Installation Installation
------------ ------------
Please check the dev.ryzom.com for more information Please visit http://dev.ryzom.com for more information.

View file

@ -35,6 +35,7 @@
#cmakedefine HAVE_STAT64 1 #cmakedefine HAVE_STAT64 1
#cmakedefine NL_OPENGL_AVAILABLE ${NL_OPENGL_AVAILABLE} #cmakedefine NL_OPENGL_AVAILABLE ${NL_OPENGL_AVAILABLE}
#cmakedefine NL_OPENGLES_AVAILABLE ${NL_OPENGLES_AVAILABLE}
#cmakedefine NL_DIRECT3D_AVAILABLE ${NL_DIRECT3D_AVAILABLE} #cmakedefine NL_DIRECT3D_AVAILABLE ${NL_DIRECT3D_AVAILABLE}
#cmakedefine NL_FMOD_AVAILABLE ${NL_FMOD_AVAILABLE} #cmakedefine NL_FMOD_AVAILABLE ${NL_FMOD_AVAILABLE}

View file

@ -54,24 +54,27 @@ IF(WITH_GTK)
FIND_PACKAGE(GTK2) FIND_PACKAGE(GTK2)
ENDIF(WITH_GTK) ENDIF(WITH_GTK)
IF(UNIX) IF(WITH_INSTALL_LIBRARIES)
SET(prefix ${CMAKE_INSTALL_PREFIX}) IF(UNIX)
SET(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(libdir ${CMAKE_INSTALL_PREFIX}/lib) SET(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
SET(includedir ${CMAKE_INSTALL_PREFIX}/include) SET(libdir ${CMAKE_INSTALL_PREFIX}/lib)
SET(enable_ligo ${WITH_LIGO}) SET(includedir ${CMAKE_INSTALL_PREFIX}/include)
SET(enable_logic ${WITH_LOGIC}) SET(enable_ligo ${WITH_LIGO})
SET(enable_georges ${WITH_GEORGES}) SET(enable_logic ${WITH_LOGIC})
SET(enable_net ${WITH_NET}) SET(enable_georges ${WITH_GEORGES})
SET(enable_3d ${WITH_3D}) SET(enable_net ${WITH_NET})
SET(enable_pacs ${WITH_PACS}) SET(enable_3d ${WITH_3D})
SET(enable_sound ${WITH_SOUND}) SET(enable_pacs ${WITH_PACS})
CONFIGURE_FILE(nel-config.in ${CMAKE_CURRENT_BINARY_DIR}/nel-config) SET(enable_sound ${WITH_SOUND})
CONFIGURE_FILE(nel-config.in ${CMAKE_CURRENT_BINARY_DIR}/nel-config)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/nel-config DESTINATION bin) INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/nel-config DESTINATION bin)
ENDIF(UNIX) ENDIF(UNIX)
ADD_SUBDIRECTORY(include)
ENDIF(WITH_INSTALL_LIBRARIES)
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(src)
IF(WITH_NEL_SAMPLES) IF(WITH_NEL_SAMPLES)

View file

@ -107,7 +107,7 @@ public:
bool Visible; bool Visible;
/// Precomputed Lighting. /// Precomputed Lighting.
// If true (false by default), then the instance don't cast shadow (used by ig_lighter.exe). // If true (false by default), then the instance don't cast shadow (used by ig_lighter).
bool DontCastShadow; bool DontCastShadow;
// If true (false by default), then the instance's lighting will not be precomputed. // If true (false by default), then the instance's lighting will not be precomputed.
bool AvoidStaticLightPreCompute; bool AvoidStaticLightPreCompute;
@ -120,7 +120,7 @@ public:
* If 0xFF => take Ambient of the sun. * If 0xFF => take Ambient of the sun.
*/ */
uint8 LocalAmbientId; uint8 LocalAmbientId;
/** if true (false by default), the instance don't cast shadow, but ONLY FOR ig_lighter.exe (ig_lighter_lib) /** if true (false by default), the instance don't cast shadow, but ONLY FOR ig_lighter (ig_lighter_lib)
* (zone_lighter and zone_ig_lighter ignore it). * (zone_lighter and zone_ig_lighter ignore it).
* This is a special trick for the "Matis Serre" where the exterior mesh cast shadow in the interior, but * This is a special trick for the "Matis Serre" where the exterior mesh cast shadow in the interior, but
* is not visible in the interior in realTime because of cluster clipping.... omg :( * is not visible in the interior in realTime because of cluster clipping.... omg :(

View file

@ -697,6 +697,7 @@ public:
virtual bool addLinearFloatKey(const UKeyLinearFloat &key) virtual bool addLinearFloatKey(const UKeyLinearFloat &key)
{ {
CKeyFloat k; CKeyFloat k;
k.OODeltaTime= 0.f;
k.Value= key.Value; k.Value= key.Value;
addKey(k, key.Time); addKey(k, key.Time);
return true; return true;

View file

@ -142,11 +142,14 @@ namespace CEGUI
void captureCursor(bool capture) { void captureCursor(bool capture) {
m_Captured=capture; m_Captured=capture;
if(capture) { if(capture)
{
m_Driver->setCapture(true); m_Driver->setCapture(true);
m_Driver->showCursor(false); m_Driver->showCursor(false);
m_InputDriver.activateMouse(); m_InputDriver.activateMouse();
} else { }
else
{
m_Driver->setCapture(false); m_Driver->setCapture(false);
m_Driver->showCursor(true); m_Driver->showCursor(true);
m_InputDriver.deactivateMouse(); m_InputDriver.deactivateMouse();
@ -178,7 +181,8 @@ namespace CEGUI
class NeLInputDriver : public NLMISC::IEventListener class NeLInputDriver : public NLMISC::IEventListener
{ {
public: public:
NeLInputDriver() { NeLInputDriver()
{
m_MouseX=0.5f; m_MouseX=0.5f;
m_MouseY=0.5f; m_MouseY=0.5f;
m_Active=false; m_Active=false;
@ -189,7 +193,8 @@ namespace CEGUI
} }
virtual ~NeLInputDriver() { ; } virtual ~NeLInputDriver() { ; }
void addToServer(NLMISC::CEventServer& server) { void addToServer(NLMISC::CEventServer& server)
{
server.addListener(NLMISC::EventMouseMoveId, this); server.addListener(NLMISC::EventMouseMoveId, this);
server.addListener(NLMISC::EventMouseDownId, this); server.addListener(NLMISC::EventMouseDownId, this);
server.addListener(NLMISC::EventMouseUpId, this); server.addListener(NLMISC::EventMouseUpId, this);
@ -200,7 +205,8 @@ namespace CEGUI
m_AsyncListener.addToServer(server); m_AsyncListener.addToServer(server);
} }
void removeFromServer(NLMISC::CEventServer& server) { void removeFromServer(NLMISC::CEventServer& server)
{
server.removeListener(NLMISC::EventMouseMoveId, this); server.removeListener(NLMISC::EventMouseMoveId, this);
server.removeListener(NLMISC::EventMouseDownId, this); server.removeListener(NLMISC::EventMouseDownId, this);
server.removeListener(NLMISC::EventMouseUpId, this); server.removeListener(NLMISC::EventMouseUpId, this);
@ -226,9 +232,11 @@ namespace CEGUI
* *
* \param event An event, probably a CEventMouse or CEventKey/Char. * \param event An event, probably a CEventMouse or CEventKey/Char.
*/ */
virtual void operator ()(const NLMISC::CEvent& event) { virtual void operator ()(const NLMISC::CEvent& event)
{
// don't process any input if we're inactive. // don't process any input if we're inactive.
if(m_Active==false) { if(m_Active==false)
{
return; // not processing ANY input return; // not processing ANY input
} }
@ -236,36 +244,51 @@ namespace CEGUI
{ {
// otherwise, on with the festivities. // otherwise, on with the festivities.
// catch ALL mouse event, just in case. // catch ALL mouse event, just in case.
if(event==NLMISC::EventMouseDownId||event==NLMISC::EventMouseUpId||event==NLMISC::EventMouseMoveId||event==NLMISC::EventMouseDblClkId||event==NLMISC::EventMouseWheelId) { if(event==NLMISC::EventMouseDownId||event==NLMISC::EventMouseUpId||event==NLMISC::EventMouseMoveId||event==NLMISC::EventMouseDblClkId||event==NLMISC::EventMouseWheelId)
if(!m_MouseActive) { {
if(!m_MouseActive)
{
// we're not processing any mouse activity. The cursor isn't captured maybe? // we're not processing any mouse activity. The cursor isn't captured maybe?
return; return;
} }
NLMISC::CEventMouse *mouseEvent=(NLMISC::CEventMouse *)&event; NLMISC::CEventMouse *mouseEvent=(NLMISC::CEventMouse *)&event;
// a mouse button was pressed. // a mouse button was pressed.
if(event == NLMISC::EventMouseDownId) { if(event == NLMISC::EventMouseDownId)
{
// it was the left button... // it was the left button...
if (mouseEvent->Button & NLMISC::leftButton) { if (mouseEvent->Button & NLMISC::leftButton)
{
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton); CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
// it was the right button... // it was the right button...
} else if (mouseEvent->Button & NLMISC::rightButton) { }
else if (mouseEvent->Button & NLMISC::rightButton)
{
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton); CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton);
} else if (mouseEvent->Button & NLMISC::middleButton) { }
else if (mouseEvent->Button & NLMISC::middleButton)
{
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton); CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::MiddleButton);
} }
// a mouse button was released // a mouse button was released
} else if (event == NLMISC::EventMouseUpId) { }
else if (event == NLMISC::EventMouseUpId)
{
// it was the left button... // it was the left button...
if(mouseEvent->Button & NLMISC::leftButton) { if(mouseEvent->Button & NLMISC::leftButton)
{
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton); CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
// it was the right button... // it was the right button...
} else if (mouseEvent->Button & NLMISC::rightButton) { }
else if (mouseEvent->Button & NLMISC::rightButton)
{
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton); CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton);
} else if (mouseEvent->Button & NLMISC::middleButton) { } else if (mouseEvent->Button & NLMISC::middleButton) {
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton); CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::MiddleButton);
} }
} else if (event == NLMISC::EventMouseMoveId) { }
else if (event == NLMISC::EventMouseMoveId)
{
// convert into screen coordinates. // convert into screen coordinates.
float delta_x=(float)(mouseEvent->X - m_MouseX)*m_Width; float delta_x=(float)(mouseEvent->X - m_MouseX)*m_Width;
float delta_y=(float)((1.0f-mouseEvent->Y) - m_MouseY)*m_Height; float delta_y=(float)((1.0f-mouseEvent->Y) - m_MouseY)*m_Height;
@ -276,18 +299,26 @@ namespace CEGUI
// and save for delta. // and save for delta.
m_MouseX=mouseEvent->X; m_MouseX=mouseEvent->X;
m_MouseY=1.0f-mouseEvent->Y; m_MouseY=1.0f-mouseEvent->Y;
} else if (event == NLMISC::EventMouseWheelId) { }
else if (event == NLMISC::EventMouseWheelId)
{
NLMISC::CEventMouseWheel *ev=(NLMISC::CEventMouseWheel *)&event; NLMISC::CEventMouseWheel *ev=(NLMISC::CEventMouseWheel *)&event;
float dir=0.0f; float dir=0.0f;
if(ev->Direction) dir=0.5f; if(ev->Direction) dir=0.5f;
else dir=-0.5f; else dir=-0.5f;
CEGUI::System::getSingleton().injectMouseWheelChange(dir); CEGUI::System::getSingleton().injectMouseWheelChange(dir);
} }
} else { // assume otherwise that it's a character. }
if(event==NLMISC::EventCharId) { else
{
// assume otherwise that it's a character.
if(event==NLMISC::EventCharId)
{
unsigned char c = (char)((NLMISC::CEventChar&)event).Char; unsigned char c = (char)((NLMISC::CEventChar&)event).Char;
CEGUI::System::getSingleton().injectChar((CEGUI::utf32)c); CEGUI::System::getSingleton().injectChar((CEGUI::utf32)c);
} else if(event==NLMISC::EventKeyDownId) { }
else if(event==NLMISC::EventKeyDownId)
{
NLMISC::CEventKeyDown *keyvent=(NLMISC::CEventKeyDown *)&event; NLMISC::CEventKeyDown *keyvent=(NLMISC::CEventKeyDown *)&event;
CEGUI::System::getSingleton().injectKeyDown(m_KeyMap[keyvent->Key]); CEGUI::System::getSingleton().injectKeyDown(m_KeyMap[keyvent->Key]);
} }
@ -296,7 +327,8 @@ namespace CEGUI
catch (CEGUI::Exception) { } catch (CEGUI::Exception) { }
} }
void initKeyMap() { void initKeyMap()
{
m_KeyMap[NLMISC::Key0 ]=CEGUI::Key::Zero; m_KeyMap[NLMISC::Key0 ]=CEGUI::Key::Zero;
m_KeyMap[NLMISC::Key1 ]=CEGUI::Key::One; m_KeyMap[NLMISC::Key1 ]=CEGUI::Key::One;
m_KeyMap[NLMISC::Key2 ]=CEGUI::Key::Two; m_KeyMap[NLMISC::Key2 ]=CEGUI::Key::Two;

View file

@ -201,7 +201,7 @@ void loadForm (const std::vector<std::string> &sheetFilters, const std::string &
ifile.serialCont (container); ifile.serialCont (container);
ifile.close (); ifile.close ();
} }
catch (NLMISC::Exception &e) catch (const NLMISC::Exception &e)
{ {
// clear the container because it can contains partially loaded sheet so we must clean it before continue // clear the container because it can contains partially loaded sheet so we must clean it before continue
container.clear (); container.clear ();
@ -456,7 +456,7 @@ void loadForm (const std::vector<std::string> &sheetFilters, const std::string &
ofile.close (); ofile.close ();
} }
} }
catch (NLMISC::Exception &e) catch (const NLMISC::Exception &e)
{ {
nlinfo ("loadForm(): Exception during saving the packed file, it will be recreated next launch (%s)", e.what()); nlinfo ("loadForm(): Exception during saving the packed file, it will be recreated next launch (%s)", e.what());
} }
@ -564,7 +564,7 @@ void loadForm2(const std::vector<std::string> &sheetFilters, const std::string &
ifile.serialPtrCont (container); ifile.serialPtrCont (container);
ifile.close (); ifile.close ();
} }
catch (NLMISC::Exception &e) catch (const NLMISC::Exception &e)
{ {
// clear the container because it can contains partially loaded sheet so we must clean it before continue // clear the container because it can contains partially loaded sheet so we must clean it before continue
container.clear (); container.clear ();
@ -819,7 +819,7 @@ void loadForm2(const std::vector<std::string> &sheetFilters, const std::string &
ofile.close (); ofile.close ();
} }
} }
catch (NLMISC::Exception &e) catch (const NLMISC::Exception &e)
{ {
nlinfo ("loadForm(): Exception during saving the packed file, it will be recreated next launch (%s)", e.what()); nlinfo ("loadForm(): Exception during saving the packed file, it will be recreated next launch (%s)", e.what());
} }
@ -925,7 +925,7 @@ void loadForm (const std::vector<std::string> &sheetFilters, const std::string &
ifile.serialCont (container); ifile.serialCont (container);
ifile.close (); ifile.close ();
} }
catch (NLMISC::Exception &e) catch (const NLMISC::Exception &e)
{ {
// clear the container because it can contains partially loaded sheet so we must clean it before continue // clear the container because it can contains partially loaded sheet so we must clean it before continue
container.clear (); container.clear ();
@ -1183,7 +1183,7 @@ void loadForm (const std::vector<std::string> &sheetFilters, const std::string &
ofile.close (); ofile.close ();
} }
} }
catch (NLMISC::Exception &e) catch (const NLMISC::Exception &e)
{ {
nlinfo ("loadForm(): Exception during saving the packed file, it will be recreated next launch (%s)", e.what()); nlinfo ("loadForm(): Exception during saving the packed file, it will be recreated next launch (%s)", e.what());
} }

View file

@ -261,7 +261,7 @@ inline bool loadXmlPrimitiveFile(CPrimitives &primDoc, const std::string &fileNa
// Read it // Read it
return primDoc.read (xmlIn.getRootNode (), NLMISC::CFile::getFilename(fileName).c_str(), ligoConfig); return primDoc.read (xmlIn.getRootNode (), NLMISC::CFile::getFilename(fileName).c_str(), ligoConfig);
} }
catch(NLMISC::Exception e) catch(const NLMISC::Exception &e)
{ {
nlwarning("Error reading input file '%s': '%s'", fileName.c_str(), e.what()); nlwarning("Error reading input file '%s': '%s'", fileName.c_str(), e.what());
return false; return false;
@ -294,7 +294,7 @@ inline bool saveXmlPrimitiveFile(CPrimitives &primDoc, const std::string &fileNa
// return xmlSaveFile(fileName.c_str(), xmlDoc) != -1; // return xmlSaveFile(fileName.c_str(), xmlDoc) != -1;
} }
catch(NLMISC::Exception e) catch(const NLMISC::Exception &e)
{ {
nlwarning("Error writing output file '%s': '%s'", fileName.c_str(), e.what()); nlwarning("Error writing output file '%s': '%s'", fileName.c_str(), e.what());
return false; return false;

View file

@ -63,7 +63,7 @@ namespace NLMISC
* printf ("%d ", bar.asInt (i)); * printf ("%d ", bar.asInt (i));
* printf("\n"); * printf("\n");
* } * }
* catch (EConfigFile &e) * catch (const EConfigFile &e)
* { * {
* // Something goes wrong... catch that * // Something goes wrong... catch that
* printf ("%s\n", e.what ()); * printf ("%s\n", e.what ());

View file

@ -169,7 +169,7 @@ void setCrashAlreadyReported(bool state);
*\endcode *\endcode
*/ */
#ifdef NL_NO_DEBUG #ifdef NL_NO_DEBUG
# if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# define nldebug __noop # define nldebug __noop
# else # else
# define nldebug 0&& # define nldebug 0&&
@ -184,7 +184,7 @@ void setCrashAlreadyReported(bool state);
* Same as nldebug but it will be display in debug and in release mode. * Same as nldebug but it will be display in debug and in release mode.
*/ */
#ifdef NL_NO_DEBUG #ifdef NL_NO_DEBUG
# if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# define nlinfo __noop # define nlinfo __noop
# else # else
# define nlinfo 0&& # define nlinfo 0&&
@ -212,7 +212,7 @@ void setCrashAlreadyReported(bool state);
*/ */
#ifdef NL_NO_DEBUG #ifdef NL_NO_DEBUG
# if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# define nlwarning __noop # define nlwarning __noop
# else # else
# define nlwarning 0&& # define nlwarning 0&&
@ -583,7 +583,11 @@ template<class T, class U> inline T type_cast(U o)
/** Compile time assertion /** Compile time assertion
*/ */
#define nlctassert(cond) sizeof(uint[(cond) ? 1 : 0]) #ifdef NL_ISO_CPP0X_AVAILABLE
# define nlctassert(cond) static_assert(cond, "Compile time assert in "#cond)
#else
# define nlctassert(cond) sizeof(uint[(cond) ? 1 : 0])
#endif
/** /**
* Allow to verify an object was accessed before its destructor call. * Allow to verify an object was accessed before its destructor call.

View file

@ -238,11 +238,11 @@ namespace STRING_MANAGER
return false; return false;
} }
bool findCol(ucstring colName, uint &colIndex) bool findCol(const ucstring &colName, uint &colIndex)
{ {
if (Data.empty()) if (Data.empty())
return false; return false;
TWorksheet::TRow::iterator it = std::find(Data[0].begin(), Data[0].end(), ucstring(colName)); TWorksheet::TRow::iterator it = std::find(Data[0].begin(), Data[0].end(), colName);
if (it == Data[0].end()) if (it == Data[0].end())
return false; return false;

View file

@ -71,7 +71,7 @@ struct EXmlParsingError : public EStream
// File not found // File not found
} }
} }
catch (Exception &e) catch (const Exception &e)
{ {
// Something wrong appends // Something wrong appends
} }

View file

@ -64,7 +64,7 @@ namespace NLMISC {
// Close the file // Close the file
file.close (); file.close ();
} }
catch (Exception &e) catch (const Exception &e)
{ {
} }
\endcode \endcode

View file

@ -105,4 +105,7 @@ CHashKey getSHA1(const std::string &filename, bool forcePath = false);
// This function get a buffer with size and returns his SHA hash key // This function get a buffer with size and returns his SHA hash key
CHashKey getSHA1(const uint8 *buffer, uint32 size); CHashKey getSHA1(const uint8 *buffer, uint32 size);
// This function get a buffer and key with size and returns his HMAC-SHA1 hash key
CHashKey getHMacSHA1(const uint8 *text, uint32 text_len, const uint8 *key, uint32 key_len);
#endif // NL_SHA1_H #endif // NL_SHA1_H

View file

@ -352,7 +352,7 @@ public:
} }
}; };
#if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) #if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
// This operator only purpose is to compare with NULL value // This operator only purpose is to compare with NULL value
template <class T> template <class T>

View file

@ -945,10 +945,13 @@ inline CSString operator+(const char* s0,const CSString& s1)
return CSString(s0)+s1; return CSString(s0)+s1;
} }
#ifndef NL_COMP_VC10
// TODO: check if it can be disabled for other compilers too
inline CSString operator+(const std::string& s0,const CSString& s1) inline CSString operator+(const std::string& s0,const CSString& s1)
{ {
return s0+static_cast<const std::string&>(s1); return s0+static_cast<const std::string&>(s1);
} }
#endif // NL_COMP_VC10
} // NLMISC } // NLMISC

View file

@ -51,14 +51,10 @@
# ifndef _WIN32_WINNT # ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0500 // Minimal OS = Windows 2000 (NeL is not supported on Windows 95/98) # define _WIN32_WINNT 0x0500 // Minimal OS = Windows 2000 (NeL is not supported on Windows 95/98)
# endif # endif
# if _MSC_VER >= 1500 # if _MSC_VER >= 1600
# define NL_COMP_VC10
# elif _MSC_VER >= 1500
# define NL_COMP_VC9 # define NL_COMP_VC9
# ifndef _STLPORT_VERSION // STLport doesn't depend on MS STL features
# if defined(_HAS_TR1) && (_HAS_TR1 + 0) // VC9 TR1 feature pack
# define NL_ISO_STDTR1_AVAILABLE
# define NL_ISO_STDTR1_HEADER(header) <header>
# endif
# endif
# elif _MSC_VER >= 1400 # elif _MSC_VER >= 1400
# define NL_COMP_VC8 # define NL_COMP_VC8
# undef nl_time # undef nl_time
@ -79,6 +75,10 @@
# define NL_COMP_VC6 # define NL_COMP_VC6
# define NL_COMP_NEED_PARAM_ON_METHOD # define NL_COMP_NEED_PARAM_ON_METHOD
# endif # endif
# if defined(_HAS_TR1) && (_HAS_TR1 + 0) // VC9 TR1 feature pack or later
# define NL_ISO_STDTR1_AVAILABLE
# define NL_ISO_STDTR1_HEADER(header) <header>
# endif
# ifdef _DEBUG # ifdef _DEBUG
# define NL_DEBUG # define NL_DEBUG
# elif defined (NDEBUG) # elif defined (NDEBUG)
@ -117,6 +117,10 @@
# define NL_COMP_GCC # define NL_COMP_GCC
#endif #endif
#if defined(_HAS_CPP0X) || defined(__GXX_EXPERIMENTAL_CXX0X__)
# define NL_ISO_CPP0X_AVAILABLE
#endif
// gcc 3.4 introduced ISO C++ with tough template rules // gcc 3.4 introduced ISO C++ with tough template rules
// //
// NL_ISO_SYNTAX can be used using #if NL_ISO_SYNTAX or #if !NL_ISO_SYNTAX // NL_ISO_SYNTAX can be used using #if NL_ISO_SYNTAX or #if !NL_ISO_SYNTAX
@ -149,7 +153,7 @@
# pragma warning (disable : 4390) // don't warn in empty block "if(exp) ;" # pragma warning (disable : 4390) // don't warn in empty block "if(exp) ;"
# pragma warning (disable : 4996) // 'vsnprintf': This function or variable may be unsafe. Consider using vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. # pragma warning (disable : 4996) // 'vsnprintf': This function or variable may be unsafe. Consider using vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
// Debug : Sept 01 2006 // Debug : Sept 01 2006
# if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# pragma warning (disable : 4005) // don't warn on redefinitions caused by xp platform sdk # pragma warning (disable : 4005) // don't warn on redefinitions caused by xp platform sdk
# endif // NL_COMP_VC8 || NL_COMP_VC9 # endif // NL_COMP_VC8 || NL_COMP_VC9
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
@ -287,20 +291,18 @@ typedef unsigned int uint; // at least 32bits (depend of processor)
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#include <inttypes.h> #include <inttypes.h>
#ifdef NL_OS_MAC #if defined(__PRI_64_LENGTH_MODIFIER__)
#define NL_I64 __PRI_64_LENGTH_MODIFIER__ # define NL_I64 __PRI_64_LENGTH_MODIFIER__
#elif defined(__PRI64_PREFIX)
# define NL_I64 __PRI64_PREFIX
#else #else
#define NL_I64 __PRI64_PREFIX # ifdef _LP64
# define NL_I64 "l"
# else
# define NL_I64 "ll"
# endif // _LP64
#endif #endif
/*
#ifdef _LP64
# define NL_I64 "l"
#else
# define NL_I64 "ll"
#endif // _LP64
*/
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
// CHashMap, CHashSet and CHashMultiMap definitions // CHashMap, CHashSet and CHashMultiMap definitions
@ -364,7 +366,7 @@ typedef uint16 ucchar;
// To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234) // To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) # if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# define INT64_CONSTANT(c) (c##LL) # define INT64_CONSTANT(c) (c##LL)
# define SINT64_CONSTANT(c) (c##LL) # define SINT64_CONSTANT(c) (c##LL)
# define UINT64_CONSTANT(c) (c##LL) # define UINT64_CONSTANT(c) (c##LL)

View file

@ -524,7 +524,7 @@ namespace NLNET
// run the module task command control to module task method // run the module task command control to module task method
(_Module->*_TaskMethod)(); (_Module->*_TaskMethod)();
} }
catch (NLMISC::Exception e) catch (const NLMISC::Exception &e)
{ {
nlwarning("In module task '%s', exception '%e' thrown", typeid(this).name(), e.what()); nlwarning("In module task '%s', exception '%e' thrown", typeid(this).name(), e.what());
} }

View file

@ -94,7 +94,7 @@ CInstanceGroup* LoadInstanceGroup(const char* sFilename)
newIG->serial (file); newIG->serial (file);
// All is good // All is good
} }
catch (Exception &) catch (const Exception &)
{ {
// Cannot save the file // Cannot save the file
delete newIG; delete newIG;

View file

@ -42,7 +42,6 @@ using namespace std;
using namespace NL3D; using namespace NL3D;
using namespace NLMISC; using namespace NLMISC;
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
int WINAPI WinMain( HINSTANCE hInstance, int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,

View file

@ -116,7 +116,7 @@ int main (int /* argc */, char ** /* argv */)
int val = cf.getVar ("unknown_variable").asInt(); int val = cf.getVar ("unknown_variable").asInt();
nlinfo("unknown_variable = %d", val); nlinfo("unknown_variable = %d", val);
} }
catch (EConfigFile &e) catch (const EConfigFile &e)
{ {
nlinfo("something goes wrong with configfile: %s", e.what()); nlinfo("something goes wrong with configfile: %s", e.what());
} }

View file

@ -63,7 +63,7 @@ int main (int /* argc */, char ** /* argv */)
{ {
nlerror ("nlerror() %d", 4); nlerror ("nlerror() %d", 4);
} }
catch(EFatalError &) catch(const EFatalError &)
{ {
// just continue... // just continue...
nlinfo ("nlerror() generated an EFatalError exception, just ignore it"); nlinfo ("nlerror() generated an EFatalError exception, just ignore it");

View file

@ -109,7 +109,7 @@ int main (int argc, char **argv)
CInetAddress addr(LSHost+":3333"); CInetAddress addr(LSHost+":3333");
Client->connect(addr); Client->connect(addr);
} }
catch(ESocket &e) catch(const ESocket &e)
{ {
printf("%s\n", e.what()); printf("%s\n", e.what());
return 0; return 0;

View file

@ -101,7 +101,7 @@ public:
{ {
fsPort = IService::ConfigFile.getVar("FSPort").asInt(); fsPort = IService::ConfigFile.getVar("FSPort").asInt();
} }
catch ( EUnknownVar& ) catch (const EUnknownVar&)
{ {
} }
_FServer.init(fsPort); _FServer.init(fsPort);
@ -148,7 +148,7 @@ public:
{ {
fesPort = IService5::ConfigFile.getVar("FESPort").asInt(); fesPort = IService5::ConfigFile.getVar("FESPort").asInt();
} }
catch ( EUnknownVar& ) catch (const EUnknownVar&)
{ {
} }

View file

@ -190,7 +190,7 @@ void cbInit (CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
return; return;
} }
} }
catch (Exception &) catch (const Exception &)
{ {
// bad client version, disconnect it // bad client version, disconnect it
CallbackServer->disconnect (from); CallbackServer->disconnect (from);
@ -530,7 +530,7 @@ void handleReceivedPong (CClient *client, sint64 pongTime)
// init the UDP connection // init the UDP connection
if (client == NULL) if (client == NULL)
{ {
uint32 session; uint32 session = 0;
msgin.serial (session); msgin.serial (session);
// Find a new udp connection, find the linked // Find a new udp connection, find the linked
@ -568,13 +568,13 @@ void handleReceivedPong (CClient *client, sint64 pongTime)
} }
// Read the message // Read the message
sint64 pingTime; sint64 pingTime = 0;
msgin.serial(pingTime); msgin.serial(pingTime);
uint32 pongNumber; uint32 pongNumber = 0;
msgin.serial(pongNumber); msgin.serial(pongNumber);
uint32 blockNumber; uint32 blockNumber = 0;
msgin.serial(blockNumber); msgin.serial(blockNumber);
// nlinfo ("receive a pong from %s pongnb %d %"NL_I64"d", CurrentInMsg->AddrFrom.asString().c_str(), pongNumber, pongTime - pingTime); // nlinfo ("receive a pong from %s pongnb %d %"NL_I64"d", CurrentInMsg->AddrFrom.asString().c_str(), pongNumber, pongTime - pingTime);
@ -611,7 +611,7 @@ void sendPing ()
// send the new ping to the client // send the new ping to the client
ReceiveTask->DataSock->sendTo (msgout.buffer(), size, GETCLIENTA(it)->Address); ReceiveTask->DataSock->sendTo (msgout.buffer(), size, GETCLIENTA(it)->Address);
} }
catch (Exception &e) catch (const Exception &e)
{ {
nlwarning ("Can't send UDP packet to '%s' (%s)", GETCLIENTA(it)->Address.asString().c_str(), e.what()); nlwarning ("Can't send UDP packet to '%s' (%s)", GETCLIENTA(it)->Address.asString().c_str(), e.what());
} }
@ -734,7 +734,7 @@ public:
updateStat (); updateStat ();
} }
} }
catch (Exception &e) catch (const Exception &e)
{ {
nlerrornoex ("Exception not catched: '%s'", e.what()); nlerrornoex ("Exception not catched: '%s'", e.what());
} }

View file

@ -232,7 +232,7 @@ void cbInit (CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
{ {
UdpSock->connect( CInetAddress (ServerAddr, UDPPort) ); UdpSock->connect( CInetAddress (ServerAddr, UDPPort) );
} }
catch ( Exception& e ) catch (const Exception &e)
{ {
InfoLog->displayRawNL ("Cannot connect to remote UDP host '%s': %s", ServerAddr.c_str(), e.what() ); InfoLog->displayRawNL ("Cannot connect to remote UDP host '%s': %s", ServerAddr.c_str(), e.what() );
exit (""); exit ("");
@ -291,7 +291,7 @@ int main( int argc, char **argv )
InfoLog->displayRawNL ("Waiting the server answer..."); InfoLog->displayRawNL ("Waiting the server answer...");
} }
catch(Exception &e) catch(const Exception &e)
{ {
InfoLog->displayRawNL ("Can't connect to %s:%d (%s)\n", ServerAddr.c_str(), TCPPort, e.what()); InfoLog->displayRawNL ("Can't connect to %s:%d (%s)\n", ServerAddr.c_str(), TCPPort, e.what());
exit (""); exit ("");

View file

@ -108,7 +108,7 @@ void CReceiveTask::run()
DataSock->receivedFrom( _ReceivedMessage.userDataW(), _DatagramLength, _ReceivedMessage.AddrFrom ); DataSock->receivedFrom( _ReceivedMessage.userDataW(), _DatagramLength, _ReceivedMessage.AddrFrom );
d = CTime::getLocalTime (); d = CTime::getLocalTime ();
} }
catch ( ESocket& ) catch (const ESocket&)
{ {
// Remove the client corresponding to the address // Remove the client corresponding to the address
_ReceivedMessage.setTypeEvent( TReceivedMessage::RemoveClient ); _ReceivedMessage.setTypeEvent( TReceivedMessage::RemoveClient );

View file

@ -371,7 +371,7 @@ int main ()
// Remove mouse listener // Remove mouse listener
pDriver->delete3dMouseListener (plistener); pDriver->delete3dMouseListener (plistener);
} }
catch (Exception& e) catch (const Exception& e)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
::MessageBox (NULL, e.what(), "Test collision move", MB_OK|MB_ICONEXCLAMATION); ::MessageBox (NULL, e.what(), "Test collision move", MB_OK|MB_ICONEXCLAMATION);

View file

@ -85,7 +85,7 @@ void Init()
AudioMixer->getListener()->setOrientation( frontvec, upvec ); AudioMixer->getListener()->setOrientation( frontvec, upvec );
} }
catch( Exception& e ) catch(const Exception &e)
{ {
nlerror( "Error: %s", e.what() ); nlerror( "Error: %s", e.what() );
} }

View file

@ -706,6 +706,9 @@ IF(WITH_PCH)
ENDIF(WITH_PCH) ENDIF(WITH_PCH)
NL_GEN_PC(nel-3d.pc) NL_GEN_PC(nel-3d.pc)
INSTALL(TARGETS nel3d LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
INSTALL(TARGETS nel3d LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
ADD_SUBDIRECTORY(driver) ADD_SUBDIRECTORY(driver)

View file

@ -227,7 +227,7 @@ bool CAnimationSet::loadFromFiles(const std::string &path, bool recurse /* = tru
iFile.close(); iFile.close();
} }
catch (NLMISC::EStream &e) catch (const NLMISC::EStream &e)
{ {
if (wantWarningMessage) if (wantWarningMessage)
{ {

View file

@ -338,7 +338,7 @@ void CAsyncFileManager3D::CMeshLoad::run()
// Finally affect the pointer (Trans-Thread operation -> this operation must be atomic) // Finally affect the pointer (Trans-Thread operation -> this operation must be atomic)
*_ppShp = mesh.getShapePointer(); *_ppShp = mesh.getShapePointer();
} }
catch(EPathNotFound &) catch(const EPathNotFound &)
{ {
nlwarning ("Couldn't load '%s'", MeshName.c_str()); nlwarning ("Couldn't load '%s'", MeshName.c_str());
*_ppShp = (IShape*)-1; *_ppShp = (IShape*)-1;
@ -382,7 +382,7 @@ void CAsyncFileManager3D::CIGLoad::run (void)
*_ppIG = pIG; *_ppIG = pIG;
} }
catch(EPathNotFound &) catch(const EPathNotFound &)
{ {
nlwarning ("Couldn't load '%s'", _IGName.c_str()); nlwarning ("Couldn't load '%s'", _IGName.c_str());
*_ppIG = (CInstanceGroup*)-1; *_ppIG = (CInstanceGroup*)-1;
@ -429,7 +429,7 @@ void CAsyncFileManager3D::CIGLoadUser::run (void)
return; return;
} }
} }
catch(EPathNotFound &) catch(const EPathNotFound &)
{ {
nlwarning ("Couldn't load '%s'", _IGName.c_str()); nlwarning ("Couldn't load '%s'", _IGName.c_str());
delete pIG; delete pIG;

View file

@ -16,7 +16,9 @@ IF(WITH_PCH)
ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_direct3d_win ${CMAKE_CURRENT_SOURCE_DIR}/stddirect3d.h ${CMAKE_CURRENT_SOURCE_DIR}/stddirect3d.cpp) ADD_NATIVE_PRECOMPILED_HEADER(nel_drv_direct3d_win ${CMAKE_CURRENT_SOURCE_DIR}/stddirect3d.h ${CMAKE_CURRENT_SOURCE_DIR}/stddirect3d.cpp)
ENDIF(WITH_PCH) ENDIF(WITH_PCH)
INSTALL(TARGETS nel_drv_direct3d_win LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib RUNTIME DESTINATION bin COMPONENT drivers3d) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC_DRIVERS) OR NOT WITH_STATIC_DRIVERS)
IF(WITH_MAXPLUGIN) INSTALL(TARGETS nel_drv_direct3d_win LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib RUNTIME DESTINATION bin COMPONENT drivers3d)
INSTALL(TARGETS nel_drv_direct3d_win RUNTIME DESTINATION maxplugin COMPONENT drivers3d) IF(WITH_MAXPLUGIN)
ENDIF(WITH_MAXPLUGIN) INSTALL(TARGETS nel_drv_direct3d_win RUNTIME DESTINATION maxplugin COMPONENT drivers3d)
ENDIF(WITH_MAXPLUGIN)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC_DRIVERS) OR NOT WITH_STATIC_DRIVERS)

View file

@ -1600,7 +1600,7 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r
_EventEmitter.addEmitter(diee, true); _EventEmitter.addEmitter(diee, true);
} }
} }
catch(EDirectInput &e) catch(const EDirectInput &e)
{ {
nlinfo(e.what()); nlinfo(e.what());
} }

View file

@ -485,7 +485,7 @@ NLMISC::IMouseDevice* CDriverD3D::enableLowLevelMouse(bool enable, bool exclusiv
if (diee) if (diee)
res = diee->getMouseDevice(exclusive); res = diee->getMouseDevice(exclusive);
} }
catch (EDirectInput &) catch (const EDirectInput &)
{ {
} }
} }
@ -517,7 +517,7 @@ NLMISC::IKeyboardDevice* CDriverD3D::enableLowLevelKeyboard(bool enable)
if (diee) if (diee)
res = diee->getKeyboardDevice(); res = diee->getKeyboardDevice();
} }
catch (EDirectInput &) catch (const EDirectInput &)
{ {
} }
} }
@ -561,7 +561,7 @@ uint CDriverD3D::getDoubleClickDelay(bool hardwareMouse)
{ {
md = diee->getMouseDevice(hardwareMouse); md = diee->getMouseDevice(hardwareMouse);
} }
catch (EDirectInput &) catch (const EDirectInput &)
{ {
// could not get device .. // could not get device ..
} }

View file

@ -318,7 +318,7 @@ bool CDriverD3D::setupMaterial(CMaterial &mat)
if (!mat._MatDrvInfo) if (!mat._MatDrvInfo)
{ {
// Insert into driver list. (so it is deleted when driver is deleted). // Insert into driver list. (so it is deleted when driver is deleted).
ItMatDrvInfoPtrList it= _MatDrvInfos.insert(_MatDrvInfos.end(), NULL); ItMatDrvInfoPtrList it= _MatDrvInfos.insert(_MatDrvInfos.end(), (NL3D::IMaterialDrvInfos*)NULL);
*it = mat._MatDrvInfo = new CMaterialDrvInfosD3D(this, it); *it = mat._MatDrvInfo = new CMaterialDrvInfosD3D(this, it);

View file

@ -347,7 +347,7 @@ bool CDriverD3D::activeShader(CShader *shd)
if ( !shd->_DrvInfo ) if ( !shd->_DrvInfo )
{ {
// insert into driver list. (so it is deleted when driver is deleted). // insert into driver list. (so it is deleted when driver is deleted).
ItShaderDrvInfoPtrList it= _ShaderDrvInfos.insert(_ShaderDrvInfos.end(), NULL); ItShaderDrvInfoPtrList it= _ShaderDrvInfos.insert(_ShaderDrvInfos.end(), (NL3D::IShaderDrvInfos*)NULL);
// create and set iterator, for future deletion. // create and set iterator, for future deletion.
shaderInfo = new CShaderDrvInfosD3D(this, it); shaderInfo = new CShaderDrvInfosD3D(this, it);
*it= shd->_DrvInfo = shaderInfo; *it= shd->_DrvInfo = shaderInfo;

View file

@ -514,7 +514,7 @@ bool CDriverD3D::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded
if ( !tex.TextureDrvShare ) if ( !tex.TextureDrvShare )
{ {
// insert into driver list. (so it is deleted when driver is deleted). // insert into driver list. (so it is deleted when driver is deleted).
ItTexDrvSharePtrList it= _TexDrvShares.insert(_TexDrvShares.end(), NULL); ItTexDrvSharePtrList it= _TexDrvShares.insert(_TexDrvShares.end(), (NL3D::CTextureDrvShare*)NULL);
// create and set iterator, for future deletion. // create and set iterator, for future deletion.
*it= tex.TextureDrvShare= new CTextureDrvShare(this, it, &tex); *it= tex.TextureDrvShare= new CTextureDrvShare(this, it, &tex);

View file

@ -1,4 +1,5 @@
FILE(GLOB SRC *.cpp *.h *.def) FILE(GLOB SRC *.cpp *.h *.def)
IF(APPLE) IF(APPLE)
FILE(GLOB MAC_SRC mac/*.h mac/*.m mac/*.mm mac/*.cpp) FILE(GLOB MAC_SRC mac/*.h mac/*.m mac/*.mm mac/*.cpp)
SET(SRC ${SRC} ${MAC_SRC}) SET(SRC ${SRC} ${MAC_SRC})
@ -60,7 +61,9 @@ IF(NOT APPLE AND WITH_PCH)
ADD_NATIVE_PRECOMPILED_HEADER(${NLDRV_OGL_LIB} ${CMAKE_CURRENT_SOURCE_DIR}/stdopengl.h ${CMAKE_CURRENT_SOURCE_DIR}/stdopengl.cpp) ADD_NATIVE_PRECOMPILED_HEADER(${NLDRV_OGL_LIB} ${CMAKE_CURRENT_SOURCE_DIR}/stdopengl.h ${CMAKE_CURRENT_SOURCE_DIR}/stdopengl.cpp)
ENDIF(NOT APPLE AND WITH_PCH) ENDIF(NOT APPLE AND WITH_PCH)
INSTALL(TARGETS ${NLDRV_OGL_LIB} LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib RUNTIME DESTINATION bin COMPONENT drivers3d) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC_DRIVERS) OR NOT WITH_STATIC_DRIVERS)
IF(WITH_MAXPLUGIN) INSTALL(TARGETS ${NLDRV_OGL_LIB} LIBRARY DESTINATION ${NL_DRIVER_PREFIX} ARCHIVE DESTINATION lib RUNTIME DESTINATION bin COMPONENT drivers3d)
INSTALL(TARGETS ${NLDRV_OGL_LIB} RUNTIME DESTINATION maxplugin COMPONENT drivers3d) IF(WITH_MAXPLUGIN)
ENDIF(WITH_MAXPLUGIN) INSTALL(TARGETS ${NLDRV_OGL_LIB} RUNTIME DESTINATION maxplugin COMPONENT drivers3d)
ENDIF(WITH_MAXPLUGIN)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC_DRIVERS) OR NOT WITH_STATIC_DRIVERS)

View file

@ -2508,8 +2508,13 @@ void CDriverGL::checkTextureOn() const
GLboolean flagCM; GLboolean flagCM;
GLboolean flagTR; GLboolean flagTR;
glGetBooleanv(GL_TEXTURE_2D, &flag2D); glGetBooleanv(GL_TEXTURE_2D, &flag2D);
#ifdef USE_OPENGLES
glGetBooleanv(GL_TEXTURE_CUBE_MAP_OES, &flagCM);
flagTR = true; // always true in OpenGL ES
#else
glGetBooleanv(GL_TEXTURE_CUBE_MAP_ARB, &flagCM); glGetBooleanv(GL_TEXTURE_CUBE_MAP_ARB, &flagCM);
glGetBooleanv(GL_TEXTURE_RECTANGLE_NV, &flagTR); glGetBooleanv(GL_TEXTURE_RECTANGLE_NV, &flagTR);
#endif
switch(dgs.getTextureMode()) switch(dgs.getTextureMode())
{ {
case CDriverGLStates::TextureDisabled: case CDriverGLStates::TextureDisabled:
@ -2545,7 +2550,8 @@ bool CDriverGL::supportOcclusionQuery() const
// *************************************************************************** // ***************************************************************************
bool CDriverGL::supportTextureRectangle() const bool CDriverGL::supportTextureRectangle() const
{ {
H_AUTO_OGL(CDriverGL_supportTextureRectangle) H_AUTO_OGL(CDriverGL_supportTextureRectangle);
return (_Extensions.NVTextureRectangle || _Extensions.EXTTextureRectangle || _Extensions.ARBTextureRectangle); return (_Extensions.NVTextureRectangle || _Extensions.EXTTextureRectangle || _Extensions.ARBTextureRectangle);
} }

View file

@ -20,22 +20,67 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#ifdef NL_OS_MAC #ifdef USE_OPENGLES
# define GL_GLEXT_LEGACY # include <GLES/gl.h>
# include <OpenGL/gl.h> # include <GLES/glext.h>
# include "mac/glext.h"
#else #else
# include <GL/gl.h> # ifdef NL_OS_MAC
# include <GL/glext.h> // Please download it from http://www.opengl.org/registry/ # define GL_GLEXT_LEGACY
# if defined(NL_OS_WINDOWS) # include <OpenGL/gl.h>
# include <GL/wglext.h> # include "mac/glext.h"
# endif # else
# include <GL/gl.h>
# include <GL/glext.h>
# if defined(NL_OS_WINDOWS)
# include <GL/wglext.h>
# endif
# endif
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef USE_OPENGLES
// OES_mapbuffer
//==============
typedef void* (APIENTRY * NEL_PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
typedef GLboolean (APIENTRY * NEL_PFNGLUNMAPBUFFEROESPROC) (GLenum target);
typedef void (APIENTRY * NEL_PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void** params);
typedef void (APIENTRY * NEL_PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
// GL_OES_framebuffer_object
//==================================
typedef GLboolean (APIENTRY * NEL_PFNGLISRENDERBUFFEROESPROC) (GLuint renderbuffer);
typedef void (APIENTRY * NEL_PFNGLBINDRENDERBUFFEROESPROC) (GLenum target, GLuint renderbuffer);
typedef void (APIENTRY * NEL_PFNGLDELETERENDERBUFFERSOESPROC) (GLsizei n, const GLuint* renderbuffers);
typedef void (APIENTRY * NEL_PFNGLGENRENDERBUFFERSOESPROC) (GLsizei n, GLuint* renderbuffers);
typedef void (APIENTRY * NEL_PFNGLRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRY * NEL_PFNGLGETRENDERBUFFERPARAMETERIVOESPROC) (GLenum target, GLenum pname, GLint* params);
typedef GLboolean (APIENTRY * NEL_PFNGLISFRAMEBUFFEROESPROC) (GLuint framebuffer);
typedef void (APIENTRY * NEL_PFNGLBINDFRAMEBUFFEROESPROC) (GLenum target, GLuint framebuffer);
typedef void (APIENTRY * NEL_PFNGLDELETEFRAMEBUFFERSOESPROC) (GLsizei n, const GLuint* framebuffers);
typedef void (APIENTRY * NEL_PFNGLGENFRAMEBUFFERSOESPROC) (GLsizei n, GLuint* framebuffers);
typedef GLenum (APIENTRY * NEL_PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) (GLenum target);
typedef void (APIENTRY * NEL_PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
typedef void (APIENTRY * NEL_PFNGLFRAMEBUFFERTEXTURE2DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (APIENTRY * NEL_PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
typedef void (APIENTRY * NEL_PFNGLGENERATEMIPMAPOESPROC) (GLenum target);
// GL_OES_texture_cube_map
//==================================
typedef void (APIENTRY * NEL_PFNGLTEXGENFOESPROC) (GLenum coord, GLenum pname, GLfloat param);
typedef void (APIENTRY * NEL_PFNGLTEXGENFVOESPROC) (GLenum coord, GLenum pname, const GLfloat *params);
typedef void (APIENTRY * NEL_PFNGLTEXGENIOESPROC) (GLenum coord, GLenum pname, GLint param);
typedef void (APIENTRY * NEL_PFNGLTEXGENIVOESPROC) (GLenum coord, GLenum pname, const GLint *params);
typedef void (APIENTRY * NEL_PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param);
typedef void (APIENTRY * NEL_PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params);
typedef void (APIENTRY * NEL_PFNGLGETTEXGENFVOESPROC) (GLenum coord, GLenum pname, GLfloat *params);
typedef void (APIENTRY * NEL_PFNGLGETTEXGENIVOESPROC) (GLenum coord, GLenum pname, GLint *params);
typedef void (APIENTRY * NEL_PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params);
#endif
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************
// The NEL Functions Typedefs. // The NEL Functions Typedefs.

View file

@ -684,7 +684,7 @@ NLMISC::IMouseDevice* CDriverGL::enableLowLevelMouse(bool enable, bool exclusive
if (diee) if (diee)
res = diee->getMouseDevice(exclusive); res = diee->getMouseDevice(exclusive);
} }
catch (EDirectInput &) catch (const EDirectInput &)
{ {
} }
} }
@ -722,7 +722,7 @@ NLMISC::IKeyboardDevice* CDriverGL::enableLowLevelKeyboard(bool enable)
if (diee) if (diee)
res = diee->getKeyboardDevice(); res = diee->getKeyboardDevice();
} }
catch (EDirectInput &) catch (const EDirectInput &)
{ {
} }
} }
@ -778,7 +778,7 @@ uint CDriverGL::getDoubleClickDelay(bool hardwareMouse)
{ {
md = diee->getMouseDevice(hardwareMouse); md = diee->getMouseDevice(hardwareMouse);
} }
catch (EDirectInput &) catch (const EDirectInput &)
{ {
// could not get device .. // could not get device ..
} }

View file

@ -139,8 +139,13 @@ void CDriverGL::setLightInternal(uint8 num, const CLight& light)
else else
{ {
// Deactivate spot properties // Deactivate spot properties
#ifdef USE_OPENGLES
glLightf (lightNum, GL_SPOT_CUTOFF, 180.f);
glLightf (lightNum, GL_SPOT_EXPONENT, 0.f);
#else
glLighti (lightNum, GL_SPOT_CUTOFF, 180); glLighti (lightNum, GL_SPOT_CUTOFF, 180);
glLighti (lightNum, GL_SPOT_EXPONENT, 0); glLighti (lightNum, GL_SPOT_EXPONENT, 0);
#endif
} }
// Flag this light as dirt. // Flag this light as dirt.

View file

@ -35,10 +35,18 @@ static void convBlend(CMaterial::TBlend blend, GLenum& glenum)
case CMaterial::srccolor: glenum=GL_SRC_COLOR; break; case CMaterial::srccolor: glenum=GL_SRC_COLOR; break;
case CMaterial::invsrccolor:glenum=GL_ONE_MINUS_SRC_COLOR; break; case CMaterial::invsrccolor:glenum=GL_ONE_MINUS_SRC_COLOR; break;
// Extended Blend modes. // Extended Blend modes.
#ifdef USE_OPENGLES
case CMaterial::blendConstantColor: glenum=GL_CONSTANT_COLOR; break;
case CMaterial::blendConstantInvColor: glenum=GL_ONE_MINUS_CONSTANT_COLOR; break;
case CMaterial::blendConstantAlpha: glenum=GL_CONSTANT_ALPHA; break;
case CMaterial::blendConstantInvAlpha: glenum=GL_ONE_MINUS_CONSTANT_ALPHA; break;
#else
case CMaterial::blendConstantColor: glenum=GL_CONSTANT_COLOR_EXT; break; case CMaterial::blendConstantColor: glenum=GL_CONSTANT_COLOR_EXT; break;
case CMaterial::blendConstantInvColor: glenum=GL_ONE_MINUS_CONSTANT_COLOR_EXT; break; case CMaterial::blendConstantInvColor: glenum=GL_ONE_MINUS_CONSTANT_COLOR_EXT; break;
case CMaterial::blendConstantAlpha: glenum=GL_CONSTANT_ALPHA_EXT; break; case CMaterial::blendConstantAlpha: glenum=GL_CONSTANT_ALPHA_EXT; break;
case CMaterial::blendConstantInvAlpha: glenum=GL_ONE_MINUS_CONSTANT_ALPHA_EXT; break; case CMaterial::blendConstantInvAlpha: glenum=GL_ONE_MINUS_CONSTANT_ALPHA_EXT; break;
#endif
default: nlstop; default: nlstop;
} }
} }
@ -137,7 +145,9 @@ void CDriverGL::setTextureEnvFunction(uint stage, CMaterial& mat)
_DriverGLStates.setTexGenMode (stage, GL_OBJECT_LINEAR); _DriverGLStates.setTexGenMode (stage, GL_OBJECT_LINEAR);
} }
else if(mode==CMaterial::TexCoordGenEyeSpace) else if(mode==CMaterial::TexCoordGenEyeSpace)
{
_DriverGLStates.setTexGenMode (stage, GL_EYE_LINEAR); _DriverGLStates.setTexGenMode (stage, GL_EYE_LINEAR);
}
} }
else else
{ {
@ -240,7 +250,9 @@ void CDriverGL::setTextureShaders(const uint8 *addressingModes, const CSmartPtr<
if (glAddrMode != _CurrentTexAddrMode[stage]) // addressing mode different from the one in the device? if (glAddrMode != _CurrentTexAddrMode[stage]) // addressing mode different from the one in the device?
{ {
_DriverGLStates.activeTextureARB(stage); _DriverGLStates.activeTextureARB(stage);
#ifndef USE_OPENGLES
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, glAddrMode); glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, glAddrMode);
#endif
_CurrentTexAddrMode[stage] = glAddrMode; _CurrentTexAddrMode[stage] = glAddrMode;
} }
} }
@ -264,7 +276,7 @@ bool CDriverGL::setupMaterial(CMaterial& mat)
if (!mat._MatDrvInfo) if (!mat._MatDrvInfo)
{ {
// insert into driver list. (so it is deleted when driver is deleted). // insert into driver list. (so it is deleted when driver is deleted).
ItMatDrvInfoPtrList it= _MatDrvInfos.insert(_MatDrvInfos.end(), NULL); ItMatDrvInfoPtrList it= _MatDrvInfos.insert(_MatDrvInfos.end(), (NL3D::IMaterialDrvInfos*)NULL);
// create and set iterator, for future deletion. // create and set iterator, for future deletion.
*it= mat._MatDrvInfo= new CShaderGL(this, it); *it= mat._MatDrvInfo= new CShaderGL(this, it);
@ -807,7 +819,7 @@ void CDriverGL::setupLightMapPass(uint pass)
// fallBack if extension MulAdd not found. just mul factor with (Ambient+Diffuse) // fallBack if extension MulAdd not found. just mul factor with (Ambient+Diffuse)
if(_LightMapNoMulAddFallBack) if(_LightMapNoMulAddFallBack)
{ {
// do not use consant color to blend lightmap, but incoming diffuse color, for stage0 only. // do not use constant color to blend lightmap, but incoming diffuse color, for stage0 only.
GLfloat glcol[4]; GLfloat glcol[4];
convColor(lmapFactor, glcol); convColor(lmapFactor, glcol);
_DriverGLStates.setEmissive(lmapFactor.getPacked(), glcol); _DriverGLStates.setEmissive(lmapFactor.getPacked(), glcol);
@ -918,7 +930,11 @@ void CDriverGL::setupLightMapPass(uint pass)
if (mat._LightMapsMulx2) if (mat._LightMapsMulx2)
{ {
// Multiply x 2 // Multiply x 2
#ifdef USE_OPENGLES
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, 2);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2); glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2);
#endif
} }
} }
} }
@ -1027,7 +1043,11 @@ void CDriverGL::endLightMapMultiPass()
for (uint32 i = 0; i < (_NLightMapPerPass+1); ++i) for (uint32 i = 0; i < (_NLightMapPerPass+1); ++i)
{ {
_DriverGLStates.activeTextureARB(i); _DriverGLStates.activeTextureARB(i);
#ifdef USE_OPENGLES
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, 1);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1); glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1);
#endif
} }
} }
} }
@ -1102,13 +1122,16 @@ void CDriverGL::setupSpecularBegin()
// todo hulud remove // todo hulud remove
// _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap); // _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap);
#ifdef USE_OPENGLES
_DriverGLStates.setTexGenMode (1, GL_REFLECTION_MAP_OES);
#else
_DriverGLStates.setTexGenMode (1, GL_REFLECTION_MAP_ARB); _DriverGLStates.setTexGenMode (1, GL_REFLECTION_MAP_ARB);
#endif
// setup the good matrix for stage 1. // setup the good matrix for stage 1.
glMatrixMode(GL_TEXTURE); glMatrixMode(GL_TEXTURE);
glLoadMatrixf( _SpecularTexMtx.get() ); glLoadMatrixf( _SpecularTexMtx.get() );
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
} }
// *************************************************************************** // ***************************************************************************
@ -1292,7 +1315,8 @@ void CDriverGL::setupSpecularPass(uint pass)
_DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled); _DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled);
} }
else else
{ // Multiply texture1 by alpha_texture0 and display with add {
// Multiply texture1 by alpha_texture0 and display with add
_DriverGLStates.enableBlend(true); _DriverGLStates.enableBlend(true);
_DriverGLStates.blendFunc(GL_ONE, GL_ONE); _DriverGLStates.blendFunc(GL_ONE, GL_ONE);
@ -1957,7 +1981,9 @@ void CDriverGL::endCloudMultiPass()
nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud); nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud);
if (ATICloudShaderHandle) if (ATICloudShaderHandle)
{ {
#ifndef USE_OPENGLES
glDisable(GL_FRAGMENT_SHADER_ATI); glDisable(GL_FRAGMENT_SHADER_ATI);
#endif
} }
} }
@ -1975,7 +2001,9 @@ sint CDriverGL::beginWaterMultiPass()
*/ */
void CDriverGL::setupWaterPassR200(const CMaterial &mat) void CDriverGL::setupWaterPassR200(const CMaterial &mat)
{ {
H_AUTO_OGL(CDriverGL_setupWaterPassR200) H_AUTO_OGL(CDriverGL_setupWaterPassR200);
#ifndef USE_OPENGLES
uint k; uint k;
ITexture *tex = mat.getTexture(0); ITexture *tex = mat.getTexture(0);
if (tex) if (tex)
@ -2047,6 +2075,7 @@ void CDriverGL::setupWaterPassR200(const CMaterial &mat)
float cst[4] = { 1.f, 1.f, 1.f, 0.f }; float cst[4] = { 1.f, 1.f, 1.f, 0.f };
nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst); nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst);
} }
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -2054,7 +2083,9 @@ void CDriverGL::setupWaterPassR200(const CMaterial &mat)
*/ */
void CDriverGL::setupWaterPassARB(const CMaterial &mat) void CDriverGL::setupWaterPassARB(const CMaterial &mat)
{ {
H_AUTO_OGL(CDriverGL_setupWaterPassARB) H_AUTO_OGL(CDriverGL_setupWaterPassARB);
#ifndef USE_OPENGLES
uint k; uint k;
ITexture *tex = mat.getTexture(0); ITexture *tex = mat.getTexture(0);
if (tex) if (tex)
@ -2133,6 +2164,7 @@ void CDriverGL::setupWaterPassARB(const CMaterial &mat)
} }
} }
} }
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -2159,8 +2191,9 @@ static const float IdentityTexMat[4] = { 1.f, 0.f, 0.f, 1.f };
// *************************************************************************** // ***************************************************************************
void CDriverGL::setupWaterPassNV20(const CMaterial &mat) void CDriverGL::setupWaterPassNV20(const CMaterial &mat)
{ {
H_AUTO_OGL(CDriverGL_setupWaterPassNV20) H_AUTO_OGL(CDriverGL_setupWaterPassNV20);
#ifndef USE_OPENGLES
static bool setupDone = false; static bool setupDone = false;
static CMaterial::CTexEnv texEnvReplace; static CMaterial::CTexEnv texEnvReplace;
static CMaterial::CTexEnv texEnvModulate; static CMaterial::CTexEnv texEnvModulate;
@ -2245,6 +2278,7 @@ void CDriverGL::setupWaterPassNV20(const CMaterial &mat)
activateTexEnvMode(2, texEnvReplace); activateTexEnvMode(2, texEnvReplace);
activateTexEnvMode(3, texEnvModulate); activateTexEnvMode(3, texEnvModulate);
} }
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -2272,7 +2306,9 @@ void CDriverGL::setupWaterPass(uint /* pass */)
// *************************************************************************** // ***************************************************************************
void CDriverGL::endWaterMultiPass() void CDriverGL::endWaterMultiPass()
{ {
H_AUTO_OGL(CDriverGL_endWaterMultiPass) H_AUTO_OGL(CDriverGL_endWaterMultiPass);
#ifndef USE_OPENGLES
nlassert(_CurrentMaterial->getShader() == CMaterial::Water); nlassert(_CurrentMaterial->getShader() == CMaterial::Water);
// NB : as fragment shaders / programs bypass the texture envs, no special env enum is added (c.f CTexEnvSpecial) // NB : as fragment shaders / programs bypass the texture envs, no special env enum is added (c.f CTexEnvSpecial)
if (_Extensions.NVTextureShader) return; if (_Extensions.NVTextureShader) return;
@ -2284,6 +2320,7 @@ void CDriverGL::endWaterMultiPass()
{ {
glDisable(GL_FRAGMENT_SHADER_ATI); glDisable(GL_FRAGMENT_SHADER_ATI);
} }
#endif
} }
} // NL3D } // NL3D

View file

@ -15,24 +15,35 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdopengl.h" #include "stdopengl.h"
#include "driver_opengl.h" #include "driver_opengl.h"
namespace NL3D { namespace NL3D {
// *************************************************************************** // ***************************************************************************
void CDriverGL::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective) void CDriverGL::setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective)
{ {
H_AUTO_OGL(CDriverGL_setFrustum) H_AUTO_OGL(CDriverGL_setFrustum);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
if (perspective) if (perspective)
{ {
#ifdef USE_OPENGLES
glFrustumf(left,right,bottom,top,znear,zfar);
#else
glFrustum(left,right,bottom,top,znear,zfar); glFrustum(left,right,bottom,top,znear,zfar);
#endif
} }
else else
{ {
#ifdef USE_OPENGLES
glOrthof(left,right,bottom,top,znear,zfar);
#else
glOrtho(left,right,bottom,top,znear,zfar); glOrtho(left,right,bottom,top,znear,zfar);
#endif
} }
_ProjMatDirty = true; _ProjMatDirty = true;
// Backup znear and zfar for zbias setup // Backup znear and zfar for zbias setup

View file

@ -77,7 +77,8 @@ void CDriverGLStates::init(bool supportTextureCubeMap, bool supportTextureRect
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::forceDefaults(uint nbStages) void CDriverGLStates::forceDefaults(uint nbStages)
{ {
H_AUTO_OGL(CDriverGLStates_forceDefaults) H_AUTO_OGL(CDriverGLStates_forceDefaults);
// Enable / disable. // Enable / disable.
_CurFog= false; _CurFog= false;
_CurBlend= false; _CurBlend= false;
@ -86,6 +87,7 @@ void CDriverGLStates::forceDefaults(uint nbStages)
_CurLighting= false; _CurLighting= false;
_CurZWrite= true; _CurZWrite= true;
_CurStencilTest=false; _CurStencilTest=false;
// setup GLStates. // setup GLStates.
glDisable(GL_FOG); glDisable(GL_FOG);
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -144,33 +146,62 @@ void CDriverGLStates::forceDefaults(uint nbStages)
for(stage=0;stage<nbStages; stage++) for(stage=0;stage<nbStages; stage++)
{ {
// disable texturing. // disable texturing.
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
if(_TextureCubeMapSupported) if(_TextureCubeMapSupported)
{
#ifdef USE_OPENGLES
glDisable(GL_TEXTURE_CUBE_MAP_OES);
glDisable(GL_TEXTURE_GEN_STR_OES);
#else
glDisable(GL_TEXTURE_CUBE_MAP_ARB); glDisable(GL_TEXTURE_CUBE_MAP_ARB);
if(_TextureRectangleSupported) #endif
glDisable(GL_TEXTURE_RECTANGLE_NV); }
_TextureMode[stage]= TextureDisabled; _TextureMode[stage]= TextureDisabled;
// Tex gen init // Tex gen init
_TexGenMode[stage] = 0; _TexGenMode[stage] = 0;
glDisable( GL_TEXTURE_GEN_S );
glDisable( GL_TEXTURE_GEN_T ); #ifndef USE_OPENGLES
glDisable( GL_TEXTURE_GEN_R ); if(_TextureRectangleSupported)
glDisable( GL_TEXTURE_GEN_Q ); glDisable(GL_TEXTURE_RECTANGLE_NV);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_GEN_Q);
#endif
} }
// ActiveTexture current texture to 0. // ActiveTexture current texture to 0.
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB); nglActiveTextureARB(GL_TEXTURE0_ARB);
_CurrentActiveTextureARB= 0;
nglClientActiveTextureARB(GL_TEXTURE0_ARB); nglClientActiveTextureARB(GL_TEXTURE0_ARB);
#endif
_CurrentActiveTextureARB= 0;
_CurrentClientActiveTextureARB= 0; _CurrentClientActiveTextureARB= 0;
// Depth range // Depth range
_DepthRangeNear = 0.f; _DepthRangeNear = 0.f;
_DepthRangeFar = 1.f; _DepthRangeFar = 1.f;
_ZBias = 0.f; _ZBias = 0.f;
#ifdef USE_OPENGLES
glDepthRangef (0.f, 1.f);
#else
glDepthRange (0, 1); glDepthRange (0, 1);
#endif
// Cull order // Cull order
_CullMode = CCW; _CullMode = CCW;
@ -536,7 +567,9 @@ void CDriverGLStates::setVertexColorLighted(bool enable)
if (_VertexColorLighted) if (_VertexColorLighted)
{ {
glEnable (GL_COLOR_MATERIAL); glEnable (GL_COLOR_MATERIAL);
#ifndef USE_OPENGLES
glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE); glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE);
#endif
} }
else else
{ {
@ -558,9 +591,15 @@ void CDriverGLStates::setVertexColorLighted(bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::updateDepthRange() void CDriverGLStates::updateDepthRange()
{ {
H_AUTO_OGL(CDriverGLStates_updateDepthRange) H_AUTO_OGL(CDriverGLStates_updateDepthRange);
float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear); float delta = _ZBias * (_DepthRangeFar - _DepthRangeNear);
#ifdef USE_OPENGLES
glDepthRangef(delta + _DepthRangeNear, delta + _DepthRangeFar);
#else
glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar); glDepthRange(delta + _DepthRangeNear, delta + _DepthRangeFar);
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -605,10 +644,14 @@ void CDriverGLStates::setTexGenMode (uint stage, GLint mode)
if(mode==0) if(mode==0)
{ {
#ifdef USE_OPENGLES
glDisable(GL_TEXTURE_GEN_STR_OES);
#else
glDisable( GL_TEXTURE_GEN_S ); glDisable( GL_TEXTURE_GEN_S );
glDisable( GL_TEXTURE_GEN_T ); glDisable( GL_TEXTURE_GEN_T );
glDisable( GL_TEXTURE_GEN_R ); glDisable( GL_TEXTURE_GEN_R );
glDisable( GL_TEXTURE_GEN_Q ); glDisable( GL_TEXTURE_GEN_Q );
#endif
} }
else else
{ {
@ -630,10 +673,15 @@ void CDriverGLStates::setTexGenMode (uint stage, GLint mode)
{ {
glDisable( GL_TEXTURE_GEN_Q ); glDisable( GL_TEXTURE_GEN_Q );
} }
// Enable All. // Enable All.
#ifdef USE_OPENGLES
glEnable(GL_TEXTURE_GEN_STR_OES);
#else
glEnable( GL_TEXTURE_GEN_S ); glEnable( GL_TEXTURE_GEN_S );
glEnable( GL_TEXTURE_GEN_T ); glEnable( GL_TEXTURE_GEN_T );
glEnable( GL_TEXTURE_GEN_R ); glEnable( GL_TEXTURE_GEN_R );
#endif
} }
} }
} }
@ -649,12 +697,19 @@ void CDriverGLStates::resetTextureMode()
if (_TextureCubeMapSupported) if (_TextureCubeMapSupported)
{ {
#ifdef USE_OPENGLES
glDisable(GL_TEXTURE_CUBE_MAP_OES);
#else
glDisable(GL_TEXTURE_CUBE_MAP_ARB); glDisable(GL_TEXTURE_CUBE_MAP_ARB);
#endif
} }
#ifndef USE_OPENGLES
if (_TextureRectangleSupported) if (_TextureRectangleSupported)
{ {
glDisable(GL_TEXTURE_RECTANGLE_NV); glDisable(GL_TEXTURE_RECTANGLE_NV);
} }
#endif
_TextureMode[_CurrentActiveTextureARB]= TextureDisabled; _TextureMode[_CurrentActiveTextureARB]= TextureDisabled;
} }
@ -674,11 +729,13 @@ void CDriverGLStates::setTextureMode(TTextureMode texMode)
} }
else if(oldTexMode == TextureRect) else if(oldTexMode == TextureRect)
{ {
#ifndef USE_OPENGLES
if(_TextureRectangleSupported) if(_TextureRectangleSupported)
{ {
glDisable(GL_TEXTURE_RECTANGLE_NV); glDisable(GL_TEXTURE_RECTANGLE_NV);
} }
else else
#endif
{ {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
} }
@ -687,7 +744,11 @@ void CDriverGLStates::setTextureMode(TTextureMode texMode)
{ {
if(_TextureCubeMapSupported) if(_TextureCubeMapSupported)
{ {
#ifdef USE_OPENGLES
glDisable(GL_TEXTURE_CUBE_MAP_OES);
#else
glDisable(GL_TEXTURE_CUBE_MAP_ARB); glDisable(GL_TEXTURE_CUBE_MAP_ARB);
#endif
} }
else else
{ {
@ -702,24 +763,30 @@ void CDriverGLStates::setTextureMode(TTextureMode texMode)
} }
else if(texMode == TextureRect) else if(texMode == TextureRect)
{ {
#ifndef USE_OPENGLES
if(_TextureRectangleSupported) if(_TextureRectangleSupported)
{ {
glEnable(GL_TEXTURE_RECTANGLE_NV); glEnable(GL_TEXTURE_RECTANGLE_NV);
} }
else else
#endif
{ {
glDisable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} }
} }
else if(texMode == TextureCubeMap) else if(texMode == TextureCubeMap)
{ {
if(_TextureCubeMapSupported) if(_TextureCubeMapSupported)
{ {
#ifdef USE_OPENGLES
glEnable(GL_TEXTURE_CUBE_MAP_OES);
#else
glEnable(GL_TEXTURE_CUBE_MAP_ARB); glEnable(GL_TEXTURE_CUBE_MAP_ARB);
#endif
} }
else else
{ {
glDisable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
} }
} }
@ -736,8 +803,11 @@ void CDriverGLStates::activeTextureARB(uint stage)
if( _CurrentActiveTextureARB != stage ) if( _CurrentActiveTextureARB != stage )
{ {
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentActiveTextureARB= stage; _CurrentActiveTextureARB= stage;
} }
@ -748,7 +818,11 @@ void CDriverGLStates::forceActiveTextureARB(uint stage)
{ {
H_AUTO_OGL(CDriverGLStates_forceActiveTextureARB); H_AUTO_OGL(CDriverGLStates_forceActiveTextureARB);
#ifdef USE_OPENGLES
glActiveTexture(GL_TEXTURE0+stage);
#else
nglActiveTextureARB(GL_TEXTURE0_ARB+stage); nglActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentActiveTextureARB= stage; _CurrentActiveTextureARB= stage;
} }
@ -786,22 +860,25 @@ void CDriverGLStates::enableNormalArray(bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableWeightArray(bool enable) void CDriverGLStates::enableWeightArray(bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableWeightArray) H_AUTO_OGL(CDriverGLStates_enableWeightArray);
if(_WeightArrayEnabled != enable) if(_WeightArrayEnabled != enable)
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
glEnableClientState(GL_VERTEX_WEIGHTING_EXT); glEnableClientState(GL_VERTEX_WEIGHTING_EXT);
else else
glDisableClientState(GL_VERTEX_WEIGHTING_EXT); glDisableClientState(GL_VERTEX_WEIGHTING_EXT);
#endif
_WeightArrayEnabled= enable; _WeightArrayEnabled= enable;
} }
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableColorArray(bool enable) void CDriverGLStates::enableColorArray(bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableColorArray) H_AUTO_OGL(CDriverGLStates_enableColorArray);
if(_ColorArrayEnabled != enable) if(_ColorArrayEnabled != enable)
{ {
if(enable) if(enable)
@ -818,32 +895,42 @@ void CDriverGLStates::enableColorArray(bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableSecondaryColorArray(bool enable) void CDriverGLStates::enableSecondaryColorArray(bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableSecondaryColorArray) H_AUTO_OGL(CDriverGLStates_enableSecondaryColorArray);
if(_SecondaryColorArrayEnabled != enable) if(_SecondaryColorArrayEnabled != enable)
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
else else
glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
#endif
_SecondaryColorArrayEnabled= enable; _SecondaryColorArrayEnabled= enable;
#ifndef USE_OPENGLES
// If disable // If disable
if(!enable) if(!enable)
{ {
// GeForceFx Bug: Must reset Secondary color to 0 (if comes from a VP), else bugs // GeForceFx Bug: Must reset Secondary color to 0 (if comes from a VP), else bugs
nglSecondaryColor3ubEXT(0,0,0); nglSecondaryColor3ubEXT(0,0,0);
} }
#endif
} }
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::clientActiveTextureARB(uint stage) void CDriverGLStates::clientActiveTextureARB(uint stage)
{ {
H_AUTO_OGL(CDriverGLStates_clientActiveTextureARB) H_AUTO_OGL(CDriverGLStates_clientActiveTextureARB);
if( _CurrentClientActiveTextureARB != stage ) if( _CurrentClientActiveTextureARB != stage )
{ {
#ifdef USE_OPENGLES
glClientActiveTexture(GL_TEXTURE0+stage);
#else
nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage); nglClientActiveTextureARB(GL_TEXTURE0_ARB+stage);
#endif
_CurrentClientActiveTextureARB= stage; _CurrentClientActiveTextureARB= stage;
} }
} }
@ -851,7 +938,8 @@ void CDriverGLStates::clientActiveTextureARB(uint stage)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableTexCoordArray(bool enable) void CDriverGLStates::enableTexCoordArray(bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableTexCoordArray) H_AUTO_OGL(CDriverGLStates_enableTexCoordArray);
if(_TexCoordArrayEnabled[_CurrentClientActiveTextureARB] != enable) if(_TexCoordArrayEnabled[_CurrentClientActiveTextureARB] != enable)
{ {
if(enable) if(enable)
@ -867,14 +955,16 @@ void CDriverGLStates::enableTexCoordArray(bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableVertexAttribArray(uint glIndex, bool enable) void CDriverGLStates::enableVertexAttribArray(uint glIndex, bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableVertexAttribArray) H_AUTO_OGL(CDriverGLStates_enableVertexAttribArray);
if(_VertexAttribArrayEnabled[glIndex] != enable) if(_VertexAttribArrayEnabled[glIndex] != enable)
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
glEnableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV); glEnableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV);
else else
glDisableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV); glDisableClientState(glIndex+GL_VERTEX_ATTRIB_ARRAY0_NV);
#endif
_VertexAttribArrayEnabled[glIndex]= enable; _VertexAttribArrayEnabled[glIndex]= enable;
} }
@ -883,15 +973,18 @@ void CDriverGLStates::enableVertexAttribArray(uint glIndex, bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableVertexAttribArrayARB(uint glIndex,bool enable) void CDriverGLStates::enableVertexAttribArrayARB(uint glIndex,bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableVertexAttribArrayARB) H_AUTO_OGL(CDriverGLStates_enableVertexAttribArrayARB);
#ifndef NL3D_GLSTATE_DISABLE_CACHE #ifndef NL3D_GLSTATE_DISABLE_CACHE
if(_VertexAttribArrayEnabled[glIndex] != enable) if(_VertexAttribArrayEnabled[glIndex] != enable)
#endif #endif
{ {
#ifndef USE_OPENGLES
if(enable) if(enable)
nglEnableVertexAttribArrayARB(glIndex); nglEnableVertexAttribArrayARB(glIndex);
else else
nglDisableVertexAttribArrayARB(glIndex); nglDisableVertexAttribArrayARB(glIndex);
#endif
_VertexAttribArrayEnabled[glIndex]= enable; _VertexAttribArrayEnabled[glIndex]= enable;
} }
@ -988,7 +1081,13 @@ void CDriverGLStates::enableFog(uint enable)
void CDriverGLStates::forceBindARBVertexBuffer(uint objectID) void CDriverGLStates::forceBindARBVertexBuffer(uint objectID)
{ {
H_AUTO_OGL(CDriverGLStates_forceBindARBVertexBuffer) H_AUTO_OGL(CDriverGLStates_forceBindARBVertexBuffer)
#ifdef USE_OPENGLES
glBindBuffer(GL_ARRAY_BUFFER, objectID);
#else
nglBindBufferARB(GL_ARRAY_BUFFER_ARB, objectID); nglBindBufferARB(GL_ARRAY_BUFFER_ARB, objectID);
#endif
_CurrARBVertexBuffer = objectID; _CurrARBVertexBuffer = objectID;
} }

View file

@ -20,11 +20,15 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/3d/vertex_buffer.h" #include "nel/3d/vertex_buffer.h"
#ifdef NL_OS_MAC #ifdef USE_OPENGLES
# define GL_GLEXT_LEGACY # include <GLES/gl.h>
# include <OpenGL/gl.h>
#else #else
# include <GL/gl.h> # ifdef NL_OS_MAC
# define GL_GLEXT_LEGACY
# include <OpenGL/gl.h>
# else
# include <GL/gl.h>
# endif
#endif #endif
@ -41,7 +45,7 @@ namespace NL3D
- GL_ALPHA_TEST - GL_ALPHA_TEST
- GL_LIGHTING - GL_LIGHTING
- GL_LIGHT0 + i ..... - GL_LIGHT0 + i .....
- GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP_ARB. - GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP_ARB/OES.
- GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R - GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R
- GL_COLOR_MATERIAL - GL_COLOR_MATERIAL
- GL_FOG - GL_FOG

View file

@ -155,7 +155,11 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
// check status // check status
GLenum status; GLenum status;
#ifdef USE_OPENGLES
status = (GLenum) nglCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
#else
status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); status = (GLenum) nglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
#endif
switch(status) { switch(status) {
case GL_FRAMEBUFFER_COMPLETE_EXT: case GL_FRAMEBUFFER_COMPLETE_EXT:
InitFBO = true; InitFBO = true;
@ -197,19 +201,31 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
break; break;
#endif #endif
default: default:
nlwarning("Framebuffer incomplete\n"); nlwarning("Framebuffer incomplete status %d", (sint)status);
//nlassert(0); //nlassert(0);
} }
// clean up resources if allocation failed // clean up resources if allocation failed
if (!InitFBO) if (!InitFBO)
{ {
#ifdef USE_OPENGLES
nglDeleteFramebuffersOES(1, &FBOId);
#else
nglDeleteFramebuffersEXT(1, &FBOId); nglDeleteFramebuffersEXT(1, &FBOId);
#endif
if (AttachDepthStencil) if (AttachDepthStencil)
{ {
#ifdef USE_OPENGLES
nglDeleteRenderbuffersOES(1, &DepthFBOId);
#else
nglDeleteRenderbuffersEXT(1, &DepthFBOId); nglDeleteRenderbuffersEXT(1, &DepthFBOId);
#endif
if(!UsePackedDepthStencil) if(!UsePackedDepthStencil)
#ifdef USE_OPENGLES
nglDeleteRenderbuffersOES(1, &StencilFBOId);
#else
nglDeleteRenderbuffersEXT(1, &StencilFBOId); nglDeleteRenderbuffersEXT(1, &StencilFBOId);
#endif
} }
} }
@ -226,14 +242,22 @@ bool CTextureDrvInfosGL::activeFrameBufferObject(ITexture * tex)
if(initFrameBufferObject(tex)) if(initFrameBufferObject(tex))
{ {
glBindTexture(TextureMode, 0); glBindTexture(TextureMode, 0);
#ifdef USE_OPENGLES
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, FBOId);
#else
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId); nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBOId);
#endif
} }
else else
return false; return false;
} }
else else
{ {
#ifdef USE_OPENGLES
nglBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
#else
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
#endif
} }
return true; return true;
@ -481,7 +505,7 @@ static inline GLenum translateMinFilterToGl(CTextureDrvInfosGL *glText)
// *************************************************************************** // ***************************************************************************
static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt) static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt)
{ {
H_AUTO_OGL(sameDXTCFormat) H_AUTO_OGL(sameDXTCFormat);
if(glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1) if(glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1)
return true; return true;
if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1Alpha) if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT && tex.PixelFormat==CBitmap::DXTC1Alpha)
@ -497,7 +521,7 @@ static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt)
// *************************************************************************** // ***************************************************************************
static inline bool isDXTCFormat(GLint glfmt) static inline bool isDXTCFormat(GLint glfmt)
{ {
H_AUTO_OGL(isDXTCFormat) H_AUTO_OGL(isDXTCFormat);
if(glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT) if(glfmt==GL_COMPRESSED_RGB_S3TC_DXT1_EXT)
return true; return true;
if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) if(glfmt==GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
@ -602,7 +626,7 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
{ {
//nldebug("3D: creating CTextureDrvShare()"); //nldebug("3D: creating CTextureDrvShare()");
// insert into driver list. (so it is deleted when driver is deleted). // insert into driver list. (so it is deleted when driver is deleted).
ItTexDrvSharePtrList it= _TexDrvShares.insert(_TexDrvShares.end(), NULL); ItTexDrvSharePtrList it= _TexDrvShares.insert(_TexDrvShares.end(), (NL3D::CTextureDrvShare*)NULL);
// create and set iterator, for future deletion. // create and set iterator, for future deletion.
*it= tex.TextureDrvShare= new CTextureDrvShare(this, it, &tex); *it= tex.TextureDrvShare= new CTextureDrvShare(this, it, &tex);
@ -840,8 +864,13 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
sint size= tex.getPixels(i).size(); sint size= tex.getPixels(i).size();
if (bUpload) if (bUpload)
{ {
#ifdef USE_OPENGLES
glCompressedTexImage2D (GL_TEXTURE_2D, i-decalMipMapResize, glfmt,
tex.getWidth(i),tex.getHeight(i), 0, size, ptr);
#else
nglCompressedTexImage2DARB (GL_TEXTURE_2D, i-decalMipMapResize, glfmt, nglCompressedTexImage2DARB (GL_TEXTURE_2D, i-decalMipMapResize, glfmt,
tex.getWidth(i),tex.getHeight(i), 0, size, ptr); tex.getWidth(i),tex.getHeight(i), 0, size, ptr);
#endif
bAllUploaded = true; bAllUploaded = true;
} }
else else

View file

@ -140,7 +140,7 @@ bool CDriverGL::setupVertexBuffer(CVertexBuffer& VB)
// 1. Retrieve/Create driver shader. // 1. Retrieve/Create driver shader.
//================================== //==================================
// insert into driver list. (so it is deleted when driver is deleted). // insert into driver list. (so it is deleted when driver is deleted).
ItVBDrvInfoPtrList it= _VBDrvInfos.insert(_VBDrvInfos.end(), NULL); ItVBDrvInfoPtrList it= _VBDrvInfos.insert(_VBDrvInfos.end(), (NL3D::IVBDrvInfos*)NULL);
// create and set iterator, for future deletion. // create and set iterator, for future deletion.
CVBDrvInfosGL *info = new CVBDrvInfosGL(this, it, &VB); CVBDrvInfosGL *info = new CVBDrvInfosGL(this, it, &VB);
*it= VB.DrvInfos = info; *it= VB.DrvInfos = info;
@ -280,8 +280,12 @@ bool CDriverGL::renderLines(CMaterial& mat, uint32 firstIndex, uint32 nlines)
} }
else else
{ {
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
nlassert(_LastIB._Format == CIndexBuffer::Indices32); nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_LINES,2*nlines,GL_UNSIGNED_INT,((uint32 *) _LastIB._Values)+firstIndex); glDrawElements(GL_LINES,2*nlines,GL_UNSIGNED_INT,((uint32 *) _LastIB._Values)+firstIndex);
#endif
} }
} }
} }
@ -336,8 +340,12 @@ bool CDriverGL::renderTriangles(CMaterial& mat, uint32 firstIndex, uint32 ntris)
} }
else else
{ {
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
nlassert(_LastIB._Format == CIndexBuffer::Indices32); nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstIndex); glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstIndex);
#endif
} }
} }
} }
@ -380,8 +388,12 @@ bool CDriverGL::renderSimpleTriangles(uint32 firstTri, uint32 ntris)
} }
else else
{ {
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
nlassert(_LastIB._Format == CIndexBuffer::Indices32); nlassert(_LastIB._Format == CIndexBuffer::Indices32);
glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstTri); glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, ((uint32 *) _LastIB._Values)+firstTri);
#endif
} }
// Profiling. // Profiling.
@ -608,6 +620,9 @@ bool CDriverGL::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQuad
} }
else else
{ {
#ifdef USE_OPENGLES
nlerror("not available in OpenGL ES 1.0, only use 16 bits indices");
#else
// indices fits on 32 bits // indices fits on 32 bits
GLint indices[QUAD_BATCH_SIZE]; GLint indices[QUAD_BATCH_SIZE];
GLint *curr = indices; GLint *curr = indices;
@ -625,6 +640,7 @@ bool CDriverGL::renderRawQuads(CMaterial& mat, uint32 startIndex, uint32 numQuad
} }
while(curr != end); while(curr != end);
glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices); glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices);
#endif
} }
numLeftQuads -= numQuadsToDraw; numLeftQuads -= numQuadsToDraw;
currIndex += 4 * numQuadsToDraw; currIndex += 4 * numQuadsToDraw;
@ -665,10 +681,12 @@ void CDriverGL::setupUVPtr(uint stage, CVertexBufferInfo &VB, uint uvId)
// Setup ATI VBHard or std ptr. // Setup ATI VBHard or std ptr.
switch(VB.VBMode) switch(VB.VBMode)
{ {
#ifndef USE_OPENGLES
case CVertexBufferInfo::HwATI: case CVertexBufferInfo::HwATI:
nglArrayObjectATI(GL_TEXTURE_COORD_ARRAY, numTexCoord, GL_FLOAT, VB.VertexSize, VB.VertexObjectId, nglArrayObjectATI(GL_TEXTURE_COORD_ARRAY, numTexCoord, GL_FLOAT, VB.VertexSize, VB.VertexObjectId,
(ptrdiff_t) VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]); (ptrdiff_t) VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]);
break; break;
#endif
case CVertexBufferInfo::HwARB: case CVertexBufferInfo::HwARB:
_DriverGLStates.bindARBVertexBuffer(VB.VertexObjectId); _DriverGLStates.bindARBVertexBuffer(VB.VertexObjectId);
// with arb buffers, position is relative to the start of the stream // with arb buffers, position is relative to the start of the stream
@ -811,6 +829,21 @@ const uint CDriverGL::NumCoordinatesType[CVertexBuffer::NumType]=
// *************************************************************************** // ***************************************************************************
const uint CDriverGL::GLType[CVertexBuffer::NumType]= const uint CDriverGL::GLType[CVertexBuffer::NumType]=
{ {
#ifdef USE_OPENGLES
GL_FLOAT, // Double1
GL_FLOAT, // Float1
GL_SHORT, // Short1
GL_FLOAT, // Double2
GL_FLOAT, // Float2
GL_SHORT, // Short2
GL_FLOAT, // Double3
GL_FLOAT, // Float3
GL_SHORT, // Short3
GL_FLOAT, // Double4
GL_FLOAT, // Float4
GL_SHORT, // Short4
GL_UNSIGNED_BYTE // UChar4
#else
GL_DOUBLE, // Double1 GL_DOUBLE, // Double1
GL_FLOAT, // Float1 GL_FLOAT, // Float1
GL_SHORT, // Short1 GL_SHORT, // Short1
@ -824,6 +857,7 @@ const uint CDriverGL::GLType[CVertexBuffer::NumType]=
GL_FLOAT, // Float4 GL_FLOAT, // Float4
GL_SHORT, // Short4 GL_SHORT, // Short4
GL_UNSIGNED_BYTE // UChar4 GL_UNSIGNED_BYTE // UChar4
#endif
}; };
// *************************************************************************** // ***************************************************************************
@ -926,6 +960,7 @@ void CDriverGL::setupGlArraysStd(CVertexBufferInfo &vb)
} }
} }
break; break;
#ifndef USE_OPENGLES
case CVertexBufferInfo::HwATI: case CVertexBufferInfo::HwATI:
{ {
// setup vertex ptr. // setup vertex ptr.
@ -963,9 +998,12 @@ void CDriverGL::setupGlArraysStd(CVertexBufferInfo &vb)
nglArrayObjectATI(GL_COLOR_ARRAY, 4, GL_UNSIGNED_BYTE, vb.VertexSize, vb.VertexObjectId, (ptrdiff_t) vb.ValuePtr[CVertexBuffer::PrimaryColor]); nglArrayObjectATI(GL_COLOR_ARRAY, 4, GL_UNSIGNED_BYTE, vb.VertexSize, vb.VertexObjectId, (ptrdiff_t) vb.ValuePtr[CVertexBuffer::PrimaryColor]);
} }
else else
{
_DriverGLStates.enableColorArray(false); _DriverGLStates.enableColorArray(false);
}
} }
break; break;
#endif
default: default:
nlassert(0); nlassert(0);
break; break;
@ -1035,7 +1073,9 @@ void CDriverGL::toggleGlArraysForARBVertexProgram()
// If last was a VertexProgram setup, and now it is a standard GL array setup. // If last was a VertexProgram setup, and now it is a standard GL array setup.
if( _LastSetupGLArrayVertexProgram && !isVertexProgramEnabled () ) if( _LastSetupGLArrayVertexProgram && !isVertexProgramEnabled () )
{ {
#ifndef USE_OPENGLES
if (_Extensions.ATITextureEnvCombine3) if (_Extensions.ATITextureEnvCombine3)
#endif
{ {
// fix for ATI : when switching from Vertex Program to fixed Pipe, must clean texture, otherwise texture may be disabled in next render // fix for ATI : when switching from Vertex Program to fixed Pipe, must clean texture, otherwise texture may be disabled in next render
// (seems to be a driver bug) // (seems to be a driver bug)
@ -1046,12 +1086,16 @@ void CDriverGL::toggleGlArraysForARBVertexProgram()
// activate the texture, or disable texturing if NULL. // activate the texture, or disable texturing if NULL.
activateTexture(stage, NULL); activateTexture(stage, NULL);
} }
#ifndef USE_OPENGLES
glBegin(GL_QUADS); glBegin(GL_QUADS);
glVertex4f(0.f, 0.f, 0.f, 1.f); glVertex4f(0.f, 0.f, 0.f, 1.f);
glVertex4f(0.f, 0.f, 0.f, 1.f); glVertex4f(0.f, 0.f, 0.f, 1.f);
glVertex4f(0.f, 0.f, 0.f, 1.f); glVertex4f(0.f, 0.f, 0.f, 1.f);
glVertex4f(0.f, 0.f, 0.f, 1.f); glVertex4f(0.f, 0.f, 0.f, 1.f);
glEnd(); glEnd();
#endif
for(uint stage=0 ; stage<inlGetNumTextStages() ; stage++) for(uint stage=0 ; stage<inlGetNumTextStages() ; stage++)
{ {
// activate the texture, or disable texturing if NULL. // activate the texture, or disable texturing if NULL.
@ -1185,7 +1229,9 @@ void CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
{ {
// Secondary color // Secondary color
_DriverGLStates.enableSecondaryColorArray(true); _DriverGLStates.enableSecondaryColorArray(true);
nglSecondaryColorPointerEXT(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[value]); #ifndef USE_OPENGLES
nglSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[value]);
#endif
} }
} }
else else
@ -1199,7 +1245,9 @@ void CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
// Active this value // Active this value
_DriverGLStates.enableVertexAttribArray(glIndex, true); _DriverGLStates.enableVertexAttribArray(glIndex, true);
#ifndef USE_OPENGLES
nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]); nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#endif
} }
} }
// Else normal case, can't do anything for other values with UChar4.... // Else normal case, can't do anything for other values with UChar4....
@ -1207,7 +1255,9 @@ void CDriverGL::setupGlArraysForNVVertexProgram(CVertexBufferInfo &vb)
{ {
// Active this value // Active this value
_DriverGLStates.enableVertexAttribArray(glIndex, true); _DriverGLStates.enableVertexAttribArray(glIndex, true);
#ifndef USE_OPENGLES
nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]); nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
#endif
} }
} }
else else

View file

@ -69,7 +69,7 @@ IVertexBufferHardGL::~IVertexBufferHardGL()
H_AUTO_OGL(IVertexBufferHardGL_IVertexBufferHardGLDtor) H_AUTO_OGL(IVertexBufferHardGL_IVertexBufferHardGLDtor)
} }
#ifndef USE_OPENGLES
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************
@ -1133,7 +1133,7 @@ void CVertexArrayRangeMapObjectATI::updateLostBuffers()
} }
#endif #endif
#endif // USE_OPENGLES
// *************************************************************************** // ***************************************************************************
@ -1210,19 +1210,37 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
// create a ARB VBHard // create a ARB VBHard
GLuint vertexBufferID; GLuint vertexBufferID;
glGetError(); glGetError();
#ifdef USE_OPENGLES
glGenBuffers(1, &vertexBufferID);
#else
nglGenBuffersARB(1, &vertexBufferID); nglGenBuffersARB(1, &vertexBufferID);
#endif
if (glGetError() != GL_NO_ERROR) return false; if (glGetError() != GL_NO_ERROR) return false;
_Driver->_DriverGLStates.forceBindARBVertexBuffer(vertexBufferID); _Driver->_DriverGLStates.forceBindARBVertexBuffer(vertexBufferID);
switch(_VBType) switch(_VBType)
{ {
case CVertexBuffer::AGPPreferred: case CVertexBuffer::AGPPreferred:
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
#endif
break; break;
case CVertexBuffer::StaticPreferred: case CVertexBuffer::StaticPreferred:
if (_Driver->getStaticMemoryToVRAM()) if (_Driver->getStaticMemoryToVRAM())
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB);
#endif
else else
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
#endif
break; break;
default: default:
nlassert(0); nlassert(0);
@ -1230,7 +1248,12 @@ IVertexBufferHardGL *CVertexArrayRangeARB::createVBHardGL(uint size, CVertexBuff
} }
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
#ifdef USE_OPENGLES
glDeleteBuffers(1, &vertexBufferID);
#else
nglDeleteBuffersARB(1, &vertexBufferID); nglDeleteBuffersARB(1, &vertexBufferID);
#endif
return false; return false;
} }
CVertexBufferHardARB *newVbHard= new CVertexBufferHardARB(_Driver, vb); CVertexBufferHardARB *newVbHard= new CVertexBufferHardARB(_Driver, vb);
@ -1272,8 +1295,13 @@ void CVertexArrayRangeARB::updateLostBuffers()
{ {
nlassert((*it)->_VertexObjectId); nlassert((*it)->_VertexObjectId);
GLuint id = (GLuint) (*it)->_VertexObjectId; GLuint id = (GLuint) (*it)->_VertexObjectId;
#ifdef USE_OPENGLES
nlassert(glIsBuffer(id));
glDeleteBuffers(1, &id);
#else
nlassert(nglIsBufferARB(id)); nlassert(nglIsBufferARB(id));
nglDeleteBuffersARB(1, &id); nglDeleteBuffersARB(1, &id);
#endif
(*it)->_VertexObjectId = 0; (*it)->_VertexObjectId = 0;
(*it)->VB->setLocation(CVertexBuffer::NotResident); (*it)->VB->setLocation(CVertexBuffer::NotResident);
} }
@ -1300,6 +1328,12 @@ CVertexBufferHardARB::CVertexBufferHardARB(CDriverGL *drv, CVertexBuffer *vb) :
#ifdef NL_DEBUG #ifdef NL_DEBUG
_Unmapping = false; _Unmapping = false;
#endif #endif
#ifdef USE_OPENGLES
_Buffer = NULL;
_BufferSize = 0;
_LastBufferSize = 0;
#endif
} }
// *************************************************************************** // ***************************************************************************
@ -1316,8 +1350,13 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
if (_VertexObjectId) if (_VertexObjectId)
{ {
GLuint id = (GLuint) _VertexObjectId; GLuint id = (GLuint) _VertexObjectId;
#ifdef USE_OPENGLES
nlassert(glIsBuffer(id));
glDeleteBuffers(1, &id);
#else
nlassert(nglIsBufferARB(id)); nlassert(nglIsBufferARB(id));
nglDeleteBuffersARB(1, &id); nglDeleteBuffersARB(1, &id);
#endif
} }
if (_VertexArrayRange) if (_VertexArrayRange)
{ {
@ -1336,12 +1375,21 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
_VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList); _VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList);
} }
#endif #endif
#ifdef USE_OPENGLES
if (_Buffer)
{
delete [] _Buffer;
_Buffer = NULL;
}
#endif
} }
// *************************************************************************** // ***************************************************************************
void *CVertexBufferHardARB::lock() void *CVertexBufferHardARB::lock()
{ {
H_AUTO_OGL(CVertexBufferHardARB_lock) H_AUTO_OGL(CVertexBufferHardARB_lock);
if (_VertexPtr) return _VertexPtr; // already locked if (_VertexPtr) return _VertexPtr; // already locked
if (_Invalid) if (_Invalid)
{ {
@ -1352,7 +1400,13 @@ void *CVertexBufferHardARB::lock()
} }
// recreate a vb // recreate a vb
GLuint vertexBufferID; GLuint vertexBufferID;
#ifdef USE_OPENGLES
glGenBuffers(1, &vertexBufferID);
#else
nglGenBuffersARB(1, &vertexBufferID); nglGenBuffersARB(1, &vertexBufferID);
#endif
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
_Driver->incrementResetCounter(); _Driver->incrementResetCounter();
@ -1363,13 +1417,25 @@ void *CVertexBufferHardARB::lock()
switch(_MemType) switch(_MemType)
{ {
case CVertexBuffer::AGPPreferred: case CVertexBuffer::AGPPreferred:
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
#endif
break; break;
case CVertexBuffer::StaticPreferred: case CVertexBuffer::StaticPreferred:
if (_Driver->getStaticMemoryToVRAM()) if (_Driver->getStaticMemoryToVRAM())
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_STATIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB);
#endif
else else
#ifdef USE_OPENGLES
glBufferData(GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW);
#else
nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB); nglBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB);
#endif
break; break;
default: default:
nlassert(0); nlassert(0);
@ -1378,7 +1444,11 @@ void *CVertexBufferHardARB::lock()
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
_Driver->incrementResetCounter(); _Driver->incrementResetCounter();
#ifdef USE_OPENGLES
glDeleteBuffers(1, &vertexBufferID);
#else
nglDeleteBuffersARB(1, &vertexBufferID); nglDeleteBuffersARB(1, &vertexBufferID);
#endif
return &_DummyVB[0];; return &_DummyVB[0];;
} }
_VertexObjectId = vertexBufferID; _VertexObjectId = vertexBufferID;
@ -1394,6 +1464,39 @@ void *CVertexBufferHardARB::lock()
beforeLock= CTime::getPerformanceTime(); beforeLock= CTime::getPerformanceTime();
} }
_Driver->_DriverGLStates.bindARBVertexBuffer(_VertexObjectId); _Driver->_DriverGLStates.bindARBVertexBuffer(_VertexObjectId);
#ifdef USE_OPENGLES
if (_Driver->_Extensions.OESMapBuffer)
{
_VertexPtr = nglMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES);
if (!_VertexPtr)
{
nglUnmapBufferOES(GL_ARRAY_BUFFER);
nlassert(glIsBuffer(_VertexObjectId));
invalidate();
return &_DummyVB[0];
}
}
else
{
const uint size = VB->getNumVertices() * VB->getVertexSize();
if (size > _BufferSize)
{
if (_Buffer) delete [] _Buffer;
_Buffer = new uint8[size+3];
_BufferSize = size;
}
uint8 offset = (size_t)_Buffer % 4;
if (offset > 0) offset = 4 - offset;
_VertexPtr = _Buffer + offset;
_LastBufferSize = size;
}
#else
_VertexPtr = nglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); _VertexPtr = nglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
if (!_VertexPtr) if (!_VertexPtr)
{ {
@ -1402,6 +1505,8 @@ void *CVertexBufferHardARB::lock()
invalidate(); invalidate();
return &_DummyVB[0]; return &_DummyVB[0];
} }
#endif
#ifdef NL_DEBUG #ifdef NL_DEBUG
_VertexArrayRange->_MappedVBList.push_front(this); _VertexArrayRange->_MappedVBList.push_front(this);
_IteratorInMappedVBList = _VertexArrayRange->_MappedVBList.begin(); _IteratorInMappedVBList = _VertexArrayRange->_MappedVBList.begin();
@ -1420,7 +1525,8 @@ void *CVertexBufferHardARB::lock()
// *************************************************************************** // ***************************************************************************
void CVertexBufferHardARB::unlock() void CVertexBufferHardARB::unlock()
{ {
H_AUTO_OGL(CVertexBufferHardARB_unlock) H_AUTO_OGL(CVertexBufferHardARB_unlock);
_VertexPtr = NULL; _VertexPtr = NULL;
if (_Invalid) return; if (_Invalid) return;
if (!_VertexObjectId) return; if (!_VertexObjectId) return;
@ -1434,7 +1540,17 @@ void CVertexBufferHardARB::unlock()
#ifdef NL_DEBUG #ifdef NL_DEBUG
_Unmapping = true; _Unmapping = true;
#endif #endif
GLboolean unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); GLboolean unmapOk = false;
#ifdef USE_OPENGLES
if (_Driver->_Extensions.OESMapBuffer)
{
unmapOk = nglUnmapBufferOES(GL_ARRAY_BUFFER);
}
#else
unmapOk = nglUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
#endif
#ifdef NL_DEBUG #ifdef NL_DEBUG
_Unmapping = false; _Unmapping = false;
#endif #endif

View file

@ -113,7 +113,7 @@ protected:
bool _Invalid; bool _Invalid;
}; };
#ifndef USE_OPENGLES
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************
@ -456,6 +456,8 @@ public:
#endif #endif
}; };
#endif
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************
// ARB_vertex_buffer_object implementation // ARB_vertex_buffer_object implementation
@ -553,6 +555,11 @@ private:
CVertexArrayRangeARB *_VertexArrayRange; CVertexArrayRangeARB *_VertexArrayRange;
CVertexBuffer::TPreferredMemory _MemType; CVertexBuffer::TPreferredMemory _MemType;
void *_VertexPtr; // pointer on current datas. Null if not locked void *_VertexPtr; // pointer on current datas. Null if not locked
#ifdef USE_OPENGLES
uint8 *_Buffer;
uint32 _BufferSize;
uint32 _LastBufferSize;
#endif
// if buffer has been invalidated, returns a dummy memory block and silently fails rendering // if buffer has been invalidated, returns a dummy memory block and silently fails rendering
std::vector<uint8> _DummyVB; std::vector<uint8> _DummyVB;
// for use by CVertexArrayRangeARB // for use by CVertexArrayRangeARB

View file

@ -111,7 +111,7 @@ bool CDriverGL::activeNVVertexProgram (CVertexProgram *program)
} }
// Insert into driver list. (so it is deleted when driver is deleted). // Insert into driver list. (so it is deleted when driver is deleted).
ItVtxPrgDrvInfoPtrList it= _VtxPrgDrvInfos.insert(_VtxPrgDrvInfos.end(), NULL); ItVtxPrgDrvInfoPtrList it= _VtxPrgDrvInfos.insert(_VtxPrgDrvInfos.end(), (NL3D::IVertexProgramDrvInfos*)NULL);
// Create a driver info // Create a driver info
*it = drvInfo = new CVertexProgamDrvInfosGL (this, it); *it = drvInfo = new CVertexProgamDrvInfosGL (this, it);
@ -309,7 +309,7 @@ static uint convInputRegisterToVBFlag(uint index)
// For debugging with swizzling // For debugging with swizzling
static void doSwizzle(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW) static void doSwizzle(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW)
{ {
H_AUTO_OGL(doSwizzle) H_AUTO_OGL(doSwizzle);
nglSwizzleEXT(res, in, outX, outY, outZ, outW); nglSwizzleEXT(res, in, outX, outY, outZ, outW);
#ifdef DEBUG_SETUP_EXT_VERTEX_SHADER #ifdef DEBUG_SETUP_EXT_VERTEX_SHADER
std::string swzStr = "Swizzle : "; std::string swzStr = "Swizzle : ";
@ -359,7 +359,7 @@ static void doSwizzle(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum ou
// Perform write mask and output de bug information // Perform write mask and output de bug information
static void doWriteMask(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW) static void doWriteMask(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW)
{ {
H_AUTO_OGL(doWriteMask) H_AUTO_OGL(doWriteMask);
nglWriteMaskEXT(res, in, outX, outY, outZ, outW); nglWriteMaskEXT(res, in, outX, outY, outZ, outW);
#ifdef DEBUG_SETUP_EXT_VERTEX_SHADER #ifdef DEBUG_SETUP_EXT_VERTEX_SHADER
nlinfo("3D: Write Mask : %c%c%c%c", nlinfo("3D: Write Mask : %c%c%c%c",
@ -376,7 +376,7 @@ static void doWriteMask(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum
*/ */
bool CDriverGL::setupEXTVertexShader(const CVPParser::TProgram &program, GLuint id, uint variants[EVSNumVariants], uint16 &usedInputRegisters) bool CDriverGL::setupEXTVertexShader(const CVPParser::TProgram &program, GLuint id, uint variants[EVSNumVariants], uint16 &usedInputRegisters)
{ {
H_AUTO_OGL(CDriverGL_setupEXTVertexShader) H_AUTO_OGL(CDriverGL_setupEXTVertexShader);
// counter to see what is generated // counter to see what is generated
uint numOp = 0; uint numOp = 0;
uint numOpIndex = 0; uint numOpIndex = 0;
@ -1440,6 +1440,14 @@ bool CDriverGL::setupARBVertexProgram (const CVPParser::TProgram &inParsedProgra
nlassert(0); nlassert(0);
return false; return false;
} }
#ifdef NL_OS_MAC
// Wait for GPU to finish program upload, else draw comands might crash.
// Happened to CVegetableBlendLayerModel (glDrawElements()).
// For more information, see http://dev.ryzom.com/issues/1006
glFinish();
#endif
return true; return true;
} }
@ -1472,7 +1480,7 @@ bool CDriverGL::activeARBVertexProgram (CVertexProgram *program)
return false; return false;
} }
// Insert into driver list. (so it is deleted when driver is deleted). // Insert into driver list. (so it is deleted when driver is deleted).
ItVtxPrgDrvInfoPtrList it= _VtxPrgDrvInfos.insert(_VtxPrgDrvInfos.end(), NULL); ItVtxPrgDrvInfoPtrList it= _VtxPrgDrvInfos.insert(_VtxPrgDrvInfos.end(), (NL3D::IVertexProgramDrvInfos*)NULL);
// Create a driver info // Create a driver info
*it = drvInfo = new CVertexProgamDrvInfosGL (this, it); *it = drvInfo = new CVertexProgamDrvInfosGL (this, it);
@ -1554,7 +1562,7 @@ bool CDriverGL::activeEXTVertexShader (CVertexProgram *program)
*/ */
// Insert into driver list. (so it is deleted when driver is deleted). // Insert into driver list. (so it is deleted when driver is deleted).
ItVtxPrgDrvInfoPtrList it= _VtxPrgDrvInfos.insert(_VtxPrgDrvInfos.end(), NULL); ItVtxPrgDrvInfoPtrList it= _VtxPrgDrvInfos.insert(_VtxPrgDrvInfos.end(), (NL3D::IVertexProgramDrvInfos*)NULL);
// Create a driver info // Create a driver info
*it = drvInfo = new CVertexProgamDrvInfosGL (this, it); *it = drvInfo = new CVertexProgamDrvInfosGL (this, it);

View file

@ -188,6 +188,9 @@ bool GlWndProc(CDriverGL *driver, const void* e)
static Atom XA_WM_STATE = 0; static Atom XA_WM_STATE = 0;
static Atom XA_WM_STATE_FULLSCREEN = 0; static Atom XA_WM_STATE_FULLSCREEN = 0;
static Atom XA_WM_ICON = 0; static Atom XA_WM_ICON = 0;
static Atom XA_WM_WINDOW_TYPE = 0;
static Atom XA_WM_WINDOW_TYPE_NORMAL = 0;
static Atom XA_FRAME_EXTENTS = 0;
sint nelXErrorsHandler(Display *dpy, XErrorEvent *e) sint nelXErrorsHandler(Display *dpy, XErrorEvent *e)
{ {
@ -233,7 +236,7 @@ bool GlWndProc(CDriverGL *driver, XEvent &e)
break; break;
case Expose: case Expose:
nlwarning("Expose event"); // nlwarning("Expose event");
break; break;
case ConfigureNotify: case ConfigureNotify:
@ -243,20 +246,36 @@ bool GlWndProc(CDriverGL *driver, XEvent &e)
// first time setting decoration sizes // first time setting decoration sizes
if ((driver->_DecorationWidth == -1) || (driver->_DecorationWidth == 0)) if ((driver->_DecorationWidth == -1) || (driver->_DecorationWidth == 0))
{ {
driver->_DecorationWidth = e.xconfigure.x - driver->_WindowX; Atom type_return = 0;
driver->_DecorationHeight = e.xconfigure.y - driver->_WindowY; int format_return = 0;
unsigned long nitems_return = 0;
unsigned long bytes_after_return = 0;
long *data = NULL;
nlwarning("Decoration size x = %d, y = %d", driver->_DecorationWidth, driver->_DecorationHeight); int status = XGetWindowProperty(driver->_dpy, driver->_win, XA_FRAME_EXTENTS, 0, 4, False, XA_CARDINAL, &type_return, &format_return, &nitems_return, &bytes_after_return, (unsigned char**)&data);
// succeeded to retrieve decoration size
if (status == Success && type_return == XA_CARDINAL && format_return == 32 && nitems_return == 4 && data)
{
driver->_DecorationWidth = data[0];
driver->_DecorationHeight = data[2];
}
else
{
// use difference between current position and previous one (set by application)
driver->_DecorationWidth = e.xconfigure.x - driver->_WindowX;
driver->_DecorationHeight = e.xconfigure.y - driver->_WindowY;
}
// don't allow negative decoration sizes
if (driver->_DecorationWidth < 0) driver->_DecorationWidth = 0;
if (driver->_DecorationHeight < 0) driver->_DecorationHeight = 0;
} }
driver->_CurrentMode.Width = e.xconfigure.width; driver->_CurrentMode.Width = e.xconfigure.width;
driver->_CurrentMode.Height = e.xconfigure.height; driver->_CurrentMode.Height = e.xconfigure.height;
driver->_WindowX = e.xconfigure.x - driver->_DecorationWidth; driver->_WindowX = e.xconfigure.x - driver->_DecorationWidth;
driver->_WindowY = e.xconfigure.y - driver->_DecorationHeight; driver->_WindowY = e.xconfigure.y - driver->_DecorationHeight;
XConfigureEvent event = e.xconfigure;
nlwarning("Configure x = %d, y = %d, width = %d, height = %d, send event = %d", event.x, event.y, event.width, event.height, event.send_event);
} }
break; break;
@ -374,18 +393,25 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc)
} }
#endif // HAVE_XRENDER #endif // HAVE_XRENDER
// list all supported extensions nldebug("3D: Available X Extensions:");
sint nextensions = 0;
char **extensions = XListExtensions(_dpy, &nextensions);
std::string exts; if (DebugLog)
{
// list all supported extensions
sint nextensions = 0;
char **extensions = XListExtensions(_dpy, &nextensions);
for(sint i = 0; i < nextensions; ++i) for(sint i = 0; i < nextensions; ++i)
exts += NLMISC::toString(" %s", extensions[i]); {
if(i%5==0) DebugLog->displayRaw("3D: ");
DebugLog->displayRaw(NLMISC::toString("%s ", extensions[i]).c_str());
if(i%5==4) DebugLog->displayRaw("\n");
}
XFreeExtensionList(extensions); DebugLog->displayRaw("\n");
nlinfo("X Extensions:%s", exts.c_str()); XFreeExtensionList(extensions);
}
// set default X errors handler // set default X errors handler
XSetErrorHandler(nelXErrorsHandler); XSetErrorHandler(nelXErrorsHandler);
@ -394,6 +420,9 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc)
XA_WM_STATE = XInternAtom(_dpy, "_NET_WM_STATE", False); XA_WM_STATE = XInternAtom(_dpy, "_NET_WM_STATE", False);
XA_WM_STATE_FULLSCREEN = XInternAtom(_dpy, "_NET_WM_STATE_FULLSCREEN", False); XA_WM_STATE_FULLSCREEN = XInternAtom(_dpy, "_NET_WM_STATE_FULLSCREEN", False);
XA_WM_ICON = XInternAtom(_dpy, "_NET_WM_ICON", False); XA_WM_ICON = XInternAtom(_dpy, "_NET_WM_ICON", False);
XA_WM_WINDOW_TYPE = XInternAtom(_dpy, "_NET_WM_WINDOW_TYPE", False);
XA_WM_WINDOW_TYPE_NORMAL = XInternAtom(_dpy, "_NET_WM_WINDOW_TYPE_NORMAL", False);
XA_FRAME_EXTENTS = XInternAtom(_dpy, "_NET_FRAME_EXTENTS", False);
#endif #endif
@ -906,7 +935,6 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
_hRC=wglCreateContext(_hDC); _hRC=wglCreateContext(_hDC);
wglMakeCurrent(_hDC,_hRC); wglMakeCurrent(_hDC,_hRC);
} }
/// release old emitter /// release old emitter
@ -929,7 +957,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
_EventEmitter.addEmitter(diee, true); _EventEmitter.addEmitter(diee, true);
} }
} }
catch(EDirectInput &e) catch(const EDirectInput &e)
{ {
nlinfo(e.what()); nlinfo(e.what());
} }
@ -1522,6 +1550,42 @@ bool CDriverGL::createWindow(const GfxMode &mode)
return false; return false;
} }
// normal window type
XChangeProperty(_dpy, window, XA_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (const unsigned char*)&XA_WM_WINDOW_TYPE_NORMAL, 1);
// set WM hints
XWMHints *wm_hints = XAllocWMHints();
if (wm_hints)
{
wm_hints->flags = StateHint | InputHint;
wm_hints->initial_state = NormalState;
wm_hints->input = True;
XSetWMHints(_dpy, window, wm_hints);
XFree(wm_hints);
}
else
{
nlwarning("3D: Couldn't allocate XWMHints");
}
// set class hints
XClassHint *class_hints = XAllocClassHint();
if (class_hints)
{
class_hints->res_name = (char*)"NeL";
class_hints->res_class = (char*)"nel";
XSetClassHint(_dpy, window, class_hints);
XFree(class_hints);
}
else
{
nlwarning("3D: Couldn't allocate XClassHint");
}
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
_win = window; _win = window;
@ -1577,7 +1641,7 @@ bool CDriverGL::destroyWindow()
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
if(_DestroyWindow) if (_DestroyWindow)
{ {
[[containerView() window] release]; [[containerView() window] release];
[containerView() release]; [containerView() release];
@ -2195,11 +2259,19 @@ void CDriverGL::setWindowTitle(const ucstring &title)
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
// UTF8 properties
Xutf8SetWMProperties (_dpy, _win, (char*)title.toUtf8().c_str(), (char*)title.toUtf8().c_str(), NULL, 0, NULL, NULL, NULL); Xutf8SetWMProperties (_dpy, _win, (char*)title.toUtf8().c_str(), (char*)title.toUtf8().c_str(), NULL, 0, NULL, NULL, NULL);
#else #else
// standard properties
XTextProperty text_property; XTextProperty text_property;
XStringListToTextProperty((char**)&title.toUtf8().c_str(), 1, &text_property); if (XStringListToTextProperty((char**)&title.toUtf8().c_str(), 1, &text_property) != 0)
XSetWMProperties (_dpy, _win, &text_property, &text_property, 0, 0, NULL, 0, 0); {
XSetWMProperties (_dpy, _win, &text_property, &text_property, NULL, 0, NULL, NULL, NULL);
}
else
{
nlwarning("3D: Can't convert title to TextProperty");
}
#endif #endif
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
@ -2297,7 +2369,7 @@ emptyProc CDriverGL::getWindowProc()
// -------------------------------------------------- // --------------------------------------------------
bool CDriverGL::activate() bool CDriverGL::activate()
{ {
H_AUTO_OGL(CDriverGL_activate) H_AUTO_OGL(CDriverGL_activate);
if (_win == EmptyWindow) if (_win == EmptyWindow)
return false; return false;
@ -2376,11 +2448,15 @@ void CDriverGL::getWindowSize(uint32 &width, uint32 &height)
if (_CurrentMode.OffScreen) if (_CurrentMode.OffScreen)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
#ifndef USE_OPENGLES
if (_PBuffer) if (_PBuffer)
{ {
nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width ); nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width );
nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height ); nwglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height );
} }
#endif
#endif #endif
} }
else else

View file

@ -149,14 +149,28 @@ static NLMISC::TKey virtualKeycodeToNelKey(unsigned short keycode)
bool CCocoaEventEmitter::pasteTextFromClipboard(ucstring &text) bool CCocoaEventEmitter::pasteTextFromClipboard(ucstring &text)
{ {
#warning "OpenGL Driver: Missing Mac Implementation for pasteTextFromClipboard" NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
NSDictionary *options = [NSDictionary dictionary];
BOOL ok = [pasteboard canReadObjectForClasses:classArray options:options];
if (ok)
{
NSArray *objectsToPaste = [pasteboard readObjectsForClasses:classArray options:options];
NSString *nstext = [objectsToPaste objectAtIndex:0];
text.fromUtf8([nstext UTF8String]);
return true;
}
return false; return false;
} }
bool CCocoaEventEmitter::copyTextToClipboard(const ucstring &text) bool CCocoaEventEmitter::copyTextToClipboard(const ucstring &text)
{ {
#warning "OpenGL Driver: Missing Mac Implementation for copyTextToClipboard" NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
return false; [pasteboard clearContents];
NSArray *copiedObjects = [NSArray arrayWithObject:[NSString stringWithUTF8String:text.toUtf8().c_str()]];
[pasteboard writeObjects:copiedObjects];
return true;
} }
/// convert modifier key state to nel internal modifier key state /// convert modifier key state to nel internal modifier key state
@ -359,7 +373,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
// push the key press event to the event server // push the key press event to the event server
server->postEvent(new NLMISC::CEventKeyDown( server->postEvent(new NLMISC::CEventKeyDown(
virtualKeycodeToNelKey([event keyCode]), virtualKeycodeToNelKey([event keyCode]),
modifierFlagsToNelKeyButton([event modifierFlags]), modifiers,
[event isARepeat] == NO, this)); [event isARepeat] == NO, this));
// if this was a text event // if this was a text event
@ -372,7 +386,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
// push the text event to event server as well // push the text event to event server as well
server->postEvent(new NLMISC::CEventChar( server->postEvent(new NLMISC::CEventChar(
ucstr[0], NLMISC::noKeyButton, this)); ucstr[0], modifiers, this));
} }
break; break;
} }
@ -381,7 +395,7 @@ bool CCocoaEventEmitter::processMessage(NSEvent* event, CEventServer* server)
// push the key release event to the event server // push the key release event to the event server
server->postEvent(new NLMISC::CEventKeyUp( server->postEvent(new NLMISC::CEventKeyUp(
virtualKeycodeToNelKey([event keyCode]), virtualKeycodeToNelKey([event keyCode]),
modifierFlagsToNelKeyButton([event modifierFlags]), this)); modifiers, this));
break; break;
} }
case NSFlagsChanged:break; case NSFlagsChanged:break;

View file

@ -4851,8 +4851,10 @@ typedef ptrdiff_t GLsizeiptrARB;
#ifndef GL_ARB_shader_objects #ifndef GL_ARB_shader_objects
/* GL types for program/shader text and shader object handles */ /* GL types for program/shader text and shader object handles */
typedef char GLcharARB; typedef char GLcharARB;
#if !defined(MAC_OS_X_VERSION_10_7)
typedef unsigned int GLhandleARB; typedef unsigned int GLhandleARB;
#endif #endif
#endif
/* GL type for "half" precision (s10e5) float data in host memory */ /* GL type for "half" precision (s10e5) float data in host memory */
#ifndef GL_ARB_half_float_pixel #ifndef GL_ARB_half_float_pixel

View file

@ -1746,7 +1746,7 @@ void CDriverUser::loadHLSBank(const std::string &fileName)
throw EPathNotFound(path); throw EPathNotFound(path);
fIn.serial(*hlsBank); fIn.serial(*hlsBank);
} }
catch(Exception &) catch(const Exception &)
{ {
delete hlsBank; delete hlsBank;
throw; throw;

View file

@ -109,7 +109,7 @@ CRGBA CFastHLSModifier::convert(uint H, uint L, uint S)
return col; return col;
} }
#if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) #if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# pragma warning( push ) # pragma warning( push )
# pragma warning( disable : 4799 ) # pragma warning( disable : 4799 )
#endif #endif
@ -262,7 +262,7 @@ uint16 CFastHLSModifier::applyHLSMod(uint16 colorIn, uint8 dHue, uint dLum, uin
#pragma managed(pop) #pragma managed(pop)
#endif #endif
#if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) #if defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10)
# pragma warning( pop ) # pragma warning( pop )
#endif #endif

View file

@ -121,7 +121,7 @@ bool CInstanceGroupUser::init (const std::string &instanceGroup, bool async)
// Read the class // Read the class
_InstanceGroup.serial (file); _InstanceGroup.serial (file);
} }
catch (EStream& e) catch (const EStream& e)
{ {
// Avoid visual warning // Avoid visual warning
EStream ee=e; EStream ee=e;

View file

@ -283,7 +283,7 @@ void CLandscapeUser::refreshZonesAround(const CVector &pos, float radius, std::s
{ {
_Landscape->Landscape.checkBinds(Work.Zone->getZoneId()); _Landscape->Landscape.checkBinds(Work.Zone->getZoneId());
} }
catch (EBadBind &e) catch (const EBadBind &e)
{ {
nlwarning ("Bind error : %s", e.what()); nlwarning ("Bind error : %s", e.what());
nlstopex(("Zone Data Bind Error. Please send a report. You may continue but it should crash!")); nlstopex(("Zone Data Bind Error. Please send a report. You may continue but it should crash!"));

View file

@ -1867,7 +1867,7 @@ void CMeshMRMSkinnedGeom::updateRawSkinNormal(bool enabled, CMeshMRMSkinnedInst
CIndexBufferReadWrite ibaWrite; CIndexBufferReadWrite ibaWrite;
skinLod.RdrPass[i].lock (ibaWrite); skinLod.RdrPass[i].lock (ibaWrite);
#ifndef NL_SKINNED_MESH_MRM_INDEX16 #ifndef NL_SKINNED_MESH_MRM_INDEX16
nlassert(ibaWrite.getFormat() == CIndexBuffer::Indices32) nlassert(ibaWrite.getFormat() == CIndexBuffer::Indices32);
uint32 *dstTriPtr= (uint32 *) ibaWrite.getPtr(); uint32 *dstTriPtr= (uint32 *) ibaWrite.getPtr();
uint32 numIndices= lod.RdrPass[i].PBlock.size(); uint32 numIndices= lod.RdrPass[i].PBlock.size();
for(uint j=0;j<numIndices;j++, srcTriPtr++, dstTriPtr++) for(uint j=0;j<numIndices;j++, srcTriPtr++, dstTriPtr++)

View file

@ -29,6 +29,7 @@
#include "nel/misc/bit_mem_stream.h" #include "nel/misc/bit_mem_stream.h"
// //
#include <limits> #include <limits>
#include <iterator>
// //

View file

@ -1291,7 +1291,7 @@ bool CPSConstraintMesh::update(std::vector<sint> *numVertsVect /*= NULL*/)
{ {
_ModelBank->load(_MeshShapeFileName[k]); _ModelBank->load(_MeshShapeFileName[k]);
} }
catch (NLMISC::EPathNotFound &) catch (const NLMISC::EPathNotFound &)
{ {
nlwarning("mesh not found : %s; used as a constraint mesh particle", _MeshShapeFileName[k].c_str()); nlwarning("mesh not found : %s; used as a constraint mesh particle", _MeshShapeFileName[k].c_str());
// shape not found, so not present in the shape bank -> we create a dummy shape // shape not found, so not present in the shape bank -> we create a dummy shape
@ -2083,8 +2083,9 @@ static void DuplicatePrimitiveBlock(const CIndexBuffer &srcBlock, CIndexBuffer &
CIndexBufferReadWrite ibaWrite; CIndexBufferReadWrite ibaWrite;
destBlock.lock (ibaWrite); destBlock.lock (ibaWrite);
#ifdef NL_FORCE_INDEX_BUFFER_16
nlassert(destBlock.getFormat() == CIndexBuffer::Indices16); nlassert(destBlock.getFormat() == CIndexBuffer::Indices16);
#endif
// TMP TMP TMP // TMP TMP TMP
if (ibaRead.getFormat() == CIndexBuffer::Indices16) if (ibaRead.getFormat() == CIndexBuffer::Indices16)

View file

@ -93,7 +93,7 @@ bool CShader::loadShaderFile (const char *filename)
nlwarning ("Can't open the file %s for reading", _filename.c_str()); nlwarning ("Can't open the file %s for reading", _filename.c_str());
} }
} }
catch (Exception &e) catch (const Exception &e)
{ {
nlwarning ("Error while reading %s : %s", _filename.c_str(), e.what()); nlwarning ("Error while reading %s : %s", _filename.c_str(), e.what());
} }

View file

@ -50,12 +50,12 @@ static inline void GetTextureSize(ITexture *tex, uint &width, uint &height)
width = srcWidth; width = srcWidth;
height = srcHeight; height = srcHeight;
} }
catch (NLMISC::EPathNotFound &e) catch (const NLMISC::EPathNotFound &e)
{ {
nlinfo("%s", e.what()); nlinfo("%s", e.what());
width = height = 0; width = height = 0;
} }
catch (NLMISC::EStream &e) catch (const NLMISC::EStream &e)
{ {
nlinfo("unable to load size from a bitmap ! name = %s", tf->getFileName().c_str()); nlinfo("unable to load size from a bitmap ! name = %s", tf->getFileName().c_str());
nlinfo("reason = %s", e.what()); nlinfo("reason = %s", e.what());

View file

@ -1573,7 +1573,7 @@ void CTileSet::loadTileVegetableDesc()
// load the TileVegetableDesc // load the TileVegetableDesc
f.serial(_TileVegetableDesc); f.serial(_TileVegetableDesc);
} }
catch(Exception &e) catch(const Exception &e)
{ {
nlinfo("Error loading TileVegetableDesc: %s", e.what()); nlinfo("Error loading TileVegetableDesc: %s", e.what());
} }

View file

@ -816,7 +816,7 @@ CVegetableShape *CVegetableManager::getVegetableShape(const std::string &shap
ret = NULL; ret = NULL;
} }
} }
catch (Exception &e) catch (const Exception &e)
{ {
// Warning // Warning
nlwarning ("CVegetableManager::getVegetableShape error while loading shape file '%s' : '%s'", shape.c_str (), e.what ()); nlwarning ("CVegetableManager::getVegetableShape error while loading shape file '%s' : '%s'", shape.c_str (), e.what ());

View file

@ -844,7 +844,7 @@ void SaveZBuffer (CZoneLighter::CZBuffer &zbuffer, const char *filename)
// Save it // Save it
bitmap.writeJPG (outputZFile, 128); bitmap.writeJPG (outputZFile, 128);
} }
catch (Exception& except) catch (const Exception& except)
{ {
// Error message // Error message
nlwarning ("ERROR writing %s: %s\n", filename, except.what()); nlwarning ("ERROR writing %s: %s\n", filename, except.what());
@ -3080,13 +3080,13 @@ void CZoneLighter::lightWater(CWaterShape &ws, const CMatrix &MT, const CLightDe
diffuseTex->writeTGA(of, 24); diffuseTex->writeTGA(of, 24);
of.close(); of.close();
} }
catch (NLMISC::Exception &) catch (const NLMISC::Exception &)
{ {
nlwarning("Zone lighter : while lighting a water shape, writing %s failed! ", texFileName.c_str()); nlwarning("Zone lighter : while lighting a water shape, writing %s failed! ", texFileName.c_str());
} }
} }
} }
catch(NLMISC::Exception &e) catch(const NLMISC::Exception &e)
{ {
nlwarning("Water shape lighting failed !"); nlwarning("Water shape lighting failed !");
nlwarning(e.what()); nlwarning(e.what());

View file

@ -11,4 +11,6 @@ NL_ADD_LIB_SUFFIX(nelceguirenderer)
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DNEL_CEGUIRENDERER_EXPORTS) ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DNEL_CEGUIRENDERER_EXPORTS)
INSTALL(TARGETS nelceguirenderer RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
INSTALL(TARGETS nelceguirenderer RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)

View file

@ -21,4 +21,7 @@ IF(WITH_PCH)
ENDIF(WITH_PCH) ENDIF(WITH_PCH)
NL_GEN_PC(nel-georges.pc) NL_GEN_PC(nel-georges.pc)
INSTALL(TARGETS nelgeorges LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
INSTALL(TARGETS nelgeorges LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)

View file

@ -233,6 +233,7 @@ const CType* CFormElm::getType ()
warning (false, "getType", "This node is not an atom."); warning (false, "getType", "This node is not an atom.");
return 0; return 0;
} }
// *************************************************************************** // ***************************************************************************
bool CFormElm::getValue (string &/* result */, TEval /* evaluate */) const bool CFormElm::getValue (string &/* result */, TEval /* evaluate */) const

View file

@ -105,7 +105,7 @@ CType *CFormLoader::loadType (const char *filename)
type = NULL; type = NULL;
} }
} }
catch (Exception &e) catch (const Exception &e)
{ {
// Output error // Output error
warning (false, "loadType", "Error while loading the form (%s): %s", filename, e.what()); warning (false, "loadType", "Error while loading the form (%s): %s", filename, e.what());
@ -179,7 +179,7 @@ CFormDfn *CFormLoader::loadFormDfn (const char *filename, bool forceLoad)
_MapFormDfn.erase (lowerStr); _MapFormDfn.erase (lowerStr);
} }
} }
catch (Exception &e) catch (const Exception &e)
{ {
// Output error // Output error
warning (false, "loadFormDfn", "Error while loading the form (%s): %s", filename, e.what()); warning (false, "loadFormDfn", "Error while loading the form (%s): %s", filename, e.what());
@ -276,7 +276,7 @@ UForm *CFormLoader::loadForm (const char *filename)
_MapForm.erase (lowerStr); _MapForm.erase (lowerStr);
} }
} }
catch (Exception &e) catch (const Exception &e)
{ {
// Output error // Output error
warning (false, "loadForm", "Error while loading the form (%s): %s", filename, e.what()); warning (false, "loadForm", "Error while loading the form (%s): %s", filename, e.what());

View file

@ -19,4 +19,7 @@ IF(WITH_PCH)
ENDIF(WITH_PCH) ENDIF(WITH_PCH)
NL_GEN_PC(nel-ligo.pc) NL_GEN_PC(nel-ligo.pc)
INSTALL(TARGETS nelligo LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
INSTALL(TARGETS nelligo LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)

View file

@ -220,7 +220,7 @@ bool CLigoConfig::readPrimitiveClass (const char *_fileName, bool parsePrimitive
syntaxError (filename.c_str(), root, "Wrong root node, should be NEL_LIGO_PRIMITIVE_CLASS"); syntaxError (filename.c_str(), root, "Wrong root node, should be NEL_LIGO_PRIMITIVE_CLASS");
} }
} }
catch (Exception &e) catch (const Exception &e)
{ {
errorMessage ("File read error (%s):%s", filename.c_str(), e.what ()); errorMessage ("File read error (%s):%s", filename.c_str(), e.what ());
} }

View file

@ -146,7 +146,7 @@ void CZoneBank::debugSaveInit (CZoneBankElement &zbeTmp, const string &fileName)
output.init (&fileOut); output.init (&fileOut);
zbeTmp.serial (output); zbeTmp.serial (output);
} }
catch (Exception& /*e*/) catch (const Exception& /*e*/)
{ {
} }
@ -541,7 +541,7 @@ bool CZoneBank::addElement (const std::string &elementName, std::string &error)
error = "Can't open file " + elementName; error = "Can't open file " + elementName;
} }
} }
catch (Exception& e) catch (const Exception& e)
{ {
error = "Error while loading ligozone "+elementName+" : "+e.what(); error = "Error while loading ligozone "+elementName+" : "+e.what();
} }

View file

@ -14,4 +14,6 @@ NL_ADD_LIB_SUFFIX(nellogic)
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
INSTALL(TARGETS nellogic LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries) IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
INSTALL(TARGETS nellogic LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)

View file

@ -53,4 +53,7 @@ IF(WITH_PCH)
ENDIF(WITH_PCH) ENDIF(WITH_PCH)
NL_GEN_PC(nel-misc.pc) NL_GEN_PC(nel-misc.pc)
INSTALL(TARGETS nelmisc LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
INSTALL(TARGETS nelmisc LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)

View file

@ -188,7 +188,7 @@ bool ICommand::execute (const std::string &commandWithArgs, CLog &log, bool quie
{ {
return CCommandRegistry::getInstance().execute(commandWithArgs, log, quiet, human); return CCommandRegistry::getInstance().execute(commandWithArgs, log, quiet, human);
} }
catch(exception e) catch(const exception &e)
{ {
log.displayNL("Command '%s' thrown an exception :", commandWithArgs.c_str()); log.displayNL("Command '%s' thrown an exception :", commandWithArgs.c_str());
log.displayNL(e.what()); log.displayNL(e.what());

View file

@ -27,7 +27,10 @@ using namespace NLMISC;
#define YY_NEVER_INTERACTIVE 1 #define YY_NEVER_INTERACTIVE 1
#ifdef WIN32 #ifdef WIN32
#define YY_NO_UNISTD_H 1
#include <io.h>
#define read _read #define read _read
#define isatty _isatty
#endif #endif
/* Types */ /* Types */
@ -122,6 +125,12 @@ string \"[^\"\n]*\"
if (!cf_Ignore) if (!cf_Ignore)
{ {
cflval.Val.Type = T_STRING; cflval.Val.Type = T_STRING;
if (strlen(yytext+1) >= sizeof(cflval.Val.String))
{
strcpy (cflval.Val.String, "");
DEBUG_PRINTF("lex: string '%s' exceeds max length\n", yytext);
return STRING;
}
strcpy (cflval.Val.String, yytext+1); strcpy (cflval.Val.String, yytext+1);
cflval.Val.String[strlen(cflval.Val.String)-1] = '\0'; cflval.Val.String[strlen(cflval.Val.String)-1] = '\0';
DEBUG_PRINTF("lex: string '%s' '%s'\n", yytext, cflval.Val.String); DEBUG_PRINTF("lex: string '%s' '%s'\n", yytext, cflval.Val.String);
@ -133,6 +142,12 @@ string \"[^\"\n]*\"
if (!cf_Ignore) if (!cf_Ignore)
{ {
cflval.Val.Type = T_STRING; cflval.Val.Type = T_STRING;
if (strlen(yytext+1) >= sizeof(cflval.Val.String))
{
strcpy (cflval.Val.String, "");
DEBUG_PRINTF("lex: string '%s' exceeds max length\n", yytext);
return VARIABLE;
}
strcpy (cflval.Val.String, yytext); strcpy (cflval.Val.String, yytext);
DEBUG_PRINTF("lex: variable '%s' '%s'\n", yytext, cflval.Val.String); DEBUG_PRINTF("lex: variable '%s' '%s'\n", yytext, cflval.Val.String);
return VARIABLE; return VARIABLE;

View file

@ -832,7 +832,7 @@ void CConfigFile::checkConfigFiles ()
{ {
(*it)->reparse (); (*it)->reparse ();
} }
catch (EConfigFile &e) catch (const EConfigFile &e)
{ {
nlwarning ("CF: Exception will re-read modified config file '%s': %s", (*it)->getFilename().c_str(), e.what ()); nlwarning ("CF: Exception will re-read modified config file '%s': %s", (*it)->getFilename().c_str(), e.what ());
} }

View file

@ -969,14 +969,12 @@ void force_exception_frame(...) {std::cout.flush();}
static void exceptionTranslator(unsigned, EXCEPTION_POINTERS *pexp) static void exceptionTranslator(unsigned, EXCEPTION_POINTERS *pexp)
{ {
#ifndef NL_NO_DEBUG_FILES #ifndef NL_NO_DEBUG_FILES
FILE *file = fopen ("exception_catched", "wb"); CFile::createEmptyFile(getLogDirectory() + "exception_catched");
fclose (file);
#endif #endif
if (pexp->ExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT) if (pexp->ExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT)
{ {
#ifndef NL_NO_DEBUG_FILES #ifndef NL_NO_DEBUG_FILES
FILE *file2 = fopen ("breakpointed", "wb"); CFile::createEmptyFile(getLogDirectory() + "breakpointed");
fclose (file2);
#endif #endif
return; return;
} }
@ -1018,7 +1016,7 @@ void getCallStack(std::string &result, sint skipNFirst)
array[0] = skipNFirst; array[0] = skipNFirst;
RaiseException (0xACE0ACE, 0, 1, array); RaiseException (0xACE0ACE, 0, 1, array);
} }
catch (EDebug &e) catch (const EDebug &e)
{ {
result += e.what(); result += e.what();
} }
@ -1053,7 +1051,7 @@ void getCallStackAndLog (string &result, sint /* skipNFirst */)
// array[0] = skipNFirst; // array[0] = skipNFirst;
// RaiseException (0xACE0ACE, 0, 1, array); // RaiseException (0xACE0ACE, 0, 1, array);
// } // }
// catch (EDebug &e) // catch (const EDebug &e)
// { // {
// result += e.what(); // result += e.what();
// } // }
@ -1683,12 +1681,18 @@ NLMISC_CATEGORISED_COMMAND(nel, writeaccess, "write a uint8 value in an invalid
uint8 val = 123; uint8 val = 123;
uint8 *adr = (uint8*)0; uint8 *adr = (uint8*)0;
if(args.size() >= 1) if(args.size() >= 1)
{
#ifdef HAVE_X86_64 #ifdef HAVE_X86_64
adr = (uint8*)(uint64)atoi(args[0].c_str()); uint64 addr64;
NLMISC::fromString(args[0], addr64);
adr = (uint8*)addr64;
#else #else
adr = (uint8*)atoi(args[0].c_str()); uint32 addr32;
NLMISC::fromString(args[0], addr32);
adr = (uint8*)addr32;
#endif #endif
if(args.size() >= 2) val = (uint8)atoi(args[1].c_str()); }
if(args.size() >= 2) NLMISC::fromString(args[1], val);
*adr = val; *adr = val;
return true; return true;
} }
@ -1698,11 +1702,17 @@ NLMISC_CATEGORISED_COMMAND(nel, readaccess, "read a uint8 value in an invalid ad
uint8 val; uint8 val;
uint8 *adr = (uint8*)0; uint8 *adr = (uint8*)0;
if(args.size() == 1) if(args.size() == 1)
{
#ifdef HAVE_X86_64 #ifdef HAVE_X86_64
adr = (uint8*)(uint64)atoi(args[0].c_str()); uint64 addr64;
NLMISC::fromString(args[0], addr64);
adr = (uint8*)addr64;
#else #else
adr = (uint8*)atoi(args[0].c_str()); uint32 addr32;
NLMISC::fromString(args[0], addr32);
adr = (uint8*)addr32;
#endif #endif
}
val = *adr; val = *adr;
log.displayNL("value is %hu", (uint16)val); log.displayNL("value is %hu", (uint16)val);
return true; return true;

View file

@ -84,7 +84,7 @@ bool loadStringFile(const std::string filename, vector<TStringInfo> &stringInfos
buffer = new uint8[size]; buffer = new uint8[size];
fp.serialBuffer(buffer, size); fp.serialBuffer(buffer, size);
} }
catch(Exception &e) catch(const Exception &e)
{ {
nlinfo("Can't open file [%s] (%s)\n", filename.c_str(), e.what()); nlinfo("Can't open file [%s] (%s)\n", filename.c_str(), e.what());
return true; return true;

View file

@ -120,7 +120,7 @@ void IDisplayer::display ( const CLog::TDisplayInfo& args, const char *message )
{ {
doDisplay( args, message ); doDisplay( args, message );
} }
catch (Exception &) catch (const Exception &)
{ {
// silence // silence
} }

View file

@ -365,7 +365,7 @@ void CIFile::getline (char *buffer, uint32 bufferSize)
// read one byte // read one byte
serialBuffer ((uint8 *)buffer, 1); serialBuffer ((uint8 *)buffer, 1);
} }
catch (EFile &) catch (const EFile &)
{ {
*buffer = '\0'; *buffer = '\0';
return; return;

View file

@ -419,7 +419,7 @@ namespace NLMISC
} }
} }
} }
catch(EStream &) catch(const EStream &)
{ {
nlwarning("CInterWindowMsgQueue : Bad message format in inter window communication"); nlwarning("CInterWindowMsgQueue : Bad message format in inter window communication");
} }

View file

@ -18,7 +18,7 @@
#include "nel/misc/noise_value.h" #include "nel/misc/noise_value.h"
#include "nel/misc/fast_floor.h" #include "nel/misc/fast_floor.h"
#include "nel/misc/random.h"
namespace NLMISC namespace NLMISC
@ -45,7 +45,8 @@ public:
CRandomGrid3D() CRandomGrid3D()
{ {
//seed //seed
srand(0); CRandom Random;
Random.srand(0);
// init the grid // init the grid
for(uint z=0; z<NL3D_NOISE_GRID_SIZE; z++) for(uint z=0; z<NL3D_NOISE_GRID_SIZE; z++)
@ -56,7 +57,7 @@ public:
{ {
uint id= x + (y<<NL3D_NOISE_GRID_SIZE_SHIFT) + (z<<(NL3D_NOISE_GRID_SIZE_SHIFT*2)); uint id= x + (y<<NL3D_NOISE_GRID_SIZE_SHIFT) + (z<<(NL3D_NOISE_GRID_SIZE_SHIFT*2));
// take higher bits of rand gives better result. // take higher bits of rand gives better result.
uint v= rand() >> 5; uint v= Random.rand() >> 5;
_Texture3d[id]= v&255; _Texture3d[id]= v&255;
} }
} }
@ -80,9 +81,9 @@ public:
// init LevelPhases. // init LevelPhases.
for(i=0; i<NL3D_NOISE_LEVEL; i++) for(i=0; i<NL3D_NOISE_LEVEL; i++)
{ {
_LevelPhase[i].x= frand(NL3D_NOISE_GRID_SIZE); _LevelPhase[i].x= Random.frand(NL3D_NOISE_GRID_SIZE);
_LevelPhase[i].y= frand(NL3D_NOISE_GRID_SIZE); _LevelPhase[i].y= Random.frand(NL3D_NOISE_GRID_SIZE);
_LevelPhase[i].z= frand(NL3D_NOISE_GRID_SIZE); _LevelPhase[i].z= Random.frand(NL3D_NOISE_GRID_SIZE);
} }
// not for level 0. // not for level 0.
_LevelPhase[0]= CVector::Null; _LevelPhase[0]= CVector::Null;

Some files were not shown because too many files have changed in this diff Show more