Compare commits
96 Commits
tmp-eevee-
...
soc-2013-v
Author | SHA1 | Date | |
---|---|---|---|
0c3c49eee3 | |||
5d3b635d31 | |||
6eff1cbebc | |||
49de1ada8d | |||
49e9e98c4d | |||
e18a9440cc | |||
078884e239 | |||
f6416b94a5 | |||
9822428f6c | |||
0f1cac0d87 | |||
e2cda64f46 | |||
e0ce58dd97 | |||
d63b221f48 | |||
288d8f3ed7 | |||
3dbc408d89 | |||
fd83ad4925 | |||
98e08806c7 | |||
5a2317757d | |||
b6c6e6a2c0 | |||
55308a9557 | |||
181831d3ab | |||
63939c44e1 | |||
ef62a1fd5f | |||
c50657bb86 | |||
c05b6d6f28 | |||
149d6aadf9 | |||
1395140af1 | |||
43028ad280 | |||
23dadba462 | |||
ec1c36c628 | |||
0252c176a1 | |||
ebd4419e6d | |||
de0154c97a | |||
b67062ceee | |||
637a6c4f11 | |||
a2c1d95303 | |||
65d17750d8 | |||
0d3eda85d6 | |||
3ee7410876 | |||
ee01240c33 | |||
9987d89480 | |||
7ca6852bb2 | |||
50e3d32c56 | |||
7f9a651d8c | |||
e894b1b490 | |||
fd10c884fd | |||
910046a385 | |||
de4d3e86e5 | |||
89029befa9 | |||
1eb6997a6e | |||
4ca1fc427f | |||
c54932ed40 | |||
eb60edacfa | |||
2786d98e55 | |||
a54bcd9e1d | |||
217646208c | |||
5dd2b53bc7 | |||
0999124a25 | |||
f216c7fa35 | |||
d5a4a6d844 | |||
bd7dcd2ea0 | |||
6bb66b1073 | |||
1902d2bcfd | |||
2a2708471a | |||
0312361ef4 | |||
4ad8056310 | |||
d32535ab9f | |||
c2177eb16c | |||
17eb13ae19 | |||
b037d8c1df | |||
b5d318c165 | |||
63a508c18e | |||
4ccd805713 | |||
62939e7b86 | |||
adba2ebf14 | |||
616ca3608e | |||
ff3f06cd19 | |||
4e053891f9 | |||
b70cc3b192 | |||
29b35fa74a | |||
175974a48e | |||
f4557e3299 | |||
0512be63fb | |||
fb6adeee98 | |||
802b5c3754 | |||
febf82087c | |||
7d884a8528 | |||
4991d98fd2 | |||
7135035e9e | |||
fa487c379b | |||
281111702b | |||
552f079666 | |||
e8c68205de | |||
6059756162 | |||
d076822e66 | |||
b069eda10c |
185
CMakeLists.txt
185
CMakeLists.txt
@@ -161,11 +161,13 @@ if(UNIX AND NOT APPLE)
|
|||||||
option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
|
option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
|
||||||
option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON)
|
option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON)
|
||||||
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON)
|
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON)
|
||||||
|
option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
|
||||||
|
|
||||||
option(WITH_GHOST_XDND "Enable drag'n'drop support on X11 using XDND protocol" ON)
|
option(WITH_GHOST_XDND "Enable drag'n'drop support on X11 using XDND protocol" ON)
|
||||||
else()
|
else()
|
||||||
# not an option for other OS's
|
# not an option for other OS's
|
||||||
set(WITH_SYSTEM_GLEW OFF)
|
set(WITH_SYSTEM_GLEW OFF)
|
||||||
|
set(WITH_SYSTEM_GLES OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
@@ -295,6 +297,44 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
|||||||
mark_as_advanced(WITH_GCC_MUDFLAP)
|
mark_as_advanced(WITH_GCC_MUDFLAP)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# OpenGL
|
||||||
|
|
||||||
|
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
|
||||||
|
mark_as_advanced(WITH_GLEW_ES)
|
||||||
|
|
||||||
|
option(WITH_GLU "Provide the GL Utility Library (GLU). Only works with the 'compatibiity' profile. (deprecated)" ON)
|
||||||
|
mark_as_advanced(WITH_GLU_ES)
|
||||||
|
|
||||||
|
option(WITH_GL_SYSTEM_DESKTOP "Support using the AGL/WGL/XGL system library to initialize OpenGL. Can access 3.1+ core, compatibility, and 2.0 es profiles." ON)
|
||||||
|
mark_as_advanced(WITH_GL_SYSTEM_DESKTOP)
|
||||||
|
|
||||||
|
option(WITH_GL_SYSTEM_EMBEDDED "Support using the EGL system library to initialize OpenGL ES." OFF)
|
||||||
|
mark_as_advanced(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
|
|
||||||
|
option(WITH_GL_PROFILE_COMPAT "Support using the OpenGL 'compatibility' profile. (deprecated)" ON)
|
||||||
|
mark_as_advanced(WITH_GL_PROFILE_COMPAT)
|
||||||
|
|
||||||
|
option(WITH_GL_PROFILE_CORE "Support using the OpenGL 3.1+ 'core' profile." OFF)
|
||||||
|
mark_as_advanced(WITH_GL_PROFILE_CORE)
|
||||||
|
|
||||||
|
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
|
||||||
|
mark_as_advanced(WITH_GL_PROFILE_ES20)
|
||||||
|
|
||||||
|
option(WITH_GPU_SAFETY "Perform extensive runtime tests to catch certain graphics API usage errors. (degrades performance)" OFF)
|
||||||
|
mark_as_advanced(WITH_GPU_SAFETY)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
option(WITH_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF)
|
||||||
|
mark_as_advanced(WITH_ANGLE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Code Coverage
|
||||||
|
|
||||||
|
option(WITH_CODE_COVERAGE "Compile with support for generating code coverage information" OFF)
|
||||||
|
mark_as_advanced(WITH_CODE_COVERAGE)
|
||||||
|
|
||||||
|
# Apple
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
cmake_minimum_required(VERSION 2.8.8)
|
cmake_minimum_required(VERSION 2.8.8)
|
||||||
cmake_policy(VERSION 2.8.8)
|
cmake_policy(VERSION 2.8.8)
|
||||||
@@ -1089,7 +1129,7 @@ elseif(WIN32)
|
|||||||
set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
|
set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC90)
|
if(MSVC90 OR MSVC10)
|
||||||
set(JPEG_NAMES ${JPEG_NAMES} libjpeg)
|
set(JPEG_NAMES ${JPEG_NAMES} libjpeg)
|
||||||
endif()
|
endif()
|
||||||
find_package(jpeg REQUIRED)
|
find_package(jpeg REQUIRED)
|
||||||
@@ -2020,10 +2060,78 @@ endif()
|
|||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Configure OpenGL.
|
# Configure OpenGL.
|
||||||
|
|
||||||
|
if(WITH_GL_SYSTEM_DESKTOP)
|
||||||
find_package(OpenGL)
|
find_package(OpenGL)
|
||||||
blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
|
|
||||||
# unset(OPENGL_LIBRARIES CACHE) # not compat with older cmake
|
set(GL_LIBRARIES "${OPENGL_gl_LIBRARY}")
|
||||||
# unset(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake
|
|
||||||
|
if(WITH_GLU)
|
||||||
|
list(APPEND GL_LIBRARIES "${OPENGL_glu_LIBRARY}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
elseif(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
|
if(WITH_SYSTEM_GLES)
|
||||||
|
find_package_wrapper(OpenGLES)
|
||||||
|
|
||||||
|
if(OPENGLES_FOUND)
|
||||||
|
set(GL_LIBRARIES OPENGLES_LIBRARIES)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Unable to find OpenGL ES libraries, install them or disable WITH_SYSTEM_GLES")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(OPENGLES_LIBRARY "" CACHE FILEPATH "OpenGL ES 2.0 library file")
|
||||||
|
set(OPENGLES_EGL_LIBRARY "" CACHE FILEPATH "EGL library file")
|
||||||
|
|
||||||
|
mark_as_advanced(OPENGLES_LIBRARY OPENGLES_EGL_LIBRARY)
|
||||||
|
|
||||||
|
list(APPEND GL_LIBRARIES "${OPENGLES_LIBRARY}" "${OPENGLES_EGL_LIBRARY}")
|
||||||
|
|
||||||
|
if(WITH_ANGLE)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_ANGLE")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(OPENGLES_DLL "" CACHE FILEPATH "OpenGL ES 2.0 redistributable DLL file")
|
||||||
|
set(OPENGLES_EGL_DLL "" CACHE FILEPATH "EGL redistributable DLL file")
|
||||||
|
|
||||||
|
mark_as_advanced(OPENGLES_DLL OPENGLES_EGL_DLL)
|
||||||
|
|
||||||
|
if(WITH_ANGLE)
|
||||||
|
set(D3DCOMPILER_DLL "" CACHE FILEPATH "Direct3D Compiler redistributable DLL file (needed by ANGLE)")
|
||||||
|
|
||||||
|
get_filename_component(D3DCOMPILER_FILENAME "${D3DCOMPILER_DLL}" NAME)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DD3DCOMPILER=\"\\\"${D3DCOMPILER_FILENAME}\\\"\"")
|
||||||
|
|
||||||
|
mark_as_advanced(D3DCOMPILER_DLL)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WITH_GL_PROFILE_COMPAT)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_PROFILE_COMPAT")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WITH_GL_PROFILE_CORE)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_PROFILE_CORE")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WITH_GL_PROFILE_ES20)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_PROFILE_ES20")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WITH_GL_SYSTEM_DESKTOP)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_SYSTEM_DESKTOP")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GL_SYSTEM_EMBEDDED")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WITH_GPU_SAFETY)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GPU_SAFETY")
|
||||||
|
endif()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Configure OpenMP.
|
# Configure OpenMP.
|
||||||
@@ -2061,10 +2169,50 @@ if(WITH_SYSTEM_GLEW)
|
|||||||
GLEW_INCLUDE_PATH
|
GLEW_INCLUDE_PATH
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
# set(GLEW_LIBRARY "") # unused
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_STATIC -DGLEW_MX")
|
||||||
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
|
|
||||||
|
if(WITH_GLEW_ES)
|
||||||
|
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew-es/include")
|
||||||
|
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DWITH_GLEW_ES")
|
||||||
|
|
||||||
|
# this isn't strictly required, but potentally makes GLEW smaller and helps catch unguarded API usage
|
||||||
|
if(NOT WITH_GL_PROFILE_ES20)
|
||||||
|
# no es functions are needed
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_NO_ES")
|
||||||
|
elseif(NOT (WITH_GL_PROFILE_CORE OR WITH_GL_PROFILE_COMPAT))
|
||||||
|
# es is enabled, but the other functions are all disabled
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_ES_ONLY")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WITH_GL_PROFILE_ES20)
|
||||||
|
if(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_USE_LIB_ES20")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# XXX jwilkins: this is just an experiment to eliminate ES 1 symbols,
|
||||||
|
# GLEW doesn't really properly provide this level of control (it eliminates too many symbols, for example),
|
||||||
|
# so there are lots of modifications to GLEW to make this work,
|
||||||
|
# and no attempt to make it work beyond Blender at this point
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGL_ES_VERSION_1_0=0")
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGL_ES_VERSION_CL_1_1=0")
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGL_ES_VERSION_CM_1_1=0")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_INC_EGL")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# this won't affect the normal glew library, but is used for conditional compilation elsewhere
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_NO_ES")
|
||||||
|
|
||||||
|
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT WITH_GLU)
|
||||||
|
set(GL_DEFINITIONS "${GL_DEFINITIONS} -DGLEW_NO_GLU")
|
||||||
|
endif()
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Configure Bullet
|
# Configure Bullet
|
||||||
@@ -2299,6 +2447,18 @@ if(WITH_GCC_MUDFLAP)
|
|||||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_ERROR_MUDFLAP -Wno-error=mudflap)
|
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_ERROR_MUDFLAP -Wno-error=mudflap)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Code Coverage
|
||||||
|
if(WITH_CODE_COVERAGE)
|
||||||
|
set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -fprofile-arcs -ftest-coverage")
|
||||||
|
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -fprofile-arcs -ftest-coverage")
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lgcov")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
# Include warnings first, so its possible to disable them with user defined flags
|
# Include warnings first, so its possible to disable them with user defined flags
|
||||||
# eg: -Wno-uninitialized
|
# eg: -Wno-uninitialized
|
||||||
set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
|
set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
|
||||||
@@ -2462,6 +2622,19 @@ if(FIRST_RUN)
|
|||||||
info_cfg_option(WITH_MOD_FLUID)
|
info_cfg_option(WITH_MOD_FLUID)
|
||||||
info_cfg_option(WITH_MOD_OCEANSIM)
|
info_cfg_option(WITH_MOD_OCEANSIM)
|
||||||
|
|
||||||
|
info_cfg_text("OpenGL:")
|
||||||
|
info_cfg_option(WITH_GLEW_ES)
|
||||||
|
info_cfg_option(WITH_GLU)
|
||||||
|
info_cfg_option(WITH_GL_SYSTEM_DESKTOP)
|
||||||
|
info_cfg_option(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
|
info_cfg_option(WITH_GL_PROFILE_COMPAT)
|
||||||
|
info_cfg_option(WITH_GL_PROFILE_CORE)
|
||||||
|
info_cfg_option(WITH_GL_PROFILE_ES20)
|
||||||
|
info_cfg_option(WITH_GPU_SAFETY)
|
||||||
|
if(WIN32)
|
||||||
|
info_cfg_option(WITH_ANGLE)
|
||||||
|
endif()
|
||||||
|
|
||||||
info_cfg_text("Other:")
|
info_cfg_text("Other:")
|
||||||
info_cfg_option(WITH_OPENNL)
|
info_cfg_option(WITH_OPENNL)
|
||||||
|
|
||||||
|
0
build_files/build_environment/install_deps.sh
Executable file → Normal file
0
build_files/build_environment/install_deps.sh
Executable file → Normal file
0
build_files/build_environment/prepare_release_env.sh
Executable file → Normal file
0
build_files/build_environment/prepare_release_env.sh
Executable file → Normal file
52
build_files/cmake/Modules/FindOpenGLES.cmake
Normal file
52
build_files/cmake/Modules/FindOpenGLES.cmake
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# - Try to find OpenGLES
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# OPENGLES_FOUND - system has OpenGLES and EGL
|
||||||
|
# OPENGL_EGL_FOUND - system has EGL
|
||||||
|
# OPENGLES_INCLUDE_DIR - the GLES include directory
|
||||||
|
# OPENGLES_LIBRARY - the GLES library
|
||||||
|
# OPENGLES_EGL_INCLUDE_DIR - the EGL include directory
|
||||||
|
# OPENGLES_EGL_LIBRARY - the EGL library
|
||||||
|
# OPENGLES_LIBRARIES - all libraries needed for OpenGLES
|
||||||
|
# OPENGLES_INCLUDES - all includes needed for OpenGLES
|
||||||
|
|
||||||
|
FIND_PATH(OPENGLES_INCLUDE_DIR GLES2/gl2.h
|
||||||
|
/usr/openwin/share/include
|
||||||
|
/opt/graphics/OpenGL/include /usr/X11R6/include
|
||||||
|
/usr/include
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(OPENGLES_LIBRARY
|
||||||
|
NAMES GLESv2
|
||||||
|
PATHS /opt/graphics/OpenGL/lib
|
||||||
|
/usr/openwin/lib
|
||||||
|
/usr/shlib /usr/X11R6/lib
|
||||||
|
/usr/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_PATH(OPENGLES_EGL_INCLUDE_DIR EGL/egl.h
|
||||||
|
/usr/openwin/share/include
|
||||||
|
/opt/graphics/OpenGL/include /usr/X11R6/include
|
||||||
|
/usr/include
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_LIBRARY(OPENGLES_EGL_LIBRARY
|
||||||
|
NAMES EGL
|
||||||
|
PATHS /usr/shlib /usr/X11R6/lib
|
||||||
|
/usr/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(OPENGL_EGL_FOUND "NO")
|
||||||
|
IF(OPENGLES_EGL_LIBRARY AND OPENGLES_EGL_INCLUDE_DIR)
|
||||||
|
SET(OPENGL_EGL_FOUND "YES")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
SET(OPENGLES_FOUND "NO")
|
||||||
|
IF(OPENGLES_LIBRARY AND OPENGLES_INCLUDE_DIR AND
|
||||||
|
OPENGLES_EGL_LIBRARY AND OPENGLES_EGL_INCLUDE_DIR)
|
||||||
|
SET(OPENGLES_LIBRARIES ${OPENGLES_LIBRARY} ${OPENGLES_LIBRARIES}
|
||||||
|
${OPENGLES_EGL_LIBRARY})
|
||||||
|
SET(OPENGLES_INCLUDES ${OPENGLES_INCLUDE_DIR} ${OPENGLES_EGL_INCLUDE_DIR})
|
||||||
|
SET(OPENGLES_FOUND "YES")
|
||||||
|
ENDIF()
|
||||||
|
|
0
build_files/cmake/cmake_consistency_check.py
Executable file → Normal file
0
build_files/cmake/cmake_consistency_check.py
Executable file → Normal file
0
build_files/cmake/cmake_netbeans_project.py
Executable file → Normal file
0
build_files/cmake/cmake_netbeans_project.py
Executable file → Normal file
0
build_files/cmake/cmake_qtcreator_project.py
Executable file → Normal file
0
build_files/cmake/cmake_qtcreator_project.py
Executable file → Normal file
0
build_files/cmake/example_scripts/cmake_linux_install.sh
Executable file → Normal file
0
build_files/cmake/example_scripts/cmake_linux_install.sh
Executable file → Normal file
0
build_files/cmake/example_scripts/make_quicky.py
Executable file → Normal file
0
build_files/cmake/example_scripts/make_quicky.py
Executable file → Normal file
0
build_files/cmake/example_scripts/make_quiet.sh
Executable file → Normal file
0
build_files/cmake/example_scripts/make_quiet.sh
Executable file → Normal file
@@ -284,8 +284,7 @@ macro(setup_liblinks
|
|||||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
|
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
|
||||||
|
|
||||||
target_link_libraries(${target}
|
target_link_libraries(${target}
|
||||||
${OPENGL_gl_LIBRARY}
|
${GL_LIBRARIES}
|
||||||
${OPENGL_glu_LIBRARY}
|
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
${FREETYPE_LIBRARY})
|
${FREETYPE_LIBRARY})
|
||||||
@@ -359,9 +358,11 @@ macro(setup_liblinks
|
|||||||
endif()
|
endif()
|
||||||
if(WITH_CODEC_FFMPEG)
|
if(WITH_CODEC_FFMPEG)
|
||||||
|
|
||||||
# Strange!, without this ffmpeg gives linking errors (on linux)
|
# Strange! Without this ffmpeg gives linking errors (on linux),
|
||||||
# even though its linked above
|
# even though it's linked above.
|
||||||
|
if (WITH_GL_SYSTEM_LEGACY)
|
||||||
target_link_libraries(${target} ${OPENGL_glu_LIBRARY})
|
target_link_libraries(${target} ${OPENGL_glu_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(${target} ${FFMPEG_LIBRARIES})
|
target_link_libraries(${target} ${FFMPEG_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
0
build_files/cmake/project_info.py
Executable file → Normal file
0
build_files/cmake/project_info.py
Executable file → Normal file
0
build_files/package_spec/build_archive.py
Executable file → Normal file
0
build_files/package_spec/build_archive.py
Executable file → Normal file
0
build_files/package_spec/build_debian.sh
Executable file → Normal file
0
build_files/package_spec/build_debian.sh
Executable file → Normal file
0
build_files/package_spec/debian/rules
Executable file → Normal file
0
build_files/package_spec/debian/rules
Executable file → Normal file
0
doc/blender_file_format/BlendFileDnaExporter_25.py
Executable file → Normal file
0
doc/blender_file_format/BlendFileDnaExporter_25.py
Executable file → Normal file
0
doc/python_api/sphinx_doc_gen.sh
Executable file → Normal file
0
doc/python_api/sphinx_doc_gen.sh
Executable file → Normal file
4
extern/CMakeLists.txt
vendored
4
extern/CMakeLists.txt
vendored
@@ -47,8 +47,12 @@ if(WITH_BINRELOC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT WITH_SYSTEM_GLEW)
|
if(NOT WITH_SYSTEM_GLEW)
|
||||||
|
if(WITH_GLEW_ES)
|
||||||
|
add_subdirectory(glew-es)
|
||||||
|
else()
|
||||||
add_subdirectory(glew)
|
add_subdirectory(glew)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WITH_GAMEENGINE)
|
if(WITH_GAMEENGINE)
|
||||||
add_subdirectory(recastnavigation)
|
add_subdirectory(recastnavigation)
|
||||||
|
0
extern/Eigen3/eigen-update.sh
vendored
Executable file → Normal file
0
extern/Eigen3/eigen-update.sh
vendored
Executable file → Normal file
0
extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp
vendored
Executable file → Normal file
0
extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp
vendored
Executable file → Normal file
0
extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h
vendored
Executable file → Normal file
0
extern/bullet2/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h
vendored
Executable file → Normal file
0
extern/carve/bundle.sh
vendored
Executable file → Normal file
0
extern/carve/bundle.sh
vendored
Executable file → Normal file
0
extern/carve/include/carve/win32.h
vendored
Executable file → Normal file
0
extern/carve/include/carve/win32.h
vendored
Executable file → Normal file
0
extern/carve/mkfiles.sh
vendored
Executable file → Normal file
0
extern/carve/mkfiles.sh
vendored
Executable file → Normal file
50
extern/glew-es/CMakeLists.txt
vendored
Normal file
50
extern/glew-es/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
# The Original Code is Copyright (C) 2013, Blender Foundation
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# The Original Code is: all of this file.
|
||||||
|
#
|
||||||
|
# ***** END GPL LICENSE BLOCK *****
|
||||||
|
|
||||||
|
set(INC
|
||||||
|
include
|
||||||
|
)
|
||||||
|
|
||||||
|
set(INC_SYS
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
list(APPEND INC_SYS
|
||||||
|
${X11_X11_INCLUDE_PATH}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SRC
|
||||||
|
src/glew.c
|
||||||
|
|
||||||
|
include/GL/eglew.h
|
||||||
|
include/GL/glesew.h
|
||||||
|
include/GL/glew.h
|
||||||
|
include/GL/glxew.h
|
||||||
|
include/GL/wglew.h
|
||||||
|
)
|
||||||
|
|
||||||
|
add_definitions(${GL_DEFINITIONS})
|
||||||
|
|
||||||
|
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}")
|
12
extern/glew-es/SConscript
vendored
Normal file
12
extern/glew-es/SConscript
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
Import('env')
|
||||||
|
|
||||||
|
sources = ['src/glew.c']
|
||||||
|
|
||||||
|
defs = 'GLEW_STATIC'
|
||||||
|
incs = 'include'
|
||||||
|
|
||||||
|
env.BlenderLib ( 'extern_glew', sources, Split(incs), Split(defs), libtype=['extern','player'], priority=[50,230])
|
1384
extern/glew-es/include/GL/eglew.h
vendored
Normal file
1384
extern/glew-es/include/GL/eglew.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4318
extern/glew-es/include/GL/glesew.h
vendored
Normal file
4318
extern/glew-es/include/GL/glesew.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
20525
extern/glew-es/include/GL/glew.h
vendored
Normal file
20525
extern/glew-es/include/GL/glew.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1649
extern/glew-es/include/GL/glxew.h
vendored
Normal file
1649
extern/glew-es/include/GL/glxew.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1424
extern/glew-es/include/GL/wglew.h
vendored
Normal file
1424
extern/glew-es/include/GL/wglew.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
22392
extern/glew-es/src/glew.c
vendored
Normal file
22392
extern/glew-es/src/glew.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
extern/glew/CMakeLists.txt
vendored
2
extern/glew/CMakeLists.txt
vendored
@@ -45,6 +45,6 @@ set(SRC
|
|||||||
include/GL/wglew.h
|
include/GL/wglew.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_definitions(-DGLEW_STATIC)
|
add_definitions(${GL_DEFINITIONS})
|
||||||
|
|
||||||
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}")
|
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}")
|
||||||
|
0
extern/libmv/bundle.sh
vendored
Executable file → Normal file
0
extern/libmv/bundle.sh
vendored
Executable file → Normal file
0
extern/libmv/mkfiles.sh
vendored
Executable file → Normal file
0
extern/libmv/mkfiles.sh
vendored
Executable file → Normal file
0
extern/libmv/third_party/ceres/bundle.sh
vendored
Executable file → Normal file
0
extern/libmv/third_party/ceres/bundle.sh
vendored
Executable file → Normal file
0
extern/libmv/third_party/ceres/mkfiles.sh
vendored
Executable file → Normal file
0
extern/libmv/third_party/ceres/mkfiles.sh
vendored
Executable file → Normal file
0
extern/libmv/third_party/glog/src/windows/preprocess.sh
vendored
Executable file → Normal file
0
extern/libmv/third_party/glog/src/windows/preprocess.sh
vendored
Executable file → Normal file
@@ -21,8 +21,8 @@ set(LIBRARIES
|
|||||||
cycles_util
|
cycles_util
|
||||||
${BOOST_LIBRARIES}
|
${BOOST_LIBRARIES}
|
||||||
${OPENEXR_LIBRARIES}
|
${OPENEXR_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${SYSTEM_GL_LIBRARIES}
|
||||||
${CYCLES_GLEW_LIBRARY}
|
${CYCLES_GLEW_LIBRARY} # XXX jwilkins, is this needed with the viewport fx re-factor?
|
||||||
${OPENIMAGEIO_LIBRARIES}
|
${OPENIMAGEIO_LIBRARIES}
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${JPEG_LIBRARIES}
|
${JPEG_LIBRARIES}
|
||||||
|
@@ -9,7 +9,7 @@ set(INC
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(INC_SYS
|
set(INC_SYS
|
||||||
${OPENGL_INCLUDE_DIR}
|
${SYSTEM_GL_INCLUDE_DIR}
|
||||||
${GLEW_INCLUDE_PATH}
|
${GLEW_INCLUDE_PATH}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -60,7 +60,7 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
|
|||||||
|
|
||||||
if(transparent) {
|
if(transparent) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* non-standard blend function */
|
||||||
}
|
}
|
||||||
|
|
||||||
glColor3f(1.0f, 1.0f, 1.0f);
|
glColor3f(1.0f, 1.0f, 1.0f);
|
||||||
@@ -127,8 +127,10 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
|
|||||||
glPixelZoom(1.0f, 1.0f);
|
glPixelZoom(1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(transparent)
|
if(transparent) {
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Device *Device::create(DeviceInfo& info, Stats &stats, bool background)
|
Device *Device::create(DeviceInfo& info, Stats &stats, bool background)
|
||||||
|
@@ -967,7 +967,7 @@ public:
|
|||||||
|
|
||||||
if(transparent) {
|
if(transparent) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* non-standard blend function */
|
||||||
}
|
}
|
||||||
|
|
||||||
glColor3f(1.0f, 1.0f, 1.0f);
|
glColor3f(1.0f, 1.0f, 1.0f);
|
||||||
@@ -998,8 +998,10 @@ public:
|
|||||||
draw_params.unbind_display_space_shader_cb();
|
draw_params.unbind_display_space_shader_cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(transparent)
|
if(transparent) {
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* reset blender default */
|
||||||
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
@@ -4,8 +4,8 @@ set(INC
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(INC_SYS
|
set(INC_SYS
|
||||||
|
${SYSTEM_GL_INCLUDE_DIR}
|
||||||
${GLEW_INCLUDE_PATH}
|
${GLEW_INCLUDE_PATH}
|
||||||
${OPENGL_INCLUDE_DIR}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SRC
|
set(SRC
|
||||||
@@ -70,3 +70,7 @@ include_directories(${INC})
|
|||||||
include_directories(SYSTEM ${INC_SYS})
|
include_directories(SYSTEM ${INC_SYS})
|
||||||
|
|
||||||
add_library(cycles_util ${SRC} ${SRC_HEADERS})
|
add_library(cycles_util ${SRC} ${SRC_HEADERS})
|
||||||
|
|
||||||
|
add_definitions(-DGLEW_STATIC)
|
||||||
|
|
||||||
|
add_definitions(-DGLEW_STATIC)
|
||||||
|
@@ -38,6 +38,8 @@ set(SRC
|
|||||||
intern/GHOST_Buttons.cpp
|
intern/GHOST_Buttons.cpp
|
||||||
intern/GHOST_C-api.cpp
|
intern/GHOST_C-api.cpp
|
||||||
intern/GHOST_CallbackEventConsumer.cpp
|
intern/GHOST_CallbackEventConsumer.cpp
|
||||||
|
intern/GHOST_Context.cpp
|
||||||
|
intern/GHOST_ContextNone.cpp
|
||||||
intern/GHOST_DisplayManager.cpp
|
intern/GHOST_DisplayManager.cpp
|
||||||
intern/GHOST_EventManager.cpp
|
intern/GHOST_EventManager.cpp
|
||||||
intern/GHOST_ISystem.cpp
|
intern/GHOST_ISystem.cpp
|
||||||
@@ -63,6 +65,8 @@ set(SRC
|
|||||||
|
|
||||||
intern/GHOST_Buttons.h
|
intern/GHOST_Buttons.h
|
||||||
intern/GHOST_CallbackEventConsumer.h
|
intern/GHOST_CallbackEventConsumer.h
|
||||||
|
intern/GHOST_Context.h
|
||||||
|
intern/GHOST_ContextNone.h
|
||||||
intern/GHOST_Debug.h
|
intern/GHOST_Debug.h
|
||||||
intern/GHOST_DisplayManager.h
|
intern/GHOST_DisplayManager.h
|
||||||
intern/GHOST_Event.h
|
intern/GHOST_Event.h
|
||||||
@@ -128,7 +132,6 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
|
|||||||
add_definitions(-DWITH_GHOST_SDL)
|
add_definitions(-DWITH_GHOST_SDL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# ack, this is still system dependant
|
# ack, this is still system dependant
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
list(APPEND SRC
|
list(APPEND SRC
|
||||||
@@ -149,7 +152,6 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
|
|||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
list(APPEND SRC
|
list(APPEND SRC
|
||||||
intern/GHOST_SystemPathsWin32.cpp
|
intern/GHOST_SystemPathsWin32.cpp
|
||||||
|
|
||||||
intern/GHOST_SystemPathsWin32.h
|
intern/GHOST_SystemPathsWin32.h
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -164,7 +166,16 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
elseif(APPLE)
|
else()
|
||||||
|
if(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
|
list(APPEND SRC
|
||||||
|
intern/GHOST_ContextEGL.cpp
|
||||||
|
|
||||||
|
intern/GHOST_ContextEGL.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
list(APPEND SRC
|
list(APPEND SRC
|
||||||
intern/GHOST_DisplayManagerCocoa.mm
|
intern/GHOST_DisplayManagerCocoa.mm
|
||||||
intern/GHOST_SystemCocoa.mm
|
intern/GHOST_SystemCocoa.mm
|
||||||
@@ -177,15 +188,33 @@ elseif(APPLE)
|
|||||||
intern/GHOST_WindowCocoa.h
|
intern/GHOST_WindowCocoa.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (WITH_GL_SYSTEM_DESKTOP)
|
||||||
|
list(APPEND SRC
|
||||||
|
intern/GHOST_ContextCGL.mm
|
||||||
|
|
||||||
|
intern/GHOST_ContextCGL.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WITH_INPUT_NDOF)
|
if(WITH_INPUT_NDOF)
|
||||||
list(APPEND SRC
|
list(APPEND SRC
|
||||||
intern/GHOST_NDOFManagerCocoa.mm
|
intern/GHOST_NDOFManagerCocoa.mm
|
||||||
|
|
||||||
intern/GHOST_NDOFManagerCocoa.h
|
intern/GHOST_NDOFManagerCocoa.h
|
||||||
)
|
)
|
||||||
list(APPEND SRC_NDOF3DCONNEXION
|
list(APPEND SRC_NDOF3DCONNEXION
|
||||||
intern/GHOST_NDOFManager3Dconnexion.c
|
intern/GHOST_NDOFManager3Dconnexion.c
|
||||||
intern/GHOST_NDOFManager3Dconnexion.h
|
intern/GHOST_NDOFManager3Dconnexion.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (WITH_GL_SYSTEM_DESKTOP)
|
||||||
|
list(APPEND SRC
|
||||||
|
intern/GHOST_ContextAGL.cpp
|
||||||
|
|
||||||
|
intern/GHOST_ContextAGL.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WITH_CODEC_QUICKTIME)
|
if(WITH_CODEC_QUICKTIME)
|
||||||
@@ -210,6 +239,14 @@ elseif(UNIX)
|
|||||||
intern/GHOST_WindowX11.h
|
intern/GHOST_WindowX11.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (WITH_GL_SYSTEM_DESKTOP)
|
||||||
|
list(APPEND SRC
|
||||||
|
intern/GHOST_ContextXGL.cpp
|
||||||
|
|
||||||
|
intern/GHOST_ContextXGL.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WITH_GHOST_XDND)
|
if(WITH_GHOST_XDND)
|
||||||
add_definitions(-DWITH_XDND)
|
add_definitions(-DWITH_XDND)
|
||||||
|
|
||||||
@@ -286,6 +323,14 @@ elseif(WIN32)
|
|||||||
intern/GHOST_TaskbarWin32.h
|
intern/GHOST_TaskbarWin32.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (WITH_GL_SYSTEM_DESKTOP)
|
||||||
|
list(APPEND SRC
|
||||||
|
intern/GHOST_ContextWGL.cpp
|
||||||
|
|
||||||
|
intern/GHOST_ContextWGL.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WITH_INPUT_NDOF)
|
if(WITH_INPUT_NDOF)
|
||||||
list(APPEND SRC
|
list(APPEND SRC
|
||||||
intern/GHOST_NDOFManagerWin32.cpp
|
intern/GHOST_NDOFManagerWin32.cpp
|
||||||
@@ -296,7 +341,10 @@ elseif(WIN32)
|
|||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DGLEW_STATIC)
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
add_definitions(${GL_DEFINITIONS})
|
||||||
|
|
||||||
blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}")
|
blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}")
|
||||||
|
|
||||||
|
177
intern/ghost/intern/GHOST_Context.cpp
Normal file
177
intern/ghost/intern/GHOST_Context.cpp
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_Context.cpp
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Definition of GHOST_Context class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GHOST_Context.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GLEWContext* glewContext = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char* get_glew_error_message_string(GLenum error)
|
||||||
|
{
|
||||||
|
switch (error) {
|
||||||
|
case GLEW_OK: /* also GLEW_NO_ERROR */
|
||||||
|
return "OK";
|
||||||
|
|
||||||
|
case GLEW_ERROR_NO_GL_VERSION:
|
||||||
|
return "Unable to determine GL version.";
|
||||||
|
|
||||||
|
case GLEW_ERROR_GL_VERSION_10_ONLY:
|
||||||
|
return "OpenGL 1.1 or later is required.";
|
||||||
|
|
||||||
|
case GLEW_ERROR_GLX_VERSION_11_ONLY:
|
||||||
|
return "GLX 1.2 or later is required.";
|
||||||
|
|
||||||
|
#if WITH_GLEW_ES
|
||||||
|
case GLEW_ERROR_NOT_GLES_VERSION:
|
||||||
|
return "OpenGL ES is required.";
|
||||||
|
|
||||||
|
case GLEW_ERROR_GLES_VERSION:
|
||||||
|
return "A non-ES version of OpenGL is required.";
|
||||||
|
|
||||||
|
case GLEW_ERROR_NO_EGL_VERSION:
|
||||||
|
return "Unabled to determine EGL version.";
|
||||||
|
|
||||||
|
case GLEW_ERROR_EGL_VERSION_10_ONLY:
|
||||||
|
return "EGL 1.1 or later is required.";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char* get_glew_error_enum_string(GLenum error)
|
||||||
|
{
|
||||||
|
switch (error) {
|
||||||
|
case GLEW_OK: /* also GLEW_NO_ERROR */
|
||||||
|
return "GLEW_OK";
|
||||||
|
|
||||||
|
case GLEW_ERROR_NO_GL_VERSION:
|
||||||
|
return "GLEW_ERROR_NO_GL_VERSION";
|
||||||
|
|
||||||
|
case GLEW_ERROR_GL_VERSION_10_ONLY:
|
||||||
|
return "GLEW_ERROR_GL_VERSION_10_ONLY";
|
||||||
|
|
||||||
|
case GLEW_ERROR_GLX_VERSION_11_ONLY:
|
||||||
|
return "GLEW_ERROR_GLX_VERSION_11_ONLY";
|
||||||
|
|
||||||
|
#if WITH_GLEW_ES
|
||||||
|
case GLEW_ERROR_NOT_GLES_VERSION:
|
||||||
|
return "GLEW_ERROR_NOT_GLES_VERSION";
|
||||||
|
|
||||||
|
case GLEW_ERROR_GLES_VERSION:
|
||||||
|
return "GLEW_ERROR_GLES_VERSION";
|
||||||
|
|
||||||
|
case GLEW_ERROR_NO_EGL_VERSION:
|
||||||
|
return "GLEW_ERROR_NO_EGL_VERSION";
|
||||||
|
|
||||||
|
case GLEW_ERROR_EGL_VERSION_10_ONLY:
|
||||||
|
return "GLEW_ERROR_EGL_VERSION_10_ONLY";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GLenum glew_chk(GLenum error, const char* file, int line, const char* text)
|
||||||
|
{
|
||||||
|
if (error != GLEW_OK) {
|
||||||
|
const char* code = get_glew_error_enum_string(error);
|
||||||
|
const char* msg = get_glew_error_message_string(error);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
fprintf(
|
||||||
|
stderr,
|
||||||
|
"%s(%d):[%s] -> GLEW Error (0x%04X): %s: %s\n",
|
||||||
|
file,
|
||||||
|
line,
|
||||||
|
text,
|
||||||
|
error,
|
||||||
|
code ? code : "<no symbol>",
|
||||||
|
msg ? msg : "<no message>");
|
||||||
|
#else
|
||||||
|
fprintf(
|
||||||
|
stderr,
|
||||||
|
"GLEW Error (%04X): %s: %s\n",
|
||||||
|
error,
|
||||||
|
code ? code : "<no symbol>",
|
||||||
|
msg ? msg : "<no message>");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void GHOST_Context::initContextGLEW()
|
||||||
|
{
|
||||||
|
glewContext = new GLEWContext;
|
||||||
|
memset(glewContext, 0, sizeof(GLEWContext));
|
||||||
|
|
||||||
|
delete m_glewContext;
|
||||||
|
m_glewContext = glewContext;
|
||||||
|
|
||||||
|
GLEW_CHK(glewInit());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int GHOST_PixelFormat::computeWeight() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void GHOST_PixelFormat::print() const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int GHOST_PixelFormatChooser::choosePixelFormat(GHOST_PixelFormatChooser& factory)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
146
intern/ghost/intern/GHOST_Context.h
Normal file
146
intern/ghost/intern/GHOST_Context.h
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_Context.h
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Declaration of GHOST_Context class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GHOST_CONTEXT_H__
|
||||||
|
#define __GHOST_CONTEXT_H__
|
||||||
|
|
||||||
|
#include "GHOST_Types.h"
|
||||||
|
|
||||||
|
#define glewGetContext() glewContext
|
||||||
|
#include <GL/glew.h>
|
||||||
|
extern "C" GLEWContext* glewContext;
|
||||||
|
|
||||||
|
#include <cstdlib> // for NULL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GHOST_Context
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
GHOST_Context()
|
||||||
|
: m_glewContext(NULL)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~GHOST_Context()
|
||||||
|
{
|
||||||
|
delete m_glewContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps front and back buffers of a window.
|
||||||
|
* \return A boolean success indicator.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess swapBuffers() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activates the drawing context of this window.
|
||||||
|
* \return A boolean success indicator.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess activateDrawingContext() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call immediately after new to initialize. If this fails then immediately delete the object.
|
||||||
|
* \param stereoVisual Stereo visual for quad buffered stereo.
|
||||||
|
* \param numOfAASamples Number of samples used for AA (zero if no AA)
|
||||||
|
* \return Indication as to whether initialization has succeeded.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if it is OK for a remove the native display
|
||||||
|
* \return Indication as to whether removal has succeeded.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess releaseNativeHandles() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void initContextGLEW();
|
||||||
|
|
||||||
|
void activateGLEW() const
|
||||||
|
{
|
||||||
|
glewContext = m_glewContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
GLEWContext* m_glewContext;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GLenum glew_chk(GLenum error, const char* file, int line, const char* text);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#define GLEW_CHK(x) glew_chk((x), __FILE__, __LINE__, #x)
|
||||||
|
#else
|
||||||
|
#define GLEW_CHK(x) x
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GHOST_PixelFormat {
|
||||||
|
public:
|
||||||
|
enum swap_t { UNKNOWN, COPY, EXCHANGE, UNDEFINED };
|
||||||
|
|
||||||
|
virtual bool isUsable() const = 0;
|
||||||
|
virtual int colorBits() const = 0;
|
||||||
|
virtual int alphaBits() const = 0;
|
||||||
|
virtual int depthBits() const = 0;
|
||||||
|
virtual int stencilBits() const = 0;
|
||||||
|
virtual int samples() const = 0;
|
||||||
|
virtual bool sRGB() const = 0;
|
||||||
|
virtual swap_t swapMethod() const = 0;
|
||||||
|
|
||||||
|
int computeWeight() const;
|
||||||
|
|
||||||
|
void print() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GHOST_PixelFormatChooser {
|
||||||
|
public:
|
||||||
|
int choosePixelFormat(GHOST_PixelFormatChooser& factory);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual int safeChoosePixelFormat() const = 0;
|
||||||
|
virtual int count() const = 0;
|
||||||
|
virtual GHOST_PixelFormat* get(int i) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __GHOST_CONTEXT_H__
|
32
intern/ghost/intern/GHOST_ContextAGL.cpp
Normal file
32
intern/ghost/intern/GHOST_ContextAGL.cpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextAGL.cpp
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Definition of GHOST_ContextAGL class.
|
||||||
|
*/
|
||||||
|
|
37
intern/ghost/intern/GHOST_ContextAGL.h
Normal file
37
intern/ghost/intern/GHOST_ContextAGL.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextAGL.h
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Declaration of GHOST_ContextAGL class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GHOST_CONTEXTAGL_H__
|
||||||
|
#define __GHOST_CONTEXTAGL_H__
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __GHOST_CONTEXTAGL_H__
|
94
intern/ghost/intern/GHOST_ContextCGL.h
Normal file
94
intern/ghost/intern/GHOST_ContextCGL.h
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextCGL.h
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Declaration of GHOST_ContextCGL class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GHOST_CONTEXTCGL_H__
|
||||||
|
#define __GHOST_CONTEXTCGL_H__
|
||||||
|
|
||||||
|
|
||||||
|
#include "GHOST_Context.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GHOST_OPENGL_CGL_CONTEXT_FLAGS
|
||||||
|
#define GHOST_OPENGL_CGL_CONTEXT_FLAGS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GHOST_ContextCGL : public GHOST_Context
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
GHOST_ContextCGL(
|
||||||
|
int contextProfileMask = 0,
|
||||||
|
int contextMajorVersion = 0,
|
||||||
|
int contextMinorVersion = 0,
|
||||||
|
int contextFlags = GHOST_OPENGL_CGL_CONTEXT_FLAGS);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~GHOST_ContextCGL();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps front and back buffers of a window.
|
||||||
|
* \return A boolean success indicator.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess swapBuffers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activates the drawing context of this window.
|
||||||
|
* \return A boolean success indicator.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess activateDrawingContext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call immediately after new to initialize. If this fails then immediately delete the object.
|
||||||
|
* \param stereoVisual Stereo visual for quad buffered stereo.
|
||||||
|
* \param numOfAASamples Number of samples used for AA (zero if no AA)
|
||||||
|
* \return Indication as to whether initialization has succeeded.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if it is OK for a remove the native display
|
||||||
|
* \return Indication as to whether removal has succeeded.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess releaseNativeHandles();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __GHOST_CONTEXTCGL_H__
|
79
intern/ghost/intern/GHOST_ContextCGL.mm
Normal file
79
intern/ghost/intern/GHOST_ContextCGL.mm
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextCGL.mm
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Definition of GHOST_ContextCGL class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GHOST_ContextCGL.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_ContextCGL::GHOST_ContextCGL(
|
||||||
|
int contextProfileMask,
|
||||||
|
int contextMajorVersion,
|
||||||
|
int contextMinorVersion,
|
||||||
|
int contextFlags)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_ContextCGL::~GHOST_ContextCGL()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextCGL::swapBuffers()
|
||||||
|
{
|
||||||
|
return GHOST_kFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextCGL::activateDrawingContext()
|
||||||
|
{
|
||||||
|
return GHOST_kFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext(bool stereoVisual, GHOST_TUns16 numOfAASamples)
|
||||||
|
{
|
||||||
|
return GHOST_kFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextCGL::releaseNativeHandles()
|
||||||
|
{
|
||||||
|
return GHOST_kFailure;
|
||||||
|
}
|
470
intern/ghost/intern/GHOST_ContextEGL.cpp
Normal file
470
intern/ghost/intern/GHOST_ContextEGL.cpp
Normal file
@@ -0,0 +1,470 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextEGL.cpp
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Definition of GHOST_ContextEGL class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GHOST_ContextEGL.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EGLEWContext* eglewContext = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static const char* get_egl_error_enum_string(EGLenum error)
|
||||||
|
{
|
||||||
|
switch(error) {
|
||||||
|
case EGL_SUCCESS:
|
||||||
|
return "EGL_SUCCESS";
|
||||||
|
|
||||||
|
case EGL_NOT_INITIALIZED:
|
||||||
|
return "EGL_NOT_INITIALIZED";
|
||||||
|
|
||||||
|
case EGL_BAD_ACCESS:
|
||||||
|
return "EGL_BAD_ALLOC";
|
||||||
|
|
||||||
|
case EGL_BAD_ALLOC:
|
||||||
|
return "EGL_BAD_ALLOC";
|
||||||
|
|
||||||
|
case EGL_BAD_ATTRIBUTE:
|
||||||
|
return "EGL_BAD_ATTRIBUTE";
|
||||||
|
|
||||||
|
case EGL_BAD_CONTEXT:
|
||||||
|
return "EGL_BAD_CONTEXT";
|
||||||
|
|
||||||
|
case EGL_BAD_CONFIG:
|
||||||
|
return "EGL_BAD_CONFIG";
|
||||||
|
|
||||||
|
case EGL_BAD_CURRENT_SURFACE:
|
||||||
|
return "EGL_BAD_CURRENT_SURFACE";
|
||||||
|
|
||||||
|
case EGL_BAD_DISPLAY:
|
||||||
|
return "EGL_BAD_DISPLAY";
|
||||||
|
|
||||||
|
case EGL_BAD_SURFACE:
|
||||||
|
return "EGL_BAD_SURFACE";
|
||||||
|
|
||||||
|
case EGL_BAD_MATCH:
|
||||||
|
return "EGL_BAD_MATCH";
|
||||||
|
|
||||||
|
case EGL_BAD_PARAMETER:
|
||||||
|
return "EGL_BAD_PARAMETER";
|
||||||
|
|
||||||
|
case EGL_BAD_NATIVE_PIXMAP:
|
||||||
|
return "EGL_BAD_NATIVE_PIXMAP";
|
||||||
|
|
||||||
|
case EGL_BAD_NATIVE_WINDOW:
|
||||||
|
return "EGL_BAD_NATIVE_WINDOW";
|
||||||
|
|
||||||
|
case EGL_CONTEXT_LOST:
|
||||||
|
return "EGL_CONTEXT_LOST";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* get_egl_error_message_string(EGLenum error)
|
||||||
|
{
|
||||||
|
switch(error) {
|
||||||
|
case EGL_SUCCESS:
|
||||||
|
return "The last function succeeded without error.";
|
||||||
|
|
||||||
|
case EGL_NOT_INITIALIZED:
|
||||||
|
return "EGL is not initialized, or could not be initialized, for the specified EGL display connection.";
|
||||||
|
|
||||||
|
case EGL_BAD_ACCESS:
|
||||||
|
return "EGL cannot access a requested resource (for example a context is bound in another thread).";
|
||||||
|
|
||||||
|
case EGL_BAD_ALLOC:
|
||||||
|
return "EGL failed to allocate resources for the requested operation.";
|
||||||
|
|
||||||
|
case EGL_BAD_ATTRIBUTE:
|
||||||
|
return "An unrecognized attribute or attribute value was passed in the attribute list.";
|
||||||
|
|
||||||
|
case EGL_BAD_CONTEXT:
|
||||||
|
return "An EGLContext argument does not name a valid EGL rendering context.";
|
||||||
|
|
||||||
|
case EGL_BAD_CONFIG:
|
||||||
|
return "An EGLConfig argument does not name a valid EGL frame buffer configuration.";
|
||||||
|
|
||||||
|
case EGL_BAD_CURRENT_SURFACE:
|
||||||
|
return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid.";
|
||||||
|
|
||||||
|
case EGL_BAD_DISPLAY:
|
||||||
|
return "An EGLDisplay argument does not name a valid EGL display connection.";
|
||||||
|
|
||||||
|
case EGL_BAD_SURFACE:
|
||||||
|
return "An EGLSurface argument does not name a valid surface (window, pixel buffer or pixmap) configured for GL rendering.";
|
||||||
|
|
||||||
|
case EGL_BAD_MATCH:
|
||||||
|
return "Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).";
|
||||||
|
|
||||||
|
case EGL_BAD_PARAMETER:
|
||||||
|
return "One or more argument values are invalid.";
|
||||||
|
|
||||||
|
case EGL_BAD_NATIVE_PIXMAP:
|
||||||
|
return "A NativePixmapType argument does not refer to a valid native pixmap.";
|
||||||
|
|
||||||
|
case EGL_BAD_NATIVE_WINDOW:
|
||||||
|
return "A NativeWindowType argument does not refer to a valid native window.";
|
||||||
|
|
||||||
|
case EGL_CONTEXT_LOST:
|
||||||
|
return "A power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering.";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static bool egl_chk(bool result, const char* file = NULL, int line = 0, const char* text = NULL)
|
||||||
|
{
|
||||||
|
if (!result) {
|
||||||
|
EGLenum error = eglGetError();
|
||||||
|
|
||||||
|
const char* code = get_egl_error_enum_string(error);
|
||||||
|
const char* msg = get_egl_error_message_string(error);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
fprintf(
|
||||||
|
stderr,
|
||||||
|
"%s(%d):[%s] -> EGL Error (0x%04X): %s: %s\n",
|
||||||
|
file,
|
||||||
|
line,
|
||||||
|
text,
|
||||||
|
error,
|
||||||
|
code ? code : "<Unknown>",
|
||||||
|
msg ? msg : "<Unknown>");
|
||||||
|
#else
|
||||||
|
fprintf(
|
||||||
|
stderr,
|
||||||
|
"EGL Error (0x%04X): %s: %s\n",
|
||||||
|
error,
|
||||||
|
code ? code : "<Unknown>",
|
||||||
|
msg ? msg : "<Unknown>");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#define EGL_CHK(x) egl_chk((x), __FILE__, __LINE__, #x)
|
||||||
|
#else
|
||||||
|
#define EGL_CHK(x) egl_chk(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static inline void bindAPI(EGLenum api)
|
||||||
|
{
|
||||||
|
if (eglewContext != NULL && EGLEW_VERSION_1_2)
|
||||||
|
EGL_CHK(eglBindAPI(api));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(WITH_ANGLE)
|
||||||
|
HMODULE GHOST_ContextEGL::s_d3dcompiler = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EGLContext GHOST_ContextEGL::s_gl_sharedContext = NULL;
|
||||||
|
EGLint GHOST_ContextEGL::s_gl_sharedCount = 0;
|
||||||
|
|
||||||
|
EGLContext GHOST_ContextEGL::s_gles_sharedContext = NULL;
|
||||||
|
EGLint GHOST_ContextEGL::s_gles_sharedCount = 0;
|
||||||
|
|
||||||
|
EGLContext GHOST_ContextEGL::s_vg_sharedContext = NULL;
|
||||||
|
EGLint GHOST_ContextEGL::s_vg_sharedCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
#pragma warning(disable : 4715)
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T& choose_api(EGLenum api, T& a, T& b, T& c)
|
||||||
|
{
|
||||||
|
switch(api) {
|
||||||
|
case EGL_OPENGL_API:
|
||||||
|
return a;
|
||||||
|
case EGL_OPENGL_ES_API:
|
||||||
|
return b;
|
||||||
|
case EGL_OPENVG_API:
|
||||||
|
return c;
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_ContextEGL::GHOST_ContextEGL(
|
||||||
|
EGLNativeWindowType nativeWindow,
|
||||||
|
EGLNativeDisplayType nativeDisplay,
|
||||||
|
EGLenum api,
|
||||||
|
EGLint contextClientVersion
|
||||||
|
)
|
||||||
|
: m_nativeWindow(nativeWindow)
|
||||||
|
, m_nativeDisplay(nativeDisplay)
|
||||||
|
, m_api(api)
|
||||||
|
, m_contextClientVersion(contextClientVersion)
|
||||||
|
, m_display(EGL_NO_DISPLAY)
|
||||||
|
, m_surface(EGL_NO_SURFACE)
|
||||||
|
, m_context(EGL_NO_CONTEXT)
|
||||||
|
, m_sharedContext(choose_api(api, s_gl_sharedContext, s_gles_sharedContext, s_vg_sharedContext))
|
||||||
|
, m_sharedCount (choose_api(api, s_gl_sharedCount, s_gles_sharedCount, s_vg_sharedCount))
|
||||||
|
, m_eglewContext(NULL)
|
||||||
|
{
|
||||||
|
assert(m_nativeWindow != NULL);
|
||||||
|
assert(m_nativeDisplay != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_ContextEGL::~GHOST_ContextEGL()
|
||||||
|
{
|
||||||
|
activateEGLEW();
|
||||||
|
|
||||||
|
bindAPI(m_api);
|
||||||
|
|
||||||
|
if (m_context != EGL_NO_CONTEXT) {
|
||||||
|
if (m_context == ::eglGetCurrentContext())
|
||||||
|
EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
|
||||||
|
|
||||||
|
if (m_context != m_sharedContext || m_sharedCount == 1) {
|
||||||
|
assert(m_sharedCount > 0);
|
||||||
|
|
||||||
|
m_sharedCount--;
|
||||||
|
|
||||||
|
if (m_sharedCount == 0)
|
||||||
|
m_sharedContext = EGL_NO_CONTEXT;
|
||||||
|
|
||||||
|
EGL_CHK(::eglDestroyContext(m_display, m_context));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_surface != EGL_NO_SURFACE)
|
||||||
|
EGL_CHK(::eglDestroySurface(m_display, m_surface));
|
||||||
|
|
||||||
|
EGL_CHK(::eglTerminate(m_display));
|
||||||
|
|
||||||
|
delete m_eglewContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextEGL::swapBuffers()
|
||||||
|
{
|
||||||
|
return EGL_CHK(eglSwapBuffers(m_display, m_surface)) ? GHOST_kSuccess : GHOST_kFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextEGL::activateDrawingContext()
|
||||||
|
{
|
||||||
|
activateEGLEW();
|
||||||
|
activateGLEW();
|
||||||
|
|
||||||
|
bindAPI(m_api);
|
||||||
|
|
||||||
|
return EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context)) ? GHOST_kSuccess : GHOST_kFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void GHOST_ContextEGL::initContextEGLEW()
|
||||||
|
{
|
||||||
|
eglewContext = new EGLEWContext;
|
||||||
|
memset(eglewContext, 0, sizeof(EGLEWContext));
|
||||||
|
|
||||||
|
delete m_eglewContext;
|
||||||
|
m_eglewContext = eglewContext;
|
||||||
|
|
||||||
|
GLEW_CHK(eglewInit());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext(bool stereoVisual, GHOST_TUns16 numOfAASamples)
|
||||||
|
{
|
||||||
|
std::vector<EGLint> attrib_list;
|
||||||
|
|
||||||
|
if (stereoVisual)
|
||||||
|
fprintf(stderr, "Warning! Stereo OpenGL ES contexts are not supported.\n");
|
||||||
|
|
||||||
|
#if defined(WITH_ANGLE)
|
||||||
|
// d3dcompiler_XX.dll needs to be loaded before ANGLE will work
|
||||||
|
if (s_d3dcompiler == NULL) {
|
||||||
|
s_d3dcompiler = LoadLibrary(D3DCOMPILER);
|
||||||
|
|
||||||
|
if (s_d3dcompiler == NULL) {
|
||||||
|
printf("LoadLibrary(\"" D3DCOMPILER "\") failed!\n");
|
||||||
|
return GHOST_kFailure;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EGLDisplay prev_display = eglGetCurrentDisplay();
|
||||||
|
EGLSurface prev_draw = eglGetCurrentSurface(EGL_DRAW);
|
||||||
|
EGLSurface prev_read = eglGetCurrentSurface(EGL_READ);
|
||||||
|
EGLContext prev_context = eglGetCurrentContext();
|
||||||
|
|
||||||
|
m_display = ::eglGetDisplay(m_nativeDisplay);
|
||||||
|
|
||||||
|
if (!EGL_CHK(m_display != EGL_NO_DISPLAY))
|
||||||
|
return GHOST_kFailure;
|
||||||
|
|
||||||
|
EGLint major, minor;
|
||||||
|
|
||||||
|
if (!EGL_CHK(::eglInitialize(m_display, &major, &minor)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
fprintf(stderr, "EGL Version %d.%d\n", major, minor);
|
||||||
|
|
||||||
|
if (!EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
initContextEGLEW();
|
||||||
|
|
||||||
|
bindAPI(m_api);
|
||||||
|
|
||||||
|
attrib_list.reserve(20);
|
||||||
|
|
||||||
|
// The ARM mali ES emulator seems to need this to find a pixel fromat
|
||||||
|
// XXX jwilkins: mali also fails to initialize EGLEW because of a bug in eglGetCurrentDisplay(), so using major/minor instead of EGLEW_VERSION
|
||||||
|
if ((major == 1 && minor >= 2 || major > 1) && m_api == EGL_OPENGL_ES_API) {
|
||||||
|
if (m_contextClientVersion == 1) {
|
||||||
|
attrib_list.push_back(EGL_RENDERABLE_TYPE);
|
||||||
|
attrib_list.push_back(EGL_OPENGL_ES_BIT);
|
||||||
|
}
|
||||||
|
else if ((major == 1 && minor >= 3 || major > 1) && m_contextClientVersion == 2) {
|
||||||
|
attrib_list.push_back(EGL_RENDERABLE_TYPE);
|
||||||
|
attrib_list.push_back(EGL_OPENGL_ES2_BIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
attrib_list.push_back(EGL_RED_SIZE);
|
||||||
|
attrib_list.push_back(8);
|
||||||
|
|
||||||
|
attrib_list.push_back(EGL_GREEN_SIZE);
|
||||||
|
attrib_list.push_back(8);
|
||||||
|
|
||||||
|
attrib_list.push_back(EGL_BLUE_SIZE);
|
||||||
|
attrib_list.push_back(8);
|
||||||
|
|
||||||
|
#ifdef GHOST_OPENGL_ALPHA
|
||||||
|
attrib_list.push_back(EGL_ALPHA_SIZE);
|
||||||
|
attrib_list.push_back(8);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
attrib_list.push_back(EGL_DEPTH_SIZE);
|
||||||
|
attrib_list.push_back(24);
|
||||||
|
|
||||||
|
#ifdef GHOST_OPENGL_STENCIL
|
||||||
|
attrib_list.push_back(EGL_STENCIL_SIZE);
|
||||||
|
attrib_list.push_back(8);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (numOfAASamples > 0) {
|
||||||
|
attrib_list.push_back(EGL_SAMPLE_BUFFERS);
|
||||||
|
attrib_list.push_back(1);
|
||||||
|
|
||||||
|
attrib_list.push_back(EGL_SAMPLES);
|
||||||
|
attrib_list.push_back(numOfAASamples);
|
||||||
|
}
|
||||||
|
|
||||||
|
attrib_list.push_back(EGL_NONE);
|
||||||
|
|
||||||
|
EGLConfig config;
|
||||||
|
EGLint num_config = 0;
|
||||||
|
|
||||||
|
if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &config, 1, &num_config)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
// common error is to assume that ChooseConfig worked because it returned EGL_TRUE
|
||||||
|
if (num_config != 1) // num_config should be exactly 1
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL);
|
||||||
|
|
||||||
|
if (!EGL_CHK(m_surface != EGL_NO_SURFACE))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
attrib_list.clear();
|
||||||
|
|
||||||
|
if (m_api == EGL_OPENGL_ES_API && m_contextClientVersion != 0) {
|
||||||
|
attrib_list.push_back(EGL_CONTEXT_CLIENT_VERSION);
|
||||||
|
attrib_list.push_back(m_contextClientVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
attrib_list.push_back(EGL_NONE);
|
||||||
|
|
||||||
|
m_context = ::eglCreateContext(m_display, config, m_sharedContext, &(attrib_list[0]));
|
||||||
|
|
||||||
|
if (!EGL_CHK(m_context != EGL_NO_CONTEXT))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (m_sharedContext == EGL_NO_CONTEXT)
|
||||||
|
m_sharedContext = m_context;
|
||||||
|
|
||||||
|
m_sharedCount++;
|
||||||
|
|
||||||
|
if (!EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
// XXX jwilkins: do this again here for mali, since eglGetCurrentDisplay will now work
|
||||||
|
initContextEGLEW();
|
||||||
|
|
||||||
|
initContextGLEW();
|
||||||
|
|
||||||
|
return GHOST_kSuccess;
|
||||||
|
|
||||||
|
error:
|
||||||
|
EGL_CHK(eglMakeCurrent(prev_display, prev_draw, prev_read, prev_context));
|
||||||
|
|
||||||
|
return GHOST_kFailure;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextEGL::releaseNativeHandles()
|
||||||
|
{
|
||||||
|
m_nativeWindow = NULL;
|
||||||
|
m_nativeDisplay = NULL;
|
||||||
|
|
||||||
|
return GHOST_kSuccess;
|
||||||
|
}
|
130
intern/ghost/intern/GHOST_ContextEGL.h
Normal file
130
intern/ghost/intern/GHOST_ContextEGL.h
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextEGL.h
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Declaration of GHOST_ContextEGL class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GHOST_CONTEXTEGL_H__
|
||||||
|
#define __GHOST_CONTEXTEGL_H__
|
||||||
|
|
||||||
|
#include "GHOST_Context.h"
|
||||||
|
|
||||||
|
#define eglewGetContext() eglewContext
|
||||||
|
#include <GL/eglew.h>
|
||||||
|
extern "C" EGLEWContext* eglewContext;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GHOST_ContextEGL : public GHOST_Context
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
GHOST_ContextEGL(
|
||||||
|
EGLNativeWindowType nativeWindow,
|
||||||
|
EGLNativeDisplayType nativeDisplay,
|
||||||
|
EGLenum api = 0,
|
||||||
|
EGLint contextClientVersion = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~GHOST_ContextEGL();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps front and back buffers of a window.
|
||||||
|
* \return A boolean success indicator.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess swapBuffers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activates the drawing context of this window.
|
||||||
|
* \return A boolean success indicator.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess activateDrawingContext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to install a rendering context in this window.
|
||||||
|
* \param stereoVisual Stereo visual for quad buffered stereo.
|
||||||
|
* \param numOfAASamples Number of samples used for AA (zero if no AA)
|
||||||
|
* \return Indication as to whether installation has succeeded.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes references to native handles from this context and then returns
|
||||||
|
* GHOST_kSuccess if it is OK for the parent to release the handles
|
||||||
|
* and GHOST_kFailure if releasing the handles will interfere with sharing
|
||||||
|
* \return Indication as to whether removal has succeeded.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess releaseNativeHandles();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void activateEGLEW() const
|
||||||
|
{
|
||||||
|
eglewContext = m_eglewContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initContextEGLEW();
|
||||||
|
|
||||||
|
EGLNativeDisplayType m_nativeDisplay;
|
||||||
|
EGLNativeWindowType m_nativeWindow;
|
||||||
|
|
||||||
|
const EGLenum m_api;
|
||||||
|
const EGLint m_contextClientVersion;
|
||||||
|
|
||||||
|
EGLContext m_context;
|
||||||
|
EGLSurface m_surface;
|
||||||
|
EGLDisplay m_display;
|
||||||
|
|
||||||
|
EGLContext& m_sharedContext;
|
||||||
|
EGLint& m_sharedCount;
|
||||||
|
|
||||||
|
EGLEWContext* m_eglewContext;
|
||||||
|
|
||||||
|
static EGLContext s_gl_sharedContext;
|
||||||
|
static EGLint s_gl_sharedCount;
|
||||||
|
|
||||||
|
static EGLContext s_gles_sharedContext;
|
||||||
|
static EGLint s_gles_sharedCount;
|
||||||
|
|
||||||
|
static EGLContext s_vg_sharedContext;
|
||||||
|
static EGLint s_vg_sharedCount;
|
||||||
|
|
||||||
|
#if defined(WITH_ANGLE)
|
||||||
|
static HMODULE s_d3dcompiler;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __GHOST_CONTEXTEGL_H__
|
61
intern/ghost/intern/GHOST_ContextNone.cpp
Normal file
61
intern/ghost/intern/GHOST_ContextNone.cpp
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextNone.cpp
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Definition of GHOST_ContextNone class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GHOST_ContextNone.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextNone::swapBuffers()
|
||||||
|
{
|
||||||
|
return GHOST_kSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextNone::activateDrawingContext()
|
||||||
|
{
|
||||||
|
return GHOST_kSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextNone::initializeDrawingContext(bool, GHOST_TUns16)
|
||||||
|
{
|
||||||
|
return GHOST_kSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_ContextNone::releaseNativeHandles()
|
||||||
|
{
|
||||||
|
return GHOST_kSuccess;
|
||||||
|
}
|
72
intern/ghost/intern/GHOST_ContextNone.h
Normal file
72
intern/ghost/intern/GHOST_ContextNone.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextNone.h
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Declaration of GHOST_Context class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GHOST_CONTEXTNONE_H__
|
||||||
|
#define __GHOST_CONTEXTNONE_H__
|
||||||
|
|
||||||
|
#include "GHOST_Context.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GHOST_ContextNone : public GHOST_Context
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Dummy function
|
||||||
|
* \return Always succeeds
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess swapBuffers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dummy function
|
||||||
|
* \return Always succeeds
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess activateDrawingContext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dummy function
|
||||||
|
* \param stereoVisual ignored
|
||||||
|
* \param numOfAASamples ignored
|
||||||
|
* \return Always succeeds
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess initializeDrawingContext(bool = false, GHOST_TUns16 = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dummy function
|
||||||
|
* \return Always succeeds
|
||||||
|
*/
|
||||||
|
GHOST_TSuccess releaseNativeHandles();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __GHOST_CONTEXTNONE_H__
|
1046
intern/ghost/intern/GHOST_ContextWGL.cpp
Normal file
1046
intern/ghost/intern/GHOST_ContextWGL.cpp
Normal file
File diff suppressed because it is too large
Load Diff
162
intern/ghost/intern/GHOST_ContextWGL.h
Normal file
162
intern/ghost/intern/GHOST_ContextWGL.h
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextWGL.h
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Declaration of GHOST_ContextWGL class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GHOST_CONTEXTWGL_H__
|
||||||
|
#define __GHOST_CONTEXTWGL_H__
|
||||||
|
|
||||||
|
#include "GHOST_Context.h"
|
||||||
|
|
||||||
|
#define wglewGetContext() wglewContext
|
||||||
|
#include <GL/wglew.h>
|
||||||
|
extern "C" WGLEWContext* wglewContext;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GHOST_OPENGL_WGL_CONTEXT_FLAGS
|
||||||
|
#define GHOST_OPENGL_WGL_CONTEXT_FLAGS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GHOST_ContextWGL : public GHOST_Context
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
GHOST_ContextWGL(
|
||||||
|
HWND hWnd,
|
||||||
|
HDC hDC,
|
||||||
|
int contextProfileMask = 0,
|
||||||
|
int contextMajorVersion = 0,
|
||||||
|
int contextMinorVersion = 0,
|
||||||
|
int contextFlags = GHOST_OPENGL_WGL_CONTEXT_FLAGS);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~GHOST_ContextWGL();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps front and back buffers of a window.
|
||||||
|
* \return A boolean success indicator.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess swapBuffers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activates the drawing context of this window.
|
||||||
|
* \return A boolean success indicator.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess activateDrawingContext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call immediately after new to initialize. If this fails then immediately delete the object.
|
||||||
|
* \param stereoVisual Stereo visual for quad buffered stereo.
|
||||||
|
* \param numOfAASamples Number of samples used for AA (zero if no AA)
|
||||||
|
* \return Indication as to whether initialization has succeeded.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess initializeDrawingContext(bool stereoVisual = false, GHOST_TUns16 numOfAASamples = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if it is OK for a remove the native display
|
||||||
|
* \return Indication as to whether removal has succeeded.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess releaseNativeHandles();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void activateWGLEW() const
|
||||||
|
{
|
||||||
|
wglewContext = m_wglewContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int choose_pixel_format(
|
||||||
|
bool stereoVisual,
|
||||||
|
int numOfAASamples,
|
||||||
|
bool needAlpha,
|
||||||
|
bool needStencil,
|
||||||
|
bool sRGB);
|
||||||
|
|
||||||
|
int choose_pixel_format_arb(
|
||||||
|
bool stereoVisual,
|
||||||
|
int numOfAASamples,
|
||||||
|
bool needAlpha,
|
||||||
|
bool needStencil,
|
||||||
|
bool sRGB);
|
||||||
|
|
||||||
|
int _choose_pixel_format_arb_1(
|
||||||
|
bool stereoVisual,
|
||||||
|
int numOfAASamples,
|
||||||
|
bool needAlpha,
|
||||||
|
bool needStencil,
|
||||||
|
bool sRGB,
|
||||||
|
int& swapMethodOut);
|
||||||
|
|
||||||
|
int _choose_pixel_format_arb_2(
|
||||||
|
bool stereoVisual,
|
||||||
|
int numOfAASamples,
|
||||||
|
bool needAlpha,
|
||||||
|
bool needStencil,
|
||||||
|
bool sRGB,
|
||||||
|
int swapMethod);
|
||||||
|
|
||||||
|
void initContextWGLEW(PIXELFORMATDESCRIPTOR& preferredPFD);
|
||||||
|
|
||||||
|
HDC m_hDC;
|
||||||
|
HWND m_hWnd;
|
||||||
|
|
||||||
|
int m_contextProfileMask;
|
||||||
|
int m_contextMajorVersion;
|
||||||
|
int m_contextMinorVersion;
|
||||||
|
int m_contextFlags;
|
||||||
|
|
||||||
|
HGLRC m_hGLRC;
|
||||||
|
|
||||||
|
bool m_needSetPixelFormat;
|
||||||
|
|
||||||
|
WGLEWContext* m_wglewContext;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
const char* m_dummyVendor;
|
||||||
|
const char* m_dummyRenderer;
|
||||||
|
const char* m_dummyVersion;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static HGLRC s_sharedHGLRC;
|
||||||
|
static int s_sharedCount;
|
||||||
|
|
||||||
|
static bool s_singleContextMode;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __GHOST_CONTEXTWGL_H__
|
32
intern/ghost/intern/GHOST_ContextXGL.cpp
Normal file
32
intern/ghost/intern/GHOST_ContextXGL.cpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextXGL.cpp
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Definition of GHOST_ContextXGL class.
|
||||||
|
*/
|
||||||
|
|
37
intern/ghost/intern/GHOST_ContextXGL.h
Normal file
37
intern/ghost/intern/GHOST_ContextXGL.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2013 Blender Foundation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* The Original Code is: all of this file.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jason Wilkins
|
||||||
|
*
|
||||||
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file ghost/intern/GHOST_ContextXGL.h
|
||||||
|
* \ingroup GHOST
|
||||||
|
* Declaration of GHOST_ContextXGL class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GHOST_CONTEXTXGL_H__
|
||||||
|
#define __GHOST_CONTEXTXGL_H__
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __GHOST_CONTEXTXGL_H__
|
@@ -219,39 +219,28 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(
|
|||||||
GHOST_TWindowState state, GHOST_TDrawingContextType type,
|
GHOST_TWindowState state, GHOST_TDrawingContextType type,
|
||||||
bool stereoVisual, const bool exclusive, const GHOST_TUns16 numOfAASamples, const GHOST_TEmbedderWindowID parentWindow)
|
bool stereoVisual, const bool exclusive, const GHOST_TUns16 numOfAASamples, const GHOST_TEmbedderWindowID parentWindow)
|
||||||
{
|
{
|
||||||
GHOST_Window *window = 0;
|
GHOST_Window *window =
|
||||||
window = new GHOST_WindowWin32(this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples, parentWindow);
|
new GHOST_WindowWin32(
|
||||||
if (window) {
|
this,
|
||||||
if (window->getValid()) {
|
title,
|
||||||
|
left,
|
||||||
|
top,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
state,
|
||||||
|
type,
|
||||||
|
stereoVisual,
|
||||||
|
numOfAASamples,
|
||||||
|
parentWindow);
|
||||||
|
|
||||||
|
if (window && window->getValid()) {
|
||||||
// Store the pointer to the window
|
// Store the pointer to the window
|
||||||
//if (state != GHOST_kWindowStateFullScreen) {
|
//if (state != GHOST_kWindowStateFullScreen) {
|
||||||
m_windowManager->addWindow(window);
|
m_windowManager->addWindow(window);
|
||||||
m_windowManager->setActiveWindow(window);
|
m_windowManager->setActiveWindow(window);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
|
||||||
// Invalid parent window hwnd
|
|
||||||
if (((GHOST_WindowWin32 *)window)->getNextWindow() == NULL) {
|
|
||||||
delete window;
|
|
||||||
window = 0;
|
|
||||||
return window;
|
|
||||||
}
|
|
||||||
|
|
||||||
// An invalid window could be one that was used to test for AA
|
|
||||||
window = ((GHOST_WindowWin32 *)window)->getNextWindow();
|
|
||||||
|
|
||||||
// If another window is found, let the wm know about that one, but not the old one
|
|
||||||
if (window->getValid()) {
|
|
||||||
m_windowManager->addWindow(window);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
delete window;
|
|
||||||
window = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,7 +34,6 @@
|
|||||||
#define __GHOST_SYSTEMX11_H__
|
#define __GHOST_SYSTEMX11_H__
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <GL/glx.h>
|
|
||||||
|
|
||||||
#include "GHOST_System.h"
|
#include "GHOST_System.h"
|
||||||
#include "../GHOST_Types.h"
|
#include "../GHOST_Types.h"
|
||||||
|
@@ -38,22 +38,26 @@
|
|||||||
|
|
||||||
#include "GHOST_Window.h"
|
#include "GHOST_Window.h"
|
||||||
|
|
||||||
|
#include "GHOST_ContextNone.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GHOST_Window::GHOST_Window(
|
GHOST_Window::GHOST_Window(
|
||||||
GHOST_TUns32 width, GHOST_TUns32 height,
|
GHOST_TUns32 width, GHOST_TUns32 height,
|
||||||
GHOST_TWindowState state,
|
GHOST_TWindowState state,
|
||||||
GHOST_TDrawingContextType type,
|
|
||||||
const bool stereoVisual,
|
const bool stereoVisual,
|
||||||
const bool exclusive,
|
const bool exclusive,
|
||||||
const GHOST_TUns16 numOfAASamples)
|
const GHOST_TUns16 numOfAASamples
|
||||||
:
|
)
|
||||||
m_drawingContextType(type),
|
: m_drawingContextType(GHOST_kDrawingContextTypeNone)
|
||||||
m_cursorVisible(true),
|
, m_cursorVisible(true)
|
||||||
m_cursorGrab(GHOST_kGrabDisable),
|
, m_cursorGrab(GHOST_kGrabDisable)
|
||||||
m_cursorShape(GHOST_kStandardCursorDefault),
|
, m_cursorShape(GHOST_kStandardCursorDefault)
|
||||||
m_stereoVisual(stereoVisual),
|
, m_stereoVisual(stereoVisual)
|
||||||
m_numOfAASamples(numOfAASamples)
|
, m_numOfAASamples(numOfAASamples)
|
||||||
|
, m_context(new GHOST_ContextNone())
|
||||||
{
|
{
|
||||||
m_isUnsavedChanges = false;
|
m_isUnsavedChanges = false;
|
||||||
m_canAcceptDragOperation = false;
|
m_canAcceptDragOperation = false;
|
||||||
@@ -66,6 +70,7 @@ GHOST_Window::GHOST_Window(
|
|||||||
m_nativePixelSize = 1.0f;
|
m_nativePixelSize = 1.0f;
|
||||||
|
|
||||||
m_fullScreen = state == GHOST_kWindowStateFullScreen;
|
m_fullScreen = state == GHOST_kWindowStateFullScreen;
|
||||||
|
|
||||||
if (m_fullScreen) {
|
if (m_fullScreen) {
|
||||||
m_fullScreenWidth = width;
|
m_fullScreenWidth = width;
|
||||||
m_fullScreenHeight = height;
|
m_fullScreenHeight = height;
|
||||||
@@ -73,30 +78,64 @@ GHOST_Window::GHOST_Window(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GHOST_Window::~GHOST_Window()
|
GHOST_Window::~GHOST_Window()
|
||||||
{
|
{
|
||||||
|
delete m_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *GHOST_Window::getOSWindow() const
|
void *GHOST_Window::getOSWindow() const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType type)
|
GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType type)
|
||||||
{
|
{
|
||||||
GHOST_TSuccess success = GHOST_kSuccess;
|
|
||||||
if (type != m_drawingContextType) {
|
if (type != m_drawingContextType) {
|
||||||
success = removeDrawingContext();
|
delete m_context;
|
||||||
if (success) {
|
m_context = NULL;
|
||||||
success = installDrawingContext(type);
|
|
||||||
|
if (type != GHOST_kDrawingContextTypeNone)
|
||||||
|
m_context = newDrawingContext(type);
|
||||||
|
|
||||||
|
if (m_context != NULL) {
|
||||||
m_drawingContextType = type;
|
m_drawingContextType = type;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
m_context = new GHOST_ContextNone();
|
||||||
m_drawingContextType = GHOST_kDrawingContextTypeNone;
|
m_drawingContextType = GHOST_kDrawingContextTypeNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (type == m_drawingContextType) ? GHOST_kSuccess : GHOST_kFailure;
|
||||||
}
|
}
|
||||||
return success;
|
else {
|
||||||
|
return GHOST_kSuccess;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_Window::swapBuffers()
|
||||||
|
{
|
||||||
|
return m_context->swapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_Window::activateDrawingContext()
|
||||||
|
{
|
||||||
|
return m_context->activateDrawingContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_TSuccess GHOST_Window::releaseNativeHandles()
|
||||||
|
{
|
||||||
|
return m_context->releaseNativeHandles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GHOST_TSuccess GHOST_Window::setCursorVisibility(bool visible)
|
GHOST_TSuccess GHOST_Window::setCursorVisibility(bool visible)
|
||||||
{
|
{
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include "GHOST_IWindow.h"
|
#include "GHOST_IWindow.h"
|
||||||
|
|
||||||
class STR_String;
|
class STR_String;
|
||||||
|
class GHOST_Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform independent implementation of GHOST_IWindow.
|
* Platform independent implementation of GHOST_IWindow.
|
||||||
@@ -66,10 +67,8 @@ public:
|
|||||||
* virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
|
* virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
|
||||||
* virtual GHOST_TWindowOrder getOrder(void) = 0;
|
* virtual GHOST_TWindowOrder getOrder(void) = 0;
|
||||||
* virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
|
* virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
|
||||||
* virtual GHOST_TSuccess swapBuffers() = 0;
|
|
||||||
* virtual GHOST_TSuccess setSwapInterval() = 0;
|
* virtual GHOST_TSuccess setSwapInterval() = 0;
|
||||||
* virtual int getSwapInterval() = 0;
|
* virtual int getSwapInterval() = 0;
|
||||||
* virtual GHOST_TSuccess activateDrawingContext() = 0;
|
|
||||||
* virtual GHOST_TSuccess invalidate() = 0;
|
* virtual GHOST_TSuccess invalidate() = 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -90,35 +89,13 @@ public:
|
|||||||
GHOST_TUns32 width,
|
GHOST_TUns32 width,
|
||||||
GHOST_TUns32 height,
|
GHOST_TUns32 height,
|
||||||
GHOST_TWindowState state,
|
GHOST_TWindowState state,
|
||||||
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
|
|
||||||
const bool stereoVisual = false,
|
const bool stereoVisual = false,
|
||||||
const bool exclusive = false,
|
const bool exclusive = false,
|
||||||
const GHOST_TUns16 numOfAASamples = 0);
|
const GHOST_TUns16 numOfAASamples = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \section Interface inherited from GHOST_IWindow left for derived class
|
|
||||||
* implementation.
|
|
||||||
* virtual bool getValid() const = 0;
|
|
||||||
* virtual void setTitle(const STR_String& title) = 0;
|
|
||||||
* virtual void getTitle(STR_String& title) const = 0;
|
|
||||||
* virtual void getWindowBounds(GHOST_Rect& bounds) const = 0;
|
|
||||||
* virtual void getClientBounds(GHOST_Rect& bounds) const = 0;
|
|
||||||
* virtual GHOST_TSuccess setClientWidth(GHOST_TUns32 width) = 0;
|
|
||||||
* virtual GHOST_TSuccess setClientHeight(GHOST_TUns32 height) = 0;
|
|
||||||
* virtual GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height) = 0;
|
|
||||||
* virtual void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
|
|
||||||
* virtual void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const = 0;
|
|
||||||
* virtual GHOST_TWindowState getState() const = 0;
|
|
||||||
* virtual GHOST_TSuccess setState(GHOST_TWindowState state) = 0;
|
|
||||||
* virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
|
|
||||||
* virtual GHOST_TSuccess swapBuffers() = 0;
|
|
||||||
* virtual GHOST_TSuccess setSwapInterval() = 0;
|
* virtual GHOST_TSuccess setSwapInterval() = 0;
|
||||||
* virtual int getSwapInterval() = 0;
|
* virtual int getSwapInterval() = 0;
|
||||||
* virtual GHOST_TSuccess activateDrawingContext() = 0;
|
|
||||||
* virtual GHOST_TSuccess invalidate() = 0;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor.
|
* Destructor.
|
||||||
* Closes the window and disposes resources allocated.
|
* Closes the window and disposes resources allocated.
|
||||||
*/
|
*/
|
||||||
@@ -257,13 +234,25 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to install a rendering context in this window.
|
* Tries to install a rendering context in this window.
|
||||||
* Child classes do not need to overload this method.
|
* Child classes do not need to overload this method,
|
||||||
* They should overload the installDrawingContext and removeDrawingContext instead.
|
* They should overload newDrawingContext instead.
|
||||||
* \param type The type of rendering context installed.
|
* \param type The type of rendering context installed.
|
||||||
* \return Indication as to whether installation has succeeded.
|
* \return Indication as to whether installation has succeeded.
|
||||||
*/
|
*/
|
||||||
virtual GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type);
|
virtual GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swaps front and back buffers of a window.
|
||||||
|
* \return A boolean success indicator.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess swapBuffers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activates the drawing context of this window.
|
||||||
|
* \return A boolean success indicator.
|
||||||
|
*/
|
||||||
|
virtual GHOST_TSuccess activateDrawingContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the window user data.
|
* Returns the window user data.
|
||||||
* \return The window user data.
|
* \return The window user data.
|
||||||
@@ -295,13 +284,7 @@ protected:
|
|||||||
* \param type The type of rendering context installed.
|
* \param type The type of rendering context installed.
|
||||||
* \return Indication as to whether installation has succeeded.
|
* \return Indication as to whether installation has succeeded.
|
||||||
*/
|
*/
|
||||||
virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type) = 0;
|
virtual GHOST_Context* newDrawingContext(GHOST_TDrawingContextType type) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the current drawing context.
|
|
||||||
* \return Indication as to whether removal has succeeded.
|
|
||||||
*/
|
|
||||||
virtual GHOST_TSuccess removeDrawingContext() = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the cursor visibility on the window using
|
* Sets the cursor visibility on the window using
|
||||||
@@ -333,6 +316,9 @@ protected:
|
|||||||
|
|
||||||
virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
|
virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
|
||||||
int szx, int szy, int hotX, int hotY, int fg, int bg) = 0;
|
int szx, int szy, int hotX, int hotY, int fg, int bg) = 0;
|
||||||
|
|
||||||
|
GHOST_TSuccess releaseNativeHandles();
|
||||||
|
|
||||||
/** The the of drawing context installed in this window. */
|
/** The the of drawing context installed in this window. */
|
||||||
GHOST_TDrawingContextType m_drawingContextType;
|
GHOST_TDrawingContextType m_drawingContextType;
|
||||||
|
|
||||||
@@ -385,6 +371,9 @@ protected:
|
|||||||
|
|
||||||
/* OSX only, retina screens */
|
/* OSX only, retina screens */
|
||||||
float m_nativePixelSize;
|
float m_nativePixelSize;
|
||||||
|
|
||||||
|
private:
|
||||||
|
GHOST_Context* m_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -42,6 +42,9 @@
|
|||||||
|
|
||||||
@class CocoaWindow;
|
@class CocoaWindow;
|
||||||
@class CocoaOpenGLView;
|
@class CocoaOpenGLView;
|
||||||
|
@class NSCursor;
|
||||||
|
@class NSOpenGLContext;
|
||||||
|
@class NSScreen;
|
||||||
|
|
||||||
class GHOST_SystemCocoa;
|
class GHOST_SystemCocoa;
|
||||||
|
|
||||||
@@ -278,18 +281,24 @@ public:
|
|||||||
bool getImmediateDraw(void) const { return m_immediateDraw; }
|
bool getImmediateDraw(void) const { return m_immediateDraw; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
///**
|
||||||
* Tries to install a rendering context in this window.
|
// * Tries to install a rendering context in this window.
|
||||||
* \param type The type of rendering context installed.
|
// * \param type The type of rendering context installed.
|
||||||
* \return Indication as to whether installation has succeeded.
|
// * \return Indication as to whether installation has succeeded.
|
||||||
*/
|
// */
|
||||||
virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
|
//virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the current drawing context.
|
* \param type The type of rendering context create.
|
||||||
* \return Indication as to whether removal has succeeded.
|
* \return Indication of success.
|
||||||
*/
|
*/
|
||||||
virtual GHOST_TSuccess removeDrawingContext();
|
virtual GHOST_Context* newDrawingContext(GHOST_TDrawingContextType type);
|
||||||
|
|
||||||
|
///**
|
||||||
|
// * Removes the current drawing context.
|
||||||
|
// * \return Indication as to whether removal has succeeded.
|
||||||
|
// */
|
||||||
|
//virtual GHOST_TSuccess removeDrawingContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates the contents of this window.
|
* Invalidates the contents of this window.
|
||||||
|
@@ -21,11 +21,25 @@
|
|||||||
* The Original Code is: all of this file.
|
* The Original Code is: all of this file.
|
||||||
*
|
*
|
||||||
* Contributor(s): Maarten Gribnau 05/2001
|
* Contributor(s): Maarten Gribnau 05/2001
|
||||||
Damien Plisson 10/2009
|
* Damien Plisson 10/2009
|
||||||
|
* Jason Wilkins 02/2014
|
||||||
*
|
*
|
||||||
* ***** END GPL LICENSE BLOCK *****
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "GHOST_WindowCocoa.h"
|
||||||
|
#include "GHOST_SystemCocoa.h"
|
||||||
|
#include "GHOST_ContextNone.h"
|
||||||
|
#include "GHOST_Debug.h"
|
||||||
|
|
||||||
|
#if defined(WITH_GL_SYSTEM_DESKTOP)
|
||||||
|
#include "GHOST_ContextCGL.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
|
#include "GHOST_ContextEGL.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1050
|
#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1050
|
||||||
@@ -33,16 +47,13 @@
|
|||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <OpenGL/gl.h>
|
//#include <OpenGL/gl.h>
|
||||||
#include <OpenGL/CGLRenderers.h>
|
//#include <OpenGL/CGLRenderers.h>
|
||||||
/***** Multithreaded opengl code : uncomment for enabling
|
/***** Multithreaded opengl code : uncomment for enabling
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "GHOST_WindowCocoa.h"
|
|
||||||
#include "GHOST_SystemCocoa.h"
|
|
||||||
#include "GHOST_Debug.h"
|
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
|
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
|
||||||
/* Lion style fullscreen support when building with the 10.6 SDK */
|
/* Lion style fullscreen support when building with the 10.6 SDK */
|
||||||
@@ -546,7 +557,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
|
|||||||
GHOST_TDrawingContextType type,
|
GHOST_TDrawingContextType type,
|
||||||
const bool stereoVisual, const GHOST_TUns16 numOfAASamples
|
const bool stereoVisual, const GHOST_TUns16 numOfAASamples
|
||||||
) :
|
) :
|
||||||
GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual, false, numOfAASamples),
|
GHOST_Window(width, height, state, stereoVisual, false, numOfAASamples),
|
||||||
m_customCursor(0)
|
m_customCursor(0)
|
||||||
{
|
{
|
||||||
NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[40];
|
NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[40];
|
||||||
@@ -596,9 +607,9 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
|
|||||||
pixelFormatAttrsWindow[i++] = NSOpenGLPFABackingStore;
|
pixelFormatAttrsWindow[i++] = NSOpenGLPFABackingStore;
|
||||||
|
|
||||||
// Force software OpenGL, for debugging
|
// Force software OpenGL, for debugging
|
||||||
if (getenv("BLENDER_SOFTWAREGL")) {
|
if (getenv("BLENDER_SOFTWAREGL")) { // XXX jwilkins: fixed this to work on Intel macs? useful feature for Windows and Linux too? Maybe a command line flag is better...
|
||||||
pixelFormatAttrsWindow[i++] = NSOpenGLPFARendererID;
|
pixelFormatAttrsWindow[i++] = NSOpenGLPFARendererID;
|
||||||
pixelFormatAttrsWindow[i++] = kCGLRendererAppleSWID;
|
pixelFormatAttrsWindow[i++] = kCGLRendererGenericFloatID;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated;
|
pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated;
|
||||||
@@ -630,6 +641,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
|
|||||||
|
|
||||||
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttrsWindow];
|
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttrsWindow];
|
||||||
|
|
||||||
|
// XXX jwilkins: this code seems to have a lot of duplication from above?
|
||||||
|
|
||||||
//Fall back to no multisampling if Antialiasing init failed
|
//Fall back to no multisampling if Antialiasing init failed
|
||||||
if (pixelFormat == nil) {
|
if (pixelFormat == nil) {
|
||||||
@@ -641,9 +653,9 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
|
|||||||
pixelFormatAttrsWindow[i++] = NSOpenGLPFABackingStore;
|
pixelFormatAttrsWindow[i++] = NSOpenGLPFABackingStore;
|
||||||
|
|
||||||
// Force software OpenGL, for debugging
|
// Force software OpenGL, for debugging
|
||||||
if (getenv("BLENDER_SOFTWAREGL")) {
|
if (getenv("BLENDER_SOFTWAREGL")) {// XXX jwilkins: fixed this to work on Intel macs? useful feature for Windows and Linux too? Maybe a command line flag is better...
|
||||||
pixelFormatAttrsWindow[i++] = NSOpenGLPFARendererID;
|
pixelFormatAttrsWindow[i++] = NSOpenGLPFARendererID;
|
||||||
pixelFormatAttrsWindow[i++] = kCGLRendererAppleSWID;
|
pixelFormatAttrsWindow[i++] = kCGLRendererGenericFloatID;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated;
|
pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated;
|
||||||
@@ -1307,7 +1319,7 @@ GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext()
|
|||||||
return GHOST_kFailure;
|
return GHOST_kFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextType type)
|
GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextType type)
|
||||||
{
|
{
|
||||||
GHOST_TSuccess success = GHOST_kFailure;
|
GHOST_TSuccess success = GHOST_kFailure;
|
||||||
@@ -1387,6 +1399,51 @@ GHOST_TSuccess GHOST_WindowCocoa::removeDrawingContext()
|
|||||||
return GHOST_kFailure;
|
return GHOST_kFailure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GHOST_Context* GHOST_WindowCocoa::newDrawingContext(GHOST_TDrawingContextType type)
|
||||||
|
{
|
||||||
|
if (type == GHOST_kDrawingContextTypeOpenGL) {
|
||||||
|
#if defined(WITH_GL_SYSTEM_DESKTOP)
|
||||||
|
|
||||||
|
#if defined(WITH_GL_PROFILE_CORE)
|
||||||
|
// XXX jwilkins: some implementations will only give you 3.2 even if later compatible versions are available
|
||||||
|
GHOST_Context* context = new GHOST_ContextCGL(WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 3, 2);
|
||||||
|
#elif defined(WITH_GL_PROFILE_ES20)
|
||||||
|
GHOST_Context* context = new GHOST_ContextCGL(WGL_CONTEXT_ES2_PROFILE_BIT_EXT, 2, 0);
|
||||||
|
#elif defined(WITH_GL_PROFILE_COMPAT)
|
||||||
|
GHOST_Context* context = new GHOST_ContextCGL();
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
|
|
||||||
|
#if defined(WITH_GL_PROFILE_CORE)
|
||||||
|
// XXX jwilkins: not sure yet how to request a core context from EGL
|
||||||
|
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_API);
|
||||||
|
#elif defined(WITH_GL_PROFILE_ES20)
|
||||||
|
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_ES_API, 2);
|
||||||
|
#elif defined(WITH_GL_PROFILE_COMPAT)
|
||||||
|
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_API);
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
if (context->initializeDrawingContext(m_stereoVisual, m_numOfAASamples))
|
||||||
|
return context;
|
||||||
|
else
|
||||||
|
delete context;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GHOST_TSuccess GHOST_WindowCocoa::invalidate()
|
GHOST_TSuccess GHOST_WindowCocoa::invalidate()
|
||||||
|
@@ -29,82 +29,34 @@
|
|||||||
* \ingroup GHOST
|
* \ingroup GHOST
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#define _USE_MATH_DEFINES
|
||||||
|
|
||||||
#include "GHOST_WindowWin32.h"
|
#include "GHOST_WindowWin32.h"
|
||||||
#include "GHOST_SystemWin32.h"
|
#include "GHOST_SystemWin32.h"
|
||||||
#include "GHOST_DropTargetWin32.h"
|
#include "GHOST_DropTargetWin32.h"
|
||||||
|
#include "GHOST_ContextNone.h"
|
||||||
#include "utfconv.h"
|
#include "utfconv.h"
|
||||||
#include "utf_winfunc.h"
|
#include "utf_winfunc.h"
|
||||||
|
|
||||||
// Need glew for some defines
|
#if defined(WITH_GL_SYSTEM_DESKTOP)
|
||||||
#include <GL/glew.h>
|
#include "GHOST_ContextWGL.h"
|
||||||
#include <GL/wglew.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
// MSVC6 still doesn't define M_PI
|
|
||||||
#ifndef M_PI
|
|
||||||
# define M_PI 3.1415926536
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Some more multisample defines
|
#if defined(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
#include "GHOST_ContextEGL.h"
|
||||||
#define WGL_SAMPLES_ARB 0x2042
|
#endif
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const wchar_t *GHOST_WindowWin32::s_windowClassName = L"GHOST_WindowClass";
|
const wchar_t *GHOST_WindowWin32::s_windowClassName = L"GHOST_WindowClass";
|
||||||
const int GHOST_WindowWin32::s_maxTitleLength = 128;
|
const int GHOST_WindowWin32::s_maxTitleLength = 128;
|
||||||
HGLRC GHOST_WindowWin32::s_firsthGLRc = NULL;
|
|
||||||
HDC GHOST_WindowWin32::s_firstHDC = NULL;
|
|
||||||
|
|
||||||
static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd);
|
|
||||||
static int EnumPixelFormats(HDC hdc);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Color and depth bit values are not to be trusted.
|
|
||||||
* For instance, on TNT2:
|
|
||||||
* When the screen color depth is set to 16 bit, we get 5 color bits
|
|
||||||
* and 16 depth bits.
|
|
||||||
* When the screen color depth is set to 32 bit, we get 8 color bits
|
|
||||||
* and 24 depth bits.
|
|
||||||
* Just to be safe, we request high waulity settings.
|
|
||||||
*/
|
|
||||||
static PIXELFORMATDESCRIPTOR sPreferredFormat = {
|
|
||||||
sizeof(PIXELFORMATDESCRIPTOR), /* size */
|
|
||||||
1, /* version */
|
|
||||||
PFD_SUPPORT_OPENGL |
|
|
||||||
PFD_DRAW_TO_WINDOW |
|
|
||||||
PFD_SWAP_COPY | /* support swap copy */
|
|
||||||
PFD_DOUBLEBUFFER, /* support double-buffering */
|
|
||||||
PFD_TYPE_RGBA, /* color type */
|
|
||||||
32, /* prefered color depth */
|
|
||||||
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
|
|
||||||
0, /* no alpha buffer */
|
|
||||||
0, /* alpha bits (ignored) */
|
|
||||||
0, /* no accumulation buffer */
|
|
||||||
0, 0, 0, 0, /* accum bits (ignored) */
|
|
||||||
32, /* depth buffer */
|
|
||||||
0, /* no stencil buffer */
|
|
||||||
0, /* no auxiliary buffers */
|
|
||||||
PFD_MAIN_PLANE, /* main layer */
|
|
||||||
0, /* reserved */
|
|
||||||
0, 0, 0 /* no layer, visible, damage masks */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Intel videocards don't work fine with multiple contexts and
|
|
||||||
* have to share the same context for all windows.
|
|
||||||
* But if we just share context for all windows it could work incorrect
|
|
||||||
* with multiple videocards configuration. Suppose, that Intel videocards
|
|
||||||
* can't be in multiple-devices configuration. */
|
|
||||||
static int is_crappy_intel_card(void)
|
|
||||||
{
|
|
||||||
static short is_crappy = -1;
|
|
||||||
|
|
||||||
if (is_crappy == -1) {
|
|
||||||
const char *vendor = (const char *)glGetString(GL_VENDOR);
|
|
||||||
is_crappy = (strstr(vendor, "Intel") != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return is_crappy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* force NVidia Optimus to used dedicated graphics */
|
/* force NVidia Optimus to used dedicated graphics */
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -122,16 +74,14 @@ GHOST_WindowWin32::GHOST_WindowWin32(
|
|||||||
GHOST_TDrawingContextType type,
|
GHOST_TDrawingContextType type,
|
||||||
const bool stereoVisual,
|
const bool stereoVisual,
|
||||||
const GHOST_TUns16 numOfAASamples,
|
const GHOST_TUns16 numOfAASamples,
|
||||||
GHOST_TEmbedderWindowID parentwindowhwnd,
|
GHOST_TEmbedderWindowID parentwindowhwnd
|
||||||
GHOST_TSuccess msEnabled,
|
//GHOST_TSuccess msEnabled,
|
||||||
int msPixelFormat)
|
//int msPixelFormat
|
||||||
:
|
)
|
||||||
GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone,
|
: GHOST_Window(width, height, state, stereoVisual, false, numOfAASamples),
|
||||||
stereoVisual, false, numOfAASamples),
|
|
||||||
m_inLiveResize(false),
|
m_inLiveResize(false),
|
||||||
m_system(system),
|
m_system(system),
|
||||||
m_hDC(0),
|
m_hDC(0),
|
||||||
m_hGlRc(0),
|
|
||||||
m_hasMouseCaptured(false),
|
m_hasMouseCaptured(false),
|
||||||
m_hasGrabMouse(false),
|
m_hasGrabMouse(false),
|
||||||
m_nPressedButtons(0),
|
m_nPressedButtons(0),
|
||||||
@@ -140,18 +90,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
|
|||||||
m_tabletData(NULL),
|
m_tabletData(NULL),
|
||||||
m_tablet(0),
|
m_tablet(0),
|
||||||
m_maxPressure(0),
|
m_maxPressure(0),
|
||||||
m_multisample(numOfAASamples),
|
|
||||||
m_multisampleEnabled(msEnabled),
|
|
||||||
m_msPixelFormat(msPixelFormat),
|
|
||||||
//For recreation
|
|
||||||
m_title(title),
|
|
||||||
m_left(left),
|
|
||||||
m_top(top),
|
|
||||||
m_width(width),
|
|
||||||
m_height(height),
|
|
||||||
m_normal_state(GHOST_kWindowStateNormal),
|
m_normal_state(GHOST_kWindowStateNormal),
|
||||||
m_stereo(stereoVisual),
|
|
||||||
m_nextWindow(NULL),
|
|
||||||
m_parentWindowHwnd(parentwindowhwnd)
|
m_parentWindowHwnd(parentwindowhwnd)
|
||||||
{
|
{
|
||||||
OSVERSIONINFOEX versionInfo;
|
OSVERSIONINFOEX versionInfo;
|
||||||
@@ -272,6 +211,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
|
|||||||
0); // pointer to window-creation data
|
0); // pointer to window-creation data
|
||||||
free(title_16);
|
free(title_16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_hWnd) {
|
if (m_hWnd) {
|
||||||
// Register this window as a droptarget. Requires m_hWnd to be valid.
|
// Register this window as a droptarget. Requires m_hWnd to be valid.
|
||||||
// Note that OleInitialize(0) has to be called prior to this. Done in GHOST_SystemWin32.
|
// Note that OleInitialize(0) has to be called prior to this. Done in GHOST_SystemWin32.
|
||||||
@@ -286,10 +226,9 @@ GHOST_WindowWin32::GHOST_WindowWin32(
|
|||||||
// Store the device context
|
// Store the device context
|
||||||
m_hDC = ::GetDC(m_hWnd);
|
m_hDC = ::GetDC(m_hWnd);
|
||||||
|
|
||||||
if (!s_firstHDC) {
|
GHOST_TSuccess success = setDrawingContextType(type);
|
||||||
s_firstHDC = m_hDC;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (success) {
|
||||||
// Show the window
|
// Show the window
|
||||||
int nCmdShow;
|
int nCmdShow;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
@@ -304,18 +243,16 @@ GHOST_WindowWin32::GHOST_WindowWin32(
|
|||||||
nCmdShow = SW_SHOWNORMAL;
|
nCmdShow = SW_SHOWNORMAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GHOST_TSuccess success;
|
|
||||||
success = setDrawingContextType(type);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
::ShowWindow(m_hWnd, nCmdShow);
|
::ShowWindow(m_hWnd, nCmdShow);
|
||||||
|
|
||||||
// Force an initial paint of the window
|
// Force an initial paint of the window
|
||||||
::UpdateWindow(m_hWnd);
|
::UpdateWindow(m_hWnd);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//invalidate the window
|
//invalidate the window
|
||||||
m_hWnd = 0;
|
::DestroyWindow(m_hWnd);
|
||||||
|
m_hWnd = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,11 +331,10 @@ GHOST_WindowWin32::GHOST_WindowWin32(
|
|||||||
|
|
||||||
GHOST_WindowWin32::~GHOST_WindowWin32()
|
GHOST_WindowWin32::~GHOST_WindowWin32()
|
||||||
{
|
{
|
||||||
if (m_Bar)
|
if (m_Bar) {
|
||||||
{
|
|
||||||
m_Bar->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
|
m_Bar->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
|
||||||
m_Bar->Release();
|
m_Bar->Release();
|
||||||
};
|
}
|
||||||
|
|
||||||
if (m_wintab) {
|
if (m_wintab) {
|
||||||
GHOST_WIN32_WTClose fpWTClose = (GHOST_WIN32_WTClose) ::GetProcAddress(m_wintab, "WTClose");
|
GHOST_WIN32_WTClose fpWTClose = (GHOST_WIN32_WTClose) ::GetProcAddress(m_wintab, "WTClose");
|
||||||
@@ -410,19 +346,15 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
|
|||||||
m_tabletData = NULL;
|
m_tabletData = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_customCursor) {
|
if (m_customCursor) {
|
||||||
DestroyCursor(m_customCursor);
|
DestroyCursor(m_customCursor);
|
||||||
m_customCursor = NULL;
|
m_customCursor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
::wglMakeCurrent(NULL, NULL);
|
if (m_hWnd != NULL && m_hDC != NULL && releaseNativeHandles())
|
||||||
m_multisampleEnabled = GHOST_kFailure;
|
|
||||||
m_multisample = 0;
|
|
||||||
setDrawingContextType(GHOST_kDrawingContextTypeNone);
|
|
||||||
if (m_hDC && m_hDC != s_firstHDC) {
|
|
||||||
::ReleaseDC(m_hWnd, m_hDC);
|
::ReleaseDC(m_hWnd, m_hDC);
|
||||||
m_hDC = 0;
|
|
||||||
}
|
|
||||||
if (m_hWnd) {
|
if (m_hWnd) {
|
||||||
if (m_dropTarget) {
|
if (m_dropTarget) {
|
||||||
// Disable DragDrop
|
// Disable DragDrop
|
||||||
@@ -436,11 +368,6 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GHOST_Window *GHOST_WindowWin32::getNextWindow()
|
|
||||||
{
|
|
||||||
return m_nextWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GHOST_WindowWin32::getValid() const
|
bool GHOST_WindowWin32::getValid() const
|
||||||
{
|
{
|
||||||
return m_hWnd != 0;
|
return m_hWnd != 0;
|
||||||
@@ -651,16 +578,6 @@ GHOST_TSuccess GHOST_WindowWin32::setOrder(GHOST_TWindowOrder order)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GHOST_TSuccess GHOST_WindowWin32::swapBuffers()
|
|
||||||
{
|
|
||||||
HDC hDC = m_hDC;
|
|
||||||
|
|
||||||
if (is_crappy_intel_card())
|
|
||||||
hDC = ::wglGetCurrentDC();
|
|
||||||
|
|
||||||
return ::SwapBuffers(hDC) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
|
|
||||||
}
|
|
||||||
|
|
||||||
GHOST_TSuccess GHOST_WindowWin32::setSwapInterval(int interval)
|
GHOST_TSuccess GHOST_WindowWin32::setSwapInterval(int interval)
|
||||||
{
|
{
|
||||||
if (!WGL_EXT_swap_control)
|
if (!WGL_EXT_swap_control)
|
||||||
@@ -676,24 +593,6 @@ int GHOST_WindowWin32::getSwapInterval()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GHOST_TSuccess GHOST_WindowWin32::activateDrawingContext()
|
|
||||||
{
|
|
||||||
GHOST_TSuccess success;
|
|
||||||
if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
|
|
||||||
if (m_hDC && m_hGlRc) {
|
|
||||||
success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
success = GHOST_kSuccess;
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GHOST_TSuccess GHOST_WindowWin32::invalidate()
|
GHOST_TSuccess GHOST_WindowWin32::invalidate()
|
||||||
{
|
{
|
||||||
GHOST_TSuccess success;
|
GHOST_TSuccess success;
|
||||||
@@ -706,266 +605,58 @@ GHOST_TSuccess GHOST_WindowWin32::invalidate()
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
GHOST_TSuccess GHOST_WindowWin32::initMultisample(PIXELFORMATDESCRIPTOR pfd)
|
|
||||||
{
|
|
||||||
int pixelFormat;
|
|
||||||
bool success = FALSE;
|
|
||||||
UINT numFormats;
|
|
||||||
HDC hDC = GetDC(getHWND());
|
|
||||||
float fAttributes[] = {0, 0};
|
|
||||||
UINT nMaxFormats = 1;
|
|
||||||
|
|
||||||
// The attributes to look for
|
|
||||||
int iAttributes[] = {
|
GHOST_Context* GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType type)
|
||||||
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
|
{
|
||||||
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
|
if (type == GHOST_kDrawingContextTypeOpenGL) {
|
||||||
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
|
#if defined(WITH_GL_SYSTEM_DESKTOP)
|
||||||
WGL_COLOR_BITS_ARB, pfd.cColorBits,
|
|
||||||
WGL_DEPTH_BITS_ARB, pfd.cDepthBits,
|
#if defined(WITH_GL_PROFILE_CORE)
|
||||||
#ifdef GHOST_OPENGL_ALPHA
|
// XXX jwilkins: some implementations will only give you 3.2 even if later compatible versions are available
|
||||||
WGL_ALPHA_BITS_ARB, pfd.cAlphaBits,
|
GHOST_Context* context = new GHOST_ContextWGL(m_hWnd, m_hDC, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 3, 2);
|
||||||
|
#elif defined(WITH_GL_PROFILE_ES20)
|
||||||
|
GHOST_Context* context = new GHOST_ContextWGL(m_hWnd, m_hDC, WGL_CONTEXT_ES2_PROFILE_BIT_EXT, 2, 0);
|
||||||
|
#elif defined(WITH_GL_PROFILE_COMPAT)
|
||||||
|
GHOST_Context* context = new GHOST_ContextWGL(m_hWnd, m_hDC);
|
||||||
|
#else
|
||||||
|
#error
|
||||||
#endif
|
#endif
|
||||||
WGL_STENCIL_BITS_ARB, pfd.cStencilBits,
|
|
||||||
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
|
|
||||||
WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
|
|
||||||
WGL_SAMPLES_ARB, m_multisample,
|
|
||||||
0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get the function
|
#elif defined(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
|
|
||||||
|
|
||||||
if (!wglChoosePixelFormatARB)
|
#if defined(WITH_GL_PROFILE_CORE)
|
||||||
{
|
// XXX jwilkins: not sure yet how to request a core context from EGL
|
||||||
m_multisampleEnabled = GHOST_kFailure;
|
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_API);
|
||||||
return GHOST_kFailure;
|
#elif defined(WITH_GL_PROFILE_ES20)
|
||||||
|
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_ES_API, 2);
|
||||||
|
#elif defined(WITH_GL_PROFILE_COMPAT)
|
||||||
|
GHOST_Context* context = new GHOST_ContextEGL(m_hWnd, m_hDC, EGL_OPENGL_API);
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error
|
||||||
|
#endif
|
||||||
|
if (context->initializeDrawingContext(m_stereoVisual, m_numOfAASamples))
|
||||||
|
return context;
|
||||||
|
else
|
||||||
|
delete context;
|
||||||
}
|
}
|
||||||
|
|
||||||
// iAttributes[17] is the initial multisample. If not valid try to use the closest valid value under it.
|
return NULL;
|
||||||
while (iAttributes[17] > 0) {
|
|
||||||
// See if the format is valid
|
|
||||||
success = wglChoosePixelFormatARB(hDC, iAttributes, fAttributes, nMaxFormats, &pixelFormat, &numFormats);
|
|
||||||
GHOST_PRINTF("WGL_SAMPLES_ARB = %i --> success = %i, %i formats\n", iAttributes[17], success, numFormats);
|
|
||||||
|
|
||||||
if (success && numFormats >= 1 && m_multisampleEnabled == GHOST_kFailure) {
|
|
||||||
GHOST_PRINTF("valid pixel format with %i multisamples\n", iAttributes[17]);
|
|
||||||
m_multisampleEnabled = GHOST_kSuccess;
|
|
||||||
m_msPixelFormat = pixelFormat;
|
|
||||||
}
|
|
||||||
iAttributes[17] -= 1;
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
if (m_multisampleEnabled == GHOST_kSuccess) {
|
|
||||||
return GHOST_kSuccess;
|
|
||||||
}
|
|
||||||
GHOST_PRINT("no available pixel format\n");
|
|
||||||
return GHOST_kFailure;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextType type)
|
|
||||||
{
|
|
||||||
GHOST_TSuccess success;
|
|
||||||
switch (type) {
|
|
||||||
case GHOST_kDrawingContextTypeOpenGL:
|
|
||||||
{
|
|
||||||
// If this window has multisample enabled, use the supplied format
|
|
||||||
if (m_multisampleEnabled)
|
|
||||||
{
|
|
||||||
if (SetPixelFormat(m_hDC, m_msPixelFormat, &sPreferredFormat) == FALSE)
|
|
||||||
{
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the context
|
|
||||||
m_hGlRc = ::wglCreateContext(m_hDC);
|
|
||||||
if (m_hGlRc) {
|
|
||||||
if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) {
|
|
||||||
if (s_firsthGLRc) {
|
|
||||||
if (is_crappy_intel_card()) {
|
|
||||||
if (::wglMakeCurrent(NULL, NULL) == TRUE) {
|
|
||||||
::wglDeleteContext(m_hGlRc);
|
|
||||||
m_hGlRc = s_firsthGLRc;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
::wglDeleteContext(m_hGlRc);
|
|
||||||
m_hGlRc = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
::wglCopyContext(s_firsthGLRc, m_hGlRc, GL_ALL_ATTRIB_BITS);
|
|
||||||
::wglShareLists(s_firsthGLRc, m_hGlRc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
s_firsthGLRc = m_hGlRc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_hGlRc) {
|
|
||||||
success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success == GHOST_kFailure) {
|
|
||||||
printf("Failed to get a context....\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (m_stereoVisual)
|
|
||||||
sPreferredFormat.dwFlags |= PFD_STEREO;
|
|
||||||
|
|
||||||
// Attempt to match device context pixel format to the preferred format
|
|
||||||
int iPixelFormat = EnumPixelFormats(m_hDC);
|
|
||||||
if (iPixelFormat == 0) {
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (::SetPixelFormat(m_hDC, iPixelFormat, &sPreferredFormat) == FALSE) {
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// For debugging only: retrieve the pixel format chosen
|
|
||||||
PIXELFORMATDESCRIPTOR preferredFormat;
|
|
||||||
::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &preferredFormat);
|
|
||||||
|
|
||||||
// Create the context
|
|
||||||
m_hGlRc = ::wglCreateContext(m_hDC);
|
|
||||||
if (m_hGlRc) {
|
|
||||||
if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) {
|
|
||||||
if (s_firsthGLRc) {
|
|
||||||
if (is_crappy_intel_card()) {
|
|
||||||
if (::wglMakeCurrent(NULL, NULL) == TRUE) {
|
|
||||||
::wglDeleteContext(m_hGlRc);
|
|
||||||
m_hGlRc = s_firsthGLRc;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
::wglDeleteContext(m_hGlRc);
|
|
||||||
m_hGlRc = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
::wglShareLists(s_firsthGLRc, m_hGlRc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
s_firsthGLRc = m_hGlRc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_hGlRc) {
|
|
||||||
success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success == GHOST_kFailure) {
|
|
||||||
printf("Failed to get a context....\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempt to enable multisample
|
|
||||||
if (m_multisample && WGL_ARB_multisample && !m_multisampleEnabled && !is_crappy_intel_card())
|
|
||||||
{
|
|
||||||
success = initMultisample(preferredFormat);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Make sure we don't screw up the context
|
|
||||||
if (m_hGlRc == s_firsthGLRc)
|
|
||||||
s_firsthGLRc = NULL;
|
|
||||||
m_drawingContextType = GHOST_kDrawingContextTypeOpenGL;
|
|
||||||
removeDrawingContext();
|
|
||||||
|
|
||||||
// Create a new window
|
|
||||||
GHOST_TWindowState new_state = getState();
|
|
||||||
|
|
||||||
m_nextWindow = new GHOST_WindowWin32((GHOST_SystemWin32 *)GHOST_ISystem::getSystem(),
|
|
||||||
m_title,
|
|
||||||
m_left,
|
|
||||||
m_top,
|
|
||||||
m_width,
|
|
||||||
m_height,
|
|
||||||
new_state,
|
|
||||||
type,
|
|
||||||
m_stereo,
|
|
||||||
m_multisample,
|
|
||||||
m_parentWindowHwnd,
|
|
||||||
m_multisampleEnabled,
|
|
||||||
m_msPixelFormat);
|
|
||||||
|
|
||||||
// Return failure so we can trash this window.
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_multisampleEnabled = GHOST_kSuccess;
|
|
||||||
printf("Multisample failed to initialize\n");
|
|
||||||
success = GHOST_kSuccess;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GHOST_kDrawingContextTypeNone:
|
|
||||||
success = GHOST_kSuccess;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
GHOST_TSuccess GHOST_WindowWin32::removeDrawingContext()
|
|
||||||
{
|
|
||||||
GHOST_TSuccess success;
|
|
||||||
switch (m_drawingContextType) {
|
|
||||||
case GHOST_kDrawingContextTypeOpenGL:
|
|
||||||
// we shouldn't remove the drawing context if it's the first OpenGL context
|
|
||||||
// If we do, we get corrupted drawing. See #19997
|
|
||||||
if (m_hGlRc && m_hGlRc != s_firsthGLRc) {
|
|
||||||
success = ::wglDeleteContext(m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
|
|
||||||
m_hGlRc = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GHOST_kDrawingContextTypeNone:
|
|
||||||
success = GHOST_kSuccess;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
success = GHOST_kFailure;
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GHOST_WindowWin32::lostMouseCapture()
|
void GHOST_WindowWin32::lostMouseCapture()
|
||||||
{
|
{
|
||||||
if (m_hasMouseCaptured)
|
if (m_hasMouseCaptured) {
|
||||||
{ m_hasGrabMouse = false;
|
m_hasGrabMouse = false;
|
||||||
m_nPressedButtons = 0;
|
m_nPressedButtons = 0;
|
||||||
m_hasMouseCaptured = false; };
|
m_hasMouseCaptured = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GHOST_WindowWin32::registerMouseClickEvent(int press)
|
void GHOST_WindowWin32::registerMouseClickEvent(int press)
|
||||||
@@ -1308,95 +999,3 @@ GHOST_TSuccess GHOST_WindowWin32::endProgressBar()
|
|||||||
return GHOST_kFailure;
|
return GHOST_kFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ron Fosner's code for weighting pixel formats and forcing software.
|
|
||||||
* See http://www.opengl.org/resources/faq/technical/weight.cpp */
|
|
||||||
|
|
||||||
static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd)
|
|
||||||
{
|
|
||||||
int weight = 0;
|
|
||||||
|
|
||||||
/* assume desktop color depth is 32 bits per pixel */
|
|
||||||
|
|
||||||
/* cull unusable pixel formats */
|
|
||||||
/* if no formats can be found, can we determine why it was rejected? */
|
|
||||||
if (!(pfd.dwFlags & PFD_SUPPORT_OPENGL) ||
|
|
||||||
!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
|
|
||||||
!(pfd.dwFlags & PFD_DOUBLEBUFFER) || /* Blender _needs_ this */
|
|
||||||
(pfd.cDepthBits <= 8) ||
|
|
||||||
!(pfd.iPixelType == PFD_TYPE_RGBA))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
weight = 1; /* it's usable */
|
|
||||||
|
|
||||||
/* the bigger the depth buffer the better */
|
|
||||||
/* give no weight to a 16-bit depth buffer, because those are crap */
|
|
||||||
weight += pfd.cDepthBits - 16;
|
|
||||||
|
|
||||||
weight += pfd.cColorBits - 8;
|
|
||||||
|
|
||||||
#ifdef GHOST_OPENGL_ALPHA
|
|
||||||
if (pfd.cAlphaBits > 0)
|
|
||||||
weight ++;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* want swap copy capability -- it matters a lot */
|
|
||||||
if (pfd.dwFlags & PFD_SWAP_COPY) weight += 16;
|
|
||||||
|
|
||||||
/* but if it's a generic (not accelerated) view, it's really bad */
|
|
||||||
if (pfd.dwFlags & PFD_GENERIC_FORMAT) weight /= 10;
|
|
||||||
|
|
||||||
return weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A modification of Ron Fosner's replacement for ChoosePixelFormat */
|
|
||||||
/* returns 0 on error, else returns the pixel format number to be used */
|
|
||||||
static int EnumPixelFormats(HDC hdc)
|
|
||||||
{
|
|
||||||
int iPixelFormat;
|
|
||||||
int i, n, w, weight = 0;
|
|
||||||
PIXELFORMATDESCRIPTOR pfd;
|
|
||||||
|
|
||||||
/* we need a device context to do anything */
|
|
||||||
if (!hdc) return 0;
|
|
||||||
|
|
||||||
iPixelFormat = 1; /* careful! PFD numbers are 1 based, not zero based */
|
|
||||||
|
|
||||||
/* obtain detailed information about
|
|
||||||
* the device context's first pixel format */
|
|
||||||
n = 1 + ::DescribePixelFormat(hdc, iPixelFormat,
|
|
||||||
sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
|
||||||
|
|
||||||
/* choose a pixel format using the useless Windows function in case
|
|
||||||
* we come up empty handed */
|
|
||||||
iPixelFormat = ::ChoosePixelFormat(hdc, &sPreferredFormat);
|
|
||||||
|
|
||||||
if (!iPixelFormat) return 0; /* couldn't find one to use */
|
|
||||||
|
|
||||||
for (i = 1; i <= n; i++) { /* not the idiom, but it's right */
|
|
||||||
::DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
|
||||||
w = WeightPixelFormat(pfd);
|
|
||||||
// be strict on stereo
|
|
||||||
if (!((sPreferredFormat.dwFlags ^ pfd.dwFlags) & PFD_STEREO)) {
|
|
||||||
if (w > weight) {
|
|
||||||
weight = w;
|
|
||||||
iPixelFormat = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (weight == 0) {
|
|
||||||
// we could find the correct stereo setting, just find any suitable format
|
|
||||||
for (i = 1; i <= n; i++) { /* not the idiom, but it's right */
|
|
||||||
::DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
|
||||||
w = WeightPixelFormat(pfd);
|
|
||||||
if (w > weight) {
|
|
||||||
weight = w;
|
|
||||||
iPixelFormat = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return iPixelFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -37,15 +37,19 @@
|
|||||||
#error WIN32 only!
|
#error WIN32 only!
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
|
#define _WIN32_WINNT 0x501 // require Windows XP or newer
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
|
||||||
#include "GHOST_Window.h"
|
#include "GHOST_Window.h"
|
||||||
#include "GHOST_TaskbarWin32.h"
|
#include "GHOST_TaskbarWin32.h"
|
||||||
|
|
||||||
#ifndef __MINGW64__
|
#ifndef __MINGW64__
|
||||||
#define _WIN32_WINNT 0x501 // require Windows XP or newer
|
|
||||||
#endif
|
#endif
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
//#if defined(WITH_GL_SYSTEM_EMBEDDED) // XXX jwilkins: can remove this after implementing GHOST_Context
|
||||||
|
//#include <GL/eglew.h>
|
||||||
|
//#endif
|
||||||
|
|
||||||
#include <wintab.h>
|
#include <wintab.h>
|
||||||
#define PACKETDATA (PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION | PK_CURSOR)
|
#define PACKETDATA (PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION | PK_CURSOR)
|
||||||
@@ -94,9 +98,9 @@ public:
|
|||||||
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
|
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
|
||||||
const bool stereoVisual = false,
|
const bool stereoVisual = false,
|
||||||
const GHOST_TUns16 numOfAASamples = 0,
|
const GHOST_TUns16 numOfAASamples = 0,
|
||||||
GHOST_TEmbedderWindowID parentWindowHwnd = 0,
|
GHOST_TEmbedderWindowID parentWindowHwnd = 0
|
||||||
GHOST_TSuccess msEnabled = GHOST_kFailure,
|
//GHOST_TSuccess msEnabled = GHOST_kFailure,
|
||||||
int msPixelFormat = 0
|
//int msPixelFormat = 0
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,12 +109,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual ~GHOST_WindowWin32();
|
virtual ~GHOST_WindowWin32();
|
||||||
|
|
||||||
/**
|
///**
|
||||||
* Returns the window to replace this one if it's getting replaced
|
// * Returns the window to replace this one if it's getting replaced
|
||||||
* \return The window replacing this one.
|
// * \return The window replacing this one.
|
||||||
*/
|
// */
|
||||||
|
|
||||||
GHOST_Window *getNextWindow();
|
//GHOST_Window *getNextWindow();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns indication as to whether the window is valid.
|
* Returns indication as to whether the window is valid.
|
||||||
@@ -208,10 +212,6 @@ public:
|
|||||||
virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
|
virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swaps front and back buffers of a window.
|
|
||||||
* \return Indication of success.
|
|
||||||
*/
|
|
||||||
virtual GHOST_TSuccess swapBuffers();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the swap interval for swapBuffers.
|
* Sets the swap interval for swapBuffers.
|
||||||
@@ -226,12 +226,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual int getSwapInterval();
|
virtual int getSwapInterval();
|
||||||
|
|
||||||
/**
|
|
||||||
* Activates the drawing context of this window.
|
|
||||||
* \return Indication of success.
|
|
||||||
*/
|
|
||||||
virtual GHOST_TSuccess activateDrawingContext();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates the contents of this window.
|
* Invalidates the contents of this window.
|
||||||
*/
|
*/
|
||||||
@@ -248,13 +242,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual GHOST_TSuccess endProgressBar();
|
virtual GHOST_TSuccess endProgressBar();
|
||||||
|
|
||||||
/**
|
///**
|
||||||
* Returns the name of the window class.
|
// * Returns the name of the window class.
|
||||||
* \return The name of the window class.
|
// * \return The name of the window class.
|
||||||
*/
|
// */
|
||||||
static const wchar_t *getWindowClassName() {
|
//static const wchar_t *getWindowClassName() {
|
||||||
return s_windowClassName;
|
// return s_windowClassName;
|
||||||
}
|
//}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a mouse click event (should be called
|
* Register a mouse click event (should be called
|
||||||
@@ -296,23 +290,16 @@ public:
|
|||||||
GHOST_TSuccess endFullScreen() const {return GHOST_kFailure;}
|
GHOST_TSuccess endFullScreen() const {return GHOST_kFailure;}
|
||||||
|
|
||||||
/** if the window currently resizing */
|
/** if the window currently resizing */
|
||||||
bool m_inLiveResize;
|
bool m_inLiveResize; // XXX jwilkins: ugh
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
GHOST_TSuccess initMultisample(PIXELFORMATDESCRIPTOR pfd);
|
//GHOST_TSuccess initMultisample(PIXELFORMATDESCRIPTOR pfd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to install a rendering context in this window.
|
* \param type The type of rendering context create.
|
||||||
* \param type The type of rendering context installed.
|
|
||||||
* \return Indication of success.
|
* \return Indication of success.
|
||||||
*/
|
*/
|
||||||
virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
|
virtual GHOST_Context* newDrawingContext(GHOST_TDrawingContextType type);
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the current drawing context.
|
|
||||||
* \return Indication of success.
|
|
||||||
*/
|
|
||||||
virtual GHOST_TSuccess removeDrawingContext();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the cursor visibility on the window using
|
* Sets the cursor visibility on the window using
|
||||||
@@ -360,12 +347,29 @@ protected:
|
|||||||
HWND m_hWnd;
|
HWND m_hWnd;
|
||||||
/** Device context handle. */
|
/** Device context handle. */
|
||||||
HDC m_hDC;
|
HDC m_hDC;
|
||||||
/** OpenGL rendering context. */
|
|
||||||
HGLRC m_hGlRc;
|
//#if defined(WITH_GL_SYSTEM_DESKTOP) || defined(WITH_GL_SYSTEM_LEGACY)
|
||||||
/** The first created OpenGL context (for sharing display lists) */
|
// /** OpenGL rendering context. */
|
||||||
static HGLRC s_firsthGLRc;
|
// HGLRC m_hGlRc;
|
||||||
/** The first created device context handle. */
|
// /** The first created OpenGL context (for sharing display lists) */
|
||||||
static HDC s_firstHDC;
|
// static HGLRC s_firsthGLRc;
|
||||||
|
// /** The first created device context handle. */
|
||||||
|
// static HDC s_firstHDC;
|
||||||
|
//#endif
|
||||||
|
//#if defined(WITH_GL_SYSTEM_EMBEDDED)
|
||||||
|
// EGLContext m_egl_context;
|
||||||
|
// EGLSurface m_egl_surface;
|
||||||
|
// EGLDisplay m_egl_display;
|
||||||
|
//
|
||||||
|
//#if defined(WITH_ANGLE)
|
||||||
|
// static HMODULE s_d3dcompiler;
|
||||||
|
//#endif
|
||||||
|
//
|
||||||
|
// static EGLContext s_egl_first_context;
|
||||||
|
//
|
||||||
|
// static bool s_eglew_initialized;
|
||||||
|
//#endif
|
||||||
|
|
||||||
/** Flag for if window has captured the mouse */
|
/** Flag for if window has captured the mouse */
|
||||||
bool m_hasMouseCaptured;
|
bool m_hasMouseCaptured;
|
||||||
/** Flag if an operator grabs the mouse with WM_cursor_grab_enable/ungrab()
|
/** Flag if an operator grabs the mouse with WM_cursor_grab_enable/ungrab()
|
||||||
@@ -393,26 +397,26 @@ protected:
|
|||||||
LONG m_maxPressure;
|
LONG m_maxPressure;
|
||||||
LONG m_maxAzimuth, m_maxAltitude;
|
LONG m_maxAzimuth, m_maxAltitude;
|
||||||
|
|
||||||
/** Preferred number of samples */
|
///** Preferred number of samples */
|
||||||
GHOST_TUns16 m_multisample;
|
//GHOST_TUns16 m_multisample;
|
||||||
|
|
||||||
/** Check if multisample is supported */
|
///** Check if multisample is supported */
|
||||||
GHOST_TSuccess m_multisampleEnabled;
|
//GHOST_TSuccess m_multisampleEnabled;
|
||||||
|
|
||||||
/** The pixelFormat to use for multisample */
|
///** The pixelFormat to use for multisample */
|
||||||
int m_msPixelFormat;
|
//int m_msPixelFormat;
|
||||||
|
|
||||||
/** We need to following to recreate the window */
|
///** We need to following to recreate the window */
|
||||||
const STR_String& m_title;
|
//const STR_String& m_title;
|
||||||
GHOST_TInt32 m_left;
|
//GHOST_TInt32 m_left;
|
||||||
GHOST_TInt32 m_top;
|
//GHOST_TInt32 m_top;
|
||||||
GHOST_TUns32 m_width;
|
//GHOST_TUns32 m_width;
|
||||||
GHOST_TUns32 m_height;
|
//GHOST_TUns32 m_height;
|
||||||
GHOST_TWindowState m_normal_state;
|
GHOST_TWindowState m_normal_state;
|
||||||
bool m_stereo;
|
//bool m_stereo;
|
||||||
|
|
||||||
/** The GHOST_System passes this to wm if this window is being replaced */
|
///** The GHOST_System passes this to wm if this window is being replaced */
|
||||||
GHOST_Window *m_nextWindow;
|
//GHOST_Window *m_nextWindow;
|
||||||
|
|
||||||
/** Hwnd to parent window */
|
/** Hwnd to parent window */
|
||||||
GHOST_TEmbedderWindowID m_parentWindowHwnd;
|
GHOST_TEmbedderWindowID m_parentWindowHwnd;
|
||||||
|
@@ -156,8 +156,11 @@ static long BLENDER_ICON_48x48x32[] = {
|
|||||||
4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303,
|
4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303, 4671303,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef GLEW_INC_EGL
|
||||||
|
EGLContext GHOST_WindowX11::s_firstContext = NULL;
|
||||||
|
#else
|
||||||
GLXContext GHOST_WindowX11::s_firstContext = NULL;
|
GLXContext GHOST_WindowX11::s_firstContext = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
GHOST_WindowX11::
|
GHOST_WindowX11::
|
||||||
GHOST_WindowX11(
|
GHOST_WindowX11(
|
||||||
@@ -192,11 +195,12 @@ GHOST_WindowX11(
|
|||||||
|
|
||||||
int attributes[40], i, samples;
|
int attributes[40], i, samples;
|
||||||
int natom;
|
int natom;
|
||||||
int glxVersionMajor, glxVersionMinor; /* As in GLX major.minor */
|
int major, minor; /* As in GLX major.minor */
|
||||||
|
|
||||||
m_visual = NULL;
|
m_visual = NULL;
|
||||||
|
|
||||||
if (!glXQueryVersion(m_display, &glxVersionMajor, &glxVersionMinor)) {
|
#ifndef GLEW_INC_EGL
|
||||||
|
if (!glXQueryVersion(m_display, &major, &minor)) {
|
||||||
printf("%s:%d: X11 glXQueryVersion() failed, verify working openGL system!\n", __FILE__, __LINE__);
|
printf("%s:%d: X11 glXQueryVersion() failed, verify working openGL system!\n", __FILE__, __LINE__);
|
||||||
|
|
||||||
/* exit if this is the first window */
|
/* exit if this is the first window */
|
||||||
@@ -225,7 +229,7 @@ GHOST_WindowX11(
|
|||||||
attributes[i++] = GLX_ALPHA_SIZE; attributes[i++] = 1;
|
attributes[i++] = GLX_ALPHA_SIZE; attributes[i++] = 1;
|
||||||
#endif
|
#endif
|
||||||
/* GLX >= 1.4 required for multi-sample */
|
/* GLX >= 1.4 required for multi-sample */
|
||||||
if (samples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) {
|
if(samples && (major >= 1) && (minor >= 4)) {
|
||||||
attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1;
|
attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1;
|
||||||
attributes[i++] = GLX_SAMPLES; attributes[i++] = samples;
|
attributes[i++] = GLX_SAMPLES; attributes[i++] = samples;
|
||||||
}
|
}
|
||||||
@@ -256,10 +260,12 @@ GHOST_WindowX11(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
m_visual = (XVisualInfo*)calloc(sizeof(XVisualInfo), 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Create a bunch of attributes needed to create an X window. */
|
/* Create a bunch of attributes needed to create an X window. */
|
||||||
|
|
||||||
|
|
||||||
/* First create a colormap for the window and visual.
|
/* First create a colormap for the window and visual.
|
||||||
* This seems pretty much a legacy feature as we are in rgba mode anyway. */
|
* This seems pretty much a legacy feature as we are in rgba mode anyway. */
|
||||||
|
|
||||||
@@ -267,11 +273,14 @@ GHOST_WindowX11(
|
|||||||
unsigned int xattributes_valuemask = (CWBorderPixel | CWColormap | CWEventMask);
|
unsigned int xattributes_valuemask = (CWBorderPixel | CWColormap | CWEventMask);
|
||||||
memset(&xattributes, 0, sizeof(xattributes));
|
memset(&xattributes, 0, sizeof(xattributes));
|
||||||
|
|
||||||
xattributes.colormap = XCreateColormap(m_display,
|
#ifndef WITH_ANDROID
|
||||||
|
xattributes.colormap =
|
||||||
|
XCreateColormap(
|
||||||
|
m_display,
|
||||||
RootWindow(m_display, m_visual->screen),
|
RootWindow(m_display, m_visual->screen),
|
||||||
m_visual->visual,
|
m_visual->visual,
|
||||||
AllocNone
|
AllocNone);
|
||||||
);
|
#endif
|
||||||
|
|
||||||
xattributes.border_pixel = 0;
|
xattributes.border_pixel = 0;
|
||||||
|
|
||||||
@@ -307,7 +316,6 @@ GHOST_WindowX11(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
Window root_return;
|
Window root_return;
|
||||||
int x_return, y_return;
|
int x_return, y_return;
|
||||||
unsigned int w_return, h_return, border_w_return, depth_return;
|
unsigned int w_return, h_return, border_w_return, depth_return;
|
||||||
@@ -336,7 +344,6 @@ GHOST_WindowX11(
|
|||||||
);
|
);
|
||||||
|
|
||||||
XSelectInput(m_display, parentWindow, SubstructureNotifyMask);
|
XSelectInput(m_display, parentWindow, SubstructureNotifyMask);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_XDND
|
#ifdef WITH_XDND
|
||||||
@@ -519,6 +526,7 @@ bool GHOST_WindowX11::createX11_XIC()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_X11_XINPUT
|
#ifdef WITH_X11_XINPUT
|
||||||
|
|
||||||
void GHOST_WindowX11::initXInputDevices()
|
void GHOST_WindowX11::initXInputDevices()
|
||||||
{
|
{
|
||||||
XExtensionVersion *version = XGetExtensionVersion(m_display, INAME);
|
XExtensionVersion *version = XGetExtensionVersion(m_display, INAME);
|
||||||
@@ -1083,7 +1091,11 @@ GHOST_WindowX11::
|
|||||||
swapBuffers()
|
swapBuffers()
|
||||||
{
|
{
|
||||||
if (getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL) {
|
if (getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL) {
|
||||||
|
#ifdef GLEW_INC_EGL
|
||||||
|
eglSwapBuffers(gl_display, gl_surface);
|
||||||
|
#else
|
||||||
glXSwapBuffers(m_display, m_window);
|
glXSwapBuffers(m_display, m_window);
|
||||||
|
#endif
|
||||||
return GHOST_kSuccess;
|
return GHOST_kSuccess;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1096,7 +1108,11 @@ GHOST_WindowX11::
|
|||||||
activateDrawingContext()
|
activateDrawingContext()
|
||||||
{
|
{
|
||||||
if (m_context != NULL) {
|
if (m_context != NULL) {
|
||||||
|
#ifdef GLEW_INC_EGL
|
||||||
|
//eglMakeCurrent(gl_display, gl_surface, gl_surface, m_context);
|
||||||
|
#else
|
||||||
glXMakeCurrent(m_display, m_window, m_context);
|
glXMakeCurrent(m_display, m_window, m_context);
|
||||||
|
#endif
|
||||||
/* Disable AA by default */
|
/* Disable AA by default */
|
||||||
if (m_numOfAASamples > 0) {
|
if (m_numOfAASamples > 0) {
|
||||||
glDisable(GL_MULTISAMPLE_ARB);
|
glDisable(GL_MULTISAMPLE_ARB);
|
||||||
@@ -1174,7 +1190,11 @@ GHOST_WindowX11::
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_context != s_firstContext) {
|
if (m_context != s_firstContext) {
|
||||||
|
#ifdef GLEW_INC_EGL
|
||||||
|
eglDestroyContext(gl_display, m_context);
|
||||||
|
#else
|
||||||
glXDestroyContext(m_display, m_context);
|
glXDestroyContext(m_display, m_context);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_owner == m_window) {
|
if (p_owner == m_window) {
|
||||||
@@ -1195,7 +1215,12 @@ GHOST_WindowX11::
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
XDestroyWindow(m_display, m_window);
|
XDestroyWindow(m_display, m_window);
|
||||||
|
|
||||||
|
#ifdef GLEW_INC_EGL
|
||||||
|
free(m_visual);
|
||||||
|
#else
|
||||||
XFree(m_visual);
|
XFree(m_visual);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1215,6 +1240,7 @@ installDrawingContext(
|
|||||||
GHOST_TSuccess success;
|
GHOST_TSuccess success;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GHOST_kDrawingContextTypeOpenGL:
|
case GHOST_kDrawingContextTypeOpenGL:
|
||||||
|
#ifndef GLEW_INC_EGL
|
||||||
{
|
{
|
||||||
#ifdef WITH_X11_XINPUT
|
#ifdef WITH_X11_XINPUT
|
||||||
/* use our own event handlers to avoid exiting blender,
|
/* use our own event handlers to avoid exiting blender,
|
||||||
@@ -1237,14 +1263,77 @@ installDrawingContext(
|
|||||||
else {
|
else {
|
||||||
success = GHOST_kFailure;
|
success = GHOST_kFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_X11_XINPUT
|
#ifdef WITH_X11_XINPUT
|
||||||
/* Restore handler */
|
/* Restore handler */
|
||||||
(void) XSetErrorHandler(old_handler);
|
(void) XSetErrorHandler(old_handler);
|
||||||
(void) XSetIOErrorHandler(old_handler_io);
|
(void) XSetIOErrorHandler(old_handler_io);
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
EGLint ver[2];
|
||||||
|
EGLint num_config;
|
||||||
|
EGLConfig config;
|
||||||
|
EGLint attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
|
||||||
|
|
||||||
|
EGLint attribList[] =
|
||||||
|
{
|
||||||
|
EGL_RED_SIZE, 8,
|
||||||
|
EGL_GREEN_SIZE, 8,
|
||||||
|
EGL_BLUE_SIZE, 8,
|
||||||
|
EGL_DEPTH_SIZE, 8,
|
||||||
|
//EGL_ALPHA_SIZE, 8,
|
||||||
|
/*EGL_ALPHA_SIZE, 8,
|
||||||
|
|
||||||
|
EGL_STENCIL_SIZE, 8,
|
||||||
|
EGL_SAMPLE_BUFFERS, 1,*/
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
gl_display = eglGetDisplay((EGLNativeDisplayType)m_display);
|
||||||
|
if(gl_display == EGL_NO_DISPLAY)
|
||||||
|
{
|
||||||
|
success = GHOST_kFailure;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(!eglInitialize(gl_display, &ver[0], &ver[1]))
|
||||||
|
{
|
||||||
|
success = GHOST_kFailure;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!eglGetConfigs(gl_display, NULL, 0, &num_config))
|
||||||
|
{
|
||||||
|
success = GHOST_kFailure;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!eglChooseConfig(gl_display, attribList, &config, 1, &num_config))
|
||||||
|
{
|
||||||
|
success = GHOST_kFailure;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
gl_surface = eglCreateWindowSurface(gl_display, config, (EGLNativeWindowType)m_window, NULL);
|
||||||
|
if (gl_surface == EGL_NO_SURFACE)
|
||||||
|
{
|
||||||
|
success = GHOST_kFailure;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m_context = eglCreateContext(gl_display, config, EGL_NO_CONTEXT, attribs);
|
||||||
|
if(m_context == EGL_NO_CONTEXT)
|
||||||
|
{
|
||||||
|
success = GHOST_kFailure;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!eglMakeCurrent(gl_display, gl_surface, gl_surface, m_context))
|
||||||
|
{
|
||||||
|
success = GHOST_kFailure;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
glClearColor(0.447, 0.447, 0.447, 0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
glEnable(GL_DITHER);
|
||||||
|
eglSwapBuffers(gl_display, gl_surface);
|
||||||
|
success = GHOST_kSuccess;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
case GHOST_kDrawingContextTypeNone:
|
case GHOST_kDrawingContextTypeNone:
|
||||||
{
|
{
|
||||||
success = GHOST_kSuccess;
|
success = GHOST_kSuccess;
|
||||||
@@ -1266,15 +1355,19 @@ GHOST_TSuccess
|
|||||||
GHOST_WindowX11::
|
GHOST_WindowX11::
|
||||||
removeDrawingContext()
|
removeDrawingContext()
|
||||||
{
|
{
|
||||||
GHOST_TSuccess success;
|
GHOST_TSuccess success = GHOST_kFailure;
|
||||||
|
|
||||||
if (m_context != NULL) {
|
#ifndef GLEW_INC_EGL
|
||||||
|
if (m_context != NULL) { // XXX jwilkins: seems odd not to check if this is s_firstContext
|
||||||
glXDestroyContext(m_display, m_context);
|
glXDestroyContext(m_display, m_context);
|
||||||
|
m_context = NULL;
|
||||||
success = GHOST_kSuccess;
|
success = GHOST_kSuccess;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
success = GHOST_kFailure;
|
success = GHOST_kFailure;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,14 @@
|
|||||||
|
|
||||||
#include "GHOST_Window.h"
|
#include "GHOST_Window.h"
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <GL/glx.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
|
#ifndef GLEW_INC_EGL
|
||||||
|
#include <GL/glxew.h>
|
||||||
|
#else
|
||||||
|
#include <GL/eglew.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// For tablets
|
// For tablets
|
||||||
#ifdef WITH_X11_XINPUT
|
#ifdef WITH_X11_XINPUT
|
||||||
# include <X11/extensions/XInput.h>
|
# include <X11/extensions/XInput.h>
|
||||||
@@ -350,14 +357,25 @@ private:
|
|||||||
void initXInputDevices();
|
void initXInputDevices();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef GLEW_INC_EGL
|
||||||
|
EGLContext m_context;
|
||||||
|
EGLSurface gl_surface;
|
||||||
|
EGLDisplay gl_display;
|
||||||
|
#else
|
||||||
GLXContext m_context;
|
GLXContext m_context;
|
||||||
|
#endif
|
||||||
|
|
||||||
Window m_window;
|
Window m_window;
|
||||||
Display *m_display;
|
Display *m_display;
|
||||||
XVisualInfo *m_visual;
|
XVisualInfo *m_visual;
|
||||||
GHOST_TWindowState m_normal_state;
|
GHOST_TWindowState m_normal_state;
|
||||||
|
|
||||||
/** The first created OpenGL context (for sharing display lists) */
|
/** The first created OpenGL context (for sharing display lists) */
|
||||||
|
#ifndef GLEW_INC_EGL
|
||||||
|
static EGLContext s_firstContext;
|
||||||
|
#else
|
||||||
static GLXContext s_firstContext;
|
static GLXContext s_firstContext;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// A pointer to the typed system class.
|
/// A pointer to the typed system class.
|
||||||
|
|
||||||
|
@@ -65,6 +65,7 @@
|
|||||||
/* needed for uintptr_t and attributes, exception, dont use BLI anywhere else in MEM_* */
|
/* needed for uintptr_t and attributes, exception, dont use BLI anywhere else in MEM_* */
|
||||||
#include "../../source/blender/blenlib/BLI_sys_types.h"
|
#include "../../source/blender/blenlib/BLI_sys_types.h"
|
||||||
#include "../../source/blender/blenlib/BLI_compiler_attrs.h"
|
#include "../../source/blender/blenlib/BLI_compiler_attrs.h"
|
||||||
|
#include "../../source/blender/blenlib/BLI_utildefines.h" /* for __func__ */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
0
release/bin/blender-softwaregl
Executable file → Normal file
0
release/bin/blender-softwaregl
Executable file → Normal file
0
release/bin/blender-thumbnailer.py
Executable file → Normal file
0
release/bin/blender-thumbnailer.py
Executable file → Normal file
0
release/datafiles/blender_icons_update.py
Executable file → Normal file
0
release/datafiles/blender_icons_update.py
Executable file → Normal file
0
release/datafiles/ctodata.py
Executable file → Normal file
0
release/datafiles/ctodata.py
Executable file → Normal file
0
release/datafiles/datatoc.py
Executable file → Normal file
0
release/datafiles/datatoc.py
Executable file → Normal file
0
release/datafiles/prvicons_update.py
Executable file → Normal file
0
release/datafiles/prvicons_update.py
Executable file → Normal file
0
release/scripts/modules/bl_i18n_utils/merge_po.py
Executable file → Normal file
0
release/scripts/modules/bl_i18n_utils/merge_po.py
Executable file → Normal file
0
release/scripts/modules/bl_i18n_utils/utils_languages_menu.py
Executable file → Normal file
0
release/scripts/modules/bl_i18n_utils/utils_languages_menu.py
Executable file → Normal file
0
release/scripts/modules/bl_i18n_utils/utils_rtl.py
Executable file → Normal file
0
release/scripts/modules/bl_i18n_utils/utils_rtl.py
Executable file → Normal file
0
release/scripts/modules/blend_render_info.py
Executable file → Normal file
0
release/scripts/modules/blend_render_info.py
Executable file → Normal file
@@ -32,6 +32,8 @@
|
|||||||
#ifndef __BLF_API_H__
|
#ifndef __BLF_API_H__
|
||||||
#define __BLF_API_H__
|
#define __BLF_API_H__
|
||||||
|
|
||||||
|
#include <string.h> /* for size_t */
|
||||||
|
|
||||||
struct rctf;
|
struct rctf;
|
||||||
struct ColorManagedDisplay;
|
struct ColorManagedDisplay;
|
||||||
|
|
||||||
@@ -71,6 +73,8 @@ void BLF_size(int fontid, int size, int dpi);
|
|||||||
void BLF_matrix(int fontid, const double m[16]);
|
void BLF_matrix(int fontid, const double m[16]);
|
||||||
|
|
||||||
/* Draw the string using the default font, size and dpi. */
|
/* Draw the string using the default font, size and dpi. */
|
||||||
|
void BLF_draw_default_lock(void);
|
||||||
|
void BLF_draw_default_unlock(void);
|
||||||
void BLF_draw_default(float x, float y, float z, const char *str, size_t len);
|
void BLF_draw_default(float x, float y, float z, const char *str, size_t len);
|
||||||
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len);
|
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len);
|
||||||
|
|
||||||
@@ -79,6 +83,11 @@ void BLF_draw(int fontid, const char *str, size_t len);
|
|||||||
void BLF_draw_ascii(int fontid, const char *str, size_t len);
|
void BLF_draw_ascii(int fontid, const char *str, size_t len);
|
||||||
int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth);
|
int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth);
|
||||||
|
|
||||||
|
/* Draw large blocks of text more efficiently by
|
||||||
|
explicitely reserving OpenGL for that purpose*/
|
||||||
|
void BLF_draw_lock(int fontid);
|
||||||
|
void BLF_draw_unlock(int fontid);
|
||||||
|
|
||||||
/* Get the string byte offset that fits within a given width */
|
/* Get the string byte offset that fits within a given width */
|
||||||
size_t BLF_width_to_strlen(int fontid, const char *str, size_t len, float width, float *r_width);
|
size_t BLF_width_to_strlen(int fontid, const char *str, size_t len, float width, float *r_width);
|
||||||
/* Same as BLF_width_to_strlen but search from the string end */
|
/* Same as BLF_width_to_strlen but search from the string end */
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
#ifndef __BLF_TRANSLATION_H__
|
#ifndef __BLF_TRANSLATION_H__
|
||||||
#define __BLF_TRANSLATION_H__
|
#define __BLF_TRANSLATION_H__
|
||||||
|
|
||||||
#include "BLI_utildefines.h" /* for bool type */
|
#include "BLI_sys_types.h" /* for bool type */
|
||||||
|
|
||||||
#define TEXT_DOMAIN_NAME "blender"
|
#define TEXT_DOMAIN_NAME "blender"
|
||||||
|
|
||||||
|
@@ -32,6 +32,7 @@ set(INC
|
|||||||
../imbuf
|
../imbuf
|
||||||
../../../intern/guardedalloc
|
../../../intern/guardedalloc
|
||||||
../../../intern/locale
|
../../../intern/locale
|
||||||
|
../gpu
|
||||||
)
|
)
|
||||||
|
|
||||||
set(INC_SYS
|
set(INC_SYS
|
||||||
@@ -58,7 +59,7 @@ if(WITH_INTERNATIONAL)
|
|||||||
add_definitions(-DWITH_INTERNATIONAL)
|
add_definitions(-DWITH_INTERNATIONAL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DGLEW_STATIC)
|
add_definitions(${GL_DEFINITIONS})
|
||||||
|
|
||||||
blender_add_lib(bf_blenfont "${SRC}" "${INC}" "${INC_SYS}")
|
blender_add_lib(bf_blenfont "${SRC}" "${INC}" "${INC_SYS}")
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@ incs = [
|
|||||||
'../blenkernel',
|
'../blenkernel',
|
||||||
'../blenlib',
|
'../blenlib',
|
||||||
'../editors/include',
|
'../editors/include',
|
||||||
|
'../gpu',
|
||||||
'../imbuf',
|
'../imbuf',
|
||||||
'../makesdna',
|
'../makesdna',
|
||||||
'../makesrna',
|
'../makesrna',
|
||||||
|
@@ -50,12 +50,16 @@
|
|||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_threads.h"
|
#include "BLI_threads.h"
|
||||||
|
|
||||||
#include "BIF_gl.h"
|
|
||||||
#include "BLF_api.h"
|
#include "BLF_api.h"
|
||||||
|
|
||||||
#include "blf_internal_types.h"
|
#include "blf_internal_types.h"
|
||||||
#include "blf_internal.h"
|
#include "blf_internal.h"
|
||||||
|
|
||||||
|
#include "GPU_blender_aspect.h"
|
||||||
|
#include "GPU_immediate.h"
|
||||||
|
#include "GPU_matrix.h"
|
||||||
|
#include "GPU_font.h"
|
||||||
|
|
||||||
/* Max number of font in memory.
|
/* Max number of font in memory.
|
||||||
* Take care that now every font have a glyph cache per size/dpi,
|
* Take care that now every font have a glyph cache per size/dpi,
|
||||||
* so we don't need load the same font with different size, just
|
* so we don't need load the same font with different size, just
|
||||||
@@ -160,10 +164,10 @@ static int blf_global_font_init(void)
|
|||||||
|
|
||||||
if (global_font_default == -1) {
|
if (global_font_default == -1) {
|
||||||
printf("Warning: Can't find default font!\n");
|
printf("Warning: Can't find default font!\n");
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,31 +462,36 @@ void BLF_blur(int fontid, int size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BLF_draw_default_lock(void)
|
||||||
|
{
|
||||||
|
if (blf_global_font_init()) {
|
||||||
|
BLF_draw_lock(global_font_default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BLF_draw_default_unlock(void)
|
||||||
|
{
|
||||||
|
if (blf_global_font_init()) {
|
||||||
|
BLF_draw_unlock(global_font_default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
|
void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
|
||||||
{
|
{
|
||||||
if (!str)
|
if (str && blf_global_font_init()) {
|
||||||
return;
|
|
||||||
|
|
||||||
if (!blf_global_font_init())
|
|
||||||
return;
|
|
||||||
|
|
||||||
BLF_size(global_font_default, global_font_points, global_font_dpi);
|
BLF_size(global_font_default, global_font_points, global_font_dpi);
|
||||||
BLF_position(global_font_default, x, y, z);
|
BLF_position(global_font_default, x, y, z);
|
||||||
BLF_draw(global_font_default, str, len);
|
BLF_draw(global_font_default, str, len);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* same as above but call 'BLF_draw_ascii' */
|
/* same as above but call 'BLF_draw_ascii' */
|
||||||
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
|
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
|
||||||
{
|
{
|
||||||
if (!str)
|
if (str && blf_global_font_init()) {
|
||||||
return;
|
|
||||||
|
|
||||||
if (!blf_global_font_init())
|
|
||||||
return;
|
|
||||||
|
|
||||||
BLF_size(global_font_default, global_font_points, global_font_dpi);
|
|
||||||
BLF_position(global_font_default, x, y, z);
|
BLF_position(global_font_default, x, y, z);
|
||||||
BLF_draw_ascii(global_font_default, str, len); /* XXX, use real length */
|
BLF_draw(global_font_default, str, len); /* XXX, use real length */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLF_rotation_default(float angle)
|
void BLF_rotation_default(float angle)
|
||||||
@@ -494,103 +503,154 @@ void BLF_rotation_default(float angle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blf_draw__start(FontBLF *font, GLint *mode, GLint *param)
|
static void draw_lock(FontBLF *font)
|
||||||
{
|
{
|
||||||
/*
|
if (!font) {
|
||||||
* The pixmap alignment hack is handle
|
return;
|
||||||
* in BLF_position (old ui_rasterpos_safe).
|
}
|
||||||
*/
|
|
||||||
|
if (font->locked == 0) {
|
||||||
|
GPU_font_begin();
|
||||||
|
|
||||||
|
if (font->shadow || font->blur) {
|
||||||
|
gpuImmediateFormat_T2_C4_V2(); // DOODLE: blurred and/or shadowed text
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gpuImmediateFormat_T2_V2(); // DOODLE: normal text
|
||||||
|
}
|
||||||
|
|
||||||
|
/* one-time GL setup */
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glEnable(GL_TEXTURE_2D);
|
}
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
|
|
||||||
/* Save the current matrix mode. */
|
font->locked++;
|
||||||
glGetIntegerv(GL_MATRIX_MODE, mode);
|
}
|
||||||
|
|
||||||
glMatrixMode(GL_TEXTURE);
|
static void draw_unlock(FontBLF *font)
|
||||||
glPushMatrix();
|
{
|
||||||
glLoadIdentity();
|
if (!font) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
GPU_ASSERT(font->locked > 0);
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
if (font->flags & BLF_MATRIX)
|
font->locked--;
|
||||||
glMultMatrixd((GLdouble *)&font->m);
|
|
||||||
|
|
||||||
glTranslatef(font->pos[0], font->pos[1], font->pos[2]);
|
if (font->locked == 0) {
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
gpuImmediateUnformat();
|
||||||
|
|
||||||
|
GPU_font_end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BLF_draw_lock(int fontid)
|
||||||
|
{
|
||||||
|
draw_lock(blf_get(fontid));
|
||||||
|
}
|
||||||
|
|
||||||
|
void BLF_draw_unlock(int fontid)
|
||||||
|
{
|
||||||
|
draw_unlock(blf_get(fontid));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void blf_draw__start(FontBLF *font)
|
||||||
|
{
|
||||||
|
/* The pixmap alignment hack is handled
|
||||||
|
in BLF_position (old ui_rasterpos_safe). */
|
||||||
|
|
||||||
|
#if GPU_SAFETY && defined(WITH_GL_PROFILE_COMPAT)
|
||||||
|
{
|
||||||
|
GLenum param;
|
||||||
|
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, (GLint*)(¶m));
|
||||||
|
GPU_ASSERT(param == GL_MODULATE);
|
||||||
|
|
||||||
|
GPU_ASSERT(gpuGetMatrixMode() == GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gpuMatrixMode(GL_TEXTURE);
|
||||||
|
gpuPushMatrix();
|
||||||
|
gpuLoadIdentity();
|
||||||
|
|
||||||
|
gpuMatrixMode(GL_MODELVIEW);
|
||||||
|
gpuPushMatrix();
|
||||||
|
|
||||||
|
|
||||||
|
if (font->flags & BLF_MATRIX) {
|
||||||
|
gpuMultMatrixd((GLdouble *)&font->m);
|
||||||
|
}
|
||||||
|
|
||||||
|
gpuTranslate(font->pos[0], font->pos[1], font->pos[2]);
|
||||||
|
|
||||||
if (font->flags & BLF_ASPECT)
|
if (font->flags & BLF_ASPECT)
|
||||||
glScalef(font->aspect[0], font->aspect[1], font->aspect[2]);
|
gpuScale(font->aspect[0], font->aspect[1], font->aspect[2]);
|
||||||
|
|
||||||
if (font->flags & BLF_ROTATION) /* radians -> degrees */
|
if (font->flags & BLF_ROTATION)
|
||||||
glRotatef(font->angle * (float)(180.0 / M_PI), 0.0f, 0.0f, 1.0f);
|
gpuRotateAxis(RAD2DEGF(font->angle), 'Z');
|
||||||
|
|
||||||
if (font->shadow || font->blur)
|
if (font->shadow || font->blur)
|
||||||
glGetFloatv(GL_CURRENT_COLOR, font->orig_col);
|
gpuGetColor4fv(font->orig_col);
|
||||||
|
|
||||||
/* always bind the texture for the first glyph */
|
/* always bind the texture for the first glyph */
|
||||||
font->tex_bind_state = -1;
|
font->tex_bind_state = -1;
|
||||||
|
|
||||||
/* Save the current parameter to restore it later. */
|
draw_lock(font);
|
||||||
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
|
|
||||||
if (*param != GL_MODULATE)
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blf_draw__end(GLint mode, GLint param)
|
static void blf_draw__end(FontBLF *font)
|
||||||
{
|
{
|
||||||
/* and restore the original value. */
|
draw_unlock(font);
|
||||||
if (param != GL_MODULATE)
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
|
|
||||||
|
|
||||||
glMatrixMode(GL_TEXTURE);
|
gpuMatrixMode(GL_TEXTURE);
|
||||||
glPopMatrix();
|
gpuPopMatrix();
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
gpuMatrixMode(GL_MODELVIEW);
|
||||||
glPopMatrix();
|
gpuPopMatrix();
|
||||||
|
|
||||||
if (mode != GL_MODELVIEW)
|
/* XXX: current color becomes undefined due to use of vertex arrays,
|
||||||
glMatrixMode(mode);
|
but a lot of code relies on it remaining the same */
|
||||||
|
if (font->shadow || font->blur)
|
||||||
glDisable(GL_BLEND);
|
gpuColor4fv(font->orig_col);
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLF_draw(int fontid, const char *str, size_t len)
|
void BLF_draw(int fontid, const char *str, size_t len)
|
||||||
{
|
{
|
||||||
|
if (len > 0 && str[0]) {
|
||||||
FontBLF *font = blf_get(fontid);
|
FontBLF *font = blf_get(fontid);
|
||||||
GLint mode, param;
|
|
||||||
|
|
||||||
if (font && font->glyph_cache) {
|
if (font && font->glyph_cache) {
|
||||||
blf_draw__start(font, &mode, ¶m);
|
blf_draw__start(font);
|
||||||
blf_font_draw(font, str, len);
|
blf_font_draw(font, str, len);
|
||||||
blf_draw__end(mode, param);
|
blf_draw__end(font);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLF_draw_ascii(int fontid, const char *str, size_t len)
|
void BLF_draw_ascii(int fontid, const char *str, size_t len)
|
||||||
{
|
{
|
||||||
|
if (len > 0 && str[0]) {
|
||||||
FontBLF *font = blf_get(fontid);
|
FontBLF *font = blf_get(fontid);
|
||||||
GLint mode, param;
|
|
||||||
|
|
||||||
if (font && font->glyph_cache) {
|
if (font && font->glyph_cache) {
|
||||||
blf_draw__start(font, &mode, ¶m);
|
blf_draw__start(font);
|
||||||
blf_font_draw_ascii(font, str, len);
|
blf_font_draw_ascii(font, str, len);
|
||||||
blf_draw__end(mode, param);
|
blf_draw__end(font);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth)
|
int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth)
|
||||||
{
|
{
|
||||||
FontBLF *font = blf_get(fontid);
|
FontBLF *font = blf_get(fontid);
|
||||||
GLint mode, param;
|
|
||||||
int columns = 0;
|
int columns = 0;
|
||||||
|
|
||||||
if (font && font->glyph_cache) {
|
if (font && font->glyph_cache) {
|
||||||
blf_draw__start(font, &mode, ¶m);
|
blf_draw__start(font);
|
||||||
columns = blf_font_draw_mono(font, str, len, cwidth);
|
columns = blf_font_draw_mono(font, str, len, cwidth);
|
||||||
blf_draw__end(mode, param);
|
blf_draw__end(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
return columns;
|
return columns;
|
||||||
|
@@ -50,8 +50,6 @@
|
|||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
#include "BLI_threads.h"
|
#include "BLI_threads.h"
|
||||||
|
|
||||||
#include "BIF_gl.h"
|
|
||||||
|
|
||||||
#include "BLF_api.h"
|
#include "BLF_api.h"
|
||||||
#include "blf_internal_types.h"
|
#include "blf_internal_types.h"
|
||||||
#include "blf_internal.h"
|
#include "blf_internal.h"
|
||||||
|
@@ -55,7 +55,6 @@
|
|||||||
#include "BLI_threads.h"
|
#include "BLI_threads.h"
|
||||||
#include "BLI_alloca.h"
|
#include "BLI_alloca.h"
|
||||||
|
|
||||||
#include "BIF_gl.h"
|
|
||||||
#include "BLF_api.h"
|
#include "BLF_api.h"
|
||||||
|
|
||||||
#include "IMB_colormanagement.h"
|
#include "IMB_colormanagement.h"
|
||||||
@@ -65,6 +64,9 @@
|
|||||||
|
|
||||||
#include "BLI_strict_flags.h"
|
#include "BLI_strict_flags.h"
|
||||||
|
|
||||||
|
#include "GPU_immediate.h"
|
||||||
|
#include "GPU_state_latch.h"
|
||||||
|
|
||||||
/* freetype2 handle ONLY for this file!. */
|
/* freetype2 handle ONLY for this file!. */
|
||||||
static FT_Library ft_lib;
|
static FT_Library ft_lib;
|
||||||
static SpinLock ft_lib_mutex;
|
static SpinLock ft_lib_mutex;
|
||||||
@@ -178,6 +180,7 @@ void blf_font_draw(FontBLF *font, const char *str, size_t len)
|
|||||||
int pen_x = 0, pen_y = 0;
|
int pen_x = 0, pen_y = 0;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table;
|
GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table;
|
||||||
|
int needs_end = false;
|
||||||
|
|
||||||
BLF_KERNING_VARS(font, has_kerning, kern_mode);
|
BLF_KERNING_VARS(font, has_kerning, kern_mode);
|
||||||
|
|
||||||
@@ -194,11 +197,18 @@ void blf_font_draw(FontBLF *font, const char *str, size_t len)
|
|||||||
BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
|
BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
|
||||||
|
|
||||||
/* do not return this loop if clipped, we want every character tested */
|
/* do not return this loop if clipped, we want every character tested */
|
||||||
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
|
/* blf_glyph_render calls gpuBegin */
|
||||||
|
blf_glyph_render(font, g, (float)pen_x, (float)pen_y, &needs_end);
|
||||||
|
|
||||||
pen_x += (int)g->advance;
|
pen_x += (int)g->advance;
|
||||||
g_prev = g;
|
g_prev = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (needs_end) {
|
||||||
|
gpuEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
gpuBindTexture(GL_TEXTURE_2D, 0); /* restore default */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* faster version of blf_font_draw, ascii only for view dimensions */
|
/* faster version of blf_font_draw, ascii only for view dimensions */
|
||||||
@@ -209,6 +219,7 @@ void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len)
|
|||||||
FT_Vector delta;
|
FT_Vector delta;
|
||||||
int pen_x = 0, pen_y = 0;
|
int pen_x = 0, pen_y = 0;
|
||||||
GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table;
|
GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table;
|
||||||
|
int needs_end = false;
|
||||||
|
|
||||||
BLF_KERNING_VARS(font, has_kerning, kern_mode);
|
BLF_KERNING_VARS(font, has_kerning, kern_mode);
|
||||||
|
|
||||||
@@ -222,11 +233,18 @@ void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len)
|
|||||||
BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
|
BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
|
||||||
|
|
||||||
/* do not return this loop if clipped, we want every character tested */
|
/* do not return this loop if clipped, we want every character tested */
|
||||||
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
|
/* blf_glyph_render calls gpuBegin */
|
||||||
|
blf_glyph_render(font, g, (float)pen_x, (float)pen_y, &needs_end);
|
||||||
|
|
||||||
pen_x += (int)g->advance;
|
pen_x += (int)g->advance;
|
||||||
g_prev = g;
|
g_prev = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (needs_end) {
|
||||||
|
gpuEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
gpuBindTexture(GL_TEXTURE_2D, 0); /* restore default */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use fixed column width, but an utf8 character may occupy multiple columns */
|
/* use fixed column width, but an utf8 character may occupy multiple columns */
|
||||||
@@ -238,6 +256,7 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
|
|||||||
int pen_x = 0, pen_y = 0;
|
int pen_x = 0, pen_y = 0;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table;
|
GlyphBLF **glyph_ascii_table = font->glyph_cache->glyph_ascii_table;
|
||||||
|
int needs_end = false;
|
||||||
|
|
||||||
blf_font_ensure_ascii_table(font);
|
blf_font_ensure_ascii_table(font);
|
||||||
|
|
||||||
@@ -250,7 +269,8 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* do not return this loop if clipped, we want every character tested */
|
/* do not return this loop if clipped, we want every character tested */
|
||||||
blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
|
/* blf_glyph_render calls gpuBegin */
|
||||||
|
blf_glyph_render(font, g, (float)pen_x, (float)pen_y, &needs_end);
|
||||||
|
|
||||||
col = BLI_wcwidth((wchar_t)c);
|
col = BLI_wcwidth((wchar_t)c);
|
||||||
if (col < 0)
|
if (col < 0)
|
||||||
@@ -260,6 +280,12 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
|
|||||||
pen_x += cwidth * col;
|
pen_x += cwidth * col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (needs_end) {
|
||||||
|
gpuEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
gpuBindTexture(GL_TEXTURE_2D, 0); /* restore default */
|
||||||
|
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,7 +52,6 @@
|
|||||||
#include "BLI_rect.h"
|
#include "BLI_rect.h"
|
||||||
#include "BLI_threads.h"
|
#include "BLI_threads.h"
|
||||||
|
|
||||||
#include "BIF_gl.h"
|
|
||||||
#include "BLF_api.h"
|
#include "BLF_api.h"
|
||||||
|
|
||||||
#include "blf_internal_types.h"
|
#include "blf_internal_types.h"
|
||||||
@@ -60,6 +59,11 @@
|
|||||||
|
|
||||||
#include "BLI_strict_flags.h"
|
#include "BLI_strict_flags.h"
|
||||||
|
|
||||||
|
#include "GPU_state_latch.h"
|
||||||
|
#include "GPU_immediate.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, unsigned int size, unsigned int dpi)
|
GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, unsigned int size, unsigned int dpi)
|
||||||
{
|
{
|
||||||
GlyphCacheBLF *p;
|
GlyphCacheBLF *p;
|
||||||
@@ -169,13 +173,18 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc)
|
|||||||
gc->p2_height = font->max_tex_size;
|
gc->p2_height = font->max_tex_size;
|
||||||
|
|
||||||
glGenTextures(1, &gc->textures[gc->cur_tex]);
|
glGenTextures(1, &gc->textures[gc->cur_tex]);
|
||||||
glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = gc->textures[gc->cur_tex]));
|
gpuBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = gc->textures[gc->cur_tex]));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
|
#if defined(WITH_GL_PROFILE_CORE)
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, gc->p2_width, gc->p2_height, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
#elif defined(WITH_GL_PROFILE_COMPAT) || defined(WITH_GL_PROFILE_ES20)
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
#endif
|
||||||
|
GPU_CHECK_NO_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c)
|
GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c)
|
||||||
@@ -309,30 +318,29 @@ void blf_glyph_free(GlyphBLF *g)
|
|||||||
|
|
||||||
static void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1, float y2)
|
static void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1, float y2)
|
||||||
{
|
{
|
||||||
glBegin(GL_QUADS);
|
gpuTexCoord2f(uv[0][0], uv[0][1]);
|
||||||
glTexCoord2f(uv[0][0], uv[0][1]);
|
gpuVertex2f(dx, y1);
|
||||||
glVertex2f(dx, y1);
|
|
||||||
|
|
||||||
glTexCoord2f(uv[0][0], uv[1][1]);
|
gpuTexCoord2f(uv[0][0], uv[1][1]);
|
||||||
glVertex2f(dx, y2);
|
gpuVertex2f(dx, y2);
|
||||||
|
|
||||||
glTexCoord2f(uv[1][0], uv[1][1]);
|
gpuTexCoord2f(uv[1][0], uv[1][1]);
|
||||||
glVertex2f(dx1, y2);
|
gpuVertex2f(dx1, y2);
|
||||||
|
|
||||||
glTexCoord2f(uv[1][0], uv[0][1]);
|
gpuTexCoord2f(uv[1][0], uv[0][1]);
|
||||||
glVertex2f(dx1, y1);
|
gpuVertex2f(dx1, y1);
|
||||||
glEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
|
static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
|
||||||
{
|
{
|
||||||
const float soft[25] = {1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f,
|
static const float soft[25] =
|
||||||
|
{1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f,
|
||||||
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
|
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
|
||||||
2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f,
|
2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f,
|
||||||
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
|
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
|
||||||
1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f};
|
1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f};
|
||||||
|
|
||||||
const float *fp = soft;
|
int i = 0;
|
||||||
float color[4];
|
float color[4];
|
||||||
float dx, dy;
|
float dx, dy;
|
||||||
|
|
||||||
@@ -341,23 +349,22 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x
|
|||||||
color[2] = shadow_col[2];
|
color[2] = shadow_col[2];
|
||||||
|
|
||||||
for (dx = -2; dx < 3; dx++) {
|
for (dx = -2; dx < 3; dx++) {
|
||||||
for (dy = -2; dy < 3; dy++, fp++) {
|
for (dy = -2; dy < 3; dy++) {
|
||||||
color[3] = *(fp) * shadow_col[3];
|
color[3] = soft[i++] * shadow_col[3];
|
||||||
glColor4fv(color);
|
gpuColor4fv(color);
|
||||||
blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
|
blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glColor4fv(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
|
static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
|
||||||
{
|
{
|
||||||
const float soft[9] = {1 / 16.0f, 2 / 16.0f, 1 / 16.0f,
|
static const float soft[9] =
|
||||||
|
{1 / 16.0f, 2 / 16.0f, 1 / 16.0f,
|
||||||
2 / 16.0f, 4 / 16.0f, 2 / 16.0f,
|
2 / 16.0f, 4 / 16.0f, 2 / 16.0f,
|
||||||
1 / 16.0f, 2 / 16.0f, 1 / 16.0f};
|
1 / 16.0f, 2 / 16.0f, 1 / 16.0f};
|
||||||
|
|
||||||
const float *fp = soft;
|
int i = 0;
|
||||||
float color[4];
|
float color[4];
|
||||||
float dx, dy;
|
float dx, dy;
|
||||||
|
|
||||||
@@ -366,14 +373,12 @@ static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x
|
|||||||
color[2] = shadow_col[2];
|
color[2] = shadow_col[2];
|
||||||
|
|
||||||
for (dx = -1; dx < 2; dx++) {
|
for (dx = -1; dx < 2; dx++) {
|
||||||
for (dy = -1; dy < 2; dy++, fp++) {
|
for (dy = -1; dy < 2; dy++) {
|
||||||
color[3] = *(fp) * shadow_col[3];
|
color[3] = soft[i++] * shadow_col[3];
|
||||||
glColor4fv(color);
|
gpuColor4fv(color);
|
||||||
blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
|
blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glColor4fv(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
|
static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
|
||||||
@@ -384,24 +389,52 @@ static void blf_glyph_calc_rect(rctf *rect, GlyphBLF *g, float x, float y)
|
|||||||
rect->ymax = y + g->pos_y - (float)g->height;
|
rect->ymax = y + g->pos_y - (float)g->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
|
void blf_glyph_render(
|
||||||
|
FontBLF *font,
|
||||||
|
GlyphBLF *g,
|
||||||
|
float x,
|
||||||
|
float y,
|
||||||
|
int *needs_end)
|
||||||
{
|
{
|
||||||
|
int need_begin = !(*needs_end);
|
||||||
rctf rect;
|
rctf rect;
|
||||||
|
|
||||||
if ((!g->width) || (!g->height))
|
if (g->width == 0 || g->height == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
blf_glyph_calc_rect(&rect, g, x, y);
|
||||||
|
|
||||||
|
if (font->flags & BLF_CLIPPING) {
|
||||||
|
/* intentionally check clipping without shadow offset */
|
||||||
|
rctf rect_test = rect;
|
||||||
|
BLI_rctf_translate(&rect_test, font->pos[0], font->pos[1]);
|
||||||
|
|
||||||
|
if (!BLI_rctf_inside_rctf(&font->clip_rec, &rect_test)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (g->build_tex == 0) {
|
if (g->build_tex == 0) {
|
||||||
GlyphCacheBLF *gc = font->glyph_cache;
|
GlyphCacheBLF *gc = font->glyph_cache;
|
||||||
|
|
||||||
|
if (!need_begin) {
|
||||||
|
gpuEnd();
|
||||||
|
need_begin = true;
|
||||||
|
*needs_end = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GPU_CHECK_NO_ERROR();
|
||||||
if (font->max_tex_size == -1)
|
if (font->max_tex_size == -1)
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size);
|
||||||
|
GPU_CHECK_NO_ERROR();
|
||||||
|
|
||||||
if (gc->cur_tex == BLF_CURTEX_UNSET) {
|
if (gc->cur_tex == BLF_CURTEX_UNSET) {
|
||||||
blf_glyph_cache_texture(font, gc);
|
blf_glyph_cache_texture(font, gc);
|
||||||
gc->x_offs = gc->pad;
|
gc->x_offs = gc->pad;
|
||||||
gc->y_offs = 0;
|
gc->y_offs = 0;
|
||||||
}
|
}
|
||||||
|
GPU_CHECK_NO_ERROR();
|
||||||
|
|
||||||
if (gc->x_offs > (gc->p2_width - gc->max_glyph_width)) {
|
if (gc->x_offs > (gc->p2_width - gc->max_glyph_width)) {
|
||||||
gc->x_offs = gc->pad;
|
gc->x_offs = gc->pad;
|
||||||
@@ -430,14 +463,16 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
|
GPU_CHECK_NO_ERROR();
|
||||||
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
GPU_CHECK_NO_ERROR();
|
||||||
glBindTexture(GL_TEXTURE_2D, g->tex);
|
gpuBindTexture(GL_TEXTURE_2D, g->tex);
|
||||||
|
#if defined(WITH_GL_PROFILE_CORE)
|
||||||
|
glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_RED, GL_UNSIGNED_BYTE, g->bitmap);
|
||||||
|
#else
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, g->xoff, g->yoff, g->width, g->height, GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap);
|
||||||
glPopClientAttrib();
|
#endif
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); /* restore default value */ //-V112
|
||||||
|
|
||||||
g->uv[0][0] = ((float)g->xoff) / ((float)gc->p2_width);
|
g->uv[0][0] = ((float)g->xoff) / ((float)gc->p2_width);
|
||||||
g->uv[0][1] = ((float)g->yoff) / ((float)gc->p2_height);
|
g->uv[0][1] = ((float)g->yoff) / ((float)gc->p2_height);
|
||||||
@@ -451,20 +486,17 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
|
|||||||
g->build_tex = 1;
|
g->build_tex = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
blf_glyph_calc_rect(&rect, g, x, y);
|
|
||||||
|
|
||||||
if (font->flags & BLF_CLIPPING) {
|
|
||||||
/* intentionally check clipping without shadow offset */
|
|
||||||
rctf rect_test = rect;
|
|
||||||
BLI_rctf_translate(&rect_test, font->pos[0], font->pos[1]);
|
|
||||||
|
|
||||||
if (!BLI_rctf_inside_rctf(&font->clip_rec, &rect_test)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (font->tex_bind_state != g->tex) {
|
if (font->tex_bind_state != g->tex) {
|
||||||
glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = g->tex));
|
if (!need_begin) {
|
||||||
|
gpuEnd();
|
||||||
|
need_begin = true;
|
||||||
|
}
|
||||||
|
gpuBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = g->tex));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (need_begin) {
|
||||||
|
gpuBegin(GL_QUADS);
|
||||||
|
*needs_end = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font->flags & BLF_SHADOW) {
|
if (font->flags & BLF_SHADOW) {
|
||||||
@@ -472,7 +504,6 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
|
|||||||
blf_glyph_calc_rect(&rect_ofs, g,
|
blf_glyph_calc_rect(&rect_ofs, g,
|
||||||
x + (float)font->shadow_x,
|
x + (float)font->shadow_x,
|
||||||
y + (float)font->shadow_y);
|
y + (float)font->shadow_y);
|
||||||
|
|
||||||
switch (font->shadow) {
|
switch (font->shadow) {
|
||||||
case 3:
|
case 3:
|
||||||
blf_texture3_draw(font->shadow_col, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
|
blf_texture3_draw(font->shadow_col, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
|
||||||
@@ -481,12 +512,11 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
|
|||||||
blf_texture5_draw(font->shadow_col, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
|
blf_texture5_draw(font->shadow_col, g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
glColor4fv(font->shadow_col);
|
gpuColor4fv(font->shadow_col);
|
||||||
blf_texture_draw(g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
|
blf_texture_draw(g->uv, rect_ofs.xmin, rect_ofs.ymin, rect_ofs.xmax, rect_ofs.ymax);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
glColor4fv(font->orig_col);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (font->blur) {
|
switch (font->blur) {
|
||||||
@@ -497,9 +527,12 @@ void blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
|
|||||||
blf_texture5_draw(font->orig_col, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
blf_texture5_draw(font->orig_col, g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
blf_texture_draw(g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
if (font->flags & BLF_SHADOW) {
|
||||||
break;
|
gpuColor4fv(font->orig_col);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
blf_texture_draw(g->uv, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -73,6 +73,6 @@ struct GlyphBLF *blf_glyph_search(struct GlyphCacheBLF *gc, unsigned int c);
|
|||||||
struct GlyphBLF *blf_glyph_add(struct FontBLF *font, unsigned int index, unsigned int c);
|
struct GlyphBLF *blf_glyph_add(struct FontBLF *font, unsigned int index, unsigned int c);
|
||||||
|
|
||||||
void blf_glyph_free(struct GlyphBLF *g);
|
void blf_glyph_free(struct GlyphBLF *g);
|
||||||
void blf_glyph_render(struct FontBLF *font, struct GlyphBLF *g, float x, float y);
|
void blf_glyph_render(struct FontBLF *font, struct GlyphBLF *g, float x, float y, int *needs_end);
|
||||||
|
|
||||||
#endif /* __BLF_INTERNAL_H__ */
|
#endif /* __BLF_INTERNAL_H__ */
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#ifndef __BLF_INTERNAL_TYPES_H__
|
#ifndef __BLF_INTERNAL_TYPES_H__
|
||||||
#define __BLF_INTERNAL_TYPES_H__
|
#define __BLF_INTERNAL_TYPES_H__
|
||||||
|
|
||||||
|
#include "GPU_glew.h"
|
||||||
|
|
||||||
typedef struct GlyphCacheBLF {
|
typedef struct GlyphCacheBLF {
|
||||||
struct GlyphCacheBLF *next;
|
struct GlyphCacheBLF *next;
|
||||||
struct GlyphCacheBLF *prev;
|
struct GlyphCacheBLF *prev;
|
||||||
@@ -225,6 +227,8 @@ typedef struct FontBLF {
|
|||||||
|
|
||||||
/* data for buffer usage (drawing into a texture buffer) */
|
/* data for buffer usage (drawing into a texture buffer) */
|
||||||
FontBufInfoBLF buf_info;
|
FontBufInfoBLF buf_info;
|
||||||
|
|
||||||
|
int locked;
|
||||||
} FontBLF;
|
} FontBLF;
|
||||||
|
|
||||||
typedef struct DirBLF {
|
typedef struct DirBLF {
|
||||||
|
@@ -52,10 +52,10 @@
|
|||||||
|
|
||||||
static const char unifont_filename[] = "droidsans.ttf.gz";
|
static const char unifont_filename[] = "droidsans.ttf.gz";
|
||||||
static unsigned char *unifont_ttf = NULL;
|
static unsigned char *unifont_ttf = NULL;
|
||||||
static int unifont_size = 0;
|
static bli_off_t unifont_size = 0;
|
||||||
static const char unifont_mono_filename[] = "bmonofont-i18n.ttf.gz";
|
static const char unifont_mono_filename[] = "bmonofont-i18n.ttf.gz";
|
||||||
static unsigned char *unifont_mono_ttf = NULL;
|
static unsigned char *unifont_mono_ttf = NULL;
|
||||||
static int unifont_mono_size = 0;
|
static bli_off_t unifont_mono_size = 0;
|
||||||
#endif /* WITH_INTERNATIONAL */
|
#endif /* WITH_INTERNATIONAL */
|
||||||
|
|
||||||
unsigned char *BLF_get_unifont(int *r_unifont_size)
|
unsigned char *BLF_get_unifont(int *r_unifont_size)
|
||||||
@@ -75,7 +75,7 @@ unsigned char *BLF_get_unifont(int *r_unifont_size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*r_unifont_size = unifont_size;
|
*r_unifont_size = (int)unifont_size; /* XXX jwilkins: assuming font file is less than 2GiB */
|
||||||
|
|
||||||
return unifont_ttf;
|
return unifont_ttf;
|
||||||
#else
|
#else
|
||||||
|
@@ -79,6 +79,8 @@
|
|||||||
#include "BKE_customdata.h"
|
#include "BKE_customdata.h"
|
||||||
#include "BKE_bvhutils.h"
|
#include "BKE_bvhutils.h"
|
||||||
|
|
||||||
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
struct CCGElem;
|
struct CCGElem;
|
||||||
struct CCGKey;
|
struct CCGKey;
|
||||||
struct MVert;
|
struct MVert;
|
||||||
@@ -134,8 +136,8 @@ typedef enum DerivedMeshType {
|
|||||||
typedef enum DMDrawOption {
|
typedef enum DMDrawOption {
|
||||||
/* the element is hidden or otherwise non-drawable */
|
/* the element is hidden or otherwise non-drawable */
|
||||||
DM_DRAW_OPTION_SKIP = 0,
|
DM_DRAW_OPTION_SKIP = 0,
|
||||||
/* normal drawing */
|
/* draw element normally */
|
||||||
DM_DRAW_OPTION_NORMAL = 1,
|
DM_DRAW_OPTION_NORMALLY = 1,
|
||||||
/* draw, but don't set the color from mcol */
|
/* draw, but don't set the color from mcol */
|
||||||
DM_DRAW_OPTION_NO_MCOL = 2,
|
DM_DRAW_OPTION_NO_MCOL = 2,
|
||||||
/* used in drawMappedFaces, use GL stipple for the face */
|
/* used in drawMappedFaces, use GL stipple for the face */
|
||||||
@@ -148,10 +150,13 @@ typedef int (*DMCompareDrawOptions)(void *userData, int cur_index, int next_inde
|
|||||||
typedef void (*DMSetDrawInterpOptions)(void *userData, int index, float t);
|
typedef void (*DMSetDrawInterpOptions)(void *userData, int index, float t);
|
||||||
typedef DMDrawOption (*DMSetDrawOptions)(void *userData, int index);
|
typedef DMDrawOption (*DMSetDrawOptions)(void *userData, int index);
|
||||||
typedef DMDrawOption (*DMSetDrawOptionsTex)(struct MTFace *tface, const bool has_vcol, int matnr);
|
typedef DMDrawOption (*DMSetDrawOptionsTex)(struct MTFace *tface, const bool has_vcol, int matnr);
|
||||||
|
typedef void (*DMForEachMappedVert)(void *, int, const float *, const float *, const short *);
|
||||||
|
typedef void (*DMForEachMappedFaceCenter)(void *, int, const float *, const float *);
|
||||||
|
|
||||||
typedef enum DMDrawFlag {
|
typedef enum DMDrawFlag {
|
||||||
DM_DRAW_USE_COLORS = 1,
|
DM_DRAW_USE_COLORS = 1,
|
||||||
DM_DRAW_ALWAYS_SMOOTH = 2
|
DM_DRAW_ALWAYS_SMOOTH = 2,
|
||||||
|
DM_DRAW_USE_NORMALS = 4,
|
||||||
} DMDrawFlag;
|
} DMDrawFlag;
|
||||||
|
|
||||||
typedef enum DMForeachFlag {
|
typedef enum DMForeachFlag {
|
||||||
@@ -172,9 +177,8 @@ typedef enum DMDirtyFlag {
|
|||||||
DM_DIRTY_NORMALS = 1 << 2,
|
DM_DIRTY_NORMALS = 1 << 2,
|
||||||
} DMDirtyFlag;
|
} DMDirtyFlag;
|
||||||
|
|
||||||
typedef struct DerivedMesh DerivedMesh;
|
typedef struct DerivedMesh {
|
||||||
struct DerivedMesh {
|
/** Private struct DerivedMesh data, only for internal struct DerivedMesh use */
|
||||||
/** Private DerivedMesh data, only for internal DerivedMesh use */
|
|
||||||
CustomData vertData, edgeData, faceData, loopData, polyData;
|
CustomData vertData, edgeData, faceData, loopData, polyData;
|
||||||
int numVertData, numEdgeData, numTessFaceData, numLoopData, numPolyData;
|
int numVertData, numEdgeData, numTessFaceData, numLoopData, numPolyData;
|
||||||
int needsFree; /* checked on ->release, is set to 0 for cached results */
|
int needsFree; /* checked on ->release, is set to 0 for cached results */
|
||||||
@@ -191,102 +195,102 @@ struct DerivedMesh {
|
|||||||
char cd_flag;
|
char cd_flag;
|
||||||
|
|
||||||
/** Calculate vert and face normals */
|
/** Calculate vert and face normals */
|
||||||
void (*calcNormals)(DerivedMesh *dm);
|
void (*calcNormals)(struct DerivedMesh *dm);
|
||||||
|
|
||||||
/** Calculate loop (split) normals */
|
/** Calculate loop (split) normals */
|
||||||
void (*calcLoopNormals)(DerivedMesh *dm, const float split_angle);
|
void (*calcLoopNormals)(struct DerivedMesh *dm, const float split_angle);
|
||||||
|
|
||||||
/** Recalculates mesh tessellation */
|
/** Recalculates mesh tessellation */
|
||||||
void (*recalcTessellation)(DerivedMesh *dm);
|
void (*recalcTessellation)(struct DerivedMesh *dm);
|
||||||
|
|
||||||
/* Misc. Queries */
|
/* Misc. Queries */
|
||||||
|
|
||||||
/* Also called in Editmode */
|
/* Also called in Editmode */
|
||||||
int (*getNumVerts)(DerivedMesh *dm);
|
int (*getNumVerts)(struct DerivedMesh *dm);
|
||||||
int (*getNumEdges)(DerivedMesh *dm);
|
int (*getNumEdges)(struct DerivedMesh *dm);
|
||||||
int (*getNumTessFaces)(DerivedMesh *dm);
|
int (*getNumTessFaces)(struct DerivedMesh *dm);
|
||||||
int (*getNumLoops)(DerivedMesh *dm);
|
int (*getNumLoops)(struct DerivedMesh *dm);
|
||||||
int (*getNumPolys)(DerivedMesh *dm);
|
int (*getNumPolys)(struct DerivedMesh *dm);
|
||||||
|
|
||||||
/** Copy a single vert/edge/tessellated face from the derived mesh into
|
/** Copy a single vert/edge/tessellated face from the derived mesh into
|
||||||
* *{vert/edge/face}_r. note that the current implementation
|
* *{vert/edge/face}_r. note that the current implementation
|
||||||
* of this function can be quite slow, iterating over all
|
* of this function can be quite slow, iterating over all
|
||||||
* elements (editmesh)
|
* elements (editmesh)
|
||||||
*/
|
*/
|
||||||
void (*getVert)(DerivedMesh *dm, int index, struct MVert *r_vert);
|
void (*getVert)(struct DerivedMesh *dm, int index, struct MVert *r_vert);
|
||||||
void (*getEdge)(DerivedMesh *dm, int index, struct MEdge *r_edge);
|
void (*getEdge)(struct DerivedMesh *dm, int index, struct MEdge *r_edge);
|
||||||
void (*getTessFace)(DerivedMesh *dm, int index, struct MFace *r_face);
|
void (*getTessFace)(struct DerivedMesh *dm, int index, struct MFace *r_face);
|
||||||
|
|
||||||
/** Return a pointer to the entire array of verts/edges/face from the
|
/** Return a pointer to the entire array of verts/edges/face from the
|
||||||
* derived mesh. if such an array does not exist yet, it will be created,
|
* derived mesh. if such an array does not exist yet, it will be created,
|
||||||
* and freed on the next ->release(). consider using getVert/Edge/Face if
|
* and freed on the next ->release(). consider using getVert/Edge/Face if
|
||||||
* you are only interested in a few verts/edges/faces.
|
* you are only interested in a few verts/edges/faces.
|
||||||
*/
|
*/
|
||||||
struct MVert *(*getVertArray)(DerivedMesh * dm);
|
struct MVert *(*getVertArray)(struct DerivedMesh * dm);
|
||||||
struct MEdge *(*getEdgeArray)(DerivedMesh * dm);
|
struct MEdge *(*getEdgeArray)(struct DerivedMesh * dm);
|
||||||
struct MFace *(*getTessFaceArray)(DerivedMesh * dm);
|
struct MFace *(*getTessFaceArray)(struct DerivedMesh * dm);
|
||||||
struct MLoop *(*getLoopArray)(DerivedMesh * dm);
|
struct MLoop *(*getLoopArray)(struct DerivedMesh * dm);
|
||||||
struct MPoly *(*getPolyArray)(DerivedMesh * dm);
|
struct MPoly *(*getPolyArray)(struct DerivedMesh * dm);
|
||||||
|
|
||||||
/** Copy all verts/edges/faces from the derived mesh into
|
/** Copy all verts/edges/faces from the derived mesh into
|
||||||
* *{vert/edge/face}_r (must point to a buffer large enough)
|
* *{vert/edge/face}_r (must point to a buffer large enough)
|
||||||
*/
|
*/
|
||||||
void (*copyVertArray)(DerivedMesh *dm, struct MVert *r_vert);
|
void (*copyVertArray)(struct DerivedMesh *dm, struct MVert *r_vert);
|
||||||
void (*copyEdgeArray)(DerivedMesh *dm, struct MEdge *r_edge);
|
void (*copyEdgeArray)(struct DerivedMesh *dm, struct MEdge *r_edge);
|
||||||
void (*copyTessFaceArray)(DerivedMesh *dm, struct MFace *r_face);
|
void (*copyTessFaceArray)(struct DerivedMesh *dm, struct MFace *r_face);
|
||||||
void (*copyLoopArray)(DerivedMesh *dm, struct MLoop *r_loop);
|
void (*copyLoopArray)(struct DerivedMesh *dm, struct MLoop *r_loop);
|
||||||
void (*copyPolyArray)(DerivedMesh *dm, struct MPoly *r_poly);
|
void (*copyPolyArray)(struct DerivedMesh *dm, struct MPoly *r_poly);
|
||||||
|
|
||||||
/** Return a copy of all verts/edges/faces from the derived mesh
|
/** Return a copy of all verts/edges/faces from the derived mesh
|
||||||
* it is the caller's responsibility to free the returned pointer
|
* it is the caller's responsibility to free the returned pointer
|
||||||
*/
|
*/
|
||||||
struct MVert *(*dupVertArray)(DerivedMesh * dm);
|
struct MVert *(*dupVertArray)(struct DerivedMesh * dm);
|
||||||
struct MEdge *(*dupEdgeArray)(DerivedMesh * dm);
|
struct MEdge *(*dupEdgeArray)(struct DerivedMesh * dm);
|
||||||
struct MFace *(*dupTessFaceArray)(DerivedMesh * dm);
|
struct MFace *(*dupTessFaceArray)(struct DerivedMesh * dm);
|
||||||
struct MLoop *(*dupLoopArray)(DerivedMesh * dm);
|
struct MLoop *(*dupLoopArray)(struct DerivedMesh * dm);
|
||||||
struct MPoly *(*dupPolyArray)(DerivedMesh * dm);
|
struct MPoly *(*dupPolyArray)(struct DerivedMesh * dm);
|
||||||
|
|
||||||
/** Return a pointer to a single element of vert/edge/face custom data
|
/** Return a pointer to a single element of vert/edge/face custom data
|
||||||
* from the derived mesh (this gives a pointer to the actual data, not
|
* from the derived mesh (this gives a pointer to the actual data, not
|
||||||
* a copy)
|
* a copy)
|
||||||
*/
|
*/
|
||||||
void *(*getVertData)(DerivedMesh *dm, int index, int type);
|
void *(*getVertData)(struct DerivedMesh *dm, int index, int type);
|
||||||
void *(*getEdgeData)(DerivedMesh *dm, int index, int type);
|
void *(*getEdgeData)(struct DerivedMesh *dm, int index, int type);
|
||||||
void *(*getTessFaceData)(DerivedMesh *dm, int index, int type);
|
void *(*getTessFaceData)(struct DerivedMesh *dm, int index, int type);
|
||||||
void *(*getPolyData)(DerivedMesh *dm, int index, int type);
|
void *(*getPolyData)(struct DerivedMesh *dm, int index, int type);
|
||||||
|
|
||||||
/** Return a pointer to the entire array of vert/edge/face custom data
|
/** Return a pointer to the entire array of vert/edge/face custom data
|
||||||
* from the derived mesh (this gives a pointer to the actual data, not
|
* from the derived mesh (this gives a pointer to the actual data, not
|
||||||
* a copy)
|
* a copy)
|
||||||
*/
|
*/
|
||||||
void *(*getVertDataArray)(DerivedMesh *dm, int type);
|
void *(*getVertDataArray)(struct DerivedMesh *dm, int type);
|
||||||
void *(*getEdgeDataArray)(DerivedMesh *dm, int type);
|
void *(*getEdgeDataArray)(struct DerivedMesh *dm, int type);
|
||||||
void *(*getTessFaceDataArray)(DerivedMesh *dm, int type);
|
void *(*getTessFaceDataArray)(struct DerivedMesh *dm, int type);
|
||||||
void *(*getLoopDataArray)(DerivedMesh *dm, int type);
|
void *(*getLoopDataArray)(struct DerivedMesh *dm, int type);
|
||||||
void *(*getPolyDataArray)(DerivedMesh *dm, int type);
|
void *(*getPolyDataArray)(struct DerivedMesh *dm, int type);
|
||||||
|
|
||||||
/** Retrieves the base CustomData structures for
|
/** Retrieves the base CustomData structures for
|
||||||
* verts/edges/tessfaces/loops/facdes*/
|
* verts/edges/tessfaces/loops/facdes*/
|
||||||
CustomData *(*getVertDataLayout)(DerivedMesh * dm);
|
CustomData *(*getVertDataLayout)(struct DerivedMesh * dm);
|
||||||
CustomData *(*getEdgeDataLayout)(DerivedMesh * dm);
|
CustomData *(*getEdgeDataLayout)(struct DerivedMesh * dm);
|
||||||
CustomData *(*getTessFaceDataLayout)(DerivedMesh * dm);
|
CustomData *(*getTessFaceDataLayout)(struct DerivedMesh * dm);
|
||||||
CustomData *(*getLoopDataLayout)(DerivedMesh * dm);
|
CustomData *(*getLoopDataLayout)(struct DerivedMesh * dm);
|
||||||
CustomData *(*getPolyDataLayout)(DerivedMesh * dm);
|
CustomData *(*getPolyDataLayout)(struct DerivedMesh * dm);
|
||||||
|
|
||||||
/** Copies all customdata for an element source into dst at index dest */
|
/** Copies all customdata for an element source into dst at index dest */
|
||||||
void (*copyFromVertCData)(DerivedMesh *dm, int source, CustomData *dst, int dest);
|
void (*copyFromVertCData)(struct DerivedMesh *dm, int source, CustomData *dst, int dest);
|
||||||
void (*copyFromEdgeCData)(DerivedMesh *dm, int source, CustomData *dst, int dest);
|
void (*copyFromEdgeCData)(struct DerivedMesh *dm, int source, CustomData *dst, int dest);
|
||||||
void (*copyFromFaceCData)(DerivedMesh *dm, int source, CustomData *dst, int dest);
|
void (*copyFromFaceCData)(struct DerivedMesh *dm, int source, CustomData *dst, int dest);
|
||||||
|
|
||||||
/** Optional grid access for subsurf */
|
/** Optional grid access for subsurf */
|
||||||
int (*getNumGrids)(DerivedMesh *dm);
|
int (*getNumGrids)(struct DerivedMesh *dm);
|
||||||
int (*getGridSize)(DerivedMesh *dm);
|
int (*getGridSize)(struct DerivedMesh *dm);
|
||||||
struct CCGElem **(*getGridData)(DerivedMesh * dm);
|
struct CCGElem **(*getGridData)(struct DerivedMesh * dm);
|
||||||
DMGridAdjacency *(*getGridAdjacency)(DerivedMesh * dm);
|
DMGridAdjacency *(*getGridAdjacency)(struct DerivedMesh * dm);
|
||||||
int *(*getGridOffset)(DerivedMesh * dm);
|
int *(*getGridOffset)(struct DerivedMesh * dm);
|
||||||
void (*getGridKey)(DerivedMesh *dm, struct CCGKey *key);
|
void (*getGridKey)(struct DerivedMesh *dm, struct CCGKey *key);
|
||||||
DMFlagMat *(*getGridFlagMats)(DerivedMesh * dm);
|
DMFlagMat *(*getGridFlagMats)(struct DerivedMesh * dm);
|
||||||
unsigned int **(*getGridHidden)(DerivedMesh * dm);
|
unsigned int **(*getGridHidden)(struct DerivedMesh * dm);
|
||||||
|
|
||||||
|
|
||||||
/** Iterate over each mapped vertex in the derived mesh, calling the
|
/** Iterate over each mapped vertex in the derived mesh, calling the
|
||||||
@@ -294,7 +298,7 @@ struct DerivedMesh {
|
|||||||
* coordinate and normal. For historical reasons the normal can be
|
* coordinate and normal. For historical reasons the normal can be
|
||||||
* passed as a float or short array, only one should be non-NULL.
|
* passed as a float or short array, only one should be non-NULL.
|
||||||
*/
|
*/
|
||||||
void (*foreachMappedVert)(DerivedMesh *dm,
|
void (*foreachMappedVert)(struct DerivedMesh *dm,
|
||||||
void (*func)(void *userData, int index, const float co[3],
|
void (*func)(void *userData, int index, const float co[3],
|
||||||
const float no_f[3], const short no_s[3]),
|
const float no_f[3], const short no_s[3]),
|
||||||
void *userData,
|
void *userData,
|
||||||
@@ -304,7 +308,7 @@ struct DerivedMesh {
|
|||||||
* given function with the original edge and the mapped edge's new
|
* given function with the original edge and the mapped edge's new
|
||||||
* coordinates.
|
* coordinates.
|
||||||
*/
|
*/
|
||||||
void (*foreachMappedEdge)(DerivedMesh *dm,
|
void (*foreachMappedEdge)(struct DerivedMesh *dm,
|
||||||
void (*func)(void *userData, int index,
|
void (*func)(void *userData, int index,
|
||||||
const float v0co[3], const float v1co[3]),
|
const float v0co[3], const float v1co[3]),
|
||||||
void *userData);
|
void *userData);
|
||||||
@@ -312,7 +316,7 @@ struct DerivedMesh {
|
|||||||
/** Iterate over each mapped loop in the derived mesh, calling the given function
|
/** Iterate over each mapped loop in the derived mesh, calling the given function
|
||||||
* with the original loop index and the mapped loops's new coordinate and normal.
|
* with the original loop index and the mapped loops's new coordinate and normal.
|
||||||
*/
|
*/
|
||||||
void (*foreachMappedLoop)(DerivedMesh *dm,
|
void (*foreachMappedLoop)(struct DerivedMesh *dm,
|
||||||
void (*func)(void *userData, int vertex_index, int face_index,
|
void (*func)(void *userData, int vertex_index, int face_index,
|
||||||
const float co[3], const float no[3]),
|
const float co[3], const float no[3]),
|
||||||
void *userData,
|
void *userData,
|
||||||
@@ -322,7 +326,7 @@ struct DerivedMesh {
|
|||||||
* given function with the original face and the mapped face's (or
|
* given function with the original face and the mapped face's (or
|
||||||
* faces') center and normal.
|
* faces') center and normal.
|
||||||
*/
|
*/
|
||||||
void (*foreachMappedFaceCenter)(DerivedMesh *dm,
|
void (*foreachMappedFaceCenter)(struct DerivedMesh *dm,
|
||||||
void (*func)(void *userData, int index,
|
void (*func)(void *userData, int index,
|
||||||
const float cent[3], const float no[3]),
|
const float cent[3], const float no[3]),
|
||||||
void *userData,
|
void *userData,
|
||||||
@@ -332,46 +336,46 @@ struct DerivedMesh {
|
|||||||
*
|
*
|
||||||
* Also called in Editmode
|
* Also called in Editmode
|
||||||
*/
|
*/
|
||||||
void (*getMinMax)(DerivedMesh *dm, float r_min[3], float r_max[3]);
|
void (*getMinMax)(struct DerivedMesh *dm, float r_min[3], float r_max[3]);
|
||||||
|
|
||||||
/** Direct Access Operations
|
/** Direct Access Operations
|
||||||
* - Can be undefined
|
* - Can be undefined
|
||||||
* - Must be defined for modifiers that only deform however */
|
* - Must be defined for modifiers that only deform however */
|
||||||
|
|
||||||
/** Get vertex location, undefined if index is not valid */
|
/** Get vertex location, undefined if index is not valid */
|
||||||
void (*getVertCo)(DerivedMesh *dm, int index, float r_co[3]);
|
void (*getVertCo)(struct DerivedMesh *dm, int index, float r_co[3]);
|
||||||
|
|
||||||
/** Fill the array (of length .getNumVerts()) with all vertex locations */
|
/** Fill the array (of length .getNumVerts()) with all vertex locations */
|
||||||
void (*getVertCos)(DerivedMesh *dm, float (*r_cos)[3]);
|
void (*getVertCos)(struct DerivedMesh *dm, float (*r_cos)[3]);
|
||||||
|
|
||||||
/** Get smooth vertex normal, undefined if index is not valid */
|
/** Get smooth vertex normal, undefined if index is not valid */
|
||||||
void (*getVertNo)(DerivedMesh *dm, int index, float r_no[3]);
|
void (*getVertNo)(struct DerivedMesh *dm, int index, float r_no[3]);
|
||||||
void (*getPolyNo)(DerivedMesh *dm, int index, float r_no[3]);
|
void (*getPolyNo)(struct DerivedMesh *dm, int index, float r_no[3]);
|
||||||
|
|
||||||
/** Get a map of vertices to faces
|
/** Get a map of vertices to faces
|
||||||
*/
|
*/
|
||||||
const struct MeshElemMap *(*getPolyMap)(struct Object *ob, DerivedMesh *dm);
|
const struct MeshElemMap *(*getPolyMap)(struct Object *ob, struct DerivedMesh *dm);
|
||||||
|
|
||||||
/** Get the BVH used for paint modes
|
/** Get the BVH used for paint modes
|
||||||
*/
|
*/
|
||||||
struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm);
|
struct PBVH *(*getPBVH)(struct Object *ob, struct DerivedMesh *dm);
|
||||||
|
|
||||||
/* Drawing Operations */
|
/* Drawing Operations */
|
||||||
|
|
||||||
/** Draw all vertices as bgl points (no options) */
|
/** Draw all vertices as bgl points (no options) */
|
||||||
void (*drawVerts)(DerivedMesh *dm);
|
void (*drawVerts)(struct DerivedMesh *dm);
|
||||||
|
|
||||||
/** Draw edges in the UV mesh (if exists) */
|
/** Draw edges in the UV mesh (if exists) */
|
||||||
void (*drawUVEdges)(DerivedMesh *dm);
|
void (*drawUVEdges)(struct DerivedMesh *dm);
|
||||||
|
|
||||||
/** Draw all edges as lines (no options)
|
/** Draw all edges as lines (no options)
|
||||||
*
|
*
|
||||||
* Also called for *final* editmode DerivedMeshes
|
* Also called for *final* editmode DerivedMeshes
|
||||||
*/
|
*/
|
||||||
void (*drawEdges)(DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges);
|
void (*drawEdges)(struct DerivedMesh *dm, bool drawLooseEdges, bool drawAllEdges);
|
||||||
|
|
||||||
/** Draw all loose edges (edges w/ no adjoining faces) */
|
/** Draw all loose edges (edges w/ no adjoining faces) */
|
||||||
void (*drawLooseEdges)(DerivedMesh *dm);
|
void (*drawLooseEdges)(struct DerivedMesh *dm);
|
||||||
|
|
||||||
/** Draw all faces
|
/** Draw all faces
|
||||||
* o Set face normal or vertex normal based on inherited face flag
|
* o Set face normal or vertex normal based on inherited face flag
|
||||||
@@ -380,13 +384,13 @@ struct DerivedMesh {
|
|||||||
*
|
*
|
||||||
* Also called for *final* editmode DerivedMeshes
|
* Also called for *final* editmode DerivedMeshes
|
||||||
*/
|
*/
|
||||||
void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4],
|
void (*drawFacesSolid)(struct DerivedMesh *dm, float (*partial_redraw_planes)[4],
|
||||||
bool fast, DMSetMaterial setMaterial);
|
bool fast, DMSetMaterial setMaterial);
|
||||||
|
|
||||||
/** Draw all faces using MTFace
|
/** Draw all faces using MTFace
|
||||||
* - Drawing options too complicated to enumerate, look at code.
|
* - Drawing options too complicated to enumerate, look at code.
|
||||||
*/
|
*/
|
||||||
void (*drawFacesTex)(DerivedMesh *dm,
|
void (*drawFacesTex)(struct DerivedMesh *dm,
|
||||||
DMSetDrawOptionsTex setDrawOptions,
|
DMSetDrawOptionsTex setDrawOptions,
|
||||||
DMCompareDrawOptions compareDrawOptions,
|
DMCompareDrawOptions compareDrawOptions,
|
||||||
void *userData);
|
void *userData);
|
||||||
@@ -395,7 +399,7 @@ struct DerivedMesh {
|
|||||||
* o setMaterial is called for every different material nr
|
* o setMaterial is called for every different material nr
|
||||||
* o Only if setMaterial returns true
|
* o Only if setMaterial returns true
|
||||||
*/
|
*/
|
||||||
void (*drawFacesGLSL)(DerivedMesh *dm, DMSetMaterial setMaterial);
|
void (*drawFacesGLSL)(struct DerivedMesh *dm, DMSetMaterial setMaterial);
|
||||||
|
|
||||||
/** Draw mapped faces (no color, or texture)
|
/** Draw mapped faces (no color, or texture)
|
||||||
* - Only if !setDrawOptions or
|
* - Only if !setDrawOptions or
|
||||||
@@ -403,14 +407,16 @@ struct DerivedMesh {
|
|||||||
* returns true
|
* returns true
|
||||||
*
|
*
|
||||||
* If drawSmooth is set to true then vertex normals should be set and
|
* If drawSmooth is set to true then vertex normals should be set and
|
||||||
* glShadeModel called with GL_SMOOTH. Otherwise the face normal should
|
* gpuShadeModel called with GL_SMOOTH. Otherwise the face normal should
|
||||||
* be set and glShadeModel called with GL_FLAT.
|
* be set and gpuShadeModel called with GL_FLAT.
|
||||||
|
*
|
||||||
|
* XXX jwilkins: the above comment needs to be reevaluated since shadeModel is going away
|
||||||
*
|
*
|
||||||
* The setDrawOptions is allowed to not set drawSmooth (for example, when
|
* The setDrawOptions is allowed to not set drawSmooth (for example, when
|
||||||
* lighting is disabled), in which case the implementation should draw as
|
* lighting is disabled), in which case the implementation should draw as
|
||||||
* smooth shaded.
|
* smooth shaded.
|
||||||
*/
|
*/
|
||||||
void (*drawMappedFaces)(DerivedMesh *dm,
|
void (*drawMappedFaces)(struct DerivedMesh *dm,
|
||||||
DMSetDrawOptions setDrawOptions,
|
DMSetDrawOptions setDrawOptions,
|
||||||
DMSetMaterial setMaterial,
|
DMSetMaterial setMaterial,
|
||||||
DMCompareDrawOptions compareDrawOptions,
|
DMCompareDrawOptions compareDrawOptions,
|
||||||
@@ -420,7 +426,7 @@ struct DerivedMesh {
|
|||||||
/** Draw mapped faces using MTFace
|
/** Draw mapped faces using MTFace
|
||||||
* - Drawing options too complicated to enumerate, look at code.
|
* - Drawing options too complicated to enumerate, look at code.
|
||||||
*/
|
*/
|
||||||
void (*drawMappedFacesTex)(DerivedMesh *dm,
|
void (*drawMappedFacesTex)(struct DerivedMesh *dm,
|
||||||
DMSetDrawOptions setDrawOptions,
|
DMSetDrawOptions setDrawOptions,
|
||||||
DMCompareDrawOptions compareDrawOptions,
|
DMCompareDrawOptions compareDrawOptions,
|
||||||
void *userData);
|
void *userData);
|
||||||
@@ -430,7 +436,7 @@ struct DerivedMesh {
|
|||||||
* - setDrawOptions is called for every face
|
* - setDrawOptions is called for every face
|
||||||
* - Only if setMaterial and setDrawOptions return true
|
* - Only if setMaterial and setDrawOptions return true
|
||||||
*/
|
*/
|
||||||
void (*drawMappedFacesGLSL)(DerivedMesh *dm,
|
void (*drawMappedFacesGLSL)(struct DerivedMesh *dm,
|
||||||
DMSetMaterial setMaterial,
|
DMSetMaterial setMaterial,
|
||||||
DMSetDrawOptions setDrawOptions,
|
DMSetDrawOptions setDrawOptions,
|
||||||
void *userData);
|
void *userData);
|
||||||
@@ -439,7 +445,7 @@ struct DerivedMesh {
|
|||||||
* - Only if !setDrawOptions or setDrawOptions(userData, mapped-edge)
|
* - Only if !setDrawOptions or setDrawOptions(userData, mapped-edge)
|
||||||
* returns true
|
* returns true
|
||||||
*/
|
*/
|
||||||
void (*drawMappedEdges)(DerivedMesh *dm,
|
void (*drawMappedEdges)(struct DerivedMesh *dm,
|
||||||
DMSetDrawOptions setDrawOptions,
|
DMSetDrawOptions setDrawOptions,
|
||||||
void *userData);
|
void *userData);
|
||||||
|
|
||||||
@@ -450,7 +456,7 @@ struct DerivedMesh {
|
|||||||
*
|
*
|
||||||
* NOTE: This routine is optional!
|
* NOTE: This routine is optional!
|
||||||
*/
|
*/
|
||||||
void (*drawMappedEdgesInterp)(DerivedMesh *dm,
|
void (*drawMappedEdgesInterp)(struct DerivedMesh *dm,
|
||||||
DMSetDrawOptions setDrawOptions,
|
DMSetDrawOptions setDrawOptions,
|
||||||
DMSetDrawInterpOptions setDrawInterpOptions,
|
DMSetDrawInterpOptions setDrawInterpOptions,
|
||||||
void *userData);
|
void *userData);
|
||||||
@@ -459,14 +465,14 @@ struct DerivedMesh {
|
|||||||
* - setMaterial is called for every different material nr
|
* - setMaterial is called for every different material nr
|
||||||
* - setFace is called to verify if a face must be hidden
|
* - setFace is called to verify if a face must be hidden
|
||||||
*/
|
*/
|
||||||
void (*drawMappedFacesMat)(DerivedMesh *dm,
|
void (*drawMappedFacesMat)(struct DerivedMesh *dm,
|
||||||
void (*setMaterial)(void *userData, int matnr, void *attribs),
|
void (*setMaterial)(void *userData, int matnr, void *attribs),
|
||||||
bool (*setFace)(void *userData, int index), void *userData);
|
bool (*setFace)(void *userData, int index), void *userData);
|
||||||
|
|
||||||
/** Release reference to the DerivedMesh. This function decides internally
|
/** Release reference to the struct DerivedMesh. This function decides internally
|
||||||
* if the DerivedMesh will be freed, or cached for later use. */
|
* if the struct DerivedMesh will be freed, or cached for later use. */
|
||||||
void (*release)(DerivedMesh *dm);
|
void (*release)(struct DerivedMesh *dm);
|
||||||
};
|
} DerivedMesh;
|
||||||
|
|
||||||
/** utility function to initialize a DerivedMesh's function pointers to
|
/** utility function to initialize a DerivedMesh's function pointers to
|
||||||
* the default implementation (for those functions which have a default)
|
* the default implementation (for those functions which have a default)
|
||||||
|
@@ -114,7 +114,7 @@ void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, st
|
|||||||
bool verify_paths);
|
bool verify_paths);
|
||||||
|
|
||||||
/* Fix all the paths for the entire database... */
|
/* Fix all the paths for the entire database... */
|
||||||
void BKE_all_animdata_fix_paths_rename(ID *ref_id, const char *prefix, const char *oldName, const char *newName);
|
void BKE_all_animdata_fix_paths_rename(struct ID *ref_id, const char *prefix, const char *oldName, const char *newName);
|
||||||
|
|
||||||
/* Fix the path after removing elements that are not ID (e.g., node) */
|
/* Fix the path after removing elements that are not ID (e.g., node) */
|
||||||
void BKE_animdata_fix_paths_remove(struct ID *id, const char *path);
|
void BKE_animdata_fix_paths_remove(struct ID *id, const char *path);
|
||||||
|
@@ -35,6 +35,7 @@ struct Main;
|
|||||||
struct rctf;
|
struct rctf;
|
||||||
struct Scene;
|
struct Scene;
|
||||||
struct wmOperator;
|
struct wmOperator;
|
||||||
|
struct UnifiedPaintSettings;
|
||||||
// enum CurveMappingPreset;
|
// enum CurveMappingPreset;
|
||||||
|
|
||||||
|
|
||||||
@@ -70,9 +71,9 @@ float BKE_brush_curve_strength_clamp(struct Brush *br, float p, const float len)
|
|||||||
float BKE_brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */
|
float BKE_brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */
|
||||||
|
|
||||||
/* sampling */
|
/* sampling */
|
||||||
float BKE_brush_sample_tex_3D(const Scene *scene, struct Brush *br, const float point[3],
|
float BKE_brush_sample_tex_3D(const struct Scene *scene, struct Brush *br, const float point[3],
|
||||||
float rgba[4], const int thread, struct ImagePool *pool);
|
float rgba[4], const int thread, struct ImagePool *pool);
|
||||||
float BKE_brush_sample_masktex(const Scene *scene, struct Brush *br, const float point[2],
|
float BKE_brush_sample_masktex(const struct Scene *scene, struct Brush *br, const float point[2],
|
||||||
const int thread, struct ImagePool *pool);
|
const int thread, struct ImagePool *pool);
|
||||||
|
|
||||||
/* texture */
|
/* texture */
|
||||||
@@ -90,9 +91,9 @@ float BKE_brush_unprojected_radius_get(const struct Scene *scene, struct Brush *
|
|||||||
void BKE_brush_unprojected_radius_set(struct Scene *scene, struct Brush *brush, float value);
|
void BKE_brush_unprojected_radius_set(struct Scene *scene, struct Brush *brush, float value);
|
||||||
|
|
||||||
float BKE_brush_alpha_get(const struct Scene *scene, struct Brush *brush);
|
float BKE_brush_alpha_get(const struct Scene *scene, struct Brush *brush);
|
||||||
void BKE_brush_alpha_set(Scene *scene, struct Brush *brush, float alpha);
|
void BKE_brush_alpha_set(struct Scene *scene, struct Brush *brush, float alpha);
|
||||||
float BKE_brush_weight_get(const Scene *scene, struct Brush *brush);
|
float BKE_brush_weight_get(const struct Scene *scene, struct Brush *brush);
|
||||||
void BKE_brush_weight_set(const Scene *scene, struct Brush *brush, float value);
|
void BKE_brush_weight_set(const struct Scene *scene, struct Brush *brush, float value);
|
||||||
|
|
||||||
int BKE_brush_use_locked_size(const struct Scene *scene, struct Brush *brush);
|
int BKE_brush_use_locked_size(const struct Scene *scene, struct Brush *brush);
|
||||||
int BKE_brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush);
|
int BKE_brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush);
|
||||||
|
@@ -71,7 +71,7 @@ typedef struct DispList {
|
|||||||
int parts, nr;
|
int parts, nr;
|
||||||
short col, rt; /* rt used by initrenderNurbs */
|
short col, rt; /* rt used by initrenderNurbs */
|
||||||
float *verts, *nors;
|
float *verts, *nors;
|
||||||
int *index;
|
unsigned int *index;
|
||||||
unsigned int *col1, *col2;
|
unsigned int *col1, *col2;
|
||||||
int charidx;
|
int charidx;
|
||||||
int totindex; /* indexed array drawing surfaces */
|
int totindex; /* indexed array drawing surfaces */
|
||||||
|
@@ -37,6 +37,8 @@
|
|||||||
* for every fresh Blender run.
|
* for every fresh Blender run.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "BLI_sys_types.h" /* for bool */
|
||||||
|
|
||||||
#include "DNA_listBase.h"
|
#include "DNA_listBase.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
* \ingroup bke
|
* \ingroup bke
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "DNA_property_types.h" /* for MAX_PROPSTRING */
|
||||||
|
|
||||||
struct bProperty;
|
struct bProperty;
|
||||||
struct ListBase;
|
struct ListBase;
|
||||||
struct Object;
|
struct Object;
|
||||||
|
@@ -272,7 +272,7 @@ set(SRC
|
|||||||
intern/pbvh_intern.h
|
intern/pbvh_intern.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_definitions(-DGLEW_STATIC)
|
add_definitions(${GL_DEFINITIONS})
|
||||||
|
|
||||||
if(WITH_AUDASPACE)
|
if(WITH_AUDASPACE)
|
||||||
list(APPEND INC
|
list(APPEND INC
|
||||||
|
@@ -70,12 +70,11 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
|
|||||||
|
|
||||||
#include "BLI_sys_types.h" /* for intptr_t support */
|
#include "BLI_sys_types.h" /* for intptr_t support */
|
||||||
|
|
||||||
#include "GL/glew.h"
|
|
||||||
|
|
||||||
#include "GPU_buffers.h"
|
#include "GPU_buffers.h"
|
||||||
#include "GPU_draw.h"
|
#include "GPU_draw.h"
|
||||||
#include "GPU_extensions.h"
|
#include "GPU_extensions.h"
|
||||||
#include "GPU_material.h"
|
#include "GPU_material.h"
|
||||||
|
#include "GPU_glew.h"
|
||||||
|
|
||||||
/* very slow! enable for testing only! */
|
/* very slow! enable for testing only! */
|
||||||
// #define USE_MODIFIER_VALIDATE
|
// #define USE_MODIFIER_VALIDATE
|
||||||
@@ -3047,18 +3046,18 @@ static void navmesh_drawColored(DerivedMesh *dm)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//UI_ThemeColor(TH_WIRE);
|
//UI_ThemeColor(TH_WIRE);
|
||||||
glDisable(GL_LIGHTING);
|
gpuDisableLighting();
|
||||||
glLineWidth(2.0);
|
gpuLineWidth(2.0);
|
||||||
dm->drawEdges(dm, 0, 1);
|
dm->drawEdges(dm, 0, 1);
|
||||||
glLineWidth(1.0);
|
gpuLineWidth(1.0);
|
||||||
glEnable(GL_LIGHTING);
|
gpuEnableLighting();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
gpuDisableLighting();
|
||||||
/* if (GPU_buffer_legacy(dm) ) */ { /* TODO - VBO draw code, not high priority - campbell */
|
/* if (GPU_buffer_legacy(dm) ) */ { /* TODO - VBO draw code, not high priority - campbell */
|
||||||
DEBUG_VBO("Using legacy code. drawNavMeshColored\n");
|
DEBUG_VBO("Using legacy code. drawNavMeshColored\n");
|
||||||
//glShadeModel(GL_SMOOTH);
|
//gpuShadeModel(GL_SMOOTH);
|
||||||
glBegin(glmode = GL_QUADS);
|
gpuBegin(glmode = GL_QUADS);
|
||||||
for (a = 0; a < dm->numTessFaceData; a++, mface++) {
|
for (a = 0; a < dm->numTessFaceData; a++, mface++) {
|
||||||
int new_glmode = mface->v4 ? GL_QUADS : GL_TRIANGLES;
|
int new_glmode = mface->v4 ? GL_QUADS : GL_TRIANGLES;
|
||||||
int pi = polygonIdx[a];
|
int pi = polygonIdx[a];
|
||||||
@@ -3070,20 +3069,20 @@ static void navmesh_drawColored(DerivedMesh *dm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (new_glmode != glmode) {
|
if (new_glmode != glmode) {
|
||||||
glEnd();
|
gpuEnd();
|
||||||
glBegin(glmode = new_glmode);
|
gpuBegin(glmode = new_glmode);
|
||||||
}
|
}
|
||||||
glColor3fv(col);
|
gpuColor3fv(col);
|
||||||
glVertex3fv(mvert[mface->v1].co);
|
gpuVertex3fv(mvert[mface->v1].co);
|
||||||
glVertex3fv(mvert[mface->v2].co);
|
gpuVertex3fv(mvert[mface->v2].co);
|
||||||
glVertex3fv(mvert[mface->v3].co);
|
gpuVertex3fv(mvert[mface->v3].co);
|
||||||
if (mface->v4) {
|
if (mface->v4) {
|
||||||
glVertex3fv(mvert[mface->v4].co);
|
gpuVertex3fv(mvert[mface->v4].co);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glEnd();
|
gpuEnd();
|
||||||
}
|
}
|
||||||
glEnable(GL_LIGHTING);
|
gpuEnableLighting();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void navmesh_DM_drawFacesTex(DerivedMesh *dm,
|
static void navmesh_DM_drawFacesTex(DerivedMesh *dm,
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
* \ingroup bke
|
* \ingroup bke
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@@ -236,7 +236,7 @@ static int findFileRecursive(char *filename_new,
|
|||||||
if (S_ISREG(status.st_mode)) { /* is file */
|
if (S_ISREG(status.st_mode)) { /* is file */
|
||||||
if (STREQLEN(filename, de->d_name, FILE_MAX)) { /* name matches */
|
if (STREQLEN(filename, de->d_name, FILE_MAX)) { /* name matches */
|
||||||
/* open the file to read its size */
|
/* open the file to read its size */
|
||||||
size = status.st_size;
|
size = (int)status.st_size; /* assumes files can't be bigger than 2GiB */
|
||||||
if ((size > 0) && (size > *filesize)) { /* find the biggest file */
|
if ((size > 0) && (size > *filesize)) { /* find the biggest file */
|
||||||
*filesize = size;
|
*filesize = size;
|
||||||
BLI_strncpy(filename_new, path, FILE_MAX);
|
BLI_strncpy(filename_new, path, FILE_MAX);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user