merge from default

--HG--
branch : gsoc2012-achievements
This commit is contained in:
mattraykowski 2013-02-12 10:24:22 -06:00
commit 8ced186cfd
1472 changed files with 17328 additions and 1965 deletions

View file

@ -60,7 +60,7 @@ IF(Mercurial_HG_EXECUTABLE)
"\\1" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}") "\\1" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}")
MACRO(Mercurial_WC_INFO dir prefix) MACRO(Mercurial_WC_INFO dir prefix)
EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} tip EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} tip --template "{rev};{node};{tags};{author}"
WORKING_DIRECTORY ${dir} WORKING_DIRECTORY ${dir}
OUTPUT_VARIABLE ${prefix}_WC_INFO OUTPUT_VARIABLE ${prefix}_WC_INFO
ERROR_VARIABLE Mercurial_hg_info_error ERROR_VARIABLE Mercurial_hg_info_error
@ -70,18 +70,18 @@ IF(Mercurial_HG_EXECUTABLE)
IF(NOT ${Mercurial_hg_info_result} EQUAL 0) IF(NOT ${Mercurial_hg_info_result} EQUAL 0)
MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} tip\" failed with output:\n${Mercurial_hg_info_error}") MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} tip\" failed with output:\n${Mercurial_hg_info_error}")
ELSE(NOT ${Mercurial_hg_info_result} EQUAL 0) ELSE(NOT ${Mercurial_hg_info_result} EQUAL 0)
LIST(LENGTH ${prefix}_WC_INFO _COUNT)
STRING(REGEX REPLACE "^(.*\n)?Repository Root: ([^\n]+).*" IF(_COUNT EQUAL 4)
"\\2" ${prefix}_WC_ROOT "${${prefix}_WC_INFO}") LIST(GET ${prefix}_WC_INFO 0 ${prefix}_WC_REVISION)
STRING(REGEX REPLACE "^(.*\n)?changeset: *([0-9]+).*" LIST(GET ${prefix}_WC_INFO 1 ${prefix}_WC_CHANGESET)
"\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}") LIST(GET ${prefix}_WC_INFO 2 ${prefix}_WC_BRANCH)
STRING(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*" LIST(GET ${prefix}_WC_INFO 3 ${prefix}_WC_LAST_CHANGED_AUTHOR)
"\\2" ${prefix}_WC_LAST_CHANGED_AUTHOR "${${prefix}_WC_INFO}") ELSE(_COUNT EQUAL 4)
STRING(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*" MESSAGE(STATUS "Bad output from HG")
"\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}") SET(${prefix}_WC_REVISION "unknown")
STRING(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*" SET(${prefix}_WC_CHANGESET "unknown")
"\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}") SET(${prefix}_WC_BRANCH "unknown")
ENDIF(_COUNT EQUAL 4)
ENDIF(NOT ${Mercurial_hg_info_result} EQUAL 0) ENDIF(NOT ${Mercurial_hg_info_result} EQUAL 0)
ENDMACRO(Mercurial_WC_INFO) ENDMACRO(Mercurial_WC_INFO)

View file

@ -2,47 +2,86 @@
# Find the Windows includes # Find the Windows includes
# #
# WINSDK_INCLUDE_DIR - where to find Windows.h # WINSDK_INCLUDE_DIR - where to find Windows.h
# WINSDK_INCLUDE_DIRS - where to find all Windows headers
# WINSDK_LIBRARY_DIR - where to find libraries
# WINSDK_FOUND - True if Windows SDK found. # WINSDK_FOUND - True if Windows SDK found.
IF(WINSDK_INCLUDE_DIR) IF(WINSDK_INCLUDE_DIR)
# Already in cache, be silent # Already in cache, be silent
SET(WINSDK_FIND_QUIETLY TRUE) SET(WindowsSDK_FIND_QUIETLY TRUE)
ENDIF(WINSDK_INCLUDE_DIR) ENDIF(WINSDK_INCLUDE_DIR)
# TODO: add the possibility to use a specific Windows SDK
IF(MSVC11)
GET_FILENAME_COMPONENT(WINSDK8_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDK8_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;ProductVersion]" NAME)
IF(WINSDK8_DIR)
IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDK8_VERSION} in ${WINSDK8_DIR}")
ENDIF(NOT WindowsSDK_FIND_QUIETLY)
IF(TARGET_ARM)
SET(WINSDK8_SUFFIX "arm")
ELSEIF(TARGET_X64)
SET(WINSDK8_SUFFIX "x64")
ELSEIF(TARGET_X86)
SET(WINSDK8_SUFFIX "x86")
ENDIF(TARGET_ARM)
ENDIF(WINSDK8_DIR)
ENDIF(MSVC11)
GET_FILENAME_COMPONENT(WINSDK71_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;InstallationFolder]" ABSOLUTE CACHE) 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) GET_FILENAME_COMPONENT(WINSDK71_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;ProductVersion]" NAME)
IF(WINSDK71_DIR) IF(WINSDK71_DIR)
IF(NOT WINSDK_FIND_QUIETLY) IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDK71_VERSION} in ${WINSDK71_DIR}") MESSAGE(STATUS "Found Windows SDK ${WINSDK71_VERSION} in ${WINSDK71_DIR}")
ENDIF(NOT WINSDK_FIND_QUIETLY) ENDIF(NOT WindowsSDK_FIND_QUIETLY)
ENDIF(WINSDK71_DIR) ENDIF(WINSDK71_DIR)
GET_FILENAME_COMPONENT(WINSDKCURRENT_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE) 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) GET_FILENAME_COMPONENT(WINSDKCURRENT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentVersion]" NAME)
IF(WINSDKCURRENT_DIR) IF(WINSDKCURRENT_DIR)
IF(NOT WINSDK_FIND_QUIETLY) IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDKCURRENT_VERSION} in ${WINSDKCURRENT_DIR}") MESSAGE(STATUS "Found Windows SDK ${WINSDKCURRENT_VERSION} in ${WINSDKCURRENT_DIR}")
ENDIF(NOT WINSDK_FIND_QUIETLY) ENDIF(NOT WindowsSDK_FIND_QUIETLY)
ENDIF(WINSDKCURRENT_DIR) ENDIF(WINSDKCURRENT_DIR)
FIND_PATH(WINSDK_INCLUDE_DIR Windows.h FIND_PATH(WINSDK_INCLUDE_DIR Windows.h
PATHS HINTS
${WINSDK8_DIR}/Include/um
${WINSDK71_DIR}/Include ${WINSDK71_DIR}/Include
${WINSDKCURRENT_DIR}/Include ${WINSDKCURRENT_DIR}/Include
) )
FIND_PATH(WINSDK_SHARED_INCLUDE_DIR d3d9.h
HINTS
${WINSDK8_DIR}/Include/shared
${WINSDK71_DIR}/Include
${WINSDKCURRENT_DIR}/Include
)
FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib
HINTS
${WINSDK8_DIR}/Lib/win8/um/${WINSDK8_SUFFIX}
${WINSDK71_DIR}/Lib
${WINSDKCURRENT_DIR}/Lib
)
FIND_PROGRAM(WINSDK_SIGNTOOL signtool FIND_PROGRAM(WINSDK_SIGNTOOL signtool
PATHS HINTS
${WINSDK8_DIR}/Bin/x86
${WINSDK71_DIR}/Bin ${WINSDK71_DIR}/Bin
${WINSDKCURRENT_DIR}/Bin ${WINSDKCURRENT_DIR}/Bin
) )
IF(WINSDK_INCLUDE_DIR) IF(WINSDK_INCLUDE_DIR)
SET(WINSDK_FOUND TRUE) SET(WINSDK_FOUND TRUE)
SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIR} ${WINSDK_SHARED_INCLUDE_DIR})
ELSE(WINSDK_INCLUDE_DIR) ELSE(WINSDK_INCLUDE_DIR)
IF(NOT WINSDK_FIND_QUIETLY) IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Windows SDK!") MESSAGE(STATUS "Warning: Unable to find Windows SDK!")
ENDIF(NOT WINSDK_FIND_QUIETLY) ENDIF(NOT WindowsSDK_FIND_QUIETLY)
ENDIF(WINSDK_INCLUDE_DIR) ENDIF(WINSDK_INCLUDE_DIR)

View file

@ -3,6 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3)
# ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory) # ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory)
# SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt) # SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt)
IF(SOURCE_DIR)
# Replace spaces by semi-columns # Replace spaces by semi-columns
IF(CMAKE_MODULE_PATH) IF(CMAKE_MODULE_PATH)
STRING(REPLACE " " ";" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) STRING(REPLACE " " ";" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
@ -17,6 +18,9 @@ ENDIF(NOT ROOT_DIR AND SOURCE_DIR)
IF(NOT SOURCE_DIR AND ROOT_DIR) IF(NOT SOURCE_DIR AND ROOT_DIR)
SET(SOURCE_DIR ${ROOT_DIR}) SET(SOURCE_DIR ${ROOT_DIR})
ENDIF(NOT SOURCE_DIR AND ROOT_DIR) ENDIF(NOT SOURCE_DIR AND ROOT_DIR)
ELSE(SOURCE_DIR)
SET(ROOT_DIR ${CMAKE_SOURCE_DIR})
ENDIF(SOURCE_DIR)
MACRO(NOW RESULT) MACRO(NOW RESULT)
IF (WIN32) IF (WIN32)
@ -53,10 +57,11 @@ IF(EXISTS "${ROOT_DIR}/.hg/")
ENDIF(MERCURIAL_FOUND) ENDIF(MERCURIAL_FOUND)
ENDIF(EXISTS "${ROOT_DIR}/.hg/") ENDIF(EXISTS "${ROOT_DIR}/.hg/")
IF(DEFINED REVISION) IF(SOURCE_DIR AND DEFINED REVISION)
IF(EXISTS ${SOURCE_DIR}/revision.h.in) IF(EXISTS ${SOURCE_DIR}/revision.h.in)
MESSAGE(STATUS "Revision: ${REVISION}")
NOW(BUILD_DATE) NOW(BUILD_DATE)
CONFIGURE_FILE(${SOURCE_DIR}/revision.h.in revision.h.txt) CONFIGURE_FILE(${SOURCE_DIR}/revision.h.in revision.h.txt)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy revision.h.txt revision.h) # copy_if_different EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy revision.h.txt revision.h) # copy_if_different
ENDIF(EXISTS ${SOURCE_DIR}/revision.h.in) ENDIF(EXISTS ${SOURCE_DIR}/revision.h.in)
ENDIF(DEFINED REVISION) ENDIF(SOURCE_DIR AND DEFINED REVISION)

View file

@ -17,13 +17,11 @@ ELSE(MSVC)
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE gcc_compiler_version) OUTPUT_VARIABLE gcc_compiler_version)
IF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]") IF(gcc_compiler_version MATCHES "^4\\.1(\\.[0-9]+)?")
SET(PCHSupport_FOUND FALSE)
ELSEIF(gcc_compiler_version MATCHES "^4\\.[0-9]+(\\.[0-9]+)?")
SET(PCHSupport_FOUND TRUE) SET(PCHSupport_FOUND TRUE)
ELSE(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]") ENDIF(gcc_compiler_version MATCHES "^4\\.1(\\.[0-9]+)?")
IF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
SET(PCHSupport_FOUND TRUE)
ENDIF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
ENDIF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
ELSE(CMAKE_COMPILER_IS_GNUCXX) ELSE(CMAKE_COMPILER_IS_GNUCXX)
# TODO: make tests for other compilers than GCC # TODO: make tests for other compilers than GCC
SET(PCHSupport_FOUND TRUE) SET(PCHSupport_FOUND TRUE)
@ -32,12 +30,19 @@ ELSE(MSVC)
SET(_PCH_include_prefix "-I") SET(_PCH_include_prefix "-I")
ENDIF(MSVC) ENDIF(MSVC)
MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags) # Set PCH_FLAGS for common flags, PCH_ARCH_XXX_FLAGS for specific archs flags and PCH_ARCHS for archs
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name) MACRO(PCH_SET_COMPILE_FLAGS _target)
SET(_FLAGS ${${_flags_var_name}} ) SET(PCH_FLAGS)
SET(PCH_ARCHS)
SET(FLAGS)
LIST(APPEND _FLAGS ${CMAKE_CXX_FLAGS})
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPER_BUILD)
LIST(APPEND _FLAGS " ${CMAKE_CXX_FLAGS_${_UPPER_BUILD}}")
IF(NOT MSVC) IF(NOT MSVC)
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE) GET_TARGET_PROPERTY(_targetType ${_target} TYPE)
IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
LIST(APPEND _FLAGS " -fPIC") LIST(APPEND _FLAGS " -fPIC")
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY) ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
@ -49,43 +54,99 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
ENDFOREACH(item) ENDFOREACH(item)
# Required for CMake 2.6 # Required for CMake 2.6
SET(GLOBAL_DEFINITIONS "") SET(GLOBAL_DEFINITIONS)
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS) GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS -D${item}) LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item) ENDFOREACH(item)
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD})
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
GET_TARGET_PROPERTY(oldProps ${_target} COMPILE_FLAGS)
IF(oldProps)
LIST(APPEND _FLAGS " ${oldProps}")
ENDIF(oldProps)
GET_TARGET_PROPERTY(oldPropsBuild ${_target} COMPILE_FLAGS_${_UPPER_BUILD})
IF(oldPropsBuild)
LIST(APPEND _FLAGS " ${oldPropsBuild}")
ENDIF(oldPropsBuild)
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS) GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
LIST(APPEND _FLAGS ${GLOBAL_DEFINITIONS}) LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}")
LIST(APPEND _FLAGS ${_directory_flags}) LIST(APPEND _FLAGS " ${_directory_flags}")
LIST(APPEND _FLAGS ${_directory_definitions}) LIST(APPEND _FLAGS " ${_directory_definitions}")
LIST(APPEND _FLAGS ${CMAKE_CXX_FLAGS})
STRING(REGEX REPLACE " +" " " _FLAGS ${_FLAGS})
# Format definitions # Format definitions
SEPARATE_ARGUMENTS(_FLAGS) SEPARATE_ARGUMENTS(_FLAGS)
IF(CLANG) IF(CLANG)
SET(_IGNORE_NEXT OFF) # Determining all architectures and get common flags
SET(_ARCH_NEXT)
SET(_XARCH_NEXT)
FOREACH(item ${_FLAGS}) FOREACH(item ${_FLAGS})
IF(_IGNORE_NEXT) IF(_ARCH_NEXT)
SET(_IGNORE_NEXT OFF) LIST(FIND PCH_ARCHS ${item} ITEM_FOUND)
ELSE(_IGNORE_NEXT) IF(ITEM_FOUND EQUAL -1)
IF(item MATCHES "^-Xarch") LIST(APPEND PCH_ARCHS ${item})
SET(_IGNORE_NEXT ON) STRING(TOUPPER "${item}" _UPPER_ARCH)
ELSEIF(item MATCHES "^-arch") SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item})
SET(_IGNORE_NEXT ON) ENDIF(ITEM_FOUND EQUAL -1)
ELSE(item MATCHES "^-Xarch") SET(_ARCH_NEXT OFF)
LIST(APPEND ${_out_compile_flags} ${item}) ELSEIF(_XARCH_NEXT)
ENDIF(item MATCHES "^-Xarch") SET(_XARCH_NEXT OFF)
ENDIF(_IGNORE_NEXT) ELSE(_ARCH_NEXT)
IF(item MATCHES "^-arch")
SET(_ARCH_NEXT ON)
ELSEIF(item MATCHES "^-Xarch_")
STRING(REGEX REPLACE "-Xarch_([a-z0-9_]+)" "\\1" item ${item})
LIST(FIND PCH_ARCHS ${item} ITEM_FOUND)
IF(ITEM_FOUND EQUAL -1)
LIST(APPEND PCH_ARCHS ${item})
STRING(TOUPPER "${item}" _UPPER_ARCH)
SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item})
ENDIF(ITEM_FOUND EQUAL -1)
SET(_XARCH_NEXT ON)
ELSE(item MATCHES "^-arch")
LIST(APPEND PCH_FLAGS ${item})
ENDIF(item MATCHES "^-arch")
ENDIF(_ARCH_NEXT)
ENDFOREACH(item) ENDFOREACH(item)
ELSE(CLANG)
SET(${_out_compile_flags} ${_FLAGS})
ENDIF(CLANG)
ENDMACRO(_PCH_GET_COMPILE_FLAGS)
MACRO(_PCH_GET_PDB_FILENAME out_filename _target) # Get architcture specific flags
SET(_XARCH_NEXT)
FOREACH(item ${_FLAGS})
IF(_XARCH_NEXT)
STRING(TOUPPER "${_XARCH_NEXT}" _UPPER_XARCH)
LIST(APPEND PCH_ARCH_${_UPPER_XARCH}_FLAGS ${item})
SET(_XARCH_NEXT OFF)
ELSE(_XARCH_NEXT)
IF(item MATCHES "^-Xarch_")
STRING(SUBSTRING "${item}" 7 -1 _XARCH_NEXT)
ENDIF(item MATCHES "^-Xarch_")
ENDIF(_XARCH_NEXT)
ENDFOREACH(item)
# Remove duplicated architectures
IF(_ARCHS AND PCH_ARCHS)
LIST(REMOVE_DUPLICATES PCH_ARCHS)
ENDIF(_ARCHS AND PCH_ARCHS)
ELSE(CLANG)
SET(PCH_FLAGS ${_FLAGS})
ENDIF(CLANG)
IF(PCH_FLAGS)
LIST(REMOVE_DUPLICATES PCH_FLAGS)
ENDIF(PCH_FLAGS)
ENDMACRO(PCH_SET_COMPILE_FLAGS)
MACRO(GET_PDB_FILENAME _out_filename _target)
# determine output directory based on target type # determine output directory based on target type
GET_TARGET_PROPERTY(_targetType ${_target} TYPE) GET_TARGET_PROPERTY(_targetType ${_target} TYPE)
IF(${_targetType} STREQUAL EXECUTABLE) IF(${_targetType} STREQUAL EXECUTABLE)
@ -103,10 +164,10 @@ MACRO(_PCH_GET_PDB_FILENAME out_filename _target)
SET(_targetPostfix "") SET(_targetPostfix "")
ENDIF(${_targetPostfix} MATCHES NOTFOUND) ENDIF(${_targetPostfix} MATCHES NOTFOUND)
SET(${out_filename} "${_targetOutput}/${_target}${_targetPostfix}.pdb") SET(${_out_filename} "${_targetOutput}/${_target}${_targetPostfix}.pdb")
ENDMACRO(_PCH_GET_PDB_FILENAME) ENDMACRO(GET_PDB_FILENAME)
MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _inputcpp _output) MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS)
IF(CMAKE_CXX_COMPILER_ARG1) IF(CMAKE_CXX_COMPILER_ARG1)
# remove leading space in compiler argument # remove leading space in compiler argument
STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1}) STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
@ -115,56 +176,117 @@ MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _inputcpp _output)
ENDIF(CMAKE_CXX_COMPILER_ARG1) ENDIF(CMAKE_CXX_COMPILER_ARG1)
IF(MSVC) IF(MSVC)
_PCH_GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target}) GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target})
SET(${out_command} ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp\"${_output}\" ${_inputcpp} /c /Fd\"${PDB_FILE}\") SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj")
ELSE(MSVC) ELSE(MSVC)
SET(HEADER_FORMAT "c++-header") SET(HEADER_FORMAT "c++-header")
SET(_FLAGS "")
IF(APPLE) IF(APPLE)
SET(HEADER_FORMAT "objective-${HEADER_FORMAT}") SET(HEADER_FORMAT "objective-${HEADER_FORMAT}")
SET(_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch)
ENDIF(APPLE) ENDIF(APPLE)
SET(${out_command} ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} -x ${HEADER_FORMAT} -o ${_output} -c ${_input}) SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} ${_FLAGS} -x ${HEADER_FORMAT} -o ${PCH_OUTPUT} -c ${PCH_INPUT})
ENDIF(MSVC) ENDIF(MSVC)
ENDMACRO(_PCH_GET_COMPILE_COMMAND) ENDMACRO(PCH_SET_COMPILE_COMMAND)
MACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT _targetName _input _arch _language)
SET(_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch")
MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
IF(MSVC) IF(MSVC)
FILE(MAKE_DIRECTORY ${_OUTPUT_DIR})
GET_FILENAME_COMPONENT(_name ${_input} NAME_WE) GET_FILENAME_COMPONENT(_name ${_input} NAME_WE)
SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.pch") SET(PCH_INPUT ${_input})
SET(PCH_OUTPUT "${_OUTPUT_DIR}/${_name}.pch")
ELSE(MSVC) ELSE(MSVC)
GET_FILENAME_COMPONENT(_name ${_input} NAME) IF(NOT "${_arch}" STREQUAL "")
SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch") SET(_OUTPUT_DIR "${_OUTPUT_DIR}_${_arch}")
ENDIF(MSVC) ENDIF(NOT "${_arch}" STREQUAL "")
ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use ) IF(NOT "${_language}" STREQUAL "")
SET(_OUTPUT_DIR "${_OUTPUT_DIR}_${_language}")
ENDIF(NOT "${_language}" STREQUAL "")
GET_FILENAME_COMPONENT(_name ${_input} NAME)
# Copy .h to output dir
SET(PCH_INPUT "${_OUTPUT_DIR}/${_name}")
ADD_CUSTOM_COMMAND(OUTPUT ${PCH_INPUT}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_input} ${PCH_INPUT}
DEPENDS ${_input}
COMMENT "[${_targetName}] Update precompiled header - done"
)
IF(CLANG)
SET(PCH_EXT "pth")
ELSE(CLANG)
SET(PCH_EXT "gch")
ENDIF(CLANG)
# For GCC and Clang, PCH needs to be in the same directory as .h
SET(PCH_OUTPUT "${_OUTPUT_DIR}/${_name}.${PCH_EXT}")
ENDIF(MSVC)
ENDMACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT)
# Add common flags
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName)
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS) GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND) IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "") SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND) ENDIF(${oldProps} MATCHES NOTFOUND)
IF(MSVC) IF(MSVC)
SET(_target_cflags "${oldProps} /Yu\"${_input}\" /FI\"${_input}\" /Fp\"${_pch_output_to_use}\"") SET(_target_cflags "${oldProps} /Yu\"${PCH_INPUT}\" /FI\"${PCH_INPUT}\" /Fp\"${PCH_OUTPUT}\"")
ELSE(MSVC) ELSE(MSVC)
# to do: test whether compiler flags match between target _targetName
# and _pch_output_to_use
FILE(TO_NATIVE_PATH ${_pch_output_to_use} _native_pch_path)
# 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 "${oldProps} ${PCH_ADDITIONAL_COMPILER_FLAGS}-include ${_input} -Winvalid-pch") SET(PCH_ADDITIONAL_COMPILER_FLAGS)
LIST(LENGTH PCH_ARCHS PCH_ARCHS_COUNT)
# If no arch is specified, create common flags
IF(PCH_ARCHS_COUNT LESS 2)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-include ${PCH_INPUT} ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(PCH_ARCHS_COUNT LESS 2)
IF(APPLE)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-fobjc-abi-version=2 -fobjc-legacy-dispatch -x objective-c++ ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(APPLE)
IF(WITH_PCH_DEBUG)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-H ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(WITH_PCH_DEBUG)
SET(_target_cflags "${oldProps} ${PCH_ADDITIONAL_COMPILER_FLAGS} -Winvalid-pch")
ENDIF(MSVC) ENDIF(MSVC)
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_DEPENDENCIES(${_targetName} pch_Generate_${_targetName})
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET) ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)
MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp) # Add specific flags for an arch
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH _targetName _arch)
LIST(LENGTH PCH_ARCHS PCH_ARCHS_COUNT)
IF(PCH_ARCHS_COUNT GREATER 1)
GET_TARGET_PROPERTY(_FLAGS ${_targetName} COMPILE_FLAGS)
IF(${_FLAGS} MATCHES NOTFOUND)
SET(_FLAGS "")
ENDIF(${_FLAGS} MATCHES NOTFOUND)
SET(_FLAGS "${_FLAGS} -Xarch_${_arch} -include${PCH_INPUT}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_FLAGS})
ENDIF(PCH_ARCHS_COUNT GREATER 1)
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH)
MACRO(PCH_CREATE_TARGET _targetName _targetNamePCH)
ADD_CUSTOM_COMMAND(OUTPUT ${PCH_OUTPUT} COMMAND ${PCH_COMMAND} COMMENT "Generating ${_targetNamePCH}" DEPENDS ${PCH_INPUT})
ADD_CUSTOM_TARGET(${_targetNamePCH} DEPENDS ${PCH_INPUT} ${PCH_OUTPUT})
ADD_DEPENDENCIES(${_targetName} ${_targetNamePCH})
ENDMACRO(PCH_CREATE_TARGET _targetName _inputh _inputcpp)
MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET(_PCH_current_target ${_targetName}) SET(_PCH_current_target ${_targetName})
IF(NOT CMAKE_BUILD_TYPE) IF(NOT CMAKE_BUILD_TYPE)
@ -174,38 +296,50 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
) )
ENDIF(NOT CMAKE_BUILD_TYPE) ENDIF(NOT CMAKE_BUILD_TYPE)
GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_inputh} _output) PCH_SET_COMPILE_FLAGS(${_targetName})
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE) IF(PCH_ARCHS)
SET(PCH_OUTPUTS)
FOREACH(_ARCH ${PCH_ARCHS})
STRING(TOUPPER "${_ARCH}" _UPPER_ARCH)
# always build static library because it doesn't need linking PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} ${_ARCH} "")
ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_inputcpp}) LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT})
_PCH_GET_COMPILE_FLAGS(_compile_FLAGS) PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_ARCH_${_UPPER_ARCH}_FLAGS};${PCH_FLAGS}")
PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch_${_ARCH})
SET_SOURCE_FILES_PROPERTIES(${_inputh} PROPERTIES GENERATED 1) ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH(${_targetName} ${_ARCH})
ENDFOREACH(_ARCH)
ELSE(PCH_ARCHS)
PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} "" "")
LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT})
_PCH_GET_COMPILE_COMMAND(_command ${_inputh} ${_inputcpp} ${_output}) PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_FLAGS}")
PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch)
ENDIF(PCH_ARCHS)
ADD_CUSTOM_COMMAND( ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName})
OUTPUT ${_output}
COMMAND ${_command}
DEPENDS ${_inputh} ${_targetName}_pch_dephelp
)
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_inputh} ${_output}) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PCH_OUTPUTS}")
ENDMACRO(ADD_PRECOMPILED_HEADER) ENDMACRO(ADD_PRECOMPILED_HEADER)
# Macro to move PCH creation file to the front of files list # Macro to move PCH creation file to the front of files list
# or remove .cpp from library/executable to avoid warning
MACRO(FIX_PRECOMPILED_HEADER _files _pch) MACRO(FIX_PRECOMPILED_HEADER _files _pch)
# Remove .cpp creating PCH from the list # Remove .cpp creating PCH from the list
LIST(REMOVE_ITEM ${_files} ${_pch}) LIST(REMOVE_ITEM ${_files} ${_pch})
IF(MSVC)
# Prepend .cpp creating PCH to the list # Prepend .cpp creating PCH to the list
LIST(INSERT ${_files} 0 ${_pch}) LIST(INSERT ${_files} 0 ${_pch})
ENDIF(MSVC)
ENDMACRO(FIX_PRECOMPILED_HEADER) ENDMACRO(FIX_PRECOMPILED_HEADER)
MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp) MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET(PCH_METHOD 0) IF(NOT PCHSupport_FOUND)
MESSAGE(STATUS "PCH disabled because compiler doesn't support them")
RETURN()
ENDIF(NOT PCHSupport_FOUND)
# 0 => creating a new target for PCH, works for all makefiles # 0 => creating a new target for PCH, works for all makefiles
# 1 => setting PCH for VC++ project, works for VC++ projects # 1 => setting PCH for VC++ project, works for VC++ projects
@ -218,6 +352,8 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
# SET(PCH_METHOD 1) # SET(PCH_METHOD 1)
ELSEIF(CMAKE_GENERATOR MATCHES "Xcode") ELSEIF(CMAKE_GENERATOR MATCHES "Xcode")
SET(PCH_METHOD 2) SET(PCH_METHOD 2)
ELSE(CMAKE_GENERATOR MATCHES "Visual Studio")
SET(PCH_METHOD 0)
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio") ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")
IF(PCH_METHOD EQUAL 1) IF(PCH_METHOD EQUAL 1)
@ -239,11 +375,6 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
# For Xcode, cmake needs my patch to process # For Xcode, cmake needs my patch to process
# GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties # GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND)
# When buiding out of the tree, precompiled may not be located # When buiding out of the tree, precompiled may not be located
# Use full path instead. # Use full path instead.
GET_FILENAME_COMPONENT(fullPath ${_inputh} ABSOLUTE) GET_FILENAME_COMPONENT(fullPath ${_inputh} ABSOLUTE)
@ -255,4 +386,7 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp}) ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp})
ENDIF(PCH_METHOD EQUAL 1) ENDIF(PCH_METHOD EQUAL 1)
IF(TARGET ${_targetName}_static)
ADD_NATIVE_PRECOMPILED_HEADER(${_targetName}_static ${_inputh} ${_inputcpp})
ENDIF(TARGET ${_targetName}_static)
ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER) ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)

View file

@ -22,32 +22,52 @@ ENDMACRO(NL_GEN_PC)
### ###
MACRO(NL_GEN_REVISION_H) MACRO(NL_GEN_REVISION_H)
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in) IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) SET(TOOL_FOUND OFF)
ADD_DEFINITIONS(-DHAVE_REVISION_H)
SET(HAVE_REVISION_H ON) IF(EXISTS "${CMAKE_SOURCE_DIR}/../.svn/")
FIND_PACKAGE(Subversion)
IF(SUBVERSION_FOUND)
SET(TOOL_FOUND ON)
ENDIF(SUBVERSION_FOUND)
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/../.svn/")
IF(EXISTS "${CMAKE_SOURCE_DIR}/../.hg/")
FIND_PACKAGE(Mercurial)
IF(MERCURIAL_FOUND)
SET(TOOL_FOUND ON)
ENDIF(MERCURIAL_FOUND)
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/../.hg/")
# if already generated # if already generated
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h) IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
# copy it # copy it
MESSAGE(STATUS "Copying provided revision.h...") MESSAGE(STATUS "Copying provided revision.h...")
FILE(COPY ${CMAKE_SOURCE_DIR}/revision.h DESTINATION ${CMAKE_BINARY_DIR}) FILE(COPY ${CMAKE_SOURCE_DIR}/revision.h DESTINATION ${CMAKE_BINARY_DIR})
ELSE(EXISTS ${CMAKE_SOURCE_DIR}/revision.h) SET(HAVE_REVISION_H ON)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
IF(TOOL_FOUND)
# a custom target that is always built # a custom target that is always built
ADD_CUSTOM_TARGET(revision ALL ADD_CUSTOM_TARGET(revision ALL
DEPENDS ${CMAKE_BINARY_DIR}/revision.h)
# creates revision.h using cmake script
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/revision.h
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}
-DSOURCE_DIR=${CMAKE_SOURCE_DIR} -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
-DROOT_DIR=${CMAKE_SOURCE_DIR}/.. -DROOT_DIR=${CMAKE_SOURCE_DIR}/..
-DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/CMakeModules
-P ${CMAKE_SOURCE_DIR}/CMakeModules/GetRevision.cmake) -P ${CMAKE_SOURCE_DIR}/CMakeModules/GetRevision.cmake)
# revision.h is a generated file # revision.h is a generated file
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/revision.h SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/revision.h
PROPERTIES GENERATED TRUE PROPERTIES GENERATED TRUE
HEADER_FILE_ONLY TRUE) HEADER_FILE_ONLY TRUE)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h) SET(HAVE_REVISION_H ON)
ENDIF(TOOL_FOUND)
IF(HAVE_REVISION_H)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_DEFINITIONS(-DHAVE_REVISION_H)
ENDIF(HAVE_REVISION_H)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in) ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
ENDMACRO(NL_GEN_REVISION_H) ENDMACRO(NL_GEN_REVISION_H)
@ -79,6 +99,11 @@ ENDMACRO(NL_TARGET_DRIVER)
# Argument: # Argument:
### ###
MACRO(NL_DEFAULT_PROPS name label) MACRO(NL_DEFAULT_PROPS name label)
IF(HAVE_REVISION_H)
# explicitly say that the target depends on revision.h
ADD_DEPENDENCIES(${name} revision)
ENDIF(HAVE_REVISION_H)
# Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name. # Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name.
# CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819 # CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819
STRING(REGEX REPLACE "\\:" " -" proj_label ${label}) STRING(REGEX REPLACE "\\:" " -" proj_label ${label})
@ -386,7 +411,7 @@ MACRO(NL_SETUP_BUILD)
ENDIF(CMAKE_GENERATOR MATCHES "Xcode") ENDIF(CMAKE_GENERATOR MATCHES "Xcode")
# If target and host CPU are the same # If target and host CPU are the same
IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}") IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING)
# x86-compatible CPU # x86-compatible CPU
IF(HOST_CPU MATCHES "x86") IF(HOST_CPU MATCHES "x86")
IF(NOT CMAKE_SIZEOF_VOID_P) IF(NOT CMAKE_SIZEOF_VOID_P)
@ -407,9 +432,9 @@ MACRO(NL_SETUP_BUILD)
MESSAGE(STATUS "Unknown architecture: ${HOST_CPU}") MESSAGE(STATUS "Unknown architecture: ${HOST_CPU}")
ENDIF(HOST_CPU MATCHES "x86") ENDIF(HOST_CPU MATCHES "x86")
# TODO: add checks for PPC # TODO: add checks for PPC
ELSE("${HOST_CPU}" STREQUAL "${TARGET_CPU}") ELSE("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING)
MESSAGE(STATUS "Compiling on ${HOST_CPU} for ${TARGET_CPU}") MESSAGE(STATUS "Compiling on ${HOST_CPU} for ${TARGET_CPU}")
ENDIF("${HOST_CPU}" STREQUAL "${TARGET_CPU}") ENDIF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING)
# Use values from environment variables # Use values from environment variables
SET(PLATFORM_CFLAGS "$ENV{CFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CFLAGS}") SET(PLATFORM_CFLAGS "$ENV{CFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CFLAGS}")
@ -430,6 +455,7 @@ MACRO(NL_SETUP_BUILD)
IF(NOT CMAKE_OSX_ARCHITECTURES) IF(NOT CMAKE_OSX_ARCHITECTURES)
IF(TARGET_CPU STREQUAL "x86_64") IF(TARGET_CPU STREQUAL "x86_64")
SET(TARGET_X64 1) SET(TARGET_X64 1)
SET(TARGET_X86 1)
ELSEIF(TARGET_CPU STREQUAL "x86") ELSEIF(TARGET_CPU STREQUAL "x86")
SET(TARGET_X86 1) SET(TARGET_X86 1)
ELSEIF(TARGET_CPU STREQUAL "armv7s") ELSEIF(TARGET_CPU STREQUAL "armv7s")
@ -446,26 +472,15 @@ MACRO(NL_SETUP_BUILD)
SET(TARGET_ARMV5 1) SET(TARGET_ARMV5 1)
ELSEIF(TARGET_CPU STREQUAL "arm") ELSEIF(TARGET_CPU STREQUAL "arm")
SET(TARGET_ARM 1) SET(TARGET_ARM 1)
ELSEIF(TARGET_CPU STREQUAL "mips")
SET(TARGET_MIPS 1)
ENDIF(TARGET_CPU STREQUAL "x86_64") ENDIF(TARGET_CPU STREQUAL "x86_64")
ENDIF(NOT CMAKE_OSX_ARCHITECTURES)
# Fix library paths suffixes for Debian MultiArch
IF(LIBRARY_ARCHITECTURE)
SET(CMAKE_LIBRARY_PATH /lib/${LIBRARY_ARCHITECTURE} /usr/lib/${LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH})
IF(TARGET_X64)
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64)
ENDIF(TARGET_X64)
IF(TARGET_X86)
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32)
ENDIF(TARGET_X86)
ENDIF(LIBRARY_ARCHITECTURE)
IF(APPLE AND NOT IOS)
SET(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
SET(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
ENDIF(APPLE AND NOT IOS)
IF(TARGET_ARM) IF(TARGET_ARM)
IF(TARGET_ARMV7S)
ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S")
ENDIF(TARGET_ARMV7S)
IF(TARGET_ARMV7) IF(TARGET_ARMV7)
ADD_PLATFORM_FLAGS("-DHAVE_ARMV7") ADD_PLATFORM_FLAGS("-DHAVE_ARMV7")
ENDIF(TARGET_ARMV7) ENDIF(TARGET_ARMV7)
@ -485,12 +500,42 @@ MACRO(NL_SETUP_BUILD)
ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64") ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64")
ENDIF(TARGET_X64) ENDIF(TARGET_X64)
IF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-DHAVE_MIPS")
ENDIF(TARGET_MIPS)
ENDIF(NOT CMAKE_OSX_ARCHITECTURES)
# Fix library paths suffixes for Debian MultiArch
IF(LIBRARY_ARCHITECTURE)
SET(CMAKE_LIBRARY_PATH /lib/${LIBRARY_ARCHITECTURE} /usr/lib/${LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH})
IF(TARGET_X64)
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64)
ELSEIF(TARGET_X86)
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32)
ENDIF(TARGET_X64)
ENDIF(LIBRARY_ARCHITECTURE)
IF(APPLE AND NOT IOS)
SET(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
SET(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
ENDIF(APPLE AND NOT IOS)
IF(WITH_LOGGING) IF(WITH_LOGGING)
ADD_PLATFORM_FLAGS("-DENABLE_LOGS") ADD_PLATFORM_FLAGS("-DENABLE_LOGS")
ENDIF(WITH_LOGGING) ENDIF(WITH_LOGGING)
IF(MSVC) IF(MSVC)
IF(MSVC10) IF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11)
SET(MSVC11 ON)
ENDIF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11)
IF(MSVC11)
ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2010, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC10)
ADD_PLATFORM_FLAGS("/Gy- /MP") ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2010, but custom optimizations don't exist # /Ox is working with VC++ 2010, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
@ -508,9 +553,9 @@ MACRO(NL_SETUP_BUILD)
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}")
ELSE(MSVC10) ELSE(MSVC11)
MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
ENDIF(MSVC10) ENDIF(MSVC11)
ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250") ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250")
@ -553,13 +598,10 @@ MACRO(NL_SETUP_BUILD)
ENDIF(CLANG) ENDIF(CLANG)
ENDIF(WIN32) ENDIF(WIN32)
IF(TARGET_ARM)
ADD_PLATFORM_FLAGS("-mthumb")
ENDIF(TARGET_ARM)
IF(APPLE) IF(APPLE)
IF(IOS) IF(IOS)
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE PATH "" FORCE) # Disable CMAKE_OSX_DEPLOYMENT_TARGET for iOS
SET(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE PATH "" FORCE)
ELSE(IOS) ELSE(IOS)
IF(NOT CMAKE_OSX_DEPLOYMENT_TARGET) IF(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE PATH "" FORCE) SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE PATH "" FORCE)
@ -585,6 +627,11 @@ MACRO(NL_SETUP_BUILD)
SET(_ARCHS "${_ARCHS} x86_64") SET(_ARCHS "${_ARCHS} x86_64")
SET(TARGET_X64 1) SET(TARGET_X64 1)
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
ELSEIF(_ARCH STREQUAL "armv7s")
SET(_ARCHS "${_ARCHS} armv7s")
SET(TARGET_ARMV7S 1)
SET(TARGET_ARM 1)
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
ELSEIF(_ARCH STREQUAL "armv7") ELSEIF(_ARCH STREQUAL "armv7")
SET(_ARCHS "${_ARCHS} armv7") SET(_ARCHS "${_ARCHS} armv7")
SET(TARGET_ARMV7 1) SET(TARGET_ARMV7 1)
@ -595,16 +642,51 @@ MACRO(NL_SETUP_BUILD)
SET(TARGET_ARMV6 1) SET(TARGET_ARMV6 1)
SET(TARGET_ARM 1) SET(TARGET_ARM 1)
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1") MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
ELSEIF(_ARCH STREQUAL "mips")
SET(_ARCHS "${_ARCHS} mips")
SET(TARGET_MIPS 1)
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
ELSE(_ARCH STREQUAL "i386") ELSE(_ARCH STREQUAL "i386")
SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})") SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})")
ENDIF(_ARCH STREQUAL "i386") ENDIF(_ARCH STREQUAL "i386")
ENDFOREACH(_ARCH) ENDFOREACH(_ARCH)
MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}") MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}")
ELSE(CMAKE_OSX_ARCHITECTURES) ELSE(CMAKE_OSX_ARCHITECTURES)
SET(TARGETS_COUNT 1) SET(TARGETS_COUNT 0)
ENDIF(CMAKE_OSX_ARCHITECTURES) ENDIF(CMAKE_OSX_ARCHITECTURES)
IF(TARGETS_COUNT EQUAL 1) IF(TARGETS_COUNT EQUAL 1)
IF(TARGET_ARM)
IF(TARGET_ARMV7S)
ADD_PLATFORM_FLAGS("-arch armv7s -DHAVE_ARMV7S")
ENDIF(TARGET_ARMV7S)
IF(TARGET_ARMV7)
ADD_PLATFORM_FLAGS("-arch armv7 -DHAVE_ARMV7")
ENDIF(TARGET_ARMV7)
IF(TARGET_ARMV6)
ADD_PLATFORM_FLAGS("-arch armv6 -DHAVE_ARMV6")
ENDIF(TARGET_ARMV6)
IF(TARGET_ARMV5)
ADD_PLATFORM_FLAGS("-arch armv5 -DHAVE_ARMV5")
ENDIF(TARGET_ARMV5)
ADD_PLATFORM_FLAGS("-mthumb -DHAVE_ARM")
ENDIF(TARGET_ARM)
IF(TARGET_X64)
ADD_PLATFORM_FLAGS("-arch x86_64 -DHAVE_X64 -DHAVE_X86_64 -DHAVE_X86")
ELSEIF(TARGET_X86)
ADD_PLATFORM_FLAGS("-arch i386 -DHAVE_X86")
ENDIF(TARGET_X64)
IF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-arch mips -DHAVE_MIPS")
ENDIF(TARGET_MIPS)
ELSEIF(TARGETS_COUNT EQUAL 0)
# Not using CMAKE_OSX_ARCHITECTURES, HAVE_XXX already defined before
IF(TARGET_ARM) IF(TARGET_ARM)
IF(TARGET_ARMV7S) IF(TARGET_ARMV7S)
ADD_PLATFORM_FLAGS("-arch armv7s") ADD_PLATFORM_FLAGS("-arch armv7s")
@ -621,15 +703,19 @@ MACRO(NL_SETUP_BUILD)
IF(TARGET_ARMV5) IF(TARGET_ARMV5)
ADD_PLATFORM_FLAGS("-arch armv5") ADD_PLATFORM_FLAGS("-arch armv5")
ENDIF(TARGET_ARMV5) ENDIF(TARGET_ARMV5)
ENDIF(TARGET_ARM)
IF(TARGET_X86) ADD_PLATFORM_FLAGS("-mthumb")
ADD_PLATFORM_FLAGS("-arch i386") ENDIF(TARGET_ARM)
ENDIF(TARGET_X86)
IF(TARGET_X64) IF(TARGET_X64)
ADD_PLATFORM_FLAGS("-arch x86_64") ADD_PLATFORM_FLAGS("-arch x86_64")
ELSEIF(TARGET_X86)
ADD_PLATFORM_FLAGS("-arch i386")
ENDIF(TARGET_X64) ENDIF(TARGET_X64)
IF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-arch mips")
ENDIF(TARGET_MIPS)
ELSE(TARGETS_COUNT EQUAL 1) ELSE(TARGETS_COUNT EQUAL 1)
IF(TARGET_ARMV6) IF(TARGET_ARMV6)
ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6") ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6")
@ -640,15 +726,21 @@ MACRO(NL_SETUP_BUILD)
ENDIF(TARGET_ARMV7) ENDIF(TARGET_ARMV7)
IF(TARGET_X86) IF(TARGET_X86)
ADD_PLATFORM_FLAGS("-arch i386 -Xarch_i386 -DHAVE_X86") ADD_PLATFORM_FLAGS("-Xarch_i386 -DHAVE_X86")
ENDIF(TARGET_X86) ENDIF(TARGET_X86)
IF(TARGET_X64) IF(TARGET_X64)
ADD_PLATFORM_FLAGS("-arch x86_64 -Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64") ADD_PLATFORM_FLAGS("-Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64")
ENDIF(TARGET_X64) ENDIF(TARGET_X64)
IF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-Xarch_mips -DHAVE_MIPS")
ENDIF(TARGET_MIPS)
ENDIF(TARGETS_COUNT EQUAL 1) ENDIF(TARGETS_COUNT EQUAL 1)
IF(IOS) IF(IOS)
SET(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE)
IF(IOS_VERSION) IF(IOS_VERSION)
PARSE_VERSION_STRING(${IOS_VERSION} IOS_VERSION_MAJOR IOS_VERSION_MINOR IOS_VERSION_PATCH) PARSE_VERSION_STRING(${IOS_VERSION} IOS_VERSION_MAJOR IOS_VERSION_MINOR IOS_VERSION_PATCH)
CONVERT_VERSION_NUMBER(${IOS_VERSION_MAJOR} ${IOS_VERSION_MINOR} ${IOS_VERSION_PATCH} IOS_VERSION_NUMBER) CONVERT_VERSION_NUMBER(${IOS_VERSION_MAJOR} ${IOS_VERSION_MINOR} ${IOS_VERSION_PATCH} IOS_VERSION_NUMBER)
@ -657,20 +749,44 @@ MACRO(NL_SETUP_BUILD)
ENDIF(IOS_VERSION) ENDIF(IOS_VERSION)
IF(CMAKE_IOS_SYSROOT) IF(CMAKE_IOS_SYSROOT)
ADD_PLATFORM_FLAGS("-isysroot${CMAKE_IOS_SYSROOT}") IF(TARGET_ARMV7S)
ADD_PLATFORM_FLAGS("-miphoneos-version-min=${IOS_VERSION}") IF(TARGETS_COUNT GREATER 1)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-iphoneos_version_min,${IOS_VERSION}") SET(XARCH "-Xarch_armv7s ")
ENDIF(TARGETS_COUNT GREATER 1)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
ENDIF(TARGET_ARMV7S)
IF(TARGET_ARMV7)
IF(TARGETS_COUNT GREATER 1)
SET(XARCH "-Xarch_armv7 ")
ENDIF(TARGETS_COUNT GREATER 1)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
ENDIF(TARGET_ARMV7)
IF(TARGET_ARMV6)
IF(TARGETS_COUNT GREATER 1)
SET(XARCH "-Xarch_armv6 ")
ENDIF(TARGETS_COUNT GREATER 1)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
ENDIF(TARGET_ARMV6)
ENDIF(CMAKE_IOS_SYSROOT) ENDIF(CMAKE_IOS_SYSROOT)
IF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86) IF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86)
IF(TARGETS_COUNT EQUAL 1) IF(TARGETS_COUNT GREATER 1)
ADD_PLATFORM_FLAGS("-arch i386")
ELSE(TARGETS_COUNT EQUAL 1)
SET(XARCH "-Xarch_i386 ") SET(XARCH "-Xarch_i386 ")
ENDIF(TARGETS_COUNT EQUAL 1) ENDIF(TARGETS_COUNT GREATER 1)
# Always force -mmacosx-version-min to override environement variable ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SIMULATOR_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") ADD_PLATFORM_FLAGS("${XARCH}-mios-simulator-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
ENDIF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86) ENDIF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86)
ELSE(IOS) ELSE(IOS)
@ -722,6 +838,46 @@ MACRO(NL_SETUP_BUILD)
ENDIF(CLANG) ENDIF(CLANG)
ENDIF(WITH_WARNINGS) ENDIF(WITH_WARNINGS)
IF(ANDROID)
ADD_PLATFORM_FLAGS("--sysroot=${PLATFORM_ROOT}")
ADD_PLATFORM_FLAGS("-ffunction-sections -funwind-tables")
ADD_PLATFORM_FLAGS("-DANDROID")
ADD_PLATFORM_FLAGS("-Wa,--noexecstack")
IF(TARGET_ARM)
ADD_PLATFORM_FLAGS("-fpic -fstack-protector")
ADD_PLATFORM_FLAGS("-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__")
IF(TARGET_ARMV7)
ADD_PLATFORM_FLAGS("-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -march=armv7-a -Wl,--fix-cortex-a8")
ELSEIF(TARGET_ARMV5)
ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float")
ENDIF(TARGET_ARMV7)
SET(TARGET_THUMB ON)
IF(TARGET_THUMB)
ADD_PLATFORM_FLAGS("-mthumb -fno-strict-aliasing -finline-limit=64")
SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm")
ELSE(TARGET_THUMB)
ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300")
SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -fno-strict-aliasing")
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -fstrict-aliasing")
ENDIF(TARGET_THUMB)
ELSEIF(TARGET_X86)
# Optimizations for Intel Atom
ADD_PLATFORM_FLAGS("-march=i686 -mtune=atom -mstackrealign -msse3 -mfpmath=sse -m32 -flto -ffast-math -funroll-loops")
ADD_PLATFORM_FLAGS("-fstack-protector -funswitch-loops -finline-limit=300")
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -fstrict-aliasing")
SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -fno-strict-aliasing")
ELSEIF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-fpic -finline-functions -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -fno-strict-aliasing")
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300")
ENDIF(TARGET_ARM)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -L${PLATFORM_ROOT}/usr/lib")
ENDIF(ANDROID)
IF(APPLE) IF(APPLE)
ADD_PLATFORM_FLAGS("-gdwarf-2") ADD_PLATFORM_FLAGS("-gdwarf-2")
ENDIF(APPLE) ENDIF(APPLE)
@ -775,7 +931,7 @@ ENDMACRO(NL_SETUP_BUILD_FLAGS)
MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE) MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE)
IF(IS_ABSOLUTE "${${NAME_RELATIVE}}") IF(IS_ABSOLUTE "${${NAME_RELATIVE}}")
SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}}) SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
ELSE(IS_ABSOLUTE "${${{NAME_RELATIVE}}") ELSE(IS_ABSOLUTE "${${NAME_RELATIVE}}")
IF(WIN32) IF(WIN32)
SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}}) SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
ELSE(WIN32) ELSE(WIN32)
@ -922,11 +1078,41 @@ MACRO(SETUP_EXTERNAL)
IF(WIN32) IF(WIN32)
FIND_PACKAGE(External REQUIRED) FIND_PACKAGE(External REQUIRED)
IF(MSVC10) IF(NOT VC_DIR)
IF(NOT MSVC10_REDIST_DIR) SET(VC_DIR $ENV{VC_DIR})
ENDIF(NOT VC_DIR)
IF(MSVC11)
IF(NOT MSVC_REDIST_DIR)
# If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC_REDIST_DIR)
IF(NOT VC_DIR)
IF(NOT VC_ROOT_DIR)
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\11.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\\WDExpress\\11.0_Config\\Setup\\VC;InstallDir]" ABSOLUTE)
IF(VC_ROOT_DIR MATCHES "registry")
SET(VS110COMNTOOLS $ENV{VS110COMNTOOLS})
IF(VS110COMNTOOLS)
FILE(TO_CMAKE_PATH ${VS110COMNTOOLS} VC_ROOT_DIR)
ENDIF(VS110COMNTOOLS)
IF(NOT VC_ROOT_DIR)
MESSAGE(FATAL_ERROR "Unable to find VC++ 2012 directory!")
ENDIF(NOT VC_ROOT_DIR)
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(NOT VC_ROOT_DIR)
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR})
ENDIF(NOT VC_DIR)
ELSEIF(MSVC10)
IF(NOT MSVC_REDIST_DIR)
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist") SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC10_REDIST_DIR) ENDIF(NOT MSVC_REDIST_DIR)
IF(NOT VC_DIR) IF(NOT VC_DIR)
IF(NOT VC_ROOT_DIR) IF(NOT VC_ROOT_DIR)
@ -948,7 +1134,7 @@ MACRO(SETUP_EXTERNAL)
# convert IDE fullpath to VC++ path # convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR}) STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR})
ENDIF(NOT VC_DIR) ENDIF(NOT VC_DIR)
ELSE(MSVC10) ELSE(MSVC11)
IF(NOT VC_DIR) IF(NOT VC_DIR)
IF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") IF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
# convert IDE fullpath to VC++ path # convert IDE fullpath to VC++ path
@ -958,7 +1144,7 @@ MACRO(SETUP_EXTERNAL)
STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER}) STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER})
ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
ENDIF(NOT VC_DIR) ENDIF(NOT VC_DIR)
ENDIF(MSVC10) ENDIF(MSVC11)
ELSE(WIN32) ELSE(WIN32)
IF(APPLE) IF(APPLE)
IF(WITH_STATIC_EXTERNAL) IF(WITH_STATIC_EXTERNAL)
@ -983,7 +1169,7 @@ MACRO(SETUP_EXTERNAL)
FIND_PACKAGE(WindowsSDK REQUIRED) FIND_PACKAGE(WindowsSDK REQUIRED)
# use VC++ and Windows SDK include paths # use VC++ and Windows SDK include paths
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIRS})
ENDIF(MSVC) ENDIF(MSVC)
ENDIF(WITH_STLPORT) ENDIF(WITH_STLPORT)
ENDMACRO(SETUP_EXTERNAL) ENDMACRO(SETUP_EXTERNAL)

View file

@ -293,6 +293,11 @@ public:
*/ */
virtual void forceDXTCCompression(bool dxtcComp)=0; virtual void forceDXTCCompression(bool dxtcComp)=0;
/** if different from 0, enable anisotropic filter on textures. -1 enables max value.
* Default is 0.
*/
virtual void setAnisotropicFilter(sint filter)=0;
/** if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..) /** if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..)
* to be divided by Divisor (2, 4, 8...) * to be divided by Divisor (2, 4, 8...)
* Default is 1. * Default is 1.

View file

@ -471,6 +471,7 @@ public:
virtual void delete3dMouseListener (U3dMouseListener *listener); virtual void delete3dMouseListener (U3dMouseListener *listener);
virtual TPolygonMode getPolygonMode (); virtual TPolygonMode getPolygonMode ();
virtual void forceDXTCCompression(bool dxtcComp); virtual void forceDXTCCompression(bool dxtcComp);
virtual void setAnisotropicFilter(sint filter);
virtual void forceTextureResize(uint divisor); virtual void forceTextureResize(uint divisor);
virtual void forceNativeFragmentPrograms(bool nativeOnly); virtual void forceNativeFragmentPrograms(bool nativeOnly);
virtual bool setMonitorColorProperties (const CMonitorColorProperties &properties); virtual bool setMonitorColorProperties (const CMonitorColorProperties &properties);

View file

@ -158,7 +158,7 @@ public:
// *************************************************************************** // ***************************************************************************
// Out of CLandscapeGlobals, because myabe used in __asm{} // Out of CLandscapeGlobals, because maybe used in __asm{}
extern uint NL3D_LandscapeGlobals_PassNTri; extern uint NL3D_LandscapeGlobals_PassNTri;
extern void *NL3D_LandscapeGlobals_PassTriCurPtr; extern void *NL3D_LandscapeGlobals_PassTriCurPtr;
extern CIndexBuffer::TFormat NL3D_LandscapeGlobals_PassTriFormat; extern CIndexBuffer::TFormat NL3D_LandscapeGlobals_PassTriFormat;

View file

@ -660,6 +660,11 @@ public:
*/ */
virtual void forceDXTCCompression(bool dxtcComp)=0; virtual void forceDXTCCompression(bool dxtcComp)=0;
/** if different from 0, enable anisotropic filter on textures. -1 enables max value.
* Default is 0.
*/
virtual void setAnisotropicFilter(sint filter)=0;
/** if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..) /** if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..)
* to be divided by Divisor (2, 4, 8...) * to be divided by Divisor (2, 4, 8...)
* Default is 1. * Default is 1.

View file

@ -19,6 +19,9 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
// Include from libxml2
#include <libxml/parser.h>
namespace NLGEORGES namespace NLGEORGES
{ {

View file

@ -19,6 +19,7 @@
#include "types_nl.h" #include "types_nl.h"
#include "tds.h" #include "tds.h"
#include "singleton.h"
namespace NLMISC { namespace NLMISC {

View file

@ -17,6 +17,7 @@
#ifndef NL_CONTIGUOUS_BLOCK_ALLOCATOR_H #ifndef NL_CONTIGUOUS_BLOCK_ALLOCATOR_H
#define NL_CONTIGUOUS_BLOCK_ALLOCATOR_H #define NL_CONTIGUOUS_BLOCK_ALLOCATOR_H
#include "types_nl.h"
namespace NLMISC namespace NLMISC
{ {

View file

@ -17,14 +17,14 @@
#ifndef NL_DEBUG_H #ifndef NL_DEBUG_H
#define NL_DEBUG_H #define NL_DEBUG_H
#include <cstdio>
#include "common.h" #include "common.h"
#include "log.h" #include "log.h"
#include "mutex.h" #include "mutex.h"
#include "mem_displayer.h" #include "mem_displayer.h"
#include "displayer.h" #include "displayer.h"
#include "app_context.h" #include "app_context.h"
#include <cstdio>
#include <set> #include <set>
namespace NLMISC namespace NLMISC
@ -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) || defined(NL_COMP_VC10) # if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 71
# 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) || defined(NL_COMP_VC10) # if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 71
# 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) || defined(NL_COMP_VC10) # if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 71
# define nlwarning __noop # define nlwarning __noop
# else # else
# define nlwarning 0&& # define nlwarning 0&&

View file

@ -17,6 +17,7 @@
#ifndef NL_FILE_H #ifndef NL_FILE_H
#define NL_FILE_H #define NL_FILE_H
#include "types_nl.h"
#include "stream.h" #include "stream.h"

View file

@ -17,6 +17,7 @@
#ifndef NL_FIXED_SIZE_ALLOCATOR_H #ifndef NL_FIXED_SIZE_ALLOCATOR_H
#define NL_FIXED_SIZE_ALLOCATOR_H #define NL_FIXED_SIZE_ALLOCATOR_H
#include "types_nl.h"
namespace NLMISC namespace NLMISC
{ {

View file

@ -17,6 +17,8 @@
#ifndef _GRID_TRAVERSAL_H #ifndef _GRID_TRAVERSAL_H
#define _GRID_TRAVERSAL_H #define _GRID_TRAVERSAL_H
#include "types_nl.h"
namespace NLMISC namespace NLMISC
{ {

View file

@ -19,7 +19,7 @@
#include "types_nl.h" #include "types_nl.h"
#include "game_device.h" #include "game_device.h"
#include "common.h"
namespace NLMISC namespace NLMISC
{ {

View file

@ -17,6 +17,7 @@
#ifndef RY_INTER_WINDOW_MSG_QUEUE_H #ifndef RY_INTER_WINDOW_MSG_QUEUE_H
#define RY_INTER_WINDOW_MSG_QUEUE_H #define RY_INTER_WINDOW_MSG_QUEUE_H
#include "types_nl.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS

View file

@ -586,7 +586,7 @@ extern uint32 NbMutexes;
/** /**
* This class ensure that the Value is accessed by only one thread. First you have to create a CSynchronized class with you type. * This class ensure that the Value is accessed by only one thread. First you have to create a CSynchronized class with your type.
* Then, if a thread want to modify or do anything on it, you create a CAccessor in a \b sub \b scope. You can modify the value * Then, if a thread want to modify or do anything on it, you create a CAccessor in a \b sub \b scope. You can modify the value
* of the CUnfairSynchronized using the value() function \b until the end of the scope. So you have to put the smaller scope as you can. * of the CUnfairSynchronized using the value() function \b until the end of the scope. So you have to put the smaller scope as you can.
* *

View file

@ -17,6 +17,7 @@
#ifndef NL_OBJECT_ARENA_ALLOCATOR_H #ifndef NL_OBJECT_ARENA_ALLOCATOR_H
#define NL_OBJECT_ARENA_ALLOCATOR_H #define NL_OBJECT_ARENA_ALLOCATOR_H
#include "types_nl.h"
#include "singleton.h" #include "singleton.h"
namespace NLMISC namespace NLMISC

View file

@ -17,9 +17,10 @@
#ifndef NL_P_THREAD_H #ifndef NL_P_THREAD_H
#define NL_P_THREAD_H #define NL_P_THREAD_H
#include "types_nl.h"
#ifdef NL_OS_UNIX #ifdef NL_OS_UNIX
#include "types_nl.h"
#include "thread.h" #include "thread.h"
#include <pthread.h> #include <pthread.h>

View file

@ -19,14 +19,13 @@
#include "types_nl.h" #include "types_nl.h"
#include "time_nl.h" #include "time_nl.h"
#include "common.h"
#include "string_mapper.h"
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "common.h"
#include "string_mapper.h"
namespace NLMISC { namespace NLMISC {
/// Exception throw when a find is not found in a lookup() call /// Exception throw when a find is not found in a lookup() call

View file

@ -21,6 +21,7 @@
#include "matrix.h" #include "matrix.h"
#include "stream.h" #include "stream.h"
#include "vector_2f.h" #include "vector_2f.h"
#include <vector> #include <vector>

View file

@ -18,6 +18,7 @@
#define NL_POOL_MEMORY_H #define NL_POOL_MEMORY_H
#include "types_nl.h" #include "types_nl.h"
#include <list> #include <list>
#include <vector> #include <vector>

View file

@ -20,6 +20,7 @@
#include "types_nl.h" #include "types_nl.h"
#include "vector.h" #include "vector.h"
#include "stream.h" #include "stream.h"
#include <cmath> #include <cmath>
namespace NLMISC namespace NLMISC

View file

@ -18,6 +18,8 @@
#ifndef NL_RESOURCE_PTR_INLINE_H #ifndef NL_RESOURCE_PTR_INLINE_H
#define NL_RESOURCE_PTR_INLINE_H #define NL_RESOURCE_PTR_INLINE_H
#include "types_nl.h"
namespace NLMISC namespace NLMISC
{ {

View file

@ -17,11 +17,11 @@
#ifndef NL_RGBA_H #ifndef NL_RGBA_H
#define NL_RGBA_H #define NL_RGBA_H
#include <algorithm>
#include "types_nl.h" #include "types_nl.h"
#include "common.h" #include "common.h"
#include <algorithm>
namespace NLMISC namespace NLMISC
{ {

View file

@ -17,11 +17,12 @@
#ifndef NL_SHA1_H #ifndef NL_SHA1_H
#define NL_SHA1_H #define NL_SHA1_H
#include <string> #include "types_nl.h"
#include "common.h" #include "common.h"
#include "stream.h" #include "stream.h"
#include <string>
struct CHashKey struct CHashKey
{ {
CHashKey () { HashKeyString.resize(20); } CHashKey () { HashKeyString.resize(20); }

View file

@ -352,7 +352,7 @@ public:
} }
}; };
#if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) || defined(NL_COMP_VC10) #if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 80
// 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

@ -18,6 +18,8 @@
#ifndef NL_SMARTPTR_INLINE_H #ifndef NL_SMARTPTR_INLINE_H
#define NL_SMARTPTR_INLINE_H #define NL_SMARTPTR_INLINE_H
#include "types_nl.h"
namespace NLMISC namespace NLMISC
{ {

View file

@ -19,6 +19,7 @@
#include "types_nl.h" #include "types_nl.h"
#include "stl_block_allocator.h" #include "stl_block_allocator.h"
#include <list> #include <list>

View file

@ -19,6 +19,7 @@
#include "types_nl.h" #include "types_nl.h"
#include "time_nl.h" #include "time_nl.h"
#include <deque> #include <deque>

View file

@ -21,6 +21,7 @@
#include "ucstring.h" #include "ucstring.h"
#include "class_registry.h" #include "class_registry.h"
#include "common.h" #include "common.h"
#include <utility> #include <utility>
#include <string> #include <string>
#include <vector> #include <vector>

View file

@ -17,10 +17,11 @@
#ifndef NL_STREAM_INLINE_H #ifndef NL_STREAM_INLINE_H
#define NL_STREAM_INLINE_H #define NL_STREAM_INLINE_H
#include <cstdio> #include "types_nl.h"
#include "debug.h" #include "debug.h"
#include <cstdio>
namespace NLMISC namespace NLMISC
{ {

View file

@ -19,6 +19,7 @@
#include "types_nl.h" #include "types_nl.h"
#include "common.h" #include "common.h"
#include <map> #include <map>
namespace NLMISC namespace NLMISC

View file

@ -18,6 +18,7 @@
#define NL_STRING_ID_ARRAY_H #define NL_STRING_ID_ARRAY_H
#include "types_nl.h" #include "types_nl.h"
#include "debug.h"
#include <cmath> #include <cmath>
#include <string> #include <string>
@ -25,8 +26,6 @@
#include <set> #include <set>
#include <algorithm> #include <algorithm>
#include "debug.h"
namespace NLMISC { namespace NLMISC {

View file

@ -18,13 +18,12 @@
#define STRING_MAPPER_H #define STRING_MAPPER_H
#include "types_nl.h" #include "types_nl.h"
#include "stream.h"
#include "mutex.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include "stream.h"
#include "mutex.h"
namespace NLMISC namespace NLMISC
{ {

View file

@ -51,12 +51,20 @@
# 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 >= 1600 # ifdef _MSC_VER
# define NL_COMP_VC
# if _MSC_VER >= 1700
# define NL_COMP_VC11
# define NL_COMP_VC_VERSION 110
# elif _MSC_VER >= 1600
# define NL_COMP_VC10 # define NL_COMP_VC10
# define NL_COMP_VC_VERSION 100
# elif _MSC_VER >= 1500 # elif _MSC_VER >= 1500
# define NL_COMP_VC9 # define NL_COMP_VC9
# define NL_COMP_VC_VERSION 90
# elif _MSC_VER >= 1400 # elif _MSC_VER >= 1400
# define NL_COMP_VC8 # define NL_COMP_VC8
# define NL_COMP_VC_VERSION 80
# undef nl_time # undef nl_time
# define nl_time _time32 // use the old 32 bit time function # define nl_time _time32 // use the old 32 bit time function
# undef nl_mktime # undef nl_mktime
@ -69,12 +77,16 @@
# define nl_difftime _difftime32 // use the old 32 bit time function # define nl_difftime _difftime32 // use the old 32 bit time function
# elif _MSC_VER >= 1310 # elif _MSC_VER >= 1310
# define NL_COMP_VC71 # define NL_COMP_VC71
# define NL_COMP_VC_VERSION 71
# elif _MSC_VER >= 1300 # elif _MSC_VER >= 1300
# define NL_COMP_VC7 # define NL_COMP_VC7
# define NL_COMP_VC_VERSION 70
# elif _MSC_VER >= 1200 # elif _MSC_VER >= 1200
# define NL_COMP_VC6 # define NL_COMP_VC6
# define NL_COMP_VC_VERSION 60
# define NL_COMP_NEED_PARAM_ON_METHOD # define NL_COMP_NEED_PARAM_ON_METHOD
# endif # endif
# endif
# if defined(_HAS_TR1) && (_HAS_TR1 + 0) // VC9 TR1 feature pack or later # if defined(_HAS_TR1) && (_HAS_TR1 + 0) // VC9 TR1 feature pack or later
# define NL_ISO_STDTR1_AVAILABLE # define NL_ISO_STDTR1_AVAILABLE
# define NL_ISO_STDTR1_HEADER(header) <header> # define NL_ISO_STDTR1_HEADER(header) <header>
@ -320,7 +332,7 @@ typedef unsigned int uint; // at least 32bits (depend of processor)
# define CHashMap std::tr1::unordered_map # define CHashMap std::tr1::unordered_map
# define CHashSet std::tr1::unordered_set # define CHashSet std::tr1::unordered_set
# define CHashMultiMap std::tr1::unordered_multimap # define CHashMultiMap std::tr1::unordered_multimap
#elif defined(NL_COMP_VC7) || defined(NL_COMP_VC71) || defined(NL_COMP_VC8) || defined(NL_COMP_VC9) // VC7 through 9 #elif defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 70 && NL_COMP_VC_VERSION <= 90) // VC7 through 9
# include <hash_map> # include <hash_map>
# include <hash_set> # include <hash_set>
# define CHashMap stdext::hash_map # define CHashMap stdext::hash_map
@ -366,7 +378,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) || defined(NL_COMP_VC10) # if defined(NL_COMP_VC) && (NL_COMP_VC_VERSION >= 80)
# 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

@ -17,6 +17,7 @@
#ifndef NL_WIN32_UTIL_H #ifndef NL_WIN32_UTIL_H
#define NL_WIN32_UTIL_H #define NL_WIN32_UTIL_H
#include "types_nl.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS

View file

@ -33,7 +33,7 @@ namespace NL3D
{ {
// *************************************************************************** // ***************************************************************************
const uint32 IDriver::InterfaceVersion = 0x6a; // added cursors methods const uint32 IDriver::InterfaceVersion = 0x6b; // added anisotropic filter
// *************************************************************************** // ***************************************************************************
IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" ) IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" )

View file

@ -292,6 +292,11 @@ CDriverD3D::CDriverD3D()
_CurrIndexBufferFormat = CIndexBuffer::IndicesUnknownFormat; _CurrIndexBufferFormat = CIndexBuffer::IndicesUnknownFormat;
_IsGeforce = false; _IsGeforce = false;
_NonPowerOfTwoTexturesSupported = false; _NonPowerOfTwoTexturesSupported = false;
_MaxAnisotropy = 0;
_AnisotropicMinSupported = false;
_AnisotropicMagSupported = false;
_AnisotropicMinCubeSupported = false;
_AnisotropicMagCubeSupported = false;
_FrustumLeft= -1.f; _FrustumLeft= -1.f;
_FrustumRight= 1.f; _FrustumRight= 1.f;
@ -1493,6 +1498,11 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r
_MaxVertexIndex = caps.MaxVertexIndex; _MaxVertexIndex = caps.MaxVertexIndex;
_IsGeforce = !(caps.DevCaps & D3DDEVCAPS_NPATCHES) && (caps.PixelShaderVersion >= D3DPS_VERSION(2, 0) || caps.PixelShaderVersion < D3DPS_VERSION(1, 4)); _IsGeforce = !(caps.DevCaps & D3DDEVCAPS_NPATCHES) && (caps.PixelShaderVersion >= D3DPS_VERSION(2, 0) || caps.PixelShaderVersion < D3DPS_VERSION(1, 4));
_NonPowerOfTwoTexturesSupported = !(caps.TextureCaps & D3DPTEXTURECAPS_POW2) || (caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL); _NonPowerOfTwoTexturesSupported = !(caps.TextureCaps & D3DPTEXTURECAPS_POW2) || (caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL);
_MaxAnisotropy = caps.MaxAnisotropy;
_AnisotropicMinSupported = (caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) != 0;
_AnisotropicMagSupported = (caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) != 0;
_AnisotropicMinCubeSupported = (caps.CubeTextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) != 0;
_AnisotropicMagCubeSupported = (caps.CubeTextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) != 0;
} }
else else
{ {
@ -1506,6 +1516,11 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r
_MaxVertexIndex = 0xffff; _MaxVertexIndex = 0xffff;
_IsGeforce = false; _IsGeforce = false;
_NonPowerOfTwoTexturesSupported = false; _NonPowerOfTwoTexturesSupported = false;
_MaxAnisotropy = 0;
_AnisotropicMinSupported = false;
_AnisotropicMagSupported = false;
_AnisotropicMinCubeSupported = false;
_AnisotropicMagCubeSupported = false;
} }
// If 16 bits vertices only, build a vb for quads rendering // If 16 bits vertices only, build a vb for quads rendering
if (_MaxVertexIndex <= 0xffff) if (_MaxVertexIndex <= 0xffff)
@ -1607,6 +1622,7 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r
// Init some variables // Init some variables
_ForceDXTCCompression = false; _ForceDXTCCompression = false;
_AnisotropicFilter = 0;
_ForceTextureResizePower = 0; _ForceTextureResizePower = 0;
_FogEnabled = false; _FogEnabled = false;
@ -2049,6 +2065,25 @@ void CDriverD3D::forceDXTCCompression(bool dxtcComp)
// *************************************************************************** // ***************************************************************************
void CDriverD3D::setAnisotropicFilter(sint filter)
{
H_AUTO_D3D(CDriverD3D_setAnisotropicFilter);
// anisotropic filter not supported
if (_MaxAnisotropy < 2) return;
if (filter < 0 || filter > _MaxAnisotropy)
{
_AnisotropicFilter = _MaxAnisotropy;
}
else
{
_AnisotropicFilter = filter;
}
}
// ***************************************************************************
void CDriverD3D::forceTextureResize(uint divisor) void CDriverD3D::forceTextureResize(uint divisor)
{ {
H_AUTO_D3D(CDriverD3D_forceTextureResize); H_AUTO_D3D(CDriverD3D_forceTextureResize);

View file

@ -777,6 +777,7 @@ public:
virtual void disableHardwareVertexArrayAGP(); virtual void disableHardwareVertexArrayAGP();
virtual void disableHardwareTextureShader(); virtual void disableHardwareTextureShader();
virtual void forceDXTCCompression(bool dxtcComp); virtual void forceDXTCCompression(bool dxtcComp);
virtual void setAnisotropicFilter(sint filter);
virtual void forceTextureResize(uint divisor); virtual void forceTextureResize(uint divisor);
virtual void forceNativeFragmentPrograms(bool /* nativeOnly */) {} // ignored virtual void forceNativeFragmentPrograms(bool /* nativeOnly */) {} // ignored
@ -1521,6 +1522,7 @@ public:
setSamplerState (stage, D3DSAMP_MAGFILTER, d3dtext->MagFilter); setSamplerState (stage, D3DSAMP_MAGFILTER, d3dtext->MagFilter);
setSamplerState (stage, D3DSAMP_MINFILTER, d3dtext->MinFilter); setSamplerState (stage, D3DSAMP_MINFILTER, d3dtext->MinFilter);
setSamplerState (stage, D3DSAMP_MIPFILTER, d3dtext->MipFilter); setSamplerState (stage, D3DSAMP_MIPFILTER, d3dtext->MipFilter);
setSamplerState (stage, D3DSAMP_MAXANISOTROPY, _AnisotropicFilter);
// Profile, log the use of this texture // Profile, log the use of this texture
if (_SumTextureMemoryUsed) if (_SumTextureMemoryUsed)
@ -2205,6 +2207,11 @@ private:
bool _CubbedMipMapSupported; bool _CubbedMipMapSupported;
bool _IsGeforce; bool _IsGeforce;
bool _NonPowerOfTwoTexturesSupported; bool _NonPowerOfTwoTexturesSupported;
uint _MaxAnisotropy;
bool _AnisotropicMinSupported;
bool _AnisotropicMagSupported;
bool _AnisotropicMinCubeSupported;
bool _AnisotropicMagCubeSupported;
uint _NbNeLTextureStages; // Number of texture stage for NeL (max IDRV_MAT_MAXTEXTURES) uint _NbNeLTextureStages; // Number of texture stage for NeL (max IDRV_MAT_MAXTEXTURES)
uint _MaxVerticesByVertexBufferHard; uint _MaxVerticesByVertexBufferHard;
uint _MaxLight; uint _MaxLight;
@ -2411,6 +2418,7 @@ private:
bool _MustRestoreLight; bool _MustRestoreLight;
D3DXMATRIX _D3DMatrixIdentity; D3DXMATRIX _D3DMatrixIdentity;
DWORD _FogColor; DWORD _FogColor;
uint _AnisotropicFilter;
// stencil buffer // stencil buffer
bool _CurStencilTest; bool _CurStencilTest;

View file

@ -355,8 +355,8 @@ bool CDriverD3D::activeShader(CShader *shd)
// Assemble the shader // Assemble the shader
LPD3DXBUFFER pErrorMsgs; LPD3DXBUFFER pErrorMsgs;
if (D3DXCreateEffect(_DeviceInterface, shd->getText(), (UINT)strlen(shd->getText())+1, NULL, NULL, 0, NULL, &(shaderInfo->Effect), &pErrorMsgs) HRESULT hr = D3DXCreateEffect(_DeviceInterface, shd->getText(), (UINT)strlen(shd->getText())+1, NULL, NULL, 0, NULL, &(shaderInfo->Effect), &pErrorMsgs);
== D3D_OK) if (hr == D3D_OK)
{ {
// Get the texture handle // Get the texture handle
uint i; uint i;
@ -374,7 +374,7 @@ bool CDriverD3D::activeShader(CShader *shd)
} }
else else
{ {
nlwarning ("Can't create shader '%s':", shd->getName()); nlwarning ("Can't create shader '%s' (0x%x):", shd->getName(), hr);
if (pErrorMsgs) if (pErrorMsgs)
nlwarning ((const char*)pErrorMsgs->GetBufferPointer()); nlwarning ((const char*)pErrorMsgs->GetBufferPointer());
shd->_ShaderChanged = false; shd->_ShaderChanged = false;

View file

@ -454,6 +454,7 @@ bool CDriverD3D::generateD3DTexture (ITexture& tex, bool textureDegradation, D3D
} }
else else
{ {
/*
// textures with mipmaps doesn't support not power of two sizes // textures with mipmaps doesn't support not power of two sizes
// only DXTC formats are beginning with a 'D' // only DXTC formats are beginning with a 'D'
if (supportNonPowerOfTwoTextures() && (!isPowerOf2(width) || !isPowerOf2(height)) && levels == 1) if (supportNonPowerOfTwoTextures() && (!isPowerOf2(width) || !isPowerOf2(height)) && levels == 1)
@ -464,6 +465,7 @@ bool CDriverD3D::generateD3DTexture (ITexture& tex, bool textureDegradation, D3D
_DeviceInterface->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); _DeviceInterface->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
_DeviceInterface->SetSamplerState(0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP); _DeviceInterface->SetSamplerState(0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);
} }
*/
HRESULT hr = _DeviceInterface->CreateTexture (width, height, levels, renderTarget?D3DUSAGE_RENDERTARGET:0, destFormat, renderTarget?D3DPOOL_DEFAULT:D3DPOOL_MANAGED, &(d3dtext->Texture2d), NULL); HRESULT hr = _DeviceInterface->CreateTexture (width, height, levels, renderTarget?D3DUSAGE_RENDERTARGET:0, destFormat, renderTarget?D3DPOOL_DEFAULT:D3DPOOL_MANAGED, &(d3dtext->Texture2d), NULL);
@ -506,6 +508,19 @@ inline void CDriverD3D::setupTextureWrapMode(ITexture& tex)
d3dtext->MagFilter = RemapMagTextureFilterTypeNeL2D3D[tex.getMagFilter()]; d3dtext->MagFilter = RemapMagTextureFilterTypeNeL2D3D[tex.getMagFilter()];
d3dtext->MinFilter = RemapMinTextureFilterTypeNeL2D3D[tex.getMinFilter()]; d3dtext->MinFilter = RemapMinTextureFilterTypeNeL2D3D[tex.getMinFilter()];
d3dtext->MipFilter = RemapMipTextureFilterTypeNeL2D3D[tex.getMinFilter()]; d3dtext->MipFilter = RemapMipTextureFilterTypeNeL2D3D[tex.getMinFilter()];
// only enable for min filter, because it's never supported for mag filter
if (_AnisotropicFilter > 1 && tex.getMinFilter() > ITexture::NearestMipMapLinear)
{
if (tex.isTextureCube())
{
if (_AnisotropicMinCubeSupported) d3dtext->MinFilter = D3DTEXF_ANISOTROPIC;
}
else
{
if (_AnisotropicMinSupported) d3dtext->MinFilter = D3DTEXF_ANISOTROPIC;
}
}
} }

View file

@ -27,7 +27,7 @@ ENDIF(WIN32)
NL_TARGET_DRIVER(${NLDRV_OGL_LIB} ${SRC}) NL_TARGET_DRIVER(${NLDRV_OGL_LIB} ${SRC})
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} nel3d nelmisc ${OPENGL_gl_LIBRARY}) TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} nel3d nelmisc ${OPENGL_gl_LIBRARY})
NL_DEFAULT_PROPS(${NLDRV_OGL_LIB} "NeL, Driver, Video: OpenGL") NL_DEFAULT_PROPS(${NLDRV_OGL_LIB} "NeL, Driver, Video: OpenGL")

View file

@ -34,8 +34,8 @@ extern "C" {
/* Header file version number */ /* Header file version number */
/* Current version at http://www.khronos.org/registry/egl/ */ /* Current version at http://www.khronos.org/registry/egl/ */
/* $Revision: 17614 $ on $Date: 2012-04-26 06:56:02 -0700 (Thu, 26 Apr 2012) $ */ /* $Revision: 19332 $ on $Date: 2012-09-28 17:56:20 -0700 (Fri, 28 Sep 2012) $ */
#define EGL_EGLEXT_VERSION 12 #define EGL_EGLEXT_VERSION 14
#ifndef EGL_KHR_config_attribs #ifndef EGL_KHR_config_attribs
#define EGL_KHR_config_attribs 1 #define EGL_KHR_config_attribs 1
@ -293,6 +293,25 @@ EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface sur
typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
#endif #endif
#ifndef EGL_ANDROID_image_native_buffer
#define EGL_ANDROID_image_native_buffer 1
struct ANativeWindowBuffer;
#define EGL_NATIVE_BUFFER_ANDROID 0x3140 /* eglCreateImageKHR target */
#endif
#ifndef EGL_ANDROID_swap_rectangle
#define EGL_ANDROID_swap_rectangle 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglSetSwapRectangleANDROID (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSWAPRECTANGLEANDROIDPROC) (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif
#ifndef EGL_ANDROID_recordable
#define EGL_ANDROID_recordable 1
#define EGL_RECORDABLE_ANDROID 0x3142 /* EGLConfig attribute */
#endif
#ifndef EGL_ANGLE_query_surface_pointer #ifndef EGL_ANGLE_query_surface_pointer
#define EGL_ANGLE_query_surface_pointer 1 #define EGL_ANGLE_query_surface_pointer 1
#ifdef EGL_EGLEXT_PROTOTYPES #ifdef EGL_EGLEXT_PROTOTYPES
@ -351,13 +370,13 @@ EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream); EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStream64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
#endif /* EGL_EGLEXT_PROTOTYPES */ #endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list); typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAM64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
#endif #endif
#endif #endif
@ -421,6 +440,47 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, E
/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */ /* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */
#endif #endif
#ifndef EGL_KHR_create_context
#define EGL_KHR_create_context 1
#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
#define EGL_CONTEXT_FLAGS_KHR 0x30FC
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
#define EGL_OPENGL_ES3_BIT_KHR 0x00000040
#endif
#ifndef EGL_KHR_surfaceless_context
#define EGL_KHR_surfaceless_context 1
/* No tokens/entry points, just relaxes an error condition */
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_cross_process_fd
#define EGL_KHR_stream_cross_process_fd 1
typedef int EGLNativeFileDescriptorKHR;
#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1))
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
#endif
#endif
#ifndef EGL_EXT_multiview_window
#define EGL_EXT_multiview_window 1
#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -444,6 +444,10 @@ extern "C" {
#define GLX_LATE_SWAPS_TEAR_EXT 0x20F3 #define GLX_LATE_SWAPS_TEAR_EXT 0x20F3
#endif #endif
#ifndef GLX_EXT_buffer_age
#define GLX_BACK_BUFFER_AGE_EXT 0x20F4
#endif
/*************************************************************/ /*************************************************************/
@ -993,6 +997,10 @@ typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx,
#define GLX_EXT_swap_control_tear 1 #define GLX_EXT_swap_control_tear 1
#endif #endif
#ifndef GLX_EXT_buffer_age
#define GLX_EXT_buffer_age 1
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1,7 +1,7 @@
#ifndef __glext_h_ #ifndef __glext_h_
#define __glext_h_ #define __glext_h_
/* $Revision: 16481 $ on $Date:: 2012-01-04 10:43:56 -0800 #$ */ /* $Revision: 19260 $ on $Date:: 2012-09-20 11:30:36 -0700 #$ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -165,6 +165,9 @@ typedef void* GLeglImageOES;
#define GL_DEPTH24_STENCIL8_OES 0x88F0 #define GL_DEPTH24_STENCIL8_OES 0x88F0
#endif #endif
/* GL_OES_required_internalformat */
/* No new tokens introduced by this extension. */
/* GL_OES_rgb8_rgba8 */ /* GL_OES_rgb8_rgba8 */
#ifndef GL_OES_rgb8_rgba8 #ifndef GL_OES_rgb8_rgba8
#define GL_RGB8_OES 0x8051 #define GL_RGB8_OES 0x8051
@ -240,7 +243,7 @@ typedef void* GLeglImageOES;
* APPLE extension tokens * APPLE extension tokens
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/
/* GL_APPLE_texture_2D_limited_npot */ /* GL_APPLE_copy_texture_levels */
/* No new tokens introduced by this extension. */ /* No new tokens introduced by this extension. */
/* GL_APPLE_framebuffer_multisample */ /* GL_APPLE_framebuffer_multisample */
@ -254,6 +257,41 @@ typedef void* GLeglImageOES;
#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA #define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA
#endif #endif
/* GL_APPLE_sync */
#ifndef GL_APPLE_sync
/* These types are defined with reference to <inttypes.h>
* in the Apple extension spec, but here we use the Khronos
* portable types in khrplatform.h, and assume those types
* are always defined.
* If any other extensions using these types are defined,
* the typedefs must move out of this block and be shared.
*/
typedef khronos_int64_t GLint64;
typedef khronos_uint64_t GLuint64;
typedef struct __GLsync *GLsync;
#define GL_SYNC_OBJECT_APPLE 0x8A53
#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111
#define GL_OBJECT_TYPE_APPLE 0x9112
#define GL_SYNC_CONDITION_APPLE 0x9113
#define GL_SYNC_STATUS_APPLE 0x9114
#define GL_SYNC_FLAGS_APPLE 0x9115
#define GL_SYNC_FENCE_APPLE 0x9116
#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117
#define GL_UNSIGNALED_APPLE 0x9118
#define GL_SIGNALED_APPLE 0x9119
#define GL_ALREADY_SIGNALED_APPLE 0x911A
#define GL_TIMEOUT_EXPIRED_APPLE 0x911B
#define GL_CONDITION_SATISFIED_APPLE 0x911C
#define GL_WAIT_FAILED_APPLE 0x911D
#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001
#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull
#endif
/* GL_APPLE_texture_2D_limited_npot */
/* No new tokens introduced by this extension. */
/* GL_APPLE_texture_format_BGRA8888 */ /* GL_APPLE_texture_format_BGRA8888 */
#ifndef GL_APPLE_texture_format_BGRA8888 #ifndef GL_APPLE_texture_format_BGRA8888
#define GL_BGRA_EXT 0x80E1 #define GL_BGRA_EXT 0x80E1
@ -288,12 +326,23 @@ typedef void* GLeglImageOES;
#define GL_STENCIL_EXT 0x1802 #define GL_STENCIL_EXT 0x1802
#endif #endif
/* GL_EXT_map_buffer_range */
#ifndef GL_EXT_map_buffer_range
#define GL_MAP_READ_BIT_EXT 0x0001
#define GL_MAP_WRITE_BIT_EXT 0x0002
#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
#endif
/* GL_EXT_multisampled_render_to_texture */ /* GL_EXT_multisampled_render_to_texture */
#ifndef GL_EXT_multisampled_render_to_texture #ifndef GL_EXT_multisampled_render_to_texture
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
#define GL_RENDERBUFFER_SAMPLES_EXT 0x9133 /* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x9134 #define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
#define GL_MAX_SAMPLES_EXT 0x9135 #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
#define GL_MAX_SAMPLES_EXT 0x8D57
#endif #endif
/* GL_EXT_multi_draw_arrays */ /* GL_EXT_multi_draw_arrays */
@ -771,6 +820,11 @@ typedef void (GL_APIENTRYP PFNGLWEIGHTPOINTEROESPROC) (GLint size, GLenum type,
#define GL_OES_packed_depth_stencil 1 #define GL_OES_packed_depth_stencil 1
#endif #endif
/* GL_OES_required_internalformat */
#ifndef GL_OES_required_internalformat
#define GL_OES_required_internalformat 1
#endif
/* GL_OES_query_matrix */ /* GL_OES_query_matrix */
#ifndef GL_OES_query_matrix #ifndef GL_OES_query_matrix
#define GL_OES_query_matrix 1 #define GL_OES_query_matrix 1
@ -892,9 +946,13 @@ typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
* APPLE extension functions * APPLE extension functions
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/
/* GL_APPLE_texture_2D_limited_npot */ /* GL_APPLE_copy_texture_levels */
#ifndef GL_APPLE_texture_2D_limited_npot #ifndef GL_APPLE_copy_texture_levels
#define GL_APPLE_texture_2D_limited_npot 1 #define GL_APPLE_copy_texture_levels 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
#endif
typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
#endif #endif
/* GL_APPLE_framebuffer_multisample */ /* GL_APPLE_framebuffer_multisample */
@ -908,6 +966,32 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum
typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
#endif #endif
/* GL_APPLE_sync */
#ifndef GL_APPLE_sync
#define GL_APPLE_sync 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags);
GL_API GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync);
GL_API void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync);
GL_API GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
GL_API void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
GL_API void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params);
GL_API void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
#endif
typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags);
typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync);
typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync);
typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params);
typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
#endif
/* GL_APPLE_texture_2D_limited_npot */
#ifndef GL_APPLE_texture_2D_limited_npot
#define GL_APPLE_texture_2D_limited_npot 1
#endif
/* GL_APPLE_texture_format_BGRA8888 */ /* GL_APPLE_texture_format_BGRA8888 */
#ifndef GL_APPLE_texture_format_BGRA8888 #ifndef GL_APPLE_texture_format_BGRA8888
#define GL_APPLE_texture_format_BGRA8888 1 #define GL_APPLE_texture_format_BGRA8888 1
@ -945,6 +1029,17 @@ GL_API void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttac
typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
#endif #endif
/* GL_EXT_map_buffer_range */
#ifndef GL_EXT_map_buffer_range
#define GL_EXT_map_buffer_range 1
#ifdef GL_GLEXT_PROTOTYPES
GL_API void GL_APIENTRY *glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
GL_API void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length);
#endif
typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
#endif
/* GL_EXT_multisampled_render_to_texture */ /* GL_EXT_multisampled_render_to_texture */
#ifndef GL_EXT_multisampled_render_to_texture #ifndef GL_EXT_multisampled_render_to_texture
#define GL_EXT_multisampled_render_to_texture 1 #define GL_EXT_multisampled_render_to_texture 1
@ -1068,8 +1163,8 @@ typedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMGPROC) (GLenum p, const GLfixed *eqn
GL_API void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); GL_API void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
#endif #endif
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
#endif #endif
/*------------------------------------------------------------------------* /*------------------------------------------------------------------------*

View file

@ -161,21 +161,12 @@ const uint CDriverGL::_EVSNumConstant = 97;
GLenum CDriverGL::NLCubeFaceToGLCubeFace[6] = GLenum CDriverGL::NLCubeFaceToGLCubeFace[6] =
{ {
#ifdef USE_OPENGLES
GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES
#else
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
#endif
}; };
// *************************************************************************** // ***************************************************************************
@ -305,6 +296,8 @@ CDriverGL::CDriverGL()
_NVTextureShaderEnabled = false; _NVTextureShaderEnabled = false;
_AnisotropicFilter = 0.f;
// Compute the Flag which say if one texture has been changed in CMaterial. // Compute the Flag which say if one texture has been changed in CMaterial.
_MaterialAllTextureTouchedFlag= 0; _MaterialAllTextureTouchedFlag= 0;
for(i=0; i < IDRV_MAT_MAXTEXTURES; i++) for(i=0; i < IDRV_MAT_MAXTEXTURES; i++)
@ -1337,11 +1330,7 @@ void CDriverGL::copyFrameBufferToTexture(ITexture *tex,
{ {
if(_Extensions.ARBTextureCubeMap) if(_Extensions.ARBTextureCubeMap)
{ {
#ifdef USE_OPENGLES
glBindTexture(GL_TEXTURE_CUBE_MAP_OES, gltext->ID);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID);
#endif
glCopyTexSubImage2D(NLCubeFaceToGLCubeFace[cubeFace], level, offsetx, offsety, x, y, width, height); glCopyTexSubImage2D(NLCubeFaceToGLCubeFace[cubeFace], level, offsetx, offsety, x, y, width, height);
} }
} }
@ -2626,11 +2615,10 @@ void CDriverGL::checkTextureOn() const
GLboolean flagCM; GLboolean flagCM;
GLboolean flagTR; GLboolean flagTR;
glGetBooleanv(GL_TEXTURE_2D, &flag2D); glGetBooleanv(GL_TEXTURE_2D, &flag2D);
glGetBooleanv(GL_TEXTURE_CUBE_MAP_ARB, &flagCM);
#ifdef USE_OPENGLES #ifdef USE_OPENGLES
glGetBooleanv(GL_TEXTURE_CUBE_MAP_OES, &flagCM);
flagTR = true; // always true in OpenGL ES flagTR = true; // always true in OpenGL ES
#else #else
glGetBooleanv(GL_TEXTURE_CUBE_MAP_ARB, &flagCM);
glGetBooleanv(GL_TEXTURE_RECTANGLE_NV, &flagTR); glGetBooleanv(GL_TEXTURE_RECTANGLE_NV, &flagTR);
#endif #endif
switch(dgs.getTextureMode()) switch(dgs.getTextureMode())

View file

@ -364,6 +364,7 @@ public:
virtual bool uploadTextureCube (ITexture& tex, NLMISC::CRect& rect, uint8 nNumMipMap, uint8 nNumFace); virtual bool uploadTextureCube (ITexture& tex, NLMISC::CRect& rect, uint8 nNumMipMap, uint8 nNumFace);
virtual void forceDXTCCompression(bool dxtcComp); virtual void forceDXTCCompression(bool dxtcComp);
virtual void setAnisotropicFilter(sint filter);
virtual void forceTextureResize(uint divisor); virtual void forceTextureResize(uint divisor);
@ -955,6 +956,8 @@ private:
bool _NVTextureShaderEnabled; bool _NVTextureShaderEnabled;
// Which stages support EMBM // Which stages support EMBM
bool _StageSupportEMBM[IDRV_MAT_MAXTEXTURES]; bool _StageSupportEMBM[IDRV_MAT_MAXTEXTURES];
// Anisotropic filtering value
float _AnisotropicFilter;
// Prec settings for material. // Prec settings for material.
CDriverGLStates _DriverGLStates; CDriverGLStates _DriverGLStates;

View file

@ -628,7 +628,7 @@ static bool setupARBTextureNonPowerOfTwo(const char *glext)
{ {
H_AUTO_OGL(setupARBTextureCompression); H_AUTO_OGL(setupARBTextureCompression);
#ifndef USE_OPENGL_ES #ifndef USE_OPENGLES
CHECK_EXT("GL_ARB_texture_non_power_of_two"); CHECK_EXT("GL_ARB_texture_non_power_of_two");
#endif #endif
@ -805,20 +805,20 @@ static bool setupARBTextureCubeMap(const char *glext)
#ifdef USE_OPENGLES #ifdef USE_OPENGLES
CHECK_EXT("OES_texture_cube_map"); CHECK_EXT("OES_texture_cube_map");
CHECK_ADDRESS(NEL_PFNGLTEXGENFOESPROC, glTexGenfOES);
CHECK_ADDRESS(NEL_PFNGLTEXGENFVOESPROC, glTexGenfvOES);
CHECK_ADDRESS(NEL_PFNGLTEXGENIOESPROC, glTexGeniOES);
CHECK_ADDRESS(NEL_PFNGLTEXGENIVOESPROC, glTexGenivOES);
CHECK_ADDRESS(NEL_PFNGLTEXGENXOESPROC, glTexGenxOES);
CHECK_ADDRESS(NEL_PFNGLTEXGENXVOESPROC, glTexGenxvOES);
CHECK_ADDRESS(NEL_PFNGLGETTEXGENFVOESPROC, glGetTexGenfvOES);
CHECK_ADDRESS(NEL_PFNGLGETTEXGENIVOESPROC, glGetTexGenivOES);
CHECK_ADDRESS(NEL_PFNGLGETTEXGENXVOESPROC, glGetTexGenxvOES);
#else #else
CHECK_EXT("GL_ARB_texture_cube_map"); CHECK_EXT("GL_ARB_texture_cube_map");
#endif #endif
// CHECK_ADDRESS(NEL_PFNGLTEXGENFOESPROC, glTexGenfOES);
// CHECK_ADDRESS(NEL_PFNGLTEXGENFVOESPROC, glTexGenfvOES);
// CHECK_ADDRESS(NEL_PFNGLTEXGENIOESPROC, glTexGeniOES);
// CHECK_ADDRESS(NEL_PFNGLTEXGENIVOESPROC, glTexGenivOES);
// CHECK_ADDRESS(NEL_PFNGLTEXGENXOESPROC, glTexGenxOES);
// CHECK_ADDRESS(NEL_PFNGLTEXGENXVOESPROC, glTexGenxvOES);
// CHECK_ADDRESS(NEL_PFNGLGETTEXGENFVOESPROC, glGetTexGenfvOES);
// CHECK_ADDRESS(NEL_PFNGLGETTEXGENIVOESPROC, glGetTexGenivOES);
// CHECK_ADDRESS(NEL_PFNGLGETTEXGENXVOESPROC, glGetTexGenxvOES);
return true; return true;
} }
@ -1499,11 +1499,7 @@ void registerGlExtensions(CGlExtensions &ext)
ext.ARBMultiTexture= setupARBMultiTexture(glext); ext.ARBMultiTexture= setupARBMultiTexture(glext);
if(ext.ARBMultiTexture) if(ext.ARBMultiTexture)
{ {
#ifdef USE_OPENGLES
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &ntext);
#else
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &ntext); glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &ntext);
#endif
// We could have more than IDRV_MAT_MAXTEXTURES but the interface only // We could have more than IDRV_MAT_MAXTEXTURES but the interface only
// support IDRV_MAT_MAXTEXTURES texture stages so take min // support IDRV_MAT_MAXTEXTURES texture stages so take min
ext.NbTextureStages= (ntext<((GLint)IDRV_MAT_MAXTEXTURES)?ntext:IDRV_MAT_MAXTEXTURES); ext.NbTextureStages= (ntext<((GLint)IDRV_MAT_MAXTEXTURES)?ntext:IDRV_MAT_MAXTEXTURES);

View file

@ -157,7 +157,7 @@ public:
NVTextureRectangle = false; NVTextureRectangle = false;
EXTTextureRectangle = false; EXTTextureRectangle = false;
EXTTextureFilterAnisotropic = false; EXTTextureFilterAnisotropic = false;
EXTTextureFilterAnisotropicMaximum = 1.f; EXTTextureFilterAnisotropicMaximum = 0.f;
ARBTextureRectangle = false; ARBTextureRectangle = false;
ARBTextureNonPowerOfTwo = false; ARBTextureNonPowerOfTwo = false;
ARBMultisample = false; ARBMultisample = false;
@ -781,3 +781,4 @@ extern NEL_PFNGLSAMPLECOVERAGEARBPROC nglSampleCoverageARB;
#endif // USE_OPENGLES #endif // USE_OPENGLES
#endif // NL_OPENGL_EXTENSION_H #endif // NL_OPENGL_EXTENSION_H

View file

@ -63,6 +63,27 @@ typedef void (APIENTRY * NEL_PFNGLGETTEXGENFVOESPROC) (GLenum coord, GLenum pnam
typedef void (APIENTRY * NEL_PFNGLGETTEXGENIVOESPROC) (GLenum coord, GLenum pname, GLint *params); typedef void (APIENTRY * NEL_PFNGLGETTEXGENIVOESPROC) (GLenum coord, GLenum pname, GLint *params);
typedef void (APIENTRY * NEL_PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); typedef void (APIENTRY * NEL_PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params);
#define GL_MULTISAMPLE_ARB GL_MULTISAMPLE
#define GL_TEXTURE_CUBE_MAP_ARB GL_TEXTURE_CUBE_MAP_OES
#define GL_NONE 0
#define GL_MAX_TEXTURE_UNITS_ARB GL_MAX_TEXTURE_UNITS
#define GL_REFLECTION_MAP_ARB GL_REFLECTION_MAP_OES
#define GL_RGB_SCALE_EXT GL_RGB_SCALE
#define GL_REFLECTION_MAP_ARB GL_REFLECTION_MAP_OES
#define GL_PREVIOUS_EXT GL_PREVIOUS
#define GL_PRIMARY_COLOR_EXT GL_PRIMARY_COLOR
#define GL_CONSTANT_EXT GL_CONSTANT
#define GL_ADD_SIGNED_EXT GL_ADD_SIGNED
#define GL_INTERPOLATE_EXT GL_INTERPOLATE
#define GL_BUMP_ENVMAP_ATI GL_INTERPOLATE
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES
#else #else
// *************************************************************************** // ***************************************************************************

View file

@ -87,10 +87,9 @@ static inline void convTexAddr(ITexture *tex, CMaterial::TTexAddressingMode mode
nlassert(mode < CMaterial::TexAddrCount); nlassert(mode < CMaterial::TexAddrCount);
static const GLenum glTex2dAddrModesNV[] = static const GLenum glTex2dAddrModesNV[] =
{ {
#ifdef USE_OPENGLES GL_NONE, GL_TEXTURE_2D,
0, GL_TEXTURE_2D #ifndef USE_OPENGLES
#else GL_PASS_THROUGH_NV, GL_CULL_FRAGMENT_NV,
GL_NONE, GL_TEXTURE_2D, GL_PASS_THROUGH_NV, GL_CULL_FRAGMENT_NV,
GL_OFFSET_TEXTURE_2D_NV, GL_OFFSET_TEXTURE_2D_SCALE_NV, GL_OFFSET_TEXTURE_2D_NV, GL_OFFSET_TEXTURE_2D_SCALE_NV,
GL_DEPENDENT_AR_TEXTURE_2D_NV, GL_DEPENDENT_GB_TEXTURE_2D_NV, GL_DEPENDENT_AR_TEXTURE_2D_NV, GL_DEPENDENT_GB_TEXTURE_2D_NV,
GL_DOT_PRODUCT_NV, GL_DOT_PRODUCT_TEXTURE_2D_NV, GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV, GL_DOT_PRODUCT_NV, GL_DOT_PRODUCT_TEXTURE_2D_NV, GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV,
@ -101,10 +100,9 @@ static inline void convTexAddr(ITexture *tex, CMaterial::TTexAddressingMode mode
static const GLenum glTexCubeAddrModesNV[] = static const GLenum glTexCubeAddrModesNV[] =
{ {
#ifdef USE_OPENGLES GL_NONE, GL_TEXTURE_CUBE_MAP_ARB,
0, GL_TEXTURE_CUBE_MAP_OES #ifndef USE_OPENGLES
#else GL_PASS_THROUGH_NV, GL_CULL_FRAGMENT_NV,
GL_NONE, GL_TEXTURE_CUBE_MAP_ARB, GL_PASS_THROUGH_NV, GL_CULL_FRAGMENT_NV,
GL_OFFSET_TEXTURE_2D_NV, GL_OFFSET_TEXTURE_2D_SCALE_NV, GL_OFFSET_TEXTURE_2D_NV, GL_OFFSET_TEXTURE_2D_SCALE_NV,
GL_DEPENDENT_AR_TEXTURE_2D_NV, GL_DEPENDENT_GB_TEXTURE_2D_NV, GL_DEPENDENT_AR_TEXTURE_2D_NV, GL_DEPENDENT_GB_TEXTURE_2D_NV,
GL_DOT_PRODUCT_NV, GL_DOT_PRODUCT_TEXTURE_2D_NV, GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV, GL_DOT_PRODUCT_NV, GL_DOT_PRODUCT_TEXTURE_2D_NV, GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV,
@ -147,11 +145,7 @@ void CDriverGL::setTextureEnvFunction(uint stage, CMaterial& mat)
{ {
// Cubic or normal ? // Cubic or normal ?
if (text->isTextureCube ()) if (text->isTextureCube ())
#ifdef USE_OPENGLES
_DriverGLStates.setTexGenMode (stage, GL_REFLECTION_MAP_OES);
#else
_DriverGLStates.setTexGenMode (stage, GL_REFLECTION_MAP_ARB); _DriverGLStates.setTexGenMode (stage, GL_REFLECTION_MAP_ARB);
#endif
else else
#ifdef USE_OPENGLES #ifdef USE_OPENGLES
_DriverGLStates.setTexGenMode (stage, GL_TEXTURE_CUBE_MAP_OES); _DriverGLStates.setTexGenMode (stage, GL_TEXTURE_CUBE_MAP_OES);
@ -974,11 +968,7 @@ 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
} }
} }
} }
@ -1087,11 +1077,7 @@ 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
} }
} }
} }
@ -1165,12 +1151,7 @@ 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);

View file

@ -165,11 +165,9 @@ void CDriverGLStates::forceDefaults(uint nbStages)
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);
#ifdef USE_OPENGLES
glDisable(GL_TEXTURE_GEN_STR_OES);
#endif #endif
} }
@ -393,6 +391,7 @@ void CDriverGLStates::enableMultisample(bool enable)
{ {
// new state. // new state.
_CurMultisample= enable; _CurMultisample= enable;
// Setup GLState. // Setup GLState.
if(_CurMultisample) if(_CurMultisample)
glEnable(GL_MULTISAMPLE_ARB); glEnable(GL_MULTISAMPLE_ARB);
@ -686,7 +685,7 @@ void CDriverGLStates::setTexGenMode (uint stage, GLint mode)
else else
{ {
#ifdef USE_OPENGLES #ifdef USE_OPENGLES
// nglTexGeniOES(GL_TEXTURE_GEN_STR_OES, GL_TEXTURE_GEN_MODE_OES, mode); nglTexGeniOES(GL_TEXTURE_GEN_STR_OES, GL_TEXTURE_GEN_MODE_OES, mode);
#else #else
glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, mode); glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, mode);
glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, mode); glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, mode);
@ -702,8 +701,8 @@ void CDriverGLStates::setTexGenMode (uint stage, GLint mode)
#ifdef USE_OPENGLES #ifdef USE_OPENGLES
// if(mode==GL_OBJECT_LINEAR || mode==GL_EYE_LINEAR) // if(mode==GL_OBJECT_LINEAR || mode==GL_EYE_LINEAR)
// { // {
nglTexGeniOES(GL_TEXTURE_GEN_STR_OES, GL_TEXTURE_GEN_MODE_OES, mode); // nglTexGeniOES(GL_TEXTURE_GEN_STR_OES, GL_TEXTURE_GEN_MODE_OES, mode);
glEnable(GL_TEXTURE_GEN_STR_OES); // glEnable(GL_TEXTURE_GEN_STR_OES);
// } // }
// else // else
// { // {
@ -742,11 +741,7 @@ 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 #ifndef USE_OPENGLES
@ -789,11 +784,7 @@ 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
{ {
@ -823,11 +814,7 @@ void CDriverGLStates::setTextureMode(TTextureMode texMode)
{ {
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
{ {
@ -872,11 +859,11 @@ void CDriverGLStates::forceActiveTextureARB(uint stage)
_CurrentActiveTextureARB= stage; _CurrentActiveTextureARB= stage;
} }
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableVertexArray(bool enable) void CDriverGLStates::enableVertexArray(bool enable)
{ {
H_AUTO_OGL(CDriverGLStates_enableVertexArray) H_AUTO_OGL(CDriverGLStates_enableVertexArray);
if(_VertexArrayEnabled != enable) if(_VertexArrayEnabled != enable)
{ {
if(enable) if(enable)
@ -1038,7 +1025,7 @@ void CDriverGLStates::enableVertexAttribArrayARB(uint glIndex,bool enable)
// *************************************************************************** // ***************************************************************************
void CDriverGLStates::enableVertexAttribArrayForEXTVertexShader(uint glIndex, bool enable, uint *variants) void CDriverGLStates::enableVertexAttribArrayForEXTVertexShader(uint glIndex, bool enable, uint *variants)
{ {
H_AUTO_OGL(CDriverGLStates_enableVertexAttribArrayForEXTVertexShader) H_AUTO_OGL(CDriverGLStates_enableVertexAttribArrayForEXTVertexShader);
if(_VertexAttribArrayEnabled[glIndex] != enable) if(_VertexAttribArrayEnabled[glIndex] != enable)
{ {

View file

@ -781,11 +781,7 @@ void CDriverGL::bindTextureWithMode(ITexture &tex)
{ {
_DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap); _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap);
// Bind this texture // Bind this texture
#ifdef USE_OPENGLES
glBindTexture(GL_TEXTURE_CUBE_MAP_OES, gltext->ID);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID);
#endif
} }
} }
else else
@ -820,19 +816,16 @@ void CDriverGL::setupTextureBasicParameters(ITexture &tex)
{ {
if (_Extensions.ARBTextureCubeMap) if (_Extensions.ARBTextureCubeMap)
{ {
#ifdef USE_OPENGLES
glTexParameteri(GL_TEXTURE_CUBE_MAP_OES,GL_TEXTURE_WRAP_S, translateWrapToGl(ITexture::Clamp, _Extensions));
glTexParameteri(GL_TEXTURE_CUBE_MAP_OES,GL_TEXTURE_WRAP_T, translateWrapToGl(ITexture::Clamp, _Extensions));
// glTexParameteri(GL_TEXTURE_CUBE_MAP_OES,GL_TEXTURE_WRAP_R, translateWrapToGl(ITexture::Clamp, _Extensions));
glTexParameteri(GL_TEXTURE_CUBE_MAP_OES,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
glTexParameteri(GL_TEXTURE_CUBE_MAP_OES,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
#else
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_S, translateWrapToGl(ITexture::Clamp, _Extensions)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_S, translateWrapToGl(ITexture::Clamp, _Extensions));
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_T, translateWrapToGl(ITexture::Clamp, _Extensions)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_T, translateWrapToGl(ITexture::Clamp, _Extensions));
#ifndef USE_OPENGLES
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_R, translateWrapToGl(ITexture::Clamp, _Extensions)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_R, translateWrapToGl(ITexture::Clamp, _Extensions));
#endif
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
#endif
if (_AnisotropicFilter > 1.f && gltext->MinFilter > ITexture::NearestMipMapLinear)
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAX_ANISOTROPY_EXT, _AnisotropicFilter);
} }
} }
else else
@ -841,6 +834,9 @@ void CDriverGL::setupTextureBasicParameters(ITexture &tex)
glTexParameteri(gltext->TextureMode,GL_TEXTURE_WRAP_T, translateWrapToGl(gltext->WrapT, _Extensions)); glTexParameteri(gltext->TextureMode,GL_TEXTURE_WRAP_T, translateWrapToGl(gltext->WrapT, _Extensions));
glTexParameteri(gltext->TextureMode,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); glTexParameteri(gltext->TextureMode,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
glTexParameteri(gltext->TextureMode,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); glTexParameteri(gltext->TextureMode,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
if (_AnisotropicFilter > 1.f && gltext->MinFilter > ITexture::NearestMipMapLinear)
glTexParameteri(gltext->TextureMode, GL_TEXTURE_MAX_ANISOTROPY_EXT, _AnisotropicFilter);
} }
// //
tex.clearFilterOrWrapModeTouched(); tex.clearFilterOrWrapModeTouched();
@ -1516,31 +1512,19 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex)
_CurrentTextureInfoGL[stage]= gltext; _CurrentTextureInfoGL[stage]= gltext;
// setup this texture // setup this texture
#ifdef USE_OPENGLES
glBindTexture(GL_TEXTURE_CUBE_MAP_OES, gltext->ID);
#else
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID);
#endif
// Change parameters of texture, if necessary. // Change parameters of texture, if necessary.
//============================================ //============================================
if(gltext->MagFilter!= tex->getMagFilter()) if(gltext->MagFilter!= tex->getMagFilter())
{ {
gltext->MagFilter= tex->getMagFilter(); gltext->MagFilter= tex->getMagFilter();
#ifdef USE_OPENGLES
glTexParameteri(GL_TEXTURE_CUBE_MAP_OES,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
#else
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
#endif
} }
if(gltext->MinFilter!= tex->getMinFilter()) if(gltext->MinFilter!= tex->getMinFilter())
{ {
gltext->MinFilter= tex->getMinFilter(); gltext->MinFilter= tex->getMinFilter();
#ifdef USE_OPENGLES
glTexParameteri(GL_TEXTURE_CUBE_MAP_OES,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
#else
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
#endif
} }
} }
} }
@ -1617,34 +1601,16 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex)
// This maps the CMaterial::TTexOperator // This maps the CMaterial::TTexOperator
static const GLenum OperatorLUT[9]= { GL_REPLACE, GL_MODULATE, GL_ADD, static const GLenum OperatorLUT[9]= { GL_REPLACE, GL_MODULATE, GL_ADD, GL_ADD_SIGNED_EXT, GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_BUMP_ENVMAP_ATI };
#ifdef USE_OPENGLES
GL_ADD_SIGNED, GL_INTERPOLATE, GL_INTERPOLATE, GL_INTERPOLATE, GL_INTERPOLATE, GL_INTERPOLATE
#else
GL_ADD_SIGNED_EXT, GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_BUMP_ENVMAP_ATI
#endif
};
// This maps the CMaterial::TTexSource // This maps the CMaterial::TTexSource
static const GLenum SourceLUT[4]= { GL_TEXTURE, static const GLenum SourceLUT[4]= { GL_TEXTURE, GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_CONSTANT_EXT };
#ifdef USE_OPENGLES
GL_PREVIOUS, GL_PRIMARY_COLOR, GL_CONSTANT
#else
GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_CONSTANT_EXT
#endif
};
// This maps the CMaterial::TTexOperand // This maps the CMaterial::TTexOperand
static const GLenum OperandLUT[4]= { GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }; static const GLenum OperandLUT[4]= { GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA };
// This maps the CMaterial::TTexOperator, used for openGL Arg2 setup. // This maps the CMaterial::TTexOperator, used for openGL Arg2 setup.
static const GLenum InterpolateSrcLUT[8]= { GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, static const GLenum InterpolateSrcLUT[8]= { GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_CONSTANT_EXT };
#ifdef USE_OPENGLES
GL_PREVIOUS, GL_PRIMARY_COLOR, GL_CONSTANT
#else
GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_CONSTANT_EXT
#endif
};
#ifndef USE_OPENGLES #ifndef USE_OPENGLES
@ -2224,6 +2190,25 @@ void CDriverGL::forceDXTCCompression(bool dxtcComp)
_ForceDXTCCompression= dxtcComp; _ForceDXTCCompression= dxtcComp;
} }
// ***************************************************************************
void CDriverGL::setAnisotropicFilter(sint filtering)
{
H_AUTO_OGL(CDriverGL_setAnisotropicFiltering);
if (!_Extensions.EXTTextureFilterAnisotropic) return;
if (filtering < 0 || filtering > _Extensions.EXTTextureFilterAnisotropicMaximum)
{
// set maximum value for anisotropic filter
_AnisotropicFilter = _Extensions.EXTTextureFilterAnisotropicMaximum;
}
else
{
// set specified value for anisotropic filter
_AnisotropicFilter = filtering;
}
}
// *************************************************************************** // ***************************************************************************
void CDriverGL::forceTextureResize(uint divisor) void CDriverGL::forceTextureResize(uint divisor)
{ {

View file

@ -1542,7 +1542,7 @@ void CVertexBufferHardARB::unlock()
#ifdef NL_DEBUG #ifdef NL_DEBUG
_Unmapping = true; _Unmapping = true;
#endif #endif
GLboolean unmapOk = false; GLboolean unmapOk = GL_FALSE;
#ifdef USE_OPENGLES #ifdef USE_OPENGLES
if (_Driver->_Extensions.OESMapBuffer) if (_Driver->_Extensions.OESMapBuffer)
@ -1671,3 +1671,4 @@ void CVertexBufferHardARB::invalidate()
#endif #endif
} // NL3D } // NL3D

View file

@ -205,8 +205,8 @@ bool CDriverGL::activeNVVertexProgram (CVertexProgram *program)
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
#ifndef USE_OPENGLES
static static
inline GLenum convSwizzleToGLFormat(CVPSwizzle::EComp comp, bool negate) inline GLenum convSwizzleToGLFormat(CVPSwizzle::EComp comp, bool negate)
{ {
@ -216,16 +216,11 @@ inline GLenum convSwizzleToGLFormat(CVPSwizzle::EComp comp, bool negate)
{ {
switch(comp) switch(comp)
{ {
#ifdef USE_OPENGLES
case CVPSwizzle::X: return GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES;
case CVPSwizzle::Y: return GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES;
case CVPSwizzle::Z: return GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES;
#else
case CVPSwizzle::X: return GL_X_EXT; case CVPSwizzle::X: return GL_X_EXT;
case CVPSwizzle::Y: return GL_Y_EXT; case CVPSwizzle::Y: return GL_Y_EXT;
case CVPSwizzle::Z: return GL_Z_EXT; case CVPSwizzle::Z: return GL_Z_EXT;
case CVPSwizzle::W: return GL_W_EXT; case CVPSwizzle::W: return GL_W_EXT;
#endif
default: default:
nlstop; nlstop;
return 0; return 0;
@ -236,16 +231,11 @@ inline GLenum convSwizzleToGLFormat(CVPSwizzle::EComp comp, bool negate)
{ {
switch(comp) switch(comp)
{ {
#ifdef USE_OPENGLES
case CVPSwizzle::X: return GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES;
case CVPSwizzle::Y: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES;
case CVPSwizzle::Z: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES;
#else
case CVPSwizzle::X: return GL_NEGATIVE_X_EXT; case CVPSwizzle::X: return GL_NEGATIVE_X_EXT;
case CVPSwizzle::Y: return GL_NEGATIVE_Y_EXT; case CVPSwizzle::Y: return GL_NEGATIVE_Y_EXT;
case CVPSwizzle::Z: return GL_NEGATIVE_Z_EXT; case CVPSwizzle::Z: return GL_NEGATIVE_Z_EXT;
case CVPSwizzle::W: return GL_NEGATIVE_W_EXT; case CVPSwizzle::W: return GL_NEGATIVE_W_EXT;
#endif
default: default:
nlstop; nlstop;
return 0; return 0;
@ -253,6 +243,7 @@ inline GLenum convSwizzleToGLFormat(CVPSwizzle::EComp comp, bool negate)
} }
} }
} }
#endif
// *************************************************************************** // ***************************************************************************
/** Convert an output register to a EXTVertexShader register /** Convert an output register to a EXTVertexShader register

View file

@ -1469,12 +1469,21 @@ UDriver::TPolygonMode CDriverUser::getPolygonMode ()
return umode; return umode;
} }
void CDriverUser::forceDXTCCompression(bool dxtcComp) void CDriverUser::forceDXTCCompression(bool dxtcComp)
{ {
NL3D_HAUTO_UI_DRIVER; NL3D_HAUTO_UI_DRIVER;
_Driver->forceDXTCCompression(dxtcComp); _Driver->forceDXTCCompression(dxtcComp);
} }
void CDriverUser::setAnisotropicFilter(sint filter)
{
NL3D_HAUTO_UI_DRIVER;
_Driver->setAnisotropicFilter(filter);
}
void CDriverUser::forceTextureResize(uint divisor) void CDriverUser::forceTextureResize(uint divisor)
{ {
NL3D_HAUTO_UI_DRIVER; NL3D_HAUTO_UI_DRIVER;

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) || defined(NL_COMP_VC10) #if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 71
# 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) || defined(NL_COMP_VC10) #if defined(NL_COMP_VC) && NL_COMP_VC_VERSION >= 71
# pragma warning( pop ) # pragma warning( pop )
#endif #endif

View file

@ -127,7 +127,7 @@ void CZone::build(const CZoneInfo &zoneInfo, uint32 numVertices)
// Compute the bbox and the bias/scale. // Compute the bbox and the bias/scale.
//===================================== //=====================================
CAABBox bb; CAABBox bb;
if(patchs.size()) if(!patchs.empty())
bb.setCenter(patchs[0].Patch.Vertices[0]); bb.setCenter(patchs[0].Patch.Vertices[0]);
bb.setHalfSize(CVector::Null); bb.setHalfSize(CVector::Null);
for(j=0;j<(sint)patchs.size();j++) for(j=0;j<(sint)patchs.size();j++)

View file

@ -25,7 +25,6 @@
#include "nel/georges/form.h" #include "nel/georges/form.h"
#include "nel/georges/form_elm.h" #include "nel/georges/form_elm.h"
#include "nel/georges/form_loader.h" #include "nel/georges/form_loader.h"
#include "nel/georges/type.h" #include "nel/georges/type.h"
using namespace NLMISC; using namespace NLMISC;

View file

@ -21,6 +21,10 @@
#include "nel/misc/bsphere.h" #include "nel/misc/bsphere.h"
#include "nel/misc/matrix.h" #include "nel/misc/matrix.h"
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC { namespace NLMISC {

View file

@ -21,6 +21,9 @@
using namespace std; using namespace std;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC namespace NLMISC
{ {

View file

@ -19,6 +19,10 @@
#include "nel/misc/dynloadlib.h" #include "nel/misc/dynloadlib.h"
#include "nel/misc/command.h" #include "nel/misc/command.h"
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC namespace NLMISC
{ {

View file

@ -23,6 +23,10 @@
using namespace std; using namespace std;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC namespace NLMISC
{ {

View file

@ -22,6 +22,9 @@
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC { namespace NLMISC {

View file

@ -25,6 +25,9 @@
using namespace std; using namespace std;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC { namespace NLMISC {

View file

@ -20,6 +20,9 @@
using namespace std; using namespace std;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC namespace NLMISC
{ {

View file

@ -26,6 +26,9 @@
using namespace std; using namespace std;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC namespace NLMISC
{ {

View file

@ -32,6 +32,9 @@ extern "C"
using namespace std; using namespace std;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLMISC namespace NLMISC
{ {

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