Ghost Context Refactor

https://developer.blender.org/D643
Separates graphics context creation from window code in Ghost so that they can vary separately.
This commit is contained in:
Jason Wilkins 2014-10-07 15:46:19 -05:00
parent a8705e99ee
commit 8d084e8c8f
236 changed files with 63900 additions and 2614 deletions

@ -169,14 +169,22 @@ mark_as_advanced(WITH_AUDASPACE)
option(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ON)
if(UNIX AND NOT APPLE)
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_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON)
set(WITH_X11 ON)
endif()
option(WITH_GHOST_XDND "Enable drag'n'drop support on X11 using XDND protocol" ON)
if(WITH_X11)
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_GHOST_XDND "Enable drag'n'drop support on X11 using XDND protocol" ON)
endif()
if(UNIX AND NOT APPLE)
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)
else()
# not an option for other OS's
set(WITH_SYSTEM_GLEW OFF)
set(WITH_SYSTEM_GLES OFF)
endif()
@ -320,6 +328,42 @@ endif()
# Unit testsing
option(WITH_GTESTS "Enable GTest unit testing" OFF)
# OpenGL
option(WITH_GLEW_MX "Support multiple GLEW contexts (experimental)" ON )
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF)
option(WITH_GL_PROFILE_COMPAT "Support using the OpenGL 'compatibility' profile. (deprecated)" ON )
option(WITH_GL_PROFILE_CORE "Support using the OpenGL 3.2+ 'core' profile." OFF)
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_GLEW_MX
WITH_GLEW_ES
WITH_GL_EGL
WITH_GL_PROFILE_COMPAT
WITH_GL_PROFILE_CORE
WITH_GL_PROFILE_ES20
)
if (WITH_GL_PROFILE_COMPAT)
set(WITH_GLU ON)
else()
set(WITH_GLU OFF)
endif()
if(WIN32)
option(WITH_GL_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_GL_ANGLE)
endif()
if(WITH_GLEW_ES AND WITH_SYSTEM_GLEW)
message(WARNING Ignoring WITH_SYSTEM_GLEW and using WITH_GLEW_ES)
set(WITH_SYSTEM_GLEW OFF)
endif()
# Apple
if(APPLE)
if(${CMAKE_VERSION} VERSION_LESS 3.0) # else breaks setting CMP0043 policy
cmake_minimum_required(VERSION 2.8.8)
@ -518,9 +562,10 @@ if(WITH_INSTALL_PORTABLE)
endif()
if(WITH_GHOST_SDL OR WITH_HEADLESS)
set(WITH_GHOST_XDND OFF)
set(WITH_X11 OFF)
set(WITH_X11_XINPUT OFF)
set(WITH_X11_XF86VMODE OFF)
set(WITH_X11_XINPUT OFF)
set(WITH_GHOST_XDND OFF)
endif()
TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
@ -602,6 +647,35 @@ set(PLATFORM_LINKFLAGS_DEBUG "")
#-----------------------------------------------------------------------------
#Platform specifics
if(WITH_X11)
find_package(X11 REQUIRED)
find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
list(APPEND PLATFORM_LINKLIBS ${X11_X11_LIB})
if(WITH_X11_XINPUT)
if(X11_Xinput_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xinput_LIB})
else()
set(WITH_X11_XINPUT OFF)
endif()
endif()
if(WITH_X11_XF86VMODE)
# XXX, why dont cmake make this available?
find_library(X11_Xxf86vmode_LIB Xxf86vm ${X11_LIB_SEARCH_PATH})
mark_as_advanced(X11_Xxf86vmode_LIB)
if(X11_Xxf86vmode_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xxf86vmode_LIB})
else()
set(WITH_X11_XF86VMODE OFF)
endif()
endif()
endif()
if(UNIX AND NOT APPLE)
macro(find_package_wrapper)
string(TOUPPER ${ARGV0} _NAME_UPPER)
@ -910,33 +984,6 @@ if(UNIX AND NOT APPLE)
# OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm -lpthread)
if((NOT WITH_HEADLESS) AND (NOT WITH_GHOST_SDL))
find_package(X11 REQUIRED)
find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
list(APPEND PLATFORM_LINKLIBS ${X11_X11_LIB})
if(WITH_X11_XINPUT)
if(X11_Xinput_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xinput_LIB})
else()
set(WITH_X11_XINPUT OFF)
endif()
endif()
if(WITH_X11_XF86VMODE)
# XXX, why dont cmake make this available?
find_library(X11_Xxf86vmode_LIB Xxf86vm ${X11_LIB_SEARCH_PATH})
mark_as_advanced(X11_Xxf86vmode_LIB)
if(X11_Xxf86vmode_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xxf86vmode_LIB})
else()
set(WITH_X11_XF86VMODE OFF)
endif()
endif()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(NOT WITH_PYTHON_MODULE)
# binreloc is linux only
@ -2078,10 +2125,123 @@ endif()
#-----------------------------------------------------------------------------
# Configure OpenGL.
find_package(OpenGL)
blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
# unset(OPENGL_LIBRARIES CACHE) # not compat with older cmake
# unset(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake
if(WITH_GLU)
list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_glu_LIBRARY}")
list(APPEND GL_DEFINITIONS -DWITH_GLU)
endif()
if(WITH_SYSTEM_GLES)
find_package_wrapper(OpenGLES)
endif()
if(WITH_GL_PROFILE_COMPAT OR WITH_GL_PROFILE_CORE)
list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_gl_LIBRARY}")
elseif(WITH_GL_PROFILE_ES20)
if(WITH_SYSTEM_GLES)
if(NOT OPENGLES_LIBRARY)
message(FATAL_ERROR "Unable to find OpenGL ES libraries. Install them or disable WITH_SYSTEM_GLES.")
endif()
list(APPEND BLENDER_GL_LIBRARIES OPENGLES_LIBRARY)
else()
set(OPENGLES_LIBRARY "" CACHE FILEPATH "OpenGL ES 2.0 library file")
mark_as_advanced(OPENGLES_LIBRARY)
list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}")
if (NOT OPENGLES_LIBRARY)
message(FATAL_ERROR "To compile WITH_GL_EGL you need to set OPENGLES_LIBRARY to the file path of an OpenGL ES 2.0 library.")
endif()
endif()
if(WIN32)
# Setup paths to files needed to install and redistribute Windows Blender with OpenGL ES
set(OPENGLES_DLL "" CACHE FILEPATH "OpenGL ES 2.0 redistributable DLL file")
mark_as_advanced(OPENGLES_DLL)
if(NOT OPENGLES_DLL)
message(FATAL_ERROR "To compile WITH_GL_PROFILE_ES20 you need to set OPENGLES_DLL to the file path of an OpenGL ES 2.0 runtime dynamic link library (DLL).")
endif()
if(WITH_GL_ANGLE)
list(APPEND GL_DEFINITIONS -DWITH_ANGLE)
set(D3DCOMPILER_DLL "" CACHE FILEPATH "Direct3D Compiler redistributable DLL file (needed by ANGLE)")
get_filename_component(D3DCOMPILER_FILENAME "${D3DCOMPILER_DLL}" NAME)
list(APPEND GL_DEFINITIONS "-DD3DCOMPILER=\"\\\"${D3DCOMPILER_FILENAME}\\\"\"")
mark_as_advanced(D3DCOMPILER_DLL)
if (D3DCOMPILER_DLL STREQUAL "")
message(FATAL_ERROR "To compile WITH_GL_ANGLE you need to set D3DCOMPILER_DLL to the file path of a copy of the DirectX redistributable DLL file: D3DCompiler_46.dll")
endif()
endif()
endif()
endif()
if(WITH_GL_EGL)
list(APPEND GL_DEFINITIONS -DWITH_GL_EGL)
if(WITH_SYSTEM_GLES)
if(NOT OPENGLES_EGL_LIBRARY)
message(FATAL_ERROR "Unable to find OpenGL ES libraries. Install them or disable WITH_SYSTEM_GLES.")
endif()
list(APPEND BLENDER_GL_LIBRARIES OPENGLES_EGL_LIBRARY)
else()
set(OPENGLES_EGL_LIBRARY "" CACHE FILEPATH "EGL library file")
mark_as_advanced(OPENGLES_EGL_LIBRARY)
list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}" "${OPENGLES_EGL_LIBRARY}")
if (NOT OPENGLES_EGL_LIBRARY)
message(FATAL_ERROR "To compile WITH_GL_EGL you need to set OPENGLES_EGL_LIBRARY to the file path of an EGL library.")
endif()
endif()
if(WIN32)
# Setup paths to files needed to install and redistribute Windows Blender with OpenGL ES
set(OPENGLES_EGL_DLL "" CACHE FILEPATH "EGL redistributable DLL file")
mark_as_advanced(OPENGLES_EGL_DLL)
if(NOT OPENGLES_EGL_DLL)
message(FATAL_ERROR "To compile WITH_GL_EGL you need to set OPENGLES_EGL_DLL to the file path of an EGL runtime dynamic link library (DLL).")
endif()
endif()
endif()
if(WITH_GL_PROFILE_COMPAT)
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_COMPAT)
endif()
if(WITH_GL_PROFILE_CORE)
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE)
endif()
if(WITH_GL_PROFILE_ES20)
list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_ES20)
endif()
if(WITH_GL_EGL)
list(APPEND GL_DEFINITIONS -DWITH_EGL)
endif()
#-----------------------------------------------------------------------------
# Configure OpenMP.
@ -2103,19 +2263,76 @@ endif()
#-----------------------------------------------------------------------------
# Configure GLEW
if(WITH_GLEW_MX)
list(APPEND GL_DEFINITIONS -DWITH_GLEW_MX)
endif()
if(WITH_SYSTEM_GLEW)
find_package(GLEW)
# Note: There is an assumption here that the system GLEW is not a static library.
if(NOT GLEW_FOUND)
message(FATAL_ERROR "GLEW is required to build blender, install it or disable WITH_SYSTEM_GLEW")
message(FATAL_ERROR "GLEW is required to build Blender. Install it or disable WITH_SYSTEM_GLEW.")
endif()
set(GLEW_INCLUDE_PATH "${GLEW_INCLUDE_DIRS}")
if(WITH_GLEW_MX)
set(BLENDER_GLEW_LIBRARIES ${GLEW_MX_LIBRARY})
else()
set(BLENDER_GLEW_LIBRARIES ${GLEW_LIBRARY})
endif()
else()
# set(GLEW_LIBRARY "") # unused
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")
list(APPEND GL_DEFINITIONS -DGLEW_STATIC -DWITH_GLEW_ES)
# These definitions remove APIs from glew.h, making GLEW smaller, and catching unguarded API usage
if(NOT WITH_GL_PROFILE_ES20)
# No ES functions are needed
list(APPEND 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
list(APPEND GL_DEFINITIONS -DGLEW_ES_ONLY)
endif()
if(WITH_GL_PROFILE_ES20)
if(WITH_GL_EGL)
list(APPEND GL_DEFINITIONS -DGLEW_USE_LIB_ES20)
endif()
# ToDo: This is an experiment to eliminate ES 1 symbols,
# GLEW doesn't really properly provide this level of control
# (for example, without modification it eliminates too many symbols)
# so there are lots of modifications to GLEW to make this work,
# and no attempt to make it work beyond Blender at this point.
list(APPEND GL_DEFINITIONS -DGL_ES_VERSION_1_0=0 -DGL_ES_VERSION_CL_1_1=0 -DGL_ES_VERSION_CM_1_1=0)
endif()
if(WITH_GL_EGL)
list(APPEND GL_DEFINITIONS -DGLEW_INC_EGL)
endif()
set(BLENDER_GLEW_LIBRARIES extern_glew_es bf_intern_glew_mx)
else()
set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
list(APPEND GL_DEFINITIONS -DGLEW_STATIC)
# This won't affect the non-experimental glew library,
# but is used for conditional compilation elsewhere.
list(APPEND GL_DEFINITIONS -DGLEW_NO_ES)
set(BLENDER_GLEW_LIBRARIES extern_glew)
endif()
endif()
if(NOT WITH_GLU)
list(APPEND GL_DEFINITIONS -DGLEW_NO_GLU)
endif()
#-----------------------------------------------------------------------------
# Configure Bullet
@ -2483,6 +2700,17 @@ if(FIRST_RUN)
info_cfg_option(WITH_MOD_FLUID)
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_EGL)
info_cfg_option(WITH_GL_PROFILE_COMPAT)
info_cfg_option(WITH_GL_PROFILE_CORE)
info_cfg_option(WITH_GL_PROFILE_ES20)
if(WIN32)
info_cfg_option(WITH_GL_ANGLE)
endif()
info_cfg_text("Other:")
info_cfg_option(WITH_OPENNL)

@ -526,6 +526,49 @@ env['CPPFLAGS'].append('-DWITH_OPENNL')
if env['OURPLATFORM'] not in ('win32-vc', 'win64-vc'):
env['CPPFLAGS'].append('-DHAVE_STDBOOL_H')
# OpenGL
if env['WITH_BF_GL_PROFILE_COMPAT']:
env['BF_GL_DEFINITIONS'].append('WITH_GL_PROFILE_COMPAT')
if env['WITH_BF_GL_PROFILE_CORE']:
env['BF_GL_DEFINITIONS'].append('WITH_GL_PROFILE_CORE')
if env['WITH_BF_GL_PROFILE_ES20']:
env['BF_GL_DEFINITIONS'].append('WITH_GL_PROFILE_ES20')
if env['WITH_BF_GL_EGL']:
env['BF_GL_DEFINITIONS'].append('WITH_EGL')
# GLEW
if env['WITH_BF_GLEW_MX']:
env['BF_GL_DEFINITIONS'].append('WITH_GLEW_MX')
if env['WITH_BF_GLEW_ES']:
env['BF_GLEW_INC'] = '#extern/glew-es/include'
env['BF_GL_DEFINITIONS'] += ['GLEW_STATIC', 'WITH_GLEW_ES']
if not env['WITH_BF_GL_PROFILE_ES20']:
# No ES functions are needed
env['BF_GL_DEFINITIONS'].append('GLEW_NO_ES')
elif not (env['WITH_BF_GL_PROFILE_CORE'] or env['WITH_BF_GL_PROFILE_COMPAT']):
# ES is enabled, but the other functions are all disabled
env['BF_GL_DEFINITIONS'].append('GLEW_ES_ONLY')
if env['WITH_BF_GL_PROFILE_ES20']:
if env['WITH_BF_GL_EGL']:
env['BF_GL_DEFINITIONS'].append('GLEW_USE_LIB_ES20')
if env['WITH_BF_GL_EGL']:
env['BF_GL_DEFINITIONS'].append('GLEW_INC_EGL')
else:
env['BF_GLEW_INC'] = '#extern/glew/include'
env['BF_GL_DEFINITIONS'].append('GLEW_STATIC')
# lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
B.root_build_dir = env['BF_BUILDDIR']
B.doc_build_dir = os.path.join(env['BF_INSTALLDIR'], 'doc')

@ -0,0 +1,76 @@
# - 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
# If OPENGLES_ROOT_DIR was defined in the environment, use it.
IF(NOT OPENGLES_ROOT_DIR AND NOT $ENV{OPENGLES_ROOT_DIR} STREQUAL "")
SET(OPENGLES_ROOT_DIR $ENV{OPENGLES_ROOT_DIR})
ENDIF()
SET(_opengles_SEARCH_DIRS
${OPENGLES_ROOT_DIR}
/usr/local
)
FIND_PATH(OPENGLES_INCLUDE_DIR
NAMES
GLES2/gl2.h
HINTS
${_opengles_SEARCH_DIRS}
)
FIND_LIBRARY(OPENGLES_LIBRARY
NAMES
GLESv2
PATHS
${_opengles_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
FIND_PATH(OPENGLES_EGL_INCLUDE_DIR
NAMES
EGL/egl.h
HINTS
${_opengles_SEARCH_DIRS}
)
FIND_LIBRARY(OPENGLES_EGL_LIBRARY
NAMES
EGL
HINTS
${_opengles_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
IF(OPENGLES_EGL_LIBRARY AND OPENGLES_EGL_INCLUDE_DIR)
SET(OPENGL_EGL_FOUND "YES")
ELSE()
SET(OPENGL_EGL_FOUND "NO")
ENDIF()
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")
ELSE()
SET(OPENGLES_FOUND "NO")
ENDIF()
MARK_AS_ADVANCED(
OPENGLES_EGL_INCLUDE_DIR
OPENGLES_EGL_LIBRARY
OPENGLES_INCLUDE_DIR
)

@ -284,8 +284,7 @@ macro(setup_liblinks
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
target_link_libraries(${target}
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${BLENDER_GL_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${FREETYPE_LIBRARY})
@ -305,7 +304,7 @@ macro(setup_liblinks
endif()
if(WITH_SYSTEM_GLEW)
target_link_libraries(${target} ${GLEW_LIBRARY})
target_link_libraries(${target} ${BLENDER_GLEW_LIBRARIES})
endif()
if(WITH_BULLET AND WITH_SYSTEM_BULLET)
target_link_libraries(${target} ${BULLET_LIBRARIES})
@ -359,9 +358,12 @@ macro(setup_liblinks
endif()
if(WITH_CODEC_FFMPEG)
# Strange!, without this ffmpeg gives linking errors (on linux)
# even though its linked above
target_link_libraries(${target} ${OPENGL_glu_LIBRARY})
# Strange! Without this ffmpeg gives linking errors (on linux),
# even though it's linked above.
# XXX: Does FFMPEG depend on GLU?
if(WITH_GLU)
target_link_libraries(${target} ${OPENGL_glu_LIBRARY})
endif()
target_link_libraries(${target} ${FFMPEG_LIBRARIES})
endif()
@ -557,6 +559,8 @@ macro(SETUP_BLENDER_SORTED_LIBS)
extern_wcwidth
extern_libmv
extern_glog
bf_intern_glew_mx
)
if(WITH_COMPOSITOR)
@ -574,7 +578,7 @@ macro(SETUP_BLENDER_SORTED_LIBS)
endif()
if(NOT WITH_SYSTEM_GLEW)
list(APPEND BLENDER_SORTED_LIBS extern_glew)
list(APPEND BLENDER_SORTED_LIBS ${BLENDER_GLEW_LIBRARIES})
endif()
if(WITH_BINRELOC)

@ -136,6 +136,8 @@ def validate_arguments(args, bc):
'WITH_BF_QUICKTIME', 'BF_QUICKTIME', 'BF_QUICKTIME_INC', 'BF_QUICKTIME_LIB', 'BF_QUICKTIME_LIBPATH',
'WITH_BF_FFTW3', 'BF_FFTW3', 'BF_FFTW3_INC', 'BF_FFTW3_LIB', 'BF_FFTW3_LIBPATH', 'WITH_BF_STATICFFTW3', 'BF_FFTW3_LIB_STATIC',
'WITH_BF_STATICOPENGL', 'BF_OPENGL', 'BF_OPENGL_INC', 'BF_OPENGL_LIB', 'BF_OPENGL_LIBPATH', 'BF_OPENGL_LIB_STATIC',
'WITH_BF_EGL', 'WITH_BF_GLEW_ES', 'BF_GLEW_INC', 'WITH_BF_GL_PROFILE_CORE', 'WITH_BF_GL_PROFILE_COMPAT', 'WITH_BF_GL_PROFILE_ES20',
'WITH_BF_COLLADA', 'BF_COLLADA', 'BF_COLLADA_INC', 'BF_COLLADA_LIB', 'BF_OPENCOLLADA', 'BF_OPENCOLLADA_INC', 'BF_OPENCOLLADA_LIB', 'BF_OPENCOLLADA_LIBPATH', 'BF_PCRE', 'BF_PCRE_LIB', 'BF_PCRE_LIBPATH', 'BF_EXPAT', 'BF_EXPAT_LIB', 'BF_EXPAT_LIBPATH',
'WITH_BF_STATICOPENCOLLADA', 'BF_OPENCOLLADA_LIB_STATIC',
'WITH_BF_PLAYER',
@ -185,6 +187,7 @@ def validate_arguments(args, bc):
opts_list_split = [
'BF_PYTHON_LINKFLAGS',
'BF_OPENGL_LINKFLAGS',
'BF_GL_DEFINITIONS',
'CFLAGS', 'CCFLAGS', 'CXXFLAGS', 'CPPFLAGS',
'REL_CFLAGS', 'REL_CCFLAGS', 'REL_CXXFLAGS',
'BGE_CXXFLAGS',
@ -462,6 +465,18 @@ def read_opts(env, cfg, args):
('BF_OPENGL_LIB_STATIC', 'OpenGL static libraries', ''),
('BF_OPENGL_LINKFLAGS', 'OpenGL link flags', ''),
(BoolVariable('WITH_BF_GLEW_MX', '', True)),
(BoolVariable('WITH_BF_GLEW_ES', '', False)),
(BoolVariable('WITH_BF_GL_EGL', '', False)),
(BoolVariable('WITH_BF_GL_PROFILE_COMPAT', '', True)),
(BoolVariable('WITH_BF_GL_PROFILE_CORE', '', False)),
(BoolVariable('WITH_BF_GL_PROFILE_ES20', '', False)),
(BoolVariable('WITH_BF_GL_ANGLE', '', False)),
('BF_GL_DEFINITIONS', '', []),
('BF_GLEW_INC', '', ''),
) # end of opts.AddVariables()
localopts.AddVariables(
(BoolVariable('WITH_BF_COLLADA', 'Build COLLADA import/export module if true', False)),
(BoolVariable('WITH_BF_STATICOPENCOLLADA', 'Staticly link to OpenCollada', False)),
('BF_COLLADA', 'COLLADA base path', ''),

12
extern/CMakeLists.txt vendored

@ -47,7 +47,11 @@ if(WITH_BINRELOC)
endif()
if(NOT WITH_SYSTEM_GLEW)
add_subdirectory(glew)
if(WITH_GLEW_ES)
add_subdirectory(glew-es)
else()
add_subdirectory(glew)
endif()
endif()
if(WITH_GAMEENGINE)
@ -79,10 +83,8 @@ if(WITH_MOD_BOOLEAN)
add_subdirectory(carve)
endif()
if(WITH_GHOST_XDND)
if(UNIX AND NOT APPLE)
add_subdirectory(xdnd)
endif()
if(WITH_X11 AND WITH_GHOST_XDND)
add_subdirectory(xdnd)
endif()
if(WITH_GTESTS)

6
extern/SConscript vendored

@ -2,7 +2,11 @@
Import('env')
SConscript(['glew/SConscript'])
if env['WITH_BF_GLEW_ES']:
SConscript(['glew-es/SConscript'])
else:
SConscript(['glew/SConscript'])
SConscript(['colamd/SConscript'])
SConscript(['rangetree/SConscript'])
SConscript(['wcwidth/SConscript'])

57
extern/glew-es/CMakeLists.txt vendored Normal file

@ -0,0 +1,57 @@
# ***** 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 *****
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})
if(WITH_GLEW_MX)
add_definitions(-DGLEW_MX)
endif()
blender_add_lib(extern_glew_es "${SRC}" "${INC}" "${INC_SYS}")

14
extern/glew-es/SConscript vendored Normal file

@ -0,0 +1,14 @@
#!/usr/bin/python
import sys
import os
Import('env')
sources = ['src/glew.c']
defs = env['BF_GL_DEFINITIONS']
if env['WITH_BF_GLEW_MX']:
defs += ['GLEW_MX']
incs = ['include']
env.BlenderLib ( 'extern_glew_es', sources, incs, defs, libtype=['extern','player'], priority=[50,230] )

1470
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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

1424
extern/glew-es/include/GL/wglew.h vendored Normal file

File diff suppressed because it is too large Load Diff

22401
extern/glew-es/src/glew.c vendored Normal file

File diff suppressed because it is too large Load Diff

@ -45,6 +45,10 @@ set(SRC
include/GL/wglew.h
)
add_definitions(-DGLEW_STATIC)
add_definitions(${GL_DEFINITIONS})
if(WITH_GLEW_MX)
add_definitions(-DGLEW_MX)
endif()
blender_add_lib(extern_glew "${SRC}" "${INC}" "${INC_SYS}")

@ -6,7 +6,10 @@ Import('env')
sources = ['src/glew.c']
defs = 'GLEW_STATIC'
incs = 'include'
defs = env['BF_GL_DEFINITIONS']
if env['WITH_BF_GLEW_MX']:
defs += ['GLEW_MX']
env.BlenderLib ( 'extern_glew', sources, Split(incs), Split(defs), libtype=['extern','player'], priority=[50,230])
incs = ['include']
env.BlenderLib ( 'extern_glew', sources, incs, defs, libtype=['extern','player'], priority=[50,230] )

File diff suppressed because it is too large Load Diff

@ -362,6 +362,26 @@ extern void ( * glXGetProcAddress (const GLubyte *procName)) (void);
#define GLX_GPU_NUM_RB_AMD 0x21A7
#define GLX_GPU_NUM_SPI_AMD 0x21A8
typedef void ( * PFNGLXBLITCONTEXTFRAMEBUFFERAMDPROC) (GLXContext dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
typedef GLXContext ( * PFNGLXCREATEASSOCIATEDCONTEXTAMDPROC) (unsigned int id, GLXContext share_list);
typedef GLXContext ( * PFNGLXCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (unsigned int id, GLXContext share_context, const int* attribList);
typedef Bool ( * PFNGLXDELETEASSOCIATEDCONTEXTAMDPROC) (GLXContext ctx);
typedef unsigned int ( * PFNGLXGETCONTEXTGPUIDAMDPROC) (GLXContext ctx);
typedef GLXContext ( * PFNGLXGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
typedef unsigned int ( * PFNGLXGETGPUIDSAMDPROC) (unsigned int maxCount, unsigned int* ids);
typedef int ( * PFNGLXGETGPUINFOAMDPROC) (unsigned int id, int property, GLenum dataType, unsigned int size, void* data);
typedef Bool ( * PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (GLXContext ctx);
#define glXBlitContextFramebufferAMD GLXEW_GET_FUN(__glewXBlitContextFramebufferAMD)
#define glXCreateAssociatedContextAMD GLXEW_GET_FUN(__glewXCreateAssociatedContextAMD)
#define glXCreateAssociatedContextAttribsAMD GLXEW_GET_FUN(__glewXCreateAssociatedContextAttribsAMD)
#define glXDeleteAssociatedContextAMD GLXEW_GET_FUN(__glewXDeleteAssociatedContextAMD)
#define glXGetContextGPUIDAMD GLXEW_GET_FUN(__glewXGetContextGPUIDAMD)
#define glXGetCurrentAssociatedContextAMD GLXEW_GET_FUN(__glewXGetCurrentAssociatedContextAMD)
#define glXGetGPUIDsAMD GLXEW_GET_FUN(__glewXGetGPUIDsAMD)
#define glXGetGPUInfoAMD GLXEW_GET_FUN(__glewXGetGPUInfoAMD)
#define glXMakeAssociatedContextCurrentAMD GLXEW_GET_FUN(__glewXMakeAssociatedContextCurrentAMD)
#define GLXEW_AMD_gpu_association GLXEW_GET_VAR(__GLXEW_AMD_gpu_association)
#endif /* GLX_AMD_gpu_association */
@ -458,6 +478,28 @@ extern void ( * glXGetProcAddressARB (const GLubyte *procName)) (void);
#endif /* GLX_ARB_multisample */
/* ---------------- GLX_ARB_robustness_application_isolation --------------- */
#ifndef GLX_ARB_robustness_application_isolation
#define GLX_ARB_robustness_application_isolation 1
#define GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008
#define GLXEW_ARB_robustness_application_isolation GLXEW_GET_VAR(__GLXEW_ARB_robustness_application_isolation)
#endif /* GLX_ARB_robustness_application_isolation */
/* ---------------- GLX_ARB_robustness_share_group_isolation --------------- */
#ifndef GLX_ARB_robustness_share_group_isolation
#define GLX_ARB_robustness_share_group_isolation 1
#define GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008
#define GLXEW_ARB_robustness_share_group_isolation GLXEW_GET_VAR(__GLXEW_ARB_robustness_share_group_isolation)
#endif /* GLX_ARB_robustness_share_group_isolation */
/* ---------------------- GLX_ARB_vertex_buffer_object --------------------- */
#ifndef GLX_ARB_vertex_buffer_object
@ -533,6 +575,17 @@ typedef void ( * PFNGLXRELEASETEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, i
#endif /* GLX_ATI_render_texture */
/* --------------------------- GLX_EXT_buffer_age -------------------------- */
#ifndef GLX_EXT_buffer_age
#define GLX_EXT_buffer_age 1
#define GLX_BACK_BUFFER_AGE_EXT 0x20F4
#define GLXEW_EXT_buffer_age GLXEW_GET_VAR(__GLXEW_EXT_buffer_age)
#endif /* GLX_EXT_buffer_age */
/* ------------------- GLX_EXT_create_context_es2_profile ------------------ */
#ifndef GLX_EXT_create_context_es2_profile
@ -544,6 +597,17 @@ typedef void ( * PFNGLXRELEASETEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, i
#endif /* GLX_EXT_create_context_es2_profile */
/* ------------------- GLX_EXT_create_context_es_profile ------------------- */
#ifndef GLX_EXT_create_context_es_profile
#define GLX_EXT_create_context_es_profile 1
#define GLX_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004
#define GLXEW_EXT_create_context_es_profile GLXEW_GET_VAR(__GLXEW_EXT_create_context_es_profile)
#endif /* GLX_EXT_create_context_es_profile */
/* --------------------- GLX_EXT_fbconfig_packed_float --------------------- */
#ifndef GLX_EXT_fbconfig_packed_float
@ -617,6 +681,17 @@ typedef void ( * PFNGLXSWAPINTERVALEXTPROC) (Display* dpy, GLXDrawable drawable,
#endif /* GLX_EXT_swap_control */
/* ----------------------- GLX_EXT_swap_control_tear ----------------------- */
#ifndef GLX_EXT_swap_control_tear
#define GLX_EXT_swap_control_tear 1
#define GLX_LATE_SWAPS_TEAR_EXT 0x20F3
#define GLXEW_EXT_swap_control_tear GLXEW_GET_VAR(__GLXEW_EXT_swap_control_tear)
#endif /* GLX_EXT_swap_control_tear */
/* ---------------------- GLX_EXT_texture_from_pixmap ---------------------- */
#ifndef GLX_EXT_texture_from_pixmap
@ -1003,16 +1078,6 @@ typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, i
#ifndef GLX_SGIS_color_range
#define GLX_SGIS_color_range 1
#define GLX_MIN_RED_SGIS 0
#define GLX_MAX_GREEN_SGIS 0
#define GLX_MIN_BLUE_SGIS 0
#define GLX_MAX_ALPHA_SGIS 0
#define GLX_MIN_GREEN_SGIS 0
#define GLX_MIN_ALPHA_SGIS 0
#define GLX_MAX_RED_SGIS 0
#define GLX_EXTENDED_RANGE_SGIS 0
#define GLX_MAX_BLUE_SGIS 0
#define GLXEW_SGIS_color_range GLXEW_GET_VAR(__GLXEW_SGIS_color_range)
#endif /* GLX_SGIS_color_range */
@ -1349,207 +1414,224 @@ typedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window,
/* ------------------------------------------------------------------------- */
#ifdef GLEW_MX
#define GLXEW_EXPORT
#define GLXEW_FUN_EXPORT GLEW_FUN_EXPORT
#define GLXEW_VAR_EXPORT
#else
#define GLXEW_EXPORT extern
#define GLXEW_FUN_EXPORT GLEW_FUN_EXPORT
#define GLXEW_VAR_EXPORT GLEW_VAR_EXPORT
#endif /* GLEW_MX */
extern PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay;
GLXEW_FUN_EXPORT PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay;
extern PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig;
extern PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext;
extern PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer;
extern PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap;
extern PFNGLXCREATEWINDOWPROC __glewXCreateWindow;
extern PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer;
extern PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap;
extern PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow;
extern PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable;
extern PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib;
extern PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs;
extern PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent;
extern PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig;
extern PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent;
extern PFNGLXQUERYCONTEXTPROC __glewXQueryContext;
extern PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable;
extern PFNGLXSELECTEVENTPROC __glewXSelectEvent;
GLXEW_FUN_EXPORT PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig;
GLXEW_FUN_EXPORT PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext;
GLXEW_FUN_EXPORT PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer;
GLXEW_FUN_EXPORT PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap;
GLXEW_FUN_EXPORT PFNGLXCREATEWINDOWPROC __glewXCreateWindow;
GLXEW_FUN_EXPORT PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer;
GLXEW_FUN_EXPORT PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap;
GLXEW_FUN_EXPORT PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow;
GLXEW_FUN_EXPORT PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable;
GLXEW_FUN_EXPORT PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib;
GLXEW_FUN_EXPORT PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs;
GLXEW_FUN_EXPORT PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent;
GLXEW_FUN_EXPORT PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig;
GLXEW_FUN_EXPORT PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent;
GLXEW_FUN_EXPORT PFNGLXQUERYCONTEXTPROC __glewXQueryContext;
GLXEW_FUN_EXPORT PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable;
GLXEW_FUN_EXPORT PFNGLXSELECTEVENTPROC __glewXSelectEvent;
extern PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB;
GLXEW_FUN_EXPORT PFNGLXBLITCONTEXTFRAMEBUFFERAMDPROC __glewXBlitContextFramebufferAMD;
GLXEW_FUN_EXPORT PFNGLXCREATEASSOCIATEDCONTEXTAMDPROC __glewXCreateAssociatedContextAMD;
GLXEW_FUN_EXPORT PFNGLXCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __glewXCreateAssociatedContextAttribsAMD;
GLXEW_FUN_EXPORT PFNGLXDELETEASSOCIATEDCONTEXTAMDPROC __glewXDeleteAssociatedContextAMD;
GLXEW_FUN_EXPORT PFNGLXGETCONTEXTGPUIDAMDPROC __glewXGetContextGPUIDAMD;
GLXEW_FUN_EXPORT PFNGLXGETCURRENTASSOCIATEDCONTEXTAMDPROC __glewXGetCurrentAssociatedContextAMD;
GLXEW_FUN_EXPORT PFNGLXGETGPUIDSAMDPROC __glewXGetGPUIDsAMD;
GLXEW_FUN_EXPORT PFNGLXGETGPUINFOAMDPROC __glewXGetGPUInfoAMD;
GLXEW_FUN_EXPORT PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __glewXMakeAssociatedContextCurrentAMD;
extern PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI;
extern PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI;
extern PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI;
GLXEW_FUN_EXPORT PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB;
extern PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT;
extern PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT;
extern PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT;
extern PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT;
GLXEW_FUN_EXPORT PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI;
GLXEW_FUN_EXPORT PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI;
GLXEW_FUN_EXPORT PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI;
extern PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT;
GLXEW_FUN_EXPORT PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT;
GLXEW_FUN_EXPORT PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT;
GLXEW_FUN_EXPORT PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT;
GLXEW_FUN_EXPORT PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT;
extern PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT;
extern PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT;
GLXEW_FUN_EXPORT PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT;
extern PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA;
GLXEW_FUN_EXPORT PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT;
GLXEW_FUN_EXPORT PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT;
extern PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA;
GLXEW_FUN_EXPORT PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA;
extern PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA;
GLXEW_FUN_EXPORT PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA;
extern PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA;
GLXEW_FUN_EXPORT PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA;
extern PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA;
GLXEW_FUN_EXPORT PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA;
extern PFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA;
extern PFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA;
GLXEW_FUN_EXPORT PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA;
extern PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV;
GLXEW_FUN_EXPORT PFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA;
GLXEW_FUN_EXPORT PFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA;
extern PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV;
extern PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV;
GLXEW_FUN_EXPORT PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV;
extern PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV;
extern PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV;
extern PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV;
extern PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV;
extern PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV;
extern PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV;
GLXEW_FUN_EXPORT PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV;
GLXEW_FUN_EXPORT PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV;
extern PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV;
extern PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV;
GLXEW_FUN_EXPORT PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV;
GLXEW_FUN_EXPORT PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV;
GLXEW_FUN_EXPORT PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV;
GLXEW_FUN_EXPORT PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV;
GLXEW_FUN_EXPORT PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV;
GLXEW_FUN_EXPORT PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV;
extern PFNGLXBINDVIDEOCAPTUREDEVICENVPROC __glewXBindVideoCaptureDeviceNV;
extern PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC __glewXEnumerateVideoCaptureDevicesNV;
extern PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC __glewXLockVideoCaptureDeviceNV;
extern PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC __glewXQueryVideoCaptureDeviceNV;
extern PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC __glewXReleaseVideoCaptureDeviceNV;
GLXEW_FUN_EXPORT PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV;
GLXEW_FUN_EXPORT PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV;
extern PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV;
extern PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV;
extern PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV;
extern PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV;
extern PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV;
extern PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV;
GLXEW_FUN_EXPORT PFNGLXBINDVIDEOCAPTUREDEVICENVPROC __glewXBindVideoCaptureDeviceNV;
GLXEW_FUN_EXPORT PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC __glewXEnumerateVideoCaptureDevicesNV;
GLXEW_FUN_EXPORT PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC __glewXLockVideoCaptureDeviceNV;
GLXEW_FUN_EXPORT PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC __glewXQueryVideoCaptureDeviceNV;
GLXEW_FUN_EXPORT PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC __glewXReleaseVideoCaptureDeviceNV;
extern PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML;
extern PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML;
extern PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML;
extern PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML;
extern PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML;
GLXEW_FUN_EXPORT PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV;
GLXEW_FUN_EXPORT PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV;
GLXEW_FUN_EXPORT PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV;
GLXEW_FUN_EXPORT PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV;
GLXEW_FUN_EXPORT PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV;
GLXEW_FUN_EXPORT PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV;
extern PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX;
extern PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX;
extern PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX;
extern PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX;
extern PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX;
extern PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX;
GLXEW_FUN_EXPORT PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML;
GLXEW_FUN_EXPORT PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML;
GLXEW_FUN_EXPORT PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML;
GLXEW_FUN_EXPORT PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML;
GLXEW_FUN_EXPORT PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML;
extern PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX;
extern PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX;
extern PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX;
extern PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX;
extern PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX;
extern PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX;
extern PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX;
extern PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX;
GLXEW_FUN_EXPORT PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX;
GLXEW_FUN_EXPORT PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX;
GLXEW_FUN_EXPORT PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX;
GLXEW_FUN_EXPORT PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX;
GLXEW_FUN_EXPORT PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX;
GLXEW_FUN_EXPORT PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX;
extern PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX;
extern PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX;
extern PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX;
extern PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX;
extern PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX;
GLXEW_FUN_EXPORT PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX;
GLXEW_FUN_EXPORT PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX;
GLXEW_FUN_EXPORT PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX;
GLXEW_FUN_EXPORT PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX;
GLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX;
GLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX;
GLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX;
GLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX;
extern PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX;
extern PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX;
GLXEW_FUN_EXPORT PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX;
GLXEW_FUN_EXPORT PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX;
GLXEW_FUN_EXPORT PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX;
GLXEW_FUN_EXPORT PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX;
GLXEW_FUN_EXPORT PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX;
extern PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX;
GLXEW_FUN_EXPORT PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX;
GLXEW_FUN_EXPORT PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX;
extern PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX;
extern PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX;
extern PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX;
extern PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX;
extern PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX;
GLXEW_FUN_EXPORT PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX;
extern PFNGLXCUSHIONSGIPROC __glewXCushionSGI;
GLXEW_FUN_EXPORT PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX;
GLXEW_FUN_EXPORT PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX;
GLXEW_FUN_EXPORT PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX;
GLXEW_FUN_EXPORT PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX;
GLXEW_FUN_EXPORT PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX;
extern PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI;
extern PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI;
GLXEW_FUN_EXPORT PFNGLXCUSHIONSGIPROC __glewXCushionSGI;
extern PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI;
GLXEW_FUN_EXPORT PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI;
GLXEW_FUN_EXPORT PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI;
extern PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI;
extern PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI;
GLXEW_FUN_EXPORT PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI;
extern PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN;
GLXEW_FUN_EXPORT PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI;
GLXEW_FUN_EXPORT PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI;
extern PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN;
extern PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN;
GLXEW_FUN_EXPORT PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN;
GLXEW_FUN_EXPORT PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN;
GLXEW_FUN_EXPORT PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN;
#if defined(GLEW_MX)
struct GLXEWContextStruct
{
#endif /* GLEW_MX */
GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_0;
GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_1;
GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_2;
GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_3;
GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_4;
GLXEW_EXPORT GLboolean __GLXEW_3DFX_multisample;
GLXEW_EXPORT GLboolean __GLXEW_AMD_gpu_association;
GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context;
GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context_profile;
GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context_robustness;
GLXEW_EXPORT GLboolean __GLXEW_ARB_fbconfig_float;
GLXEW_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB;
GLXEW_EXPORT GLboolean __GLXEW_ARB_get_proc_address;
GLXEW_EXPORT GLboolean __GLXEW_ARB_multisample;
GLXEW_EXPORT GLboolean __GLXEW_ARB_vertex_buffer_object;
GLXEW_EXPORT GLboolean __GLXEW_ATI_pixel_format_float;
GLXEW_EXPORT GLboolean __GLXEW_ATI_render_texture;
GLXEW_EXPORT GLboolean __GLXEW_EXT_create_context_es2_profile;
GLXEW_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float;
GLXEW_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB;
GLXEW_EXPORT GLboolean __GLXEW_EXT_import_context;
GLXEW_EXPORT GLboolean __GLXEW_EXT_scene_marker;
GLXEW_EXPORT GLboolean __GLXEW_EXT_swap_control;
GLXEW_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap;
GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_info;
GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_rating;
GLXEW_EXPORT GLboolean __GLXEW_INTEL_swap_event;
GLXEW_EXPORT GLboolean __GLXEW_MESA_agp_offset;
GLXEW_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer;
GLXEW_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap;
GLXEW_EXPORT GLboolean __GLXEW_MESA_release_buffers;
GLXEW_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode;
GLXEW_EXPORT GLboolean __GLXEW_MESA_swap_control;
GLXEW_EXPORT GLboolean __GLXEW_NV_copy_image;
GLXEW_EXPORT GLboolean __GLXEW_NV_float_buffer;
GLXEW_EXPORT GLboolean __GLXEW_NV_multisample_coverage;
GLXEW_EXPORT GLboolean __GLXEW_NV_present_video;
GLXEW_EXPORT GLboolean __GLXEW_NV_swap_group;
GLXEW_EXPORT GLboolean __GLXEW_NV_vertex_array_range;
GLXEW_EXPORT GLboolean __GLXEW_NV_video_capture;
GLXEW_EXPORT GLboolean __GLXEW_NV_video_output;
GLXEW_EXPORT GLboolean __GLXEW_OML_swap_method;
GLXEW_EXPORT GLboolean __GLXEW_OML_sync_control;
GLXEW_EXPORT GLboolean __GLXEW_SGIS_blended_overlay;
GLXEW_EXPORT GLboolean __GLXEW_SGIS_color_range;
GLXEW_EXPORT GLboolean __GLXEW_SGIS_multisample;
GLXEW_EXPORT GLboolean __GLXEW_SGIS_shared_multisample;
GLXEW_EXPORT GLboolean __GLXEW_SGIX_fbconfig;
GLXEW_EXPORT GLboolean __GLXEW_SGIX_hyperpipe;
GLXEW_EXPORT GLboolean __GLXEW_SGIX_pbuffer;
GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_barrier;
GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_group;
GLXEW_EXPORT GLboolean __GLXEW_SGIX_video_resize;
GLXEW_EXPORT GLboolean __GLXEW_SGIX_visual_select_group;
GLXEW_EXPORT GLboolean __GLXEW_SGI_cushion;
GLXEW_EXPORT GLboolean __GLXEW_SGI_make_current_read;
GLXEW_EXPORT GLboolean __GLXEW_SGI_swap_control;
GLXEW_EXPORT GLboolean __GLXEW_SGI_video_sync;
GLXEW_EXPORT GLboolean __GLXEW_SUN_get_transparent_index;
GLXEW_EXPORT GLboolean __GLXEW_SUN_video_resize;
GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_0;
GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_1;
GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_2;
GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_3;
GLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_4;
GLXEW_VAR_EXPORT GLboolean __GLXEW_3DFX_multisample;
GLXEW_VAR_EXPORT GLboolean __GLXEW_AMD_gpu_association;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context_profile;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context_robustness;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_fbconfig_float;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_get_proc_address;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_multisample;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_robustness_application_isolation;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_robustness_share_group_isolation;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_vertex_buffer_object;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ATI_pixel_format_float;
GLXEW_VAR_EXPORT GLboolean __GLXEW_ATI_render_texture;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_buffer_age;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_create_context_es2_profile;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_create_context_es_profile;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_import_context;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_scene_marker;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control_tear;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_visual_info;
GLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_visual_rating;
GLXEW_VAR_EXPORT GLboolean __GLXEW_INTEL_swap_event;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_agp_offset;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_release_buffers;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode;
GLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_swap_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_copy_image;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_float_buffer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_multisample_coverage;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_present_video;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_swap_group;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_vertex_array_range;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_capture;
GLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_output;
GLXEW_VAR_EXPORT GLboolean __GLXEW_OML_swap_method;
GLXEW_VAR_EXPORT GLboolean __GLXEW_OML_sync_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_blended_overlay;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_color_range;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_multisample;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_shared_multisample;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_fbconfig;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_hyperpipe;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_pbuffer;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_swap_barrier;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_swap_group;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_video_resize;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_visual_select_group;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_cushion;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_make_current_read;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_swap_control;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_video_sync;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SUN_get_transparent_index;
GLXEW_VAR_EXPORT GLboolean __GLXEW_SUN_video_resize;
#ifdef GLEW_MX
}; /* GLXEWContextStruct */
@ -1560,8 +1642,8 @@ GLXEW_EXPORT GLboolean __GLXEW_SUN_video_resize;
#ifdef GLEW_MX
typedef struct GLXEWContextStruct GLXEWContext;
extern GLenum glxewContextInit (GLXEWContext* ctx);
extern GLboolean glxewContextIsSupported (const GLXEWContext* ctx, const char* name);
GLEWAPI GLenum GLEWAPIENTRY glxewContextInit (GLXEWContext *ctx);
GLEWAPI GLboolean GLEWAPIENTRY glxewContextIsSupported (const GLXEWContext *ctx, const char *name);
#define glxewInit() glxewContextInit(glxewGetContext())
#define glxewIsSupported(x) glxewContextIsSupported(glxewGetContext(), x)
@ -1574,11 +1656,11 @@ extern GLboolean glxewContextIsSupported (const GLXEWContext* ctx, const char* n
#define GLXEW_GET_VAR(x) (*(const GLboolean*)&x)
#define GLXEW_GET_FUN(x) x
extern GLboolean glxewIsSupported (const char* name);
GLEWAPI GLboolean GLEWAPIENTRY glxewIsSupported (const char *name);
#endif /* GLEW_MX */
extern GLboolean glxewGetExtension (const char* name);
GLEWAPI GLboolean GLEWAPIENTRY glxewGetExtension (const char *name);
#ifdef __cplusplus
}

@ -446,6 +446,28 @@ typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, con
#endif /* WGL_ARB_render_texture */
/* ---------------- WGL_ARB_robustness_application_isolation --------------- */
#ifndef WGL_ARB_robustness_application_isolation
#define WGL_ARB_robustness_application_isolation 1
#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008
#define WGLEW_ARB_robustness_application_isolation WGLEW_GET_VAR(__WGLEW_ARB_robustness_application_isolation)
#endif /* WGL_ARB_robustness_application_isolation */
/* ---------------- WGL_ARB_robustness_share_group_isolation --------------- */
#ifndef WGL_ARB_robustness_share_group_isolation
#define WGL_ARB_robustness_share_group_isolation 1
#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008
#define WGLEW_ARB_robustness_share_group_isolation WGLEW_GET_VAR(__WGLEW_ARB_robustness_share_group_isolation)
#endif /* WGL_ARB_robustness_share_group_isolation */
/* ----------------------- WGL_ATI_pixel_format_float ---------------------- */
#ifndef WGL_ATI_pixel_format_float
@ -481,6 +503,17 @@ typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, con
#endif /* WGL_EXT_create_context_es2_profile */
/* ------------------- WGL_EXT_create_context_es_profile ------------------- */
#ifndef WGL_EXT_create_context_es_profile
#define WGL_EXT_create_context_es_profile 1
#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004
#define WGLEW_EXT_create_context_es_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es_profile)
#endif /* WGL_EXT_create_context_es_profile */
/* -------------------------- WGL_EXT_depth_float -------------------------- */
#ifndef WGL_EXT_depth_float
@ -686,6 +719,15 @@ typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
#endif /* WGL_EXT_swap_control */
/* ----------------------- WGL_EXT_swap_control_tear ----------------------- */
#ifndef WGL_EXT_swap_control_tear
#define WGL_EXT_swap_control_tear 1
#define WGLEW_EXT_swap_control_tear WGLEW_GET_VAR(__WGLEW_EXT_swap_control_tear)
#endif /* WGL_EXT_swap_control_tear */
/* --------------------- WGL_I3D_digital_video_control --------------------- */
#ifndef WGL_I3D_digital_video_control
@ -864,6 +906,15 @@ typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE h
#endif /* WGL_NV_DX_interop */
/* --------------------------- WGL_NV_DX_interop2 -------------------------- */
#ifndef WGL_NV_DX_interop2
#define WGL_NV_DX_interop2 1
#define WGLEW_NV_DX_interop2 WGLEW_GET_VAR(__WGLEW_NV_DX_interop2)
#endif /* WGL_NV_DX_interop2 */
/* --------------------------- WGL_NV_copy_image --------------------------- */
#ifndef WGL_NV_copy_image
@ -1120,9 +1171,11 @@ typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT6
/* ------------------------------------------------------------------------- */
#ifdef GLEW_MX
#define WGLEW_EXPORT
#define WGLEW_FUN_EXPORT
#define WGLEW_VAR_EXPORT
#else
#define WGLEW_EXPORT GLEWAPI
#define WGLEW_FUN_EXPORT GLEW_FUN_EXPORT
#define WGLEW_VAR_EXPORT GLEW_VAR_EXPORT
#endif /* GLEW_MX */
#ifdef GLEW_MX
@ -1130,200 +1183,205 @@ struct WGLEWContextStruct
{
#endif /* GLEW_MX */
WGLEW_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL;
WGLEW_FUN_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL;
WGLEW_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD;
WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD;
WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD;
WGLEW_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD;
WGLEW_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD;
WGLEW_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD;
WGLEW_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD;
WGLEW_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD;
WGLEW_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD;
WGLEW_FUN_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD;
WGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD;
WGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD;
WGLEW_FUN_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD;
WGLEW_FUN_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD;
WGLEW_FUN_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD;
WGLEW_FUN_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD;
WGLEW_FUN_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD;
WGLEW_FUN_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD;
WGLEW_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB;
WGLEW_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB;
WGLEW_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB;
WGLEW_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB;
WGLEW_FUN_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB;
WGLEW_FUN_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB;
WGLEW_FUN_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB;
WGLEW_FUN_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB;
WGLEW_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB;
WGLEW_FUN_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB;
WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB;
WGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB;
WGLEW_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB;
WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB;
WGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB;
WGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB;
WGLEW_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB;
WGLEW_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB;
WGLEW_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB;
WGLEW_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB;
WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB;
WGLEW_FUN_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB;
WGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB;
WGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB;
WGLEW_FUN_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB;
WGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB;
WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB;
WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB;
WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB;
WGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB;
WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB;
WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB;
WGLEW_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB;
WGLEW_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB;
WGLEW_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB;
WGLEW_FUN_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB;
WGLEW_FUN_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB;
WGLEW_FUN_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB;
WGLEW_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT;
WGLEW_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT;
WGLEW_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT;
WGLEW_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT;
WGLEW_FUN_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT;
WGLEW_FUN_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT;
WGLEW_FUN_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT;
WGLEW_FUN_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT;
WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT;
WGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT;
WGLEW_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT;
WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT;
WGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT;
WGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT;
WGLEW_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT;
WGLEW_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT;
WGLEW_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT;
WGLEW_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT;
WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT;
WGLEW_FUN_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT;
WGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT;
WGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT;
WGLEW_FUN_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT;
WGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT;
WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT;
WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT;
WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT;
WGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT;
WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT;
WGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT;
WGLEW_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT;
WGLEW_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT;
WGLEW_FUN_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT;
WGLEW_FUN_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT;
WGLEW_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D;
WGLEW_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D;
WGLEW_FUN_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D;
WGLEW_FUN_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D;
WGLEW_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D;
WGLEW_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D;
WGLEW_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D;
WGLEW_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D;
WGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D;
WGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D;
WGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D;
WGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D;
WGLEW_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D;
WGLEW_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D;
WGLEW_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D;
WGLEW_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D;
WGLEW_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D;
WGLEW_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D;
WGLEW_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D;
WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D;
WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D;
WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D;
WGLEW_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D;
WGLEW_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D;
WGLEW_FUN_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D;
WGLEW_FUN_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D;
WGLEW_FUN_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D;
WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D;
WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D;
WGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D;
WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D;
WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D;
WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D;
WGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D;
WGLEW_FUN_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D;
WGLEW_FUN_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D;
WGLEW_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D;
WGLEW_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D;
WGLEW_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D;
WGLEW_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D;
WGLEW_FUN_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D;
WGLEW_FUN_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D;
WGLEW_FUN_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D;
WGLEW_FUN_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D;
WGLEW_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D;
WGLEW_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D;
WGLEW_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D;
WGLEW_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D;
WGLEW_FUN_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D;
WGLEW_FUN_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D;
WGLEW_FUN_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D;
WGLEW_FUN_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D;
WGLEW_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D;
WGLEW_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D;
WGLEW_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D;
WGLEW_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D;
WGLEW_FUN_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D;
WGLEW_FUN_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D;
WGLEW_FUN_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D;
WGLEW_FUN_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D;
WGLEW_EXPORT PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV;
WGLEW_EXPORT PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV;
WGLEW_EXPORT PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV;
WGLEW_EXPORT PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV;
WGLEW_EXPORT PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV;
WGLEW_EXPORT PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV;
WGLEW_EXPORT PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV;
WGLEW_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV;
WGLEW_FUN_EXPORT PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV;
WGLEW_FUN_EXPORT PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV;
WGLEW_FUN_EXPORT PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV;
WGLEW_FUN_EXPORT PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV;
WGLEW_FUN_EXPORT PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV;
WGLEW_FUN_EXPORT PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV;
WGLEW_FUN_EXPORT PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV;
WGLEW_FUN_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV;
WGLEW_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV;
WGLEW_FUN_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV;
WGLEW_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV;
WGLEW_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV;
WGLEW_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV;
WGLEW_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV;
WGLEW_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV;
WGLEW_FUN_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV;
WGLEW_FUN_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV;
WGLEW_FUN_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV;
WGLEW_FUN_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV;
WGLEW_FUN_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV;
WGLEW_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV;
WGLEW_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV;
WGLEW_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV;
WGLEW_FUN_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV;
WGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV;
WGLEW_FUN_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV;
WGLEW_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV;
WGLEW_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV;
WGLEW_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV;
WGLEW_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV;
WGLEW_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV;
WGLEW_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV;
WGLEW_FUN_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV;
WGLEW_FUN_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV;
WGLEW_FUN_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV;
WGLEW_FUN_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV;
WGLEW_FUN_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV;
WGLEW_FUN_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV;
WGLEW_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV;
WGLEW_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV;
WGLEW_FUN_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV;
WGLEW_FUN_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV;
WGLEW_EXPORT PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV;
WGLEW_EXPORT PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV;
WGLEW_EXPORT PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV;
WGLEW_EXPORT PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV;
WGLEW_EXPORT PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV;
WGLEW_FUN_EXPORT PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV;
WGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV;
WGLEW_FUN_EXPORT PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV;
WGLEW_FUN_EXPORT PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV;
WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV;
WGLEW_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV;
WGLEW_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV;
WGLEW_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV;
WGLEW_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV;
WGLEW_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV;
WGLEW_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV;
WGLEW_FUN_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV;
WGLEW_FUN_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV;
WGLEW_FUN_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV;
WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV;
WGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV;
WGLEW_FUN_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV;
WGLEW_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML;
WGLEW_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML;
WGLEW_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML;
WGLEW_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML;
WGLEW_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML;
WGLEW_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML;
WGLEW_EXPORT GLboolean __WGLEW_3DFX_multisample;
WGLEW_EXPORT GLboolean __WGLEW_3DL_stereo_control;
WGLEW_EXPORT GLboolean __WGLEW_AMD_gpu_association;
WGLEW_EXPORT GLboolean __WGLEW_ARB_buffer_region;
WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context;
WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context_profile;
WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context_robustness;
WGLEW_EXPORT GLboolean __WGLEW_ARB_extensions_string;
WGLEW_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB;
WGLEW_EXPORT GLboolean __WGLEW_ARB_make_current_read;
WGLEW_EXPORT GLboolean __WGLEW_ARB_multisample;
WGLEW_EXPORT GLboolean __WGLEW_ARB_pbuffer;
WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format;
WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format_float;
WGLEW_EXPORT GLboolean __WGLEW_ARB_render_texture;
WGLEW_EXPORT GLboolean __WGLEW_ATI_pixel_format_float;
WGLEW_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle;
WGLEW_EXPORT GLboolean __WGLEW_EXT_create_context_es2_profile;
WGLEW_EXPORT GLboolean __WGLEW_EXT_depth_float;
WGLEW_EXPORT GLboolean __WGLEW_EXT_display_color_table;
WGLEW_EXPORT GLboolean __WGLEW_EXT_extensions_string;
WGLEW_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB;
WGLEW_EXPORT GLboolean __WGLEW_EXT_make_current_read;
WGLEW_EXPORT GLboolean __WGLEW_EXT_multisample;
WGLEW_EXPORT GLboolean __WGLEW_EXT_pbuffer;
WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format;
WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float;
WGLEW_EXPORT GLboolean __WGLEW_EXT_swap_control;
WGLEW_EXPORT GLboolean __WGLEW_I3D_digital_video_control;
WGLEW_EXPORT GLboolean __WGLEW_I3D_gamma;
WGLEW_EXPORT GLboolean __WGLEW_I3D_genlock;
WGLEW_EXPORT GLboolean __WGLEW_I3D_image_buffer;
WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock;
WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage;
WGLEW_EXPORT GLboolean __WGLEW_NV_DX_interop;
WGLEW_EXPORT GLboolean __WGLEW_NV_copy_image;
WGLEW_EXPORT GLboolean __WGLEW_NV_float_buffer;
WGLEW_EXPORT GLboolean __WGLEW_NV_gpu_affinity;
WGLEW_EXPORT GLboolean __WGLEW_NV_multisample_coverage;
WGLEW_EXPORT GLboolean __WGLEW_NV_present_video;
WGLEW_EXPORT GLboolean __WGLEW_NV_render_depth_texture;
WGLEW_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle;
WGLEW_EXPORT GLboolean __WGLEW_NV_swap_group;
WGLEW_EXPORT GLboolean __WGLEW_NV_vertex_array_range;
WGLEW_EXPORT GLboolean __WGLEW_NV_video_capture;
WGLEW_EXPORT GLboolean __WGLEW_NV_video_output;
WGLEW_EXPORT GLboolean __WGLEW_OML_sync_control;
WGLEW_FUN_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML;
WGLEW_FUN_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML;
WGLEW_FUN_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML;
WGLEW_FUN_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML;
WGLEW_FUN_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML;
WGLEW_FUN_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML;
WGLEW_VAR_EXPORT GLboolean __WGLEW_3DFX_multisample;
WGLEW_VAR_EXPORT GLboolean __WGLEW_3DL_stereo_control;
WGLEW_VAR_EXPORT GLboolean __WGLEW_AMD_gpu_association;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_buffer_region;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_profile;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_robustness;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_extensions_string;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_make_current_read;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_multisample;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pbuffer;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format_float;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_render_texture;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_robustness_application_isolation;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_robustness_share_group_isolation;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_pixel_format_float;
WGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es2_profile;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es_profile;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_depth_float;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_display_color_table;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_extensions_string;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_make_current_read;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_multisample;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pbuffer;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control;
WGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control_tear;
WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_digital_video_control;
WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_gamma;
WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_genlock;
WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_image_buffer;
WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock;
WGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop2;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_copy_image;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_float_buffer;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_gpu_affinity;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_multisample_coverage;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_present_video;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_depth_texture;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_swap_group;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_vertex_array_range;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_capture;
WGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_output;
WGLEW_VAR_EXPORT GLboolean __WGLEW_OML_sync_control;
#ifdef GLEW_MX
}; /* WGLEWContextStruct */
@ -1334,8 +1392,8 @@ WGLEW_EXPORT GLboolean __WGLEW_OML_sync_control;
#ifdef GLEW_MX
typedef struct WGLEWContextStruct WGLEWContext;
GLEWAPI GLenum wglewContextInit (WGLEWContext* ctx);
GLEWAPI GLboolean wglewContextIsSupported (const WGLEWContext* ctx, const char* name);
GLEWAPI GLenum GLEWAPIENTRY wglewContextInit (WGLEWContext *ctx);
GLEWAPI GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext *ctx, const char *name);
#define wglewInit() wglewContextInit(wglewGetContext())
#define wglewIsSupported(x) wglewContextIsSupported(wglewGetContext(), x)
@ -1348,11 +1406,11 @@ GLEWAPI GLboolean wglewContextIsSupported (const WGLEWContext* ctx, const char*
#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x)
#define WGLEW_GET_FUN(x) x
GLEWAPI GLboolean wglewIsSupported (const char* name);
GLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name);
#endif /* GLEW_MX */
GLEWAPI GLboolean wglewGetExtension (const char* name);
GLEWAPI GLboolean GLEWAPIENTRY wglewGetExtension (const char *name);
#ifdef __cplusplus
}

2312
extern/glew/src/glew.c vendored

File diff suppressed because it is too large Load Diff

@ -31,6 +31,7 @@ add_subdirectory(memutil)
add_subdirectory(opencolorio)
add_subdirectory(mikktspace)
add_subdirectory(raskter)
add_subdirectory(glew-mx)
if(WITH_AUDASPACE)
add_subdirectory(audaspace)

@ -30,6 +30,7 @@ Import ('env')
SConscript(['audaspace/SConscript',
'string/SConscript',
'ghost/SConscript',
'glew-mx/SConscript',
'guardedalloc/SConscript',
'moto/SConscript',
'memutil/SConscript/',

@ -45,7 +45,7 @@ incs = []
defs = []
cxxflags = Split(env['CXXFLAGS'])
defs.append('GLEW_STATIC')
defs += env['BF_GL_DEFINITIONS']
defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {')
defs.append('CCL_NAMESPACE_END=}')
@ -65,7 +65,12 @@ if env['WITH_BF_CYCLES_DEBUG']:
incs.extend('. bvh render device kernel kernel/osl kernel/svm util subd'.split())
incs.extend('#intern/guardedalloc #source/blender/makesrna #source/blender/makesdna #source/blender/blenlib'.split())
incs.extend('#source/blender/blenloader ../../source/blender/makesrna/intern'.split())
incs.append(env['BF_GLEW_INC'])
incs.append('#/intern/glew-mx')
incs.append('#intern/mikktspace')
incs.extend('#extern/glew/include #extern/clew/include #extern/cuew/include #intern/mikktspace'.split())
incs.append(cycles['BF_OIIO_INC'])
incs.append(cycles['BF_BOOST_INC'])
incs.append(cycles['BF_OPENEXR_INC'].split())

@ -21,8 +21,9 @@ set(LIBRARIES
cycles_util
${BOOST_LIBRARIES}
${OPENEXR_LIBRARIES}
${OPENGL_LIBRARIES}
${CYCLES_GLEW_LIBRARY}
${BLENDER_GL_LIBRARIES}
bf_intern_glew_mx
${CYCLES_APP_GLEW_LIBRARY}
${OPENIMAGEIO_LIBRARIES}
${PNG_LIBRARIES}
${JPEG_LIBRARIES}
@ -32,6 +33,8 @@ set(LIBRARIES
extern_cuew
)
add_definitions(${GL_DEFINITIONS})
if(WIN32)
list(APPEND LIBRARIES ${PTHREADS_LIBRARIES})
endif()

@ -6,6 +6,7 @@ set(INC
../kernel/svm
../util
../subd
../../glew-mx
../../guardedalloc
../../mikktspace
../../../source/blender/makesdna
@ -47,7 +48,7 @@ set(ADDON_FILES
addon/version_update.py
)
add_definitions(-DGLEW_STATIC)
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_intern_cycles "${SRC}" "${INC}" "${INC_SYS}")

@ -1,4 +1,3 @@
###########################################################################
# GLUT
@ -14,10 +13,11 @@ if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
)
endif()
if(WITH_SYSTEM_GLEW)
set(CYCLES_GLEW_LIBRARY ${GLEW_LIBRARY})
else()
set(CYCLES_GLEW_LIBRARY extern_glew)
###########################################################################
# GLEW
if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
set(CYCLES_APP_GLEW_LIBRARY ${BLENDER_GLEW_LIBRARIES})
endif()
###########################################################################
@ -32,4 +32,3 @@ if(WITH_CYCLES_CUDA_BINARIES)
set(WITH_CYCLES_CUDA_BINARIES OFF)
endif()
endif()

@ -6,10 +6,10 @@ set(INC
../kernel/osl
../util
../render
../../glew-mx
)
set(INC_SYS
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_PATH}
../../../extern/cuew/include
../../../extern/clew/include
@ -38,7 +38,7 @@ set(SRC_HEADERS
device_task.h
)
add_definitions(-DGLEW_STATIC)
add_definitions(${GL_DEFINITIONS})
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})

@ -7,6 +7,7 @@ set(INC
../kernel/osl
../bvh
../util
../../glew-mx
)
set(INC_SYS
@ -76,5 +77,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RTTI_DISABLE_FLAGS}")
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})
add_library(cycles_render ${SRC} ${SRC_HEADERS})
add_definitions(${GL_DEFINITIONS})
add_library(cycles_render ${SRC} ${SRC_HEADERS})

@ -1,11 +1,11 @@
set(INC
.
../../glew-mx
)
set(INC_SYS
${GLEW_INCLUDE_PATH}
${OPENGL_INCLUDE_DIR}
)
set(SRC
@ -71,4 +71,6 @@ set(SRC_HEADERS
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})
add_definitions(${GL_DEFINITIONS})
add_library(cycles_util ${SRC} ${SRC_HEADERS})

@ -20,7 +20,6 @@
/* OpenGL header includes, used everywhere we use OpenGL, to deal with
* platform differences in one central place. */
#include <GL/glew.h>
#include "glew-mx.h"
#endif /* __UTIL_OPENGL_H__ */

@ -248,7 +248,7 @@ void view_main_loop(const char *title, int width, int height,
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow(title);
glewInit();
mxMakeCurrentContext(mxCreateContext());
view_reshape(width, height);

@ -25,6 +25,7 @@
set(INC
.
../glew-mx
../string
../../source/blender/imbuf
../../source/blender/makesdna
@ -38,6 +39,8 @@ set(SRC
intern/GHOST_Buttons.cpp
intern/GHOST_C-api.cpp
intern/GHOST_CallbackEventConsumer.cpp
intern/GHOST_Context.cpp
intern/GHOST_ContextNone.cpp
intern/GHOST_DisplayManager.cpp
intern/GHOST_EventManager.cpp
intern/GHOST_ISystem.cpp
@ -63,6 +66,8 @@ set(SRC
intern/GHOST_Buttons.h
intern/GHOST_CallbackEventConsumer.h
intern/GHOST_Context.h
intern/GHOST_ContextNone.h
intern/GHOST_Debug.h
intern/GHOST_DisplayManager.h
intern/GHOST_Event.h
@ -120,68 +125,48 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL)
intern/GHOST_DisplayManagerSDL.cpp
intern/GHOST_SystemSDL.cpp
intern/GHOST_WindowSDL.cpp
intern/GHOST_ContextSDL.cpp
intern/GHOST_DisplayManagerSDL.h
intern/GHOST_SystemSDL.h
intern/GHOST_WindowSDL.h
intern/GHOST_ContextSDL.h
)
add_definitions(-DWITH_GHOST_SDL)
endif()
# ack, this is still system dependent
if(APPLE)
list(APPEND SRC
intern/GHOST_SystemPathsCocoa.mm
intern/GHOST_SystemPathsCocoa.h
)
elseif(UNIX)
list(APPEND SRC
intern/GHOST_SystemPathsX11.cpp
intern/GHOST_SystemPathsX11.h
)
if(NOT WITH_INSTALL_PORTABLE)
add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
endif()
elseif(WIN32)
list(APPEND SRC
intern/GHOST_SystemPathsWin32.cpp
intern/GHOST_SystemPathsWin32.h
)
list(APPEND INC
../utfconv
)
endif()
if(NOT WITH_HEADLESS)
list(APPEND INC_SYS
${SDL_INCLUDE_DIR}
)
endif()
elseif(APPLE)
elseif(APPLE AND NOT WITH_X11)
list(APPEND SRC
intern/GHOST_DisplayManagerCocoa.mm
intern/GHOST_SystemCocoa.mm
intern/GHOST_SystemPathsCocoa.mm
intern/GHOST_WindowCocoa.mm
intern/GHOST_DisplayManagerCocoa.h
intern/GHOST_SystemCocoa.h
intern/GHOST_SystemPathsCocoa.h
intern/GHOST_WindowCocoa.h
)
if (NOT WITH_GL_EGL)
list(APPEND SRC
intern/GHOST_ContextCGL.mm
intern/GHOST_ContextCGL.h
)
endif()
if(WITH_INPUT_NDOF)
list(APPEND SRC
intern/GHOST_NDOFManagerCocoa.mm
intern/GHOST_NDOFManagerCocoa.h
)
list(APPEND SRC_NDOF3DCONNEXION
intern/GHOST_NDOFManager3Dconnexion.c
intern/GHOST_NDOFManager3Dconnexion.h
@ -192,8 +177,7 @@ elseif(APPLE)
add_definitions(-DWITH_QUICKTIME)
endif()
elseif(UNIX)
elseif(WITH_X11)
list(APPEND INC_SYS
${X11_X11_INCLUDE_PATH}
)
@ -201,15 +185,21 @@ elseif(UNIX)
list(APPEND SRC
intern/GHOST_DisplayManagerX11.cpp
intern/GHOST_SystemX11.cpp
intern/GHOST_SystemPathsX11.cpp
intern/GHOST_WindowX11.cpp
intern/GHOST_DisplayManagerX11.h
intern/GHOST_SystemX11.h
intern/GHOST_SystemPathsX11.h
intern/GHOST_WindowX11.h
)
if (NOT WITH_GL_EGL)
list(APPEND SRC
intern/GHOST_ContextGLX.cpp
intern/GHOST_ContextGLX.h
)
endif()
if(WITH_GHOST_XDND)
add_definitions(-DWITH_XDND)
@ -257,6 +247,8 @@ elseif(UNIX)
)
endif()
add_definitions(-DWITH_X11)
elseif(WIN32)
## Warnings as errors, this is too strict!
#if(MSVC)
@ -267,25 +259,27 @@ elseif(WIN32)
${WINTAB_INC}
)
list(APPEND INC
../utfconv
)
list(APPEND SRC
intern/GHOST_DisplayManagerWin32.cpp
intern/GHOST_SystemWin32.cpp
intern/GHOST_SystemPathsWin32.cpp
intern/GHOST_WindowWin32.cpp
intern/GHOST_DropTargetWin32.cpp
intern/GHOST_DisplayManagerWin32.h
intern/GHOST_DropTargetWin32.h
intern/GHOST_SystemWin32.h
intern/GHOST_SystemPathsWin32.h
intern/GHOST_WindowWin32.h
intern/GHOST_TaskbarWin32.h
)
if (NOT WITH_GL_EGL)
list(APPEND SRC
intern/GHOST_ContextWGL.cpp
intern/GHOST_ContextWGL.h
)
endif()
if(WITH_INPUT_NDOF)
list(APPEND SRC
intern/GHOST_NDOFManagerWin32.cpp
@ -294,9 +288,45 @@ elseif(WIN32)
)
endif()
list(APPEND INC
../utfconv
)
endif()
add_definitions(-DGLEW_STATIC)
if(WITH_GL_EGL AND NOT (WITH_HEADLESS OR WITH_GHOST_SDL))
list(APPEND SRC
intern/GHOST_ContextEGL.cpp
intern/GHOST_ContextEGL.h
)
endif()
if(APPLE)
list(APPEND SRC
intern/GHOST_SystemPathsCocoa.mm
intern/GHOST_SystemPathsCocoa.h
)
elseif(UNIX)
list(APPEND SRC
intern/GHOST_SystemPathsX11.cpp
intern/GHOST_SystemPathsX11.h
)
if(NOT WITH_INSTALL_PORTABLE)
add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
endif()
elseif(WIN32)
list(APPEND SRC
intern/GHOST_SystemPathsWin32.cpp
intern/GHOST_SystemPathsWin32.h
)
endif()
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}")

@ -674,9 +674,17 @@ extern GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int
/**
* Gets the current swap interval for swapBuffers.
* \return An integer.
* \param windowhandle The handle to the window
* \param intervalOut pointer to location to return swap interval (left untouched if there is an error)
* \return A boolean success indicator of if swap interval was successfully read.
*/
extern int GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle);
extern GHOST_TSuccess GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle, int* intervalOut);
/**
* Gets the current swap interval for swapBuffers.
* \return Number of AA Samples (0 if there is no multisample buffer)
*/
extern GHOST_TUns16 GHOST_GetNumOfAASamples(GHOST_WindowHandle windowhandle);
/**
* Activates the drawing context of this window.

@ -212,9 +212,17 @@ public:
/**
* Gets the current swap interval for swapBuffers.
* \return An integer.
* \param windowhandle The handle to the window
* \param intervalOut pointer to location to return swap interval (left untouched if there is an error)
* \return A boolean success indicator of if swap interval was successfully read.
*/
virtual int getSwapInterval() = 0;
virtual GHOST_TSuccess getSwapInterval(int& intervalOut) = 0;
/**
* Gets the current swap interval for swapBuffers.
* \return Number of AA Samples (0 if there is no multisample buffer)
*/
virtual GHOST_TUns16 getNumOfAASamples() = 0;
/**
* Activates the drawing context of this window.

@ -36,22 +36,33 @@ sources = env.Glob('intern/*.cpp')
sources2 = env.Glob('intern/GHOST_NDOFManager3Dconnexion.c')
if window_system == 'darwin':
sources += env.Glob('intern/*.mm')
#remove, will be readded below if needed.
sources.remove('intern' + os.sep + 'GHOST_ContextCGL.mm')
if not env['WITH_BF_GL_EGL']:
sources.remove('intern' + os.sep + 'GHOST_ContextEGL.cpp')
pf = ['GHOST_DisplayManager', 'GHOST_System', 'GHOST_SystemPaths', 'GHOST_Window', 'GHOST_DropTarget', 'GHOST_NDOFManager']
defs=['_USE_MATH_DEFINES', 'GLEW_STATIC']
# seems cleaner to remove these now then add back the one that is needed
sources.remove('intern' + os.sep + 'GHOST_ContextGLX.cpp')
sources.remove('intern' + os.sep + 'GHOST_ContextWGL.cpp')
pf = ['GHOST_DisplayManager', 'GHOST_System', 'GHOST_SystemPaths', 'GHOST_Window', 'GHOST_DropTarget', 'GHOST_NDOFManager', 'GHOST_Context']
defs = env['BF_GL_DEFINITIONS']
if env['WITH_BF_GL_EGL']:
defs.append('WITH_EGL')
incs = [
'.',
'#extern/glew/include',
env['BF_GLEW_INC'],
'../glew-mx',
'#source/blender/imbuf',
'#source/blender/makesdna',
'../string',
]
incs = ' '.join(incs)
incs += ' ' + env['BF_OPENGL_INC']
if env['WITH_GHOST_SDL']:
for f in pf:
try:
@ -65,9 +76,16 @@ elif window_system in ('linux', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'f
for f in pf:
try:
sources.remove('intern' + os.sep + f + 'Win32.cpp')
except ValueError:
pass
try:
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
defs += ['WITH_X11']
## removing because scons does not support system installation
## if this is used for blender.org builds it means our distrobution
## will find any locally installed blender and double up its script path.
@ -88,23 +106,45 @@ elif window_system in ('linux', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'f
else:
sources.remove('intern' + os.sep + 'GHOST_DropTargetX11.cpp')
if not env['WITH_BF_GL_EGL']:
sources.append('intern' + os.sep + 'GHOST_ContextGLX.cpp')
elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-vc', 'win64-mingw'):
for f in pf:
try:
sources.remove('intern' + os.sep + f + 'X11.cpp')
except ValueError:
pass
try:
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
if not env['WITH_BF_GL_EGL']:
sources.append('intern' + os.sep + 'GHOST_ContextWGL.cpp')
elif window_system == 'darwin':
if env['WITH_BF_QUICKTIME']:
defs.append('WITH_QUICKTIME')
for f in pf:
try:
sources.remove('intern' + os.sep + f + 'Win32.cpp')
sources.remove('intern' + os.sep + f + 'X11.cpp')
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
if env['WITH_BF_QUICKTIME']:
defs.append('WITH_QUICKTIME')
for f in pf:
try:
sources.remove('intern' + os.sep + f + 'Win32.cpp')
except ValueError:
pass
try:
sources.remove('intern' + os.sep + f + 'X11.cpp')
except ValueError:
pass
try:
sources.remove('intern' + os.sep + f + 'SDL.cpp')
except ValueError:
pass
if not env['WITH_BF_GL_EGL']:
sources.append('intern' + os.sep + 'GHOST_ContextCGL.mm')
else:
print "Unknown window system specified."
Exit()

@ -144,15 +144,9 @@ GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
const GHOST_TUns16 numOfAASamples)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
bool bstereoVisual;
if (stereoVisual)
bstereoVisual = true;
else
bstereoVisual = false;
return (GHOST_WindowHandle) system->createWindow(title, left, top, width, height,
state, type, bstereoVisual, false,
state, type, stereoVisual != 0, false,
numOfAASamples);
}
@ -698,14 +692,21 @@ GHOST_TSuccess GHOST_SetSwapInterval(GHOST_WindowHandle windowhandle, int interv
return window->setSwapInterval(interval);
}
int GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_GetSwapInterval(GHOST_WindowHandle windowhandle, int* intervalOut)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
return window->getSwapInterval();
return window->getSwapInterval(*intervalOut);
}
GHOST_TUns16 GHOST_GetNumOfAASamples(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
return window->getNumOfAASamples();
}
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;

@ -0,0 +1,155 @@
/*
* ***** 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"
#ifdef _WIN32
# include <GL/wglew.h> // only for symbolic constants, do not use API functions
# include <tchar.h>
#endif
#include <cstdio>
#include <cstring>
#ifdef _WIN32
bool win32_chk(bool result, const char *file, int line, const char *text)
{
if (!result) {
LPTSTR formattedMsg = NULL;
DWORD error = GetLastError();
const char *msg;
DWORD count = 0;
switch (error) {
case ERROR_INVALID_VERSION_ARB:
msg = "The specified OpenGL version and feature set are either invalid or not supported.\n";
break;
case ERROR_INVALID_PROFILE_ARB:
msg = "The specified OpenGL profile and feature set are either invalid or not supported.\n";
break;
case ERROR_INVALID_PIXEL_TYPE_ARB:
msg = "The specified pixel type is invalid.\n";
break;
case ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB:
msg = ("The device contexts specified are not compatible. "
"This can occur if the device contexts are managed by "
"different drivers or possibly on different graphics adapters.\n");
break;
#ifdef WITH_GLEW_ES
case ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV:
msg = "The device context(s) and rendering context have non-matching affinity masks.\n";
break;
case ERROR_MISSING_AFFINITY_MASK_NV:
msg = "The rendering context does not have an affinity mask set.\n";
break;
#endif
case ERROR_PROFILE_DOES_NOT_MATCH_DEVICE:
msg = ("The specified profile is intended for a device of a "
"different type than the specified device.\n");
break;
default:
{
count =
FormatMessage(
(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS),
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)(&formattedMsg),
0,
NULL);
msg = count > 0 ? formattedMsg : "<no system message>\n";
break;
}
}
#ifndef NDEBUG
_ftprintf(
stderr,
"%s(%d):[%s] -> Win32 Error# (%d): %s",
file,
line,
text,
error,
msg);
#else
_ftprintf(
stderr,
"Win32 Error# (%d): %s",
error,
msg);
#endif
SetLastError(NO_ERROR);
if (count != 0)
LocalFree(formattedMsg);
}
return result;
}
#endif // _WIN32
void GHOST_Context::initContextGLEW()
{
mxDestroyContext(m_mxContext); // no-op if m_mxContext is NULL
mxMakeCurrentContext(mxCreateContext());
m_mxContext = mxGetCurrentContext();
}
void GHOST_Context::initClearGL()
{
glClearColor(0.447, 0.447, 0.447, 0.000);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.000, 0.000, 0.000, 0.000);
}

@ -0,0 +1,161 @@
/*
* ***** 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"
#include "glew-mx.h"
#include <cstdlib> // for NULL
class GHOST_Context
{
public:
/**
* Constructor.
* \param stereoVisual Stereo visual for quad buffered stereo.
* \param numOfAASamples Number of samples used for AA (zero if no AA)
*/
GHOST_Context(bool stereoVisual, GHOST_TUns16 numOfAASamples)
: m_stereoVisual(stereoVisual),
m_numOfAASamples(numOfAASamples),
m_mxContext(NULL)
{}
/**
* Destructor.
*/
virtual ~GHOST_Context() {
mxDestroyContext(m_mxContext);
}
/**
* 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.
* \return Indication as to whether initialization has succeeded.
*/
virtual GHOST_TSuccess initializeDrawingContext() = 0;
/**
* Updates the drawing context of this window. Needed
* whenever the window is changed.
* \return Indication of success.
*/
virtual GHOST_TSuccess updateDrawingContext() {
return GHOST_kFailure;
}
/**
* Checks if it is OK for a remove the native display
* \return Indication as to whether removal has succeeded.
*/
virtual GHOST_TSuccess releaseNativeHandles() = 0;
/**
* Sets the swap interval for swapBuffers.
* \param interval The swap interval to use.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess setSwapInterval(int interval) {
return GHOST_kFailure;
}
/**
* Gets the current swap interval for swapBuffers.
* \param intervalOut Variable to store the swap interval if it can be read.
* \return Whether the swap interval can be read.
*/
virtual GHOST_TSuccess getSwapInterval(int&) {
return GHOST_kFailure;
}
/** Stereo visual created. Only necessary for 'real' stereo support,
* ie quad buffered stereo. This is not always possible, depends on
* the graphics h/w
*/
inline bool isStereoVisual() const {
return m_stereoVisual;
}
/** Number of samples used in anti-aliasing, set to 0 if no AA **/
inline GHOST_TUns16 getNumOfAASamples() const {
return m_numOfAASamples;
}
protected:
void initContextGLEW();
inline void activateGLEW() const {
mxMakeCurrentContext(m_mxContext);
}
bool m_stereoVisual;
GHOST_TUns16 m_numOfAASamples;
static void initClearGL();
private:
MXContext *m_mxContext;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_Context")
#endif
};
#ifdef _WIN32
bool win32_chk(bool result, const char *file = NULL, int line = 0, const char *text = NULL);
# ifndef NDEBUG
# define WIN32_CHK(x) win32_chk((x), __FILE__, __LINE__, #x)
# else
# define WIN32_CHK(x) win32_chk(x)
# endif
#endif /* _WIN32 */
#endif // __GHOST_CONTEXT_H__

@ -0,0 +1,153 @@
/*
* ***** 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) 2014 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
*/
#ifndef __GHOST_CONTEXTCGL_H__
#define __GHOST_CONTEXTCGL_H__
#include "GHOST_Context.h"
//#define cglewGetContext() cglewContext
//#include <GL/cglew.h>
//extern "C" CGLEWContext *cglewContext;
#ifndef GHOST_OPENGL_CGL_CONTEXT_FLAGS
#define GHOST_OPENGL_CGL_CONTEXT_FLAGS 0
#endif
#ifndef GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY
#define GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY 0
#endif
@class NSWindow;
@class NSOpenGLView;
@class NSOpenGLContext;
class GHOST_ContextCGL : public GHOST_Context
{
public:
/**
* Constructor.
*/
GHOST_ContextCGL(
bool stereoVisual,
GHOST_TUns16 numOfAASamples,
NSWindow *window,
NSOpenGLView *openGLView,
int contextProfileMask,
int contextMajorVersion,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy);
/**
* 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.
* \return Indication as to whether initialization has succeeded.
*/
virtual GHOST_TSuccess initializeDrawingContext();
/**
* Removes references to native handles from this context and then returns
* \return GHOST_kSuccess if it is OK for the parent to release the handles and
* GHOST_kFailure if releasing the handles will interfere with sharing
*/
virtual GHOST_TSuccess releaseNativeHandles();
/**
* Sets the swap interval for swapBuffers.
* \param interval The swap interval to use.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess setSwapInterval(int interval);
/**
* Gets the current swap interval for swapBuffers.
* \param intervalOut Variable to store the swap interval if it can be read.
* \return Whether the swap interval can be read.
*/
virtual GHOST_TSuccess getSwapInterval(int&);
/**
* Updates the drawing context of this window.
* Needed whenever the window is changed.
* \return Indication of success.
*/
virtual GHOST_TSuccess updateDrawingContext();
//protected:
// inline void activateCGLEW() const {
// cglewContext = m_cglewContext;
// }
private:
//void initContextCGLEW()
/** The window containing the OpenGL view */
NSWindow *m_window;
/** The openGL view */
NSOpenGLView *m_openGLView;
const int m_contextProfileMask;
const int m_contextMajorVersion;
const int m_contextMinorVersion;
const int m_contextFlags;
const int m_contextResetNotificationStrategy;
/** The opgnGL drawing context */
NSOpenGLContext *m_openGLContext;
//static CGLEWContext *s_cglewContext;
/** The first created OpenGL context (for sharing display lists) */
static NSOpenGLContext *s_sharedOpenGLContext;
static int s_sharedCount;
};
#endif // __GHOST_CONTEXTCGL_H__

@ -0,0 +1,351 @@
/*
* ***** 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"
#include <Cocoa/Cocoa.h>
#ifdef GHOST_MULTITHREADED_OPENGL
#include <OpenGL/OpenGL.h>
#endif
#include <vector>
#include <cassert>
NSOpenGLContext *GHOST_ContextCGL::s_sharedOpenGLContext = nil;
int GHOST_ContextCGL::s_sharedCount = 0;
GHOST_ContextCGL::GHOST_ContextCGL(
bool stereoVisual,
GHOST_TUns16 numOfAASamples,
NSWindow *window,
NSOpenGLView *openGLView,
int contextProfileMask,
int contextMajorVersion,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy)
: GHOST_Context(stereoVisual, numOfAASamples),
m_window(window),
m_openGLView(openGLView),
m_contextProfileMask(contextProfileMask),
m_contextMajorVersion(contextMajorVersion),
m_contextMinorVersion(contextMinorVersion),
m_contextFlags(contextFlags),
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
m_openGLContext(nil)
{
assert(window != nil);
assert(openGLView != nil);
}
GHOST_ContextCGL::~GHOST_ContextCGL()
{
if (m_openGLContext != nil) {
if (m_openGLContext == [NSOpenGLContext currentContext])
[NSOpenGLContext clearCurrentContext];
[m_openGLView clearGLContext];
if (m_openGLContext != s_sharedOpenGLContext || s_sharedCount == 1) {
assert(s_sharedCount > 0);
s_sharedCount--;
if (s_sharedCount == 0)
s_sharedOpenGLContext = nil;
[m_openGLContext release];
}
}
}
GHOST_TSuccess GHOST_ContextCGL::swapBuffers()
{
if (m_openGLContext != nil) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext flushBuffer];
[pool drain];
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess GHOST_ContextCGL::setSwapInterval(int interval)
{
if (m_openGLContext != nil) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext setValues:&interval forParameter:NSOpenGLCPSwapInterval];
[pool drain];
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess GHOST_ContextCGL::getSwapInterval(int &intervalOut)
{
if (m_openGLContext != nil) {
GLint interval;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext setValues:&interval forParameter:NSOpenGLCPSwapInterval];
[pool drain];
intervalOut = static_cast<int>(interval);
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess GHOST_ContextCGL::activateDrawingContext()
{
if (m_openGLContext != nil) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext makeCurrentContext];
activateGLEW();
[pool drain];
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess GHOST_ContextCGL::updateDrawingContext()
{
if (m_openGLContext != nil) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext update];
[pool drain];
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
static void makeAttribList(
std::vector<NSOpenGLPixelFormatAttribute>& attribs,
bool stereoVisual,
int numOfAASamples,
bool needAlpha,
bool needStencil)
{
// Pixel Format Attributes for the windowed NSOpenGLContext
attribs.push_back(NSOpenGLPFADoubleBuffer);
// Guarantees the back buffer contents to be valid after a call to NSOpenGLContext object's flushBuffer
// needed for 'Draw Overlap' drawing method
attribs.push_back(NSOpenGLPFABackingStore);
// Force software OpenGL, for debugging
/* XXX jwilkins: fixed this to work on Intel macs? useful feature for Windows and Linux too?
* Maybe a command line flag is better... */
if (getenv("BLENDER_SOFTWAREGL")) {
attribs.push_back(NSOpenGLPFARendererID);
#if defined(__ppc__) || defined(__ppc64__)
attribs.push_back(kCGLRendererAppleSWID);
#else
attribs.push_back(kCGLRendererGenericFloatID);
#endif
}
else {
attribs.push_back(NSOpenGLPFAAccelerated);
}
/* Removed to allow 10.4 builds, and 2 GPUs rendering is not used anyway */
//attribs.push_back(NSOpenGLPFAAllowOfflineRenderers);
attribs.push_back(NSOpenGLPFADepthSize);
attribs.push_back((NSOpenGLPixelFormatAttribute) 32);
if (stereoVisual)
attribs.push_back(NSOpenGLPFAStereo);
if (needAlpha) {
attribs.push_back(NSOpenGLPFAAlphaSize);
attribs.push_back((NSOpenGLPixelFormatAttribute) 8);
}
if (needStencil) {
attribs.push_back(NSOpenGLPFAStencilSize);
attribs.push_back((NSOpenGLPixelFormatAttribute) 8);
}
if (numOfAASamples > 0) {
// Multisample anti-aliasing
attribs.push_back(NSOpenGLPFAMultisample);
attribs.push_back(NSOpenGLPFASampleBuffers);
attribs.push_back((NSOpenGLPixelFormatAttribute) 1);
attribs.push_back(NSOpenGLPFASamples);
attribs.push_back((NSOpenGLPixelFormatAttribute) numOfAASamples);
attribs.push_back(NSOpenGLPFANoRecovery);
}
attribs.push_back((NSOpenGLPixelFormatAttribute) 0);
}
GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
std::vector<NSOpenGLPixelFormatAttribute> attribs;
attribs.reserve(40);
NSOpenGLContext *prev_openGLContext = [m_openGLView openGLContext];
#ifdef GHOST_OPENGL_ALPHA
static const bool needAlpha = true;
#else
static const bool needAlpha = false;
#endif
#ifdef GHOST_OPENGL_STENCIL
static const bool needStencil = true;
#else
static const bool needStencil = false;
#endif
makeAttribList(attribs, m_stereoVisual, m_numOfAASamples, needAlpha, needStencil);
NSOpenGLPixelFormat *pixelFormat;
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
// Fall back to no multisampling if Antialiasing init failed
if (m_numOfAASamples > 0 && pixelFormat == nil) {
// XXX jwilkins: Does CGL only succeed when it makes an exact match on the number of samples?
// Does this need to explicitly try for a lesser match before giving up?
// (Now that I think about it, does WGL really require the code that it has for finding a lesser match?)
attribs.clear();
makeAttribList(attribs, m_stereoVisual, 0, needAlpha, needStencil);
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]];
}
if (pixelFormat == nil)
goto error;
if (m_numOfAASamples > 0) { //Set m_numOfAASamples to the actual value
GLint actualSamples;
[pixelFormat getValues:&actualSamples forAttribute:NSOpenGLPFASamples forVirtualScreen:0];
if (m_numOfAASamples != (GHOST_TUns16)actualSamples) {
fprintf(stderr,
"Warning! Unable to find a multisample pixel format that supports exactly %d samples. "
"Substituting one that uses %d samples.\n",
m_numOfAASamples, actualSamples);
m_numOfAASamples = (GHOST_TUns16)actualSamples;
}
}
[m_openGLView setPixelFormat:pixelFormat];
m_openGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:s_sharedOpenGLContext];
if (m_openGLContext == nil)
goto error;
if (s_sharedCount == 0)
s_sharedOpenGLContext = m_openGLContext;
s_sharedCount++;
#ifdef GHOST_MULTITHREADED_OPENGL
//Switch openGL to multhreaded mode
CGLContextObj cglCtx = (CGLContextObj)[tmpOpenGLContext CGLContextObj];
if (CGLEnable(cglCtx, kCGLCEMPEngine) == kCGLNoError)
printf("\nSwitched openGL to multithreaded mode\n");
#endif
#ifdef GHOST_WAIT_FOR_VSYNC
{
GLint swapInt = 1;
/* wait for vsync, to avoid tearing artifacts */
[m_openGLContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
}
#endif
[m_openGLView setOpenGLContext:m_openGLContext];
[m_openGLContext setView:m_openGLView];
initContextGLEW();
initClearGL();
[m_openGLContext flushBuffer];
[pool drain];
return GHOST_kSuccess;
error:
[m_openGLView setOpenGLContext:prev_openGLContext];
[pool drain];
return GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextCGL::releaseNativeHandles()
{
m_openGLContext = NULL;
m_openGLView = NULL;
return GHOST_kSuccess;
}

@ -0,0 +1,638 @@
/*
* ***** 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 <set>
#include <sstream>
#include <vector>
#include <cassert>
#include <cstdio>
#include <cstring>
#ifdef WITH_GLEW_MX
EGLEWContext *eglewContext = NULL;
#endif
#define CASE_CODE_RETURN_STR(code) case code: return #code;
static const char *get_egl_error_enum_string(EGLenum error)
{
switch (error) {
CASE_CODE_RETURN_STR(EGL_SUCCESS)
CASE_CODE_RETURN_STR(EGL_NOT_INITIALIZED)
CASE_CODE_RETURN_STR(EGL_BAD_ACCESS)
CASE_CODE_RETURN_STR(EGL_BAD_ALLOC)
CASE_CODE_RETURN_STR(EGL_BAD_ATTRIBUTE)
CASE_CODE_RETURN_STR(EGL_BAD_CONTEXT)
CASE_CODE_RETURN_STR(EGL_BAD_CONFIG)
CASE_CODE_RETURN_STR(EGL_BAD_CURRENT_SURFACE)
CASE_CODE_RETURN_STR(EGL_BAD_DISPLAY)
CASE_CODE_RETURN_STR(EGL_BAD_SURFACE)
CASE_CODE_RETURN_STR(EGL_BAD_MATCH)
CASE_CODE_RETURN_STR(EGL_BAD_PARAMETER)
CASE_CODE_RETURN_STR(EGL_BAD_NATIVE_PIXMAP)
CASE_CODE_RETURN_STR(EGL_BAD_NATIVE_WINDOW)
CASE_CODE_RETURN_STR(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 bool bindAPI(EGLenum api)
{
#ifdef WITH_GLEW_MX
if (eglewContext != NULL)
#endif
{
if (EGLEW_VERSION_1_2) {
return (EGL_CHK(eglBindAPI(api)) == EGL_TRUE);
}
}
return false;
}
#ifdef WITH_GL_ANGLE
HMODULE GHOST_ContextEGL::s_d3dcompiler = NULL;
#endif
EGLContext GHOST_ContextEGL::s_gl_sharedContext = EGL_NO_CONTEXT;
EGLint GHOST_ContextEGL::s_gl_sharedCount = 0;
EGLContext GHOST_ContextEGL::s_gles_sharedContext = EGL_NO_CONTEXT;
EGLint GHOST_ContextEGL::s_gles_sharedCount = 0;
EGLContext GHOST_ContextEGL::s_vg_sharedContext = EGL_NO_CONTEXT;
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(
bool stereoVisual,
GHOST_TUns16 numOfAASamples,
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLint contextProfileMask,
EGLint contextMajorVersion,
EGLint contextMinorVersion,
EGLint contextFlags,
EGLint contextResetNotificationStrategy,
EGLenum api)
: GHOST_Context(stereoVisual, numOfAASamples),
m_nativeDisplay(nativeDisplay),
m_nativeWindow (nativeWindow),
m_contextProfileMask(contextProfileMask),
m_contextMajorVersion(contextMajorVersion),
m_contextMinorVersion(contextMinorVersion),
m_contextFlags(contextFlags),
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
m_api(api),
m_context(EGL_NO_CONTEXT),
m_surface(EGL_NO_SURFACE),
m_display(EGL_NO_DISPLAY),
m_swap_interval(1),
#ifdef WITH_GLEW_MX
m_eglewContext(NULL),
#endif
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))
{
assert(m_nativeWindow != 0);
assert(m_nativeDisplay != NULL);
}
GHOST_ContextEGL::~GHOST_ContextEGL()
{
if (m_display != EGL_NO_DISPLAY) {
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));
#ifdef WITH_GLEW_MX
delete m_eglewContext;
#endif
}
}
GHOST_TSuccess GHOST_ContextEGL::swapBuffers()
{
return EGL_CHK(::eglSwapBuffers(m_display, m_surface)) ? GHOST_kSuccess : GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextEGL::setSwapInterval(int interval)
{
if (EGLEW_VERSION_1_1) {
if (EGL_CHK(::eglSwapInterval(m_display, interval))) {
m_swap_interval = interval;
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess GHOST_ContextEGL::getSwapInterval(int &intervalOut)
{
intervalOut = m_swap_interval; // XXX jwilkins: make sure there is no way to query this?
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextEGL::activateDrawingContext()
{
if (m_display) {
activateEGLEW();
activateGLEW();
bindAPI(m_api);
return EGL_CHK(::eglMakeCurrent(m_display, m_surface, m_surface, m_context)) ? GHOST_kSuccess : GHOST_kFailure;
}
else {
return GHOST_kFailure;
}
}
void GHOST_ContextEGL::initContextEGLEW()
{
#ifdef WITH_GLEW_MX
eglewContext = new EGLEWContext;
memset(eglewContext, 0, sizeof(EGLEWContext));
delete m_eglewContext;
m_eglewContext = eglewContext;
#endif
if (GLEW_CHK(eglewInit(m_display)) != GLEW_OK)
fprintf(stderr, "Warning! EGLEW failed to initialize properly.\n");
}
static const std::string &api_string(EGLenum api)
{
static const std::string a("OpenGL");
static const std::string b("OpenGL ES");
static const std::string c("OpenVG");
return choose_api(api, a, b, c);
}
GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
{
// objects have to be declared here due to the use of goto
std::vector<EGLint> attrib_list;
EGLint num_config = 0;
if (m_stereoVisual)
fprintf(stderr, "Warning! Stereo OpenGL ES contexts are not supported.\n");
m_stereoVisual = false; // It doesn't matter what the Window wants.
#ifdef WITH_GL_ANGLE
// d3dcompiler_XX.dll needs to be loaded before ANGLE will work
if (s_d3dcompiler == NULL) {
s_d3dcompiler = LoadLibrary(D3DCOMPILER);
WIN32_CHK(s_d3dcompiler != NULL);
if (s_d3dcompiler == NULL) {
fprintf(stderr, "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 egl_major, egl_minor;
if (!EGL_CHK(::eglInitialize(m_display, &egl_major, &egl_minor)))
goto error;
fprintf(stderr, "EGL Version %d.%d\n", egl_major, egl_minor);
if (!EGL_CHK(::eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)))
goto error;
initContextEGLEW();
if (!bindAPI(m_api))
goto error;
// build attribute list
attrib_list.reserve(20);
if (m_api == EGL_OPENGL_ES_API && EGLEW_VERSION_1_2) {
// According to the spec it seems that you are required to set EGL_RENDERABLE_TYPE,
// but some implementations (ANGLE) do not seem to care.
if (m_contextMajorVersion == 1) {
attrib_list.push_back(EGL_RENDERABLE_TYPE);
attrib_list.push_back(EGL_OPENGL_ES_BIT);
}
else if (m_contextMajorVersion == 2) {
attrib_list.push_back(EGL_RENDERABLE_TYPE);
attrib_list.push_back(EGL_OPENGL_ES2_BIT);
}
else if (m_contextMajorVersion == 3) {
attrib_list.push_back(EGL_RENDERABLE_TYPE);
attrib_list.push_back(EGL_OPENGL_ES3_BIT_KHR);
}
else {
fprintf(stderr,
"Warning! Unable to request an ES context of version %d.%d\n",
m_contextMajorVersion, m_contextMinorVersion);
}
if (!((m_contextMajorVersion == 1) ||
(m_contextMajorVersion == 2 && EGLEW_VERSION_1_3) ||
(m_contextMajorVersion == 3 && /*EGLEW_VERSION_1_4 &&*/ EGLEW_KHR_create_context) ||
(m_contextMajorVersion == 3 && EGLEW_VERSION_1_5)))
{
fprintf(stderr,
"Warning! May not be able to create a version %d.%d ES context with version %d.%d of EGL\n",
m_contextMajorVersion, m_contextMinorVersion, egl_major, egl_minor);
}
}
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 (m_numOfAASamples > 0) {
attrib_list.push_back(EGL_SAMPLE_BUFFERS);
attrib_list.push_back(1);
attrib_list.push_back(EGL_SAMPLES);
attrib_list.push_back(m_numOfAASamples);
}
attrib_list.push_back(EGL_NONE);
EGLConfig config;
if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &config, 1, &num_config)))
goto error;
// A 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;
if (m_numOfAASamples > 0) {
EGLint actualSamples;
if (!EGL_CHK(::eglGetConfigAttrib(m_display, config, EGL_SAMPLE_BUFFERS, &actualSamples)))
goto error;
if (m_numOfAASamples != actualSamples) {
fprintf(stderr,
"Warning! Unable to find a multisample pixel format that supports exactly %d samples. "
"Substituting one that uses %d samples.\n",
m_numOfAASamples,
actualSamples);
m_numOfAASamples = (GHOST_TUns16)actualSamples;
}
}
m_surface = ::eglCreateWindowSurface(m_display, config, m_nativeWindow, NULL);
if (!EGL_CHK(m_surface != EGL_NO_SURFACE))
goto error;
attrib_list.clear();
if (EGLEW_VERSION_1_5 || EGLEW_KHR_create_context) {
if (m_api == EGL_OPENGL_API || m_api == EGL_OPENGL_ES_API) {
if (m_contextMajorVersion != 0) {
attrib_list.push_back(EGL_CONTEXT_MAJOR_VERSION_KHR);
attrib_list.push_back(m_contextMajorVersion);
}
if (m_contextMinorVersion != 0) {
attrib_list.push_back(EGL_CONTEXT_MINOR_VERSION_KHR);
attrib_list.push_back(m_contextMinorVersion);
}
if (m_contextFlags != 0) {
attrib_list.push_back(EGL_CONTEXT_FLAGS_KHR);
attrib_list.push_back(m_contextFlags);
}
}
else {
if (m_contextMajorVersion != 0 || m_contextMinorVersion != 0) {
fprintf(stderr,
"Warning! Cannot request specific versions of %s contexts.",
api_string(m_api).c_str());
}
if (m_contextFlags != 0) {
fprintf(stderr,
"Warning! Flags cannot be set on %s contexts.",
api_string(m_api).c_str());
}
}
if (m_api == EGL_OPENGL_API) {
if (m_contextProfileMask != 0) {
attrib_list.push_back(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);
attrib_list.push_back(m_contextProfileMask);
}
}
else {
if (m_contextProfileMask != 0)
fprintf(stderr,
"Warning! Cannot select profile for %s contexts.",
api_string(m_api).c_str());
}
if (m_api == EGL_OPENGL_API || EGLEW_VERSION_1_5) {
if (m_contextResetNotificationStrategy != 0) {
attrib_list.push_back(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR);
attrib_list.push_back(m_contextResetNotificationStrategy);
}
}
else {
if (m_contextResetNotificationStrategy != 0) {
fprintf(stderr,
"Warning! EGL %d.%d cannot set the reset notification strategy on %s contexts.",
egl_major, egl_minor, api_string(m_api).c_str());
}
}
}
else {
if (m_api == EGL_OPENGL_ES_API) {
if (m_contextMajorVersion != 0) {
attrib_list.push_back(EGL_CONTEXT_CLIENT_VERSION);
attrib_list.push_back(m_contextMajorVersion);
}
}
else {
if (m_contextMajorVersion != 0 || m_contextMinorVersion != 0) {
fprintf(stderr,
"Warning! EGL %d.%d is unable to select between versions of %s.",
egl_major, egl_minor, api_string(m_api).c_str());
}
}
if (m_contextFlags != 0) {
fprintf(stderr,
"Warning! EGL %d.%d is unable to set context flags.",
egl_major, egl_minor);
}
if (m_contextProfileMask != 0) {
fprintf(stderr,
"Warning! EGL %d.%d is unable to select between profiles.",
egl_major, egl_minor);
}
if (m_contextResetNotificationStrategy != 0) {
fprintf(stderr,
"Warning! EGL %d.%d is unable to set the reset notification strategies.",
egl_major, egl_minor);
}
}
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;
initContextGLEW();
initClearGL();
::eglSwapBuffers(m_display, m_surface);
return GHOST_kSuccess;
error:
if (prev_display != EGL_NO_DISPLAY)
EGL_CHK(eglMakeCurrent(prev_display, prev_draw, prev_read, prev_context));
return GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextEGL::releaseNativeHandles()
{
m_nativeWindow = 0;
m_nativeDisplay = NULL;
return GHOST_kSuccess;
}

@ -0,0 +1,167 @@
/*
* ***** 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
*/
#ifndef __GHOST_CONTEXTEGL_H__
#define __GHOST_CONTEXTEGL_H__
#include "GHOST_Context.h"
#ifdef WITH_GLEW_MX
# define eglewGetContext() eglewContext
#endif
#include <GL/eglew.h>
#ifdef WITH_GLEW_MX
extern "C" EGLEWContext *eglewContext;
#endif
#ifndef GHOST_OPENGL_EGL_CONTEXT_FLAGS
#define GHOST_OPENGL_EGL_CONTEXT_FLAGS 0
#endif
#ifndef GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY
#define GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY 0
#endif
class GHOST_ContextEGL : public GHOST_Context
{
public:
/**
* Constructor.
*/
GHOST_ContextEGL(
bool stereoVisual,
GHOST_TUns16 numOfAASamples,
EGLNativeWindowType nativeWindow,
EGLNativeDisplayType nativeDisplay,
EGLint contextProfileMask,
EGLint contextMajorVersion,
EGLint contextMinorVersion,
EGLint contextFlags,
EGLint contextResetNotificationStrategy,
EGLenum api);
/**
* 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();
/**
* Call immediately after new to initialize. If this fails then immediately delete the object.
* \return Indication as to whether initialization has succeeded.
*/
virtual GHOST_TSuccess initializeDrawingContext();
/**
* Removes references to native handles from this context and then returns
* \return GHOST_kSuccess if it is OK for the parent to release the handles and
* GHOST_kFailure if releasing the handles will interfere with sharing
*/
virtual GHOST_TSuccess releaseNativeHandles();
/**
* Sets the swap interval for swapBuffers.
* \param interval The swap interval to use.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess setSwapInterval(int interval);
/**
* Gets the current swap interval for swapBuffers.
* \param intervalOut Variable to store the swap interval if it can be read.
* \return Whether the swap interval can be read.
*/
GHOST_TSuccess getSwapInterval(int &intervalOut);
protected:
inline void activateEGLEW() const {
#ifdef WITH_GLEW_MX
eglewContext = m_eglewContext;
#endif
}
private:
void initContextEGLEW();
EGLNativeDisplayType m_nativeDisplay;
EGLNativeWindowType m_nativeWindow;
const EGLint m_contextProfileMask;
const EGLint m_contextMajorVersion;
const EGLint m_contextMinorVersion;
const EGLint m_contextFlags;
const EGLint m_contextResetNotificationStrategy;
const EGLenum m_api;
EGLContext m_context;
EGLSurface m_surface;
EGLDisplay m_display;
EGLint m_swap_interval;
#ifdef WITH_GLEW_MX
EGLEWContext *m_eglewContext;
#endif
EGLContext &m_sharedContext;
EGLint &m_sharedCount;
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;
#ifdef WITH_GL_ANGLE
static HMODULE s_d3dcompiler;
#endif
};
#endif // __GHOST_CONTEXTEGL_H__

@ -0,0 +1,341 @@
/*
* ***** 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) 2014 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_ContextGLX.cpp
* \ingroup GHOST
*
* Definition of GHOST_ContextGLX class.
*/
#include "GHOST_ContextGLX.h"
#include "GHOST_SystemX11.h"
#include <vector>
#include <cassert>
#include <cstdio>
#include <cstring>
#ifdef WITH_GLEW_MX
GLXEWContext *glxewContext = NULL;
#endif
GLXContext GHOST_ContextGLX::s_sharedContext = None;
int GHOST_ContextGLX::s_sharedCount = 0;
GHOST_ContextGLX::GHOST_ContextGLX(
bool stereoVisual,
GHOST_TUns16 numOfAASamples,
Window window,
Display *display,
int contextProfileMask,
int contextMajorVersion,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy)
: GHOST_Context(stereoVisual, numOfAASamples),
m_display(display),
m_window(window),
m_contextProfileMask(contextProfileMask),
m_contextMajorVersion(contextMajorVersion),
m_contextMinorVersion(contextMinorVersion),
m_contextFlags(contextFlags),
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
m_visualInfo(NULL),
m_context(None)
#ifdef WITH_GLEW_MX
,
m_glxewContext(NULL)
#endif
{
assert(m_window != 0);
assert(m_display != NULL);
}
GHOST_ContextGLX::~GHOST_ContextGLX()
{
if (m_display != NULL) {
activateGLXEW();
if (m_context != None) {
if (m_window != 0 && m_context == ::glXGetCurrentContext())
::glXMakeCurrent(m_display, m_window, NULL);
if (m_context != s_sharedContext || s_sharedCount == 1) {
assert(s_sharedCount > 0);
s_sharedCount--;
if (s_sharedCount == 0)
s_sharedContext = NULL;
::glXDestroyContext(m_display, m_context);
}
}
#ifdef WITH_GLEW_MX
delete m_glxewContext;
#endif
}
XFree(m_visualInfo);
}
GHOST_TSuccess GHOST_ContextGLX::swapBuffers()
{
::glXSwapBuffers(m_display, m_window);
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextGLX::activateDrawingContext()
{
if (m_display) {
activateGLXEW();
activateGLEW();
return ::glXMakeCurrent(m_display, m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure;
}
else {
return GHOST_kFailure;
}
}
void GHOST_ContextGLX::initContextGLXEW()
{
#ifdef WITH_GLEW_MX
glxewContext = new GLXEWContext;
memset(glxewContext, 0, sizeof(GLXEWContext));
delete m_glxewContext;
m_glxewContext = glxewContext;
#endif
initContextGLEW();
}
GHOST_TSuccess GHOST_ContextGLX::initializeDrawingContext()
{
/* Set up the minimum attributes that we require and see if
* X can find us a visual matching those requirements. */
std::vector<int> attribs;
attribs.reserve(40);
int glx_major, glx_minor; /* GLX version: major.minor */
if (!glXQueryVersion(m_display, &glx_major, &glx_minor)) {
fprintf(stderr,
"%s:%d: X11 glXQueryVersion() failed, "
"verify working openGL system!\n",
__FILE__, __LINE__);
/* exit if this is the first window */
if (s_sharedContext == NULL) {
fprintf(stderr, "initial window could not find the GLX extension, exit!\n");
exit(EXIT_FAILURE);
}
return GHOST_kFailure;
}
#ifdef GHOST_OPENGL_ALPHA
const bool needAlpha = true;
#else
const bool needAlpha = false;
#endif
#ifdef GHOST_OPENGL_STENCIL
const bool needStencil = true;
#else
const bool needStencil = false;
#endif
/* Find the display with highest samples, starting at level requested */
int actualSamples = m_numOfAASamples;
for (;;) {
attribs.clear();
if (m_stereoVisual)
attribs.push_back(GLX_STEREO);
attribs.push_back(GLX_RGBA);
attribs.push_back(GLX_DOUBLEBUFFER);
attribs.push_back(GLX_RED_SIZE);
attribs.push_back(1);
attribs.push_back(GLX_BLUE_SIZE);
attribs.push_back(1);
attribs.push_back(GLX_GREEN_SIZE);
attribs.push_back(1);
attribs.push_back(GLX_DEPTH_SIZE);
attribs.push_back(1);
if (needAlpha) {
attribs.push_back(GLX_ALPHA_SIZE);
attribs.push_back(1);
}
if (needStencil) {
attribs.push_back(GLX_STENCIL_SIZE);
attribs.push_back(1);
}
/* GLX >= 1.4 required for multi-sample */
if (actualSamples > 0 && ((glx_major > 1) || (glx_major == 1 && glx_minor >= 4))) {
attribs.push_back(GLX_SAMPLE_BUFFERS);
attribs.push_back(1);
attribs.push_back(GLX_SAMPLES);
attribs.push_back(actualSamples);
}
attribs.push_back(None);
m_visualInfo = glXChooseVisual(m_display, DefaultScreen(m_display), &attribs[0]);
/* Any sample level or even zero, which means oversampling disabled, is good
* but we need a valid visual to continue */
if (m_visualInfo != NULL) {
if (actualSamples < m_numOfAASamples) {
fprintf(stderr,
"Warning! Unable to find a multisample pixel format that supports exactly %d samples. "
"Substituting one that uses %d samples.\n",
m_numOfAASamples, actualSamples);
}
break;
}
if (actualSamples == 0) {
/* All options exhausted, cannot continue */
fprintf(stderr,
"%s:%d: X11 glXChooseVisual() failed, "
"verify working openGL system!\n",
__FILE__, __LINE__);
if (s_sharedContext == None) {
fprintf(stderr, "initial window could not find the GLX extension, exit!\n");
exit(1);
}
return GHOST_kFailure;
}
else {
--actualSamples;
}
}
m_numOfAASamples = actualSamples;
#ifdef WITH_X11_XINPUT
/* use our own event handlers to avoid exiting blender,
* this would happen for eg:
* if you open blender, unplug a tablet, then open a new window. */
XErrorHandler old_handler = XSetErrorHandler (GHOST_X11_ApplicationErrorHandler );
XIOErrorHandler old_handler_io = XSetIOErrorHandler(GHOST_X11_ApplicationIOErrorHandler);
#endif
m_context = glXCreateContext(m_display, m_visualInfo, s_sharedContext, True);
GHOST_TSuccess success;
if (m_context != NULL) {
if (!s_sharedContext)
s_sharedContext = m_context;
s_sharedCount++;
glXMakeCurrent(m_display, m_window, m_context);
// Seems that this has to be called after MakeCurrent,
// which means we cannot use glX extensions until after we create a context
initContextGLXEW();
initClearGL();
::glXSwapBuffers(m_display, m_window);
success = GHOST_kSuccess;
}
else {
success = GHOST_kFailure;
}
#ifdef WITH_X11_XINPUT
/* Restore handler */
XSetErrorHandler (old_handler);
XSetIOErrorHandler(old_handler_io);
#endif
return success;
}
GHOST_TSuccess GHOST_ContextGLX::releaseNativeHandles()
{
m_window = 0;
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextGLX::setSwapInterval(int interval)
{
if (GLXEW_EXT_swap_control) {
::glXSwapIntervalEXT(m_display, m_window, interval);
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess GHOST_ContextGLX::getSwapInterval(int &intervalOut)
{
if (GLXEW_EXT_swap_control) {
unsigned int interval = 0;
::glXQueryDrawable(m_display, m_window, GLX_SWAP_INTERVAL_EXT, &interval);
intervalOut = static_cast<int>(interval);
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}

@ -0,0 +1,150 @@
/*
* ***** 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) 2014 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_ContextGLX.h
* \ingroup GHOST
*/
#ifndef __GHOST_CONTEXTGLX_H__
#define __GHOST_CONTEXTGLX_H__
#include "GHOST_Context.h"
#ifdef WITH_GLEW_MX
# define glxewGetContext() glxewContext
#endif
#include <GL/glxew.h>
#ifdef WITH_GLEW_MX
extern "C" GLXEWContext *glxewContext;
#endif
#ifndef GHOST_OPENGL_GLX_CONTEXT_FLAGS
#define GHOST_OPENGL_GLX_CONTEXT_FLAGS 0
#endif
#ifndef GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY
#define GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY 0
#endif
class GHOST_ContextGLX : public GHOST_Context
{
public:
/**
* Constructor.
*/
GHOST_ContextGLX(
bool stereoVisual,
GHOST_TUns16 numOfAASamples,
Window window,
Display *display,
int contextProfileMask,
int contextMajorVersion,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy);
/**
* Destructor.
*/
virtual ~GHOST_ContextGLX();
/**
* 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.
* \return Indication as to whether initialization has succeeded.
*/
virtual GHOST_TSuccess initializeDrawingContext();
/**
* Removes references to native handles from this context and then returns
* \return GHOST_kSuccess if it is OK for the parent to release the handles and
* GHOST_kFailure if releasing the handles will interfere with sharing
*/
virtual GHOST_TSuccess releaseNativeHandles();
/**
* Sets the swap interval for swapBuffers.
* \param interval The swap interval to use.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess setSwapInterval(int interval);
/**
* Gets the current swap interval for swapBuffers.
* \param intervalOut Variable to store the swap interval if it can be read.
* \return Whether the swap interval can be read.
*/
virtual GHOST_TSuccess getSwapInterval(int &intervalOut);
protected:
inline void activateGLXEW() const {
#ifdef WITH_GLEW_MX
glxewContext = m_glxewContext;
#endif
}
private:
void initContextGLXEW();
Display *m_display;
Window m_window;
const int m_contextProfileMask;
const int m_contextMajorVersion;
const int m_contextMinorVersion;
const int m_contextFlags;
const int m_contextResetNotificationStrategy;
XVisualInfo *m_visualInfo;
GLXContext m_context;
#ifdef WITH_GLEW_MX
GLXEWContext *m_glxewContext;
#endif
/** The first created OpenGL context (for sharing display lists) */
static GLXContext s_sharedContext;
static int s_sharedCount;
};
#endif // __GHOST_CONTEXTGLX_H__

@ -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_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::updateDrawingContext()
{
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextNone::initializeDrawingContext()
{
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextNone::releaseNativeHandles()
{
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextNone::setSwapInterval(int interval)
{
m_swapInterval = interval;
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextNone::getSwapInterval(int &intervalOut)
{
intervalOut = m_swapInterval;
return GHOST_kSuccess;
}

@ -0,0 +1,97 @@
/*
* ***** 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:
GHOST_ContextNone(
bool stereoVisual,
GHOST_TUns16 numOfAASamples)
: GHOST_Context(stereoVisual, numOfAASamples),
m_swapInterval(1)
{}
/**
* Dummy function
* \return Always succeeds
*/
virtual GHOST_TSuccess swapBuffers();
/**
* Dummy function
* \return Always succeeds
*/
virtual GHOST_TSuccess activateDrawingContext();
/**
* Dummy function
* \return Always succeeds
*/
virtual GHOST_TSuccess updateDrawingContext();
/**
* Dummy function
* \return Always succeeds
*/
virtual GHOST_TSuccess initializeDrawingContext();
/**
* Dummy function
* \return Always succeeds
*/
virtual GHOST_TSuccess releaseNativeHandles();
/**
* Dummy function
* \return Always succeeds
*/
virtual GHOST_TSuccess setSwapInterval(int interval);
/**
* Dummy function
* \param intervalOut Gets whatever was set by setSwapInterval
* \return Always succeeds
*/
virtual GHOST_TSuccess getSwapInterval(int &intervalOut);
private:
int m_swapInterval;
};
#endif // __GHOST_CONTEXTNONE_H__

@ -0,0 +1,204 @@
/*
* ***** 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) 2014 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_ContextSDL.cpp
* \ingroup GHOST
*
* Definition of GHOST_ContextSDL class.
*/
#include "GHOST_ContextSDL.h"
#include <vector>
#include <cassert>
#include <cstdio>
#include <cstring>
SDL_GLContext GHOST_ContextSDL::s_sharedContext = NULL;
int GHOST_ContextSDL::s_sharedCount = 0;
GHOST_ContextSDL::GHOST_ContextSDL(
bool stereoVisual,
GHOST_TUns16 numOfAASamples,
SDL_Window *window,
int contextProfileMask,
int contextMajorVersion,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy)
: GHOST_Context(stereoVisual, numOfAASamples),
m_window(window),
m_contextProfileMask(contextProfileMask),
m_contextMajorVersion(contextMajorVersion),
m_contextMinorVersion(contextMinorVersion),
m_contextFlags(contextFlags),
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
m_context(NULL)
{
assert(m_window != NULL);
}
GHOST_ContextSDL::~GHOST_ContextSDL()
{
if (m_context != NULL) {
if (m_window != 0 && m_context == SDL_GL_GetCurrentContext())
SDL_GL_MakeCurrent(m_window, m_context);
if (m_context != s_sharedContext || s_sharedCount == 1) {
assert(s_sharedCount > 0);
s_sharedCount--;
if (s_sharedCount == 0)
s_sharedContext = NULL;
SDL_GL_DeleteContext(m_context);
}
}
}
GHOST_TSuccess GHOST_ContextSDL::swapBuffers()
{
SDL_GL_SwapWindow(m_window);
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextSDL::activateDrawingContext()
{
if (m_context) {
activateGLEW();
return SDL_GL_MakeCurrent(m_window, m_context) ? GHOST_kSuccess : GHOST_kFailure;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess GHOST_ContextSDL::initializeDrawingContext()
{
#ifdef GHOST_OPENGL_ALPHA
const bool needAlpha = true;
#else
const bool needAlpha = false;
#endif
#ifdef GHOST_OPENGL_STENCIL
const bool needStencil = true;
#else
const bool needStencil = false;
#endif
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, m_contextProfileMask);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, m_contextMajorVersion);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, m_contextMinorVersion);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, m_contextFlags);
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
if (needAlpha) {
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
}
if (needStencil) {
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
}
if (m_stereoVisual) {
SDL_GL_SetAttribute(SDL_GL_STEREO, 1);
}
if (m_numOfAASamples) {
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, m_numOfAASamples);
}
m_context = SDL_GL_CreateContext(m_window);
GHOST_TSuccess success;
if (m_context != NULL) {
if (!s_sharedContext)
s_sharedContext = m_context;
s_sharedCount++;
success = (SDL_GL_MakeCurrent(m_window, m_context) < 0) ?
GHOST_kFailure : GHOST_kSuccess;
initContextGLEW();
initClearGL();
SDL_GL_SwapWindow(m_window);
success = GHOST_kSuccess;
}
else {
success = GHOST_kFailure;
}
return success;
}
GHOST_TSuccess GHOST_ContextSDL::releaseNativeHandles()
{
m_window = NULL;
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_ContextSDL::setSwapInterval(int interval)
{
if (SDL_GL_SetSwapInterval(interval) != -1) {
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess GHOST_ContextSDL::getSwapInterval(int &intervalOut)
{
intervalOut = SDL_GL_GetSwapInterval();
return GHOST_kSuccess;
}

@ -0,0 +1,127 @@
/*
* ***** 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) 2014 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_ContextSDL.h
* \ingroup GHOST
*/
#ifndef __GHOST_CONTEXTSDL_H__
#define __GHOST_CONTEXTSDL_H__
#include "GHOST_Context.h"
extern "C" {
#include "SDL.h"
}
#ifndef GHOST_OPENGL_SDL_CONTEXT_FLAGS
#define GHOST_OPENGL_SDL_CONTEXT_FLAGS 0
#endif
#ifndef GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY
#define GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY 0
#endif
class GHOST_ContextSDL : public GHOST_Context
{
public:
/**
* Constructor.
*/
GHOST_ContextSDL(
bool stereoVisual,
GHOST_TUns16 numOfAASamples,
SDL_Window *window,
int contextProfileMask,
int contextMajorVersion,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy);
/**
* Destructor.
*/
virtual ~GHOST_ContextSDL();
/**
* 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.
* \return Indication as to whether initialization has succeeded.
*/
virtual GHOST_TSuccess initializeDrawingContext();
/**
* Removes references to native handles from this context and then returns
* \return GHOST_kSuccess if it is OK for the parent to release the handles and
* GHOST_kFailure if releasing the handles will interfere with sharing
*/
virtual GHOST_TSuccess releaseNativeHandles();
/**
* Sets the swap interval for swapBuffers.
* \param interval The swap interval to use.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess setSwapInterval(int interval);
/**
* Gets the current swap interval for swapBuffers.
* \param intervalOut Variable to store the swap interval if it can be read.
* \return Whether the swap interval can be read.
*/
virtual GHOST_TSuccess getSwapInterval(int &intervalOut);
private:
SDL_Window *m_window;
const int m_contextProfileMask;
const int m_contextMajorVersion;
const int m_contextMinorVersion;
const int m_contextFlags;
const int m_contextResetNotificationStrategy;
SDL_GLContext m_context; /* m_sdl_glcontext */
/** The first created OpenGL context (for sharing display lists) */
static SDL_GLContext s_sharedContext;
static int s_sharedCount;
};
#endif // __GHOST_CONTEXTSDL_H__

@ -0,0 +1,876 @@
/*
* ***** 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.cpp
* \ingroup GHOST
*
* Definition of GHOST_ContextWGL class.
*/
#include "GHOST_ContextWGL.h"
#include <tchar.h>
#include <cstdio>
#include <cassert>
#include <vector>
#ifdef WITH_GLEW_MX
WGLEWContext *wglewContext = NULL;
#endif
HGLRC GHOST_ContextWGL::s_sharedHGLRC = NULL;
int GHOST_ContextWGL::s_sharedCount = 0;
bool GHOST_ContextWGL::s_singleContextMode = false;
/* Intel video-cards 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 bool is_crappy_intel_card()
{
return strstr((const char *)glGetString(GL_VENDOR), "Intel") != NULL;
}
GHOST_ContextWGL::GHOST_ContextWGL(
bool stereoVisual,
GHOST_TUns16 numOfAASamples,
HWND hWnd,
HDC hDC,
int contextProfileMask,
int contextMajorVersion,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy)
: GHOST_Context(stereoVisual, numOfAASamples),
m_hWnd(hWnd),
m_hDC(hDC),
m_contextProfileMask(contextProfileMask),
m_contextMajorVersion(contextMajorVersion),
m_contextMinorVersion(contextMinorVersion),
m_contextFlags(contextFlags),
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
m_hGLRC(NULL)
#ifdef WITH_GLEW_MX
,
m_wglewContext(NULL)
#endif
#ifndef NDEBUG
,
m_dummyVendor(NULL),
m_dummyRenderer(NULL),
m_dummyVersion(NULL)
#endif
{
assert(m_hWnd);
assert(m_hDC);
}
GHOST_ContextWGL::~GHOST_ContextWGL()
{
if (m_hGLRC != NULL) {
if (m_hGLRC == ::wglGetCurrentContext())
WIN32_CHK(::wglMakeCurrent(NULL, NULL));
if (m_hGLRC != s_sharedHGLRC || s_sharedCount == 1) {
assert(s_sharedCount > 0);
s_sharedCount--;
if (s_sharedCount == 0)
s_sharedHGLRC = NULL;
WIN32_CHK(::wglDeleteContext(m_hGLRC));
}
}
#ifdef WITH_GLEW_MX
delete m_wglewContext;
#endif
#ifndef NDEBUG
delete m_dummyRenderer;
delete m_dummyVendor;
delete m_dummyVersion;
#endif
}
GHOST_TSuccess GHOST_ContextWGL::swapBuffers()
{
return WIN32_CHK(::SwapBuffers(m_hDC)) ? GHOST_kSuccess : GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextWGL::setSwapInterval(int interval)
{
if (WGLEW_EXT_swap_control)
return WIN32_CHK(::wglSwapIntervalEXT(interval)) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
else
return GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextWGL::getSwapInterval(int &intervalOut)
{
if (WGLEW_EXT_swap_control) {
intervalOut = ::wglGetSwapIntervalEXT();
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess GHOST_ContextWGL::activateDrawingContext()
{
if (WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) {
activateGLEW();
return GHOST_kSuccess;
}
else {
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 weight_pixel_format(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.iPixelType == PFD_TYPE_RGBA) ||
(pfd.cDepthBits < 16) ||
(pfd.dwFlags & PFD_GENERIC_FORMAT)) /* no software renderers */
{
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
#ifdef GHOST_OPENGL_STENCIL
if (pfd.cStencilBits >= 8)
weight++;
#endif
/* want swap copy capability -- it matters a lot */
if (pfd.dwFlags & PFD_SWAP_COPY)
weight += 16;
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 choose_pixel_format_legacy(HDC hDC, PIXELFORMATDESCRIPTOR &preferredPFD)
{
int iPixelFormat = 0;
int weight = 0;
int iStereoPixelFormat = 0;
int stereoWeight = 0;
/* choose a pixel format using the useless Windows function in case we come up empty handed */
int iLastResortPixelFormat = ::ChoosePixelFormat(hDC, &preferredPFD);
WIN32_CHK(iLastResortPixelFormat != 0);
int lastPFD = ::DescribePixelFormat(hDC, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
WIN32_CHK(lastPFD != 0);
for (int i = 1; i <= lastPFD; i++) {
PIXELFORMATDESCRIPTOR pfd;
int check = ::DescribePixelFormat(hDC, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
WIN32_CHK(check == lastPFD);
int w = weight_pixel_format(pfd);
if (w > weight) {
weight = w;
iPixelFormat = i;
}
if (w > stereoWeight && (preferredPFD.dwFlags & pfd.dwFlags & PFD_STEREO)) {
stereoWeight = w;
iStereoPixelFormat = i;
}
}
/* choose any available stereo format over a non-stereo format */
if (iStereoPixelFormat != 0)
iPixelFormat = iStereoPixelFormat;
if (iPixelFormat == 0) {
fprintf(stderr, "Warning! Using result of ChoosePixelFormat.\n");
iPixelFormat = iLastResortPixelFormat;
}
return iPixelFormat;
}
/*
* Clone a window for the purpose of creating a temporary context to initialize WGL extensions.
* There is no generic way to clone the lpParam parameter, so the caller is responsible for cloning it themselves.
*/
static HWND clone_window(HWND hWnd, LPVOID lpParam)
{
int count;
SetLastError(NO_ERROR);
DWORD dwExStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
WIN32_CHK(GetLastError() == NO_ERROR);
WCHAR lpClassName[100] = L"";
count = GetClassNameW(hWnd, lpClassName, sizeof(lpClassName));
WIN32_CHK(count != 0);
WCHAR lpWindowName[100] = L"";
count = GetWindowTextW(hWnd, lpWindowName, sizeof(lpWindowName));
WIN32_CHK(count != 0);
DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
WIN32_CHK(GetLastError() == NO_ERROR);
RECT rect;
GetWindowRect(hWnd, &rect);
WIN32_CHK(GetLastError() == NO_ERROR);
HWND hWndParent = (HWND)GetWindowLongPtr(hWnd, GWLP_HWNDPARENT);
WIN32_CHK(GetLastError() == NO_ERROR);
HMENU hMenu = GetMenu(hWnd);
WIN32_CHK(GetLastError() == NO_ERROR);
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
WIN32_CHK(GetLastError() == NO_ERROR);
HWND hwndCloned = CreateWindowExW(
dwExStyle,
lpClassName,
lpWindowName,
dwStyle,
rect.left,
rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
hWndParent,
hMenu,
hInstance,
lpParam);
WIN32_CHK(hwndCloned != NULL);
return hwndCloned;
}
void GHOST_ContextWGL::initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD)
{
#ifdef WITH_GLEW_MX
wglewContext = new WGLEWContext;
memset(wglewContext, 0, sizeof(WGLEWContext));
delete m_wglewContext;
m_wglewContext = wglewContext;
#endif
HWND dummyHWND = NULL;
HDC dummyHDC = NULL;
HGLRC dummyHGLRC = NULL;
SetLastError(NO_ERROR);
HDC prevHDC = ::wglGetCurrentDC();
WIN32_CHK(GetLastError() == NO_ERROR);
HGLRC prevHGLRC = ::wglGetCurrentContext();
WIN32_CHK(GetLastError() == NO_ERROR);
dummyHWND = clone_window(m_hWnd, NULL);
if (dummyHWND == NULL)
goto finalize;
dummyHDC = GetDC(dummyHWND);
if (!WIN32_CHK(dummyHDC != NULL))
goto finalize;
int iPixelFormat = choose_pixel_format_legacy(dummyHDC, preferredPFD);
if (iPixelFormat == 0)
goto finalize;
PIXELFORMATDESCRIPTOR chosenPFD;
if (!WIN32_CHK(::DescribePixelFormat(dummyHDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &chosenPFD)))
goto finalize;
if (!WIN32_CHK(::SetPixelFormat(dummyHDC, iPixelFormat, &chosenPFD)))
goto finalize;
dummyHGLRC = ::wglCreateContext(dummyHDC);
if (!WIN32_CHK(dummyHGLRC != NULL))
goto finalize;
if (!WIN32_CHK(::wglMakeCurrent(dummyHDC, dummyHGLRC)))
goto finalize;
#ifdef WITH_GLEW_MX
if (GLEW_CHK(wglewInit()) != GLEW_OK)
fprintf(stderr, "Warning! WGLEW failed to initialize properly.\n");
#else
if (GLEW_CHK(glewInit()) != GLEW_OK)
fprintf(stderr, "Warning! Dummy GLEW/WGLEW failed to initialize properly.\n");
#endif
// the following are not technially WGLEW, but they also require a context to work
#ifndef NDEBUG
delete m_dummyRenderer;
delete m_dummyVendor;
delete m_dummyVersion;
m_dummyRenderer = _strdup(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
m_dummyVendor = _strdup(reinterpret_cast<const char *>(glGetString(GL_VENDOR)));
m_dummyVersion = _strdup(reinterpret_cast<const char *>(glGetString(GL_VERSION)));
#endif
s_singleContextMode = is_crappy_intel_card();
finalize:
WIN32_CHK(::wglMakeCurrent(prevHDC, prevHGLRC));
if (dummyHGLRC != NULL)
WIN32_CHK(::wglDeleteContext(dummyHGLRC));
if (dummyHWND != NULL) {
if (dummyHDC != NULL)
WIN32_CHK(::ReleaseDC(dummyHWND, dummyHDC));
WIN32_CHK(::DestroyWindow(dummyHWND));
}
}
static void makeAttribList(
std::vector<int>& out,
bool stereoVisual,
int numOfAASamples,
int swapMethod,
bool needAlpha,
bool needStencil,
bool sRGB)
{
out.clear();
out.reserve(30);
out.push_back(WGL_SUPPORT_OPENGL_ARB);
out.push_back(GL_TRUE);
out.push_back(WGL_DRAW_TO_WINDOW_ARB);
out.push_back(GL_TRUE);
out.push_back(WGL_DOUBLE_BUFFER_ARB);
out.push_back(GL_TRUE);
out.push_back(WGL_ACCELERATION_ARB);
out.push_back(WGL_FULL_ACCELERATION_ARB);
out.push_back(WGL_SWAP_METHOD_ARB);
out.push_back(swapMethod);
if (stereoVisual) {
out.push_back(WGL_STEREO_ARB);
out.push_back(GL_TRUE);
}
out.push_back(WGL_PIXEL_TYPE_ARB);
out.push_back(WGL_TYPE_RGBA_ARB);
out.push_back(WGL_COLOR_BITS_ARB);
out.push_back(24);
out.push_back(WGL_DEPTH_BITS_ARB);
out.push_back(24);
if (needAlpha) {
out.push_back(WGL_ALPHA_BITS_ARB);
out.push_back(8);
}
if (needStencil) {
out.push_back(WGL_STENCIL_BITS_ARB);
out.push_back(8);
}
if (numOfAASamples > 0) {
out.push_back(WGL_SAMPLES_ARB);
out.push_back(numOfAASamples);
out.push_back(WGL_SAMPLE_BUFFERS_ARB);
out.push_back(1);
}
if (sRGB) {
out.push_back(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
out.push_back(GL_TRUE);
}
out.push_back(0);
}
int GHOST_ContextWGL::_choose_pixel_format_arb_2(
bool stereoVisual,
int numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB,
int swapMethod)
{
std::vector<int> iAttributes;
int iPixelFormat = 0;
int samples;
// guard against some insanely high number of samples
if (numOfAASamples > 64) {
fprintf(stderr, "Warning! Clamping number of samples to 64.\n");
samples = 64;
}
else {
samples = numOfAASamples;
}
// request a format with as many samples as possible, but not more than requested
while (samples >= 0) {
makeAttribList(
iAttributes,
stereoVisual,
samples,
swapMethod,
needAlpha,
needStencil,
sRGB);
UINT nNumFormats;
WIN32_CHK(wglChoosePixelFormatARB(m_hDC, &(iAttributes[0]), NULL, 1, &iPixelFormat, &nNumFormats));
/* total number of formats that match (regardless of size of iPixelFormat array)
* see: WGL_ARB_pixel_format extension spec */
if (nNumFormats > 0)
break;
/* if not reset, then the state of iPixelFormat is undefined after call to wglChoosePixelFormatARB
* see: WGL_ARB_pixel_format extension spec */
iPixelFormat = 0;
samples--;
}
// check how many samples were actually gotten
if (iPixelFormat != 0) {
int iQuery[] = { WGL_SAMPLES_ARB };
int actualSamples;
wglGetPixelFormatAttribivARB(m_hDC, iPixelFormat, 0, 1, iQuery, &actualSamples);
if (actualSamples != numOfAASamples) {
fprintf(stderr,
"Warning! Unable to find a multisample pixel format that supports exactly %d samples. "
"Substituting one that uses %d samples.\n",
numOfAASamples, actualSamples);
m_numOfAASamples = actualSamples; // set context property to actual value
}
}
return iPixelFormat;
}
int GHOST_ContextWGL::_choose_pixel_format_arb_1(
bool stereoVisual,
int numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB,
int &swapMethodOut)
{
int iPixelFormat;
swapMethodOut = WGL_SWAP_COPY_ARB;
iPixelFormat = _choose_pixel_format_arb_2(
stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut);
if (iPixelFormat == 0) {
swapMethodOut = WGL_SWAP_UNDEFINED_ARB;
iPixelFormat = _choose_pixel_format_arb_2(
stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut);
}
if (iPixelFormat == 0) {
swapMethodOut = WGL_SWAP_EXCHANGE_ARB;
iPixelFormat = _choose_pixel_format_arb_2(
stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut);
}
return iPixelFormat;
}
int GHOST_ContextWGL::choose_pixel_format_arb(
bool stereoVisual,
int numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB)
{
int iPixelFormat;
int swapMethodOut;
iPixelFormat = _choose_pixel_format_arb_1(
stereoVisual,
numOfAASamples,
needAlpha,
needStencil,
sRGB,
swapMethodOut);
if (iPixelFormat == 0 && stereoVisual) {
fprintf(stderr, "Warning! Unable to find a stereo pixel format.\n");
iPixelFormat = _choose_pixel_format_arb_1(
false,
numOfAASamples,
needAlpha,
needStencil,
sRGB,
swapMethodOut);
m_stereoVisual = false; // set context property to actual value
}
if (swapMethodOut != WGL_SWAP_COPY_ARB) {
fprintf(stderr,
"Warning! Unable to find a pixel format that supports WGL_SWAP_COPY_ARB. "
"Substituting one that uses %s.\n",
swapMethodOut == WGL_SWAP_UNDEFINED_ARB ? "WGL_SWAP_UNDEFINED_ARB" : "WGL_SWAP_EXCHANGE_ARB");
}
return iPixelFormat;
}
int GHOST_ContextWGL::choose_pixel_format(
bool stereoVisual,
int numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB)
{
PIXELFORMATDESCRIPTOR preferredPFD = {
sizeof(PIXELFORMATDESCRIPTOR), /* size */
1, /* version */
PFD_SUPPORT_OPENGL |
PFD_DRAW_TO_WINDOW |
PFD_SWAP_COPY | /* support swap copy */
PFD_DOUBLEBUFFER | /* support double-buffering */
(stereoVisual ? PFD_STEREO : 0), /* support stereo */
PFD_TYPE_RGBA, /* color type */
24, /* preferred color depth */
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
needAlpha ? 8 : 0, /* alpha buffer */
0, /* alpha shift (ignored) */
0, /* no accumulation buffer */
0, 0, 0, 0, /* accum bits (ignored) */
24, /* depth buffer */
needStencil ? 8 : 0, /* stencil buffer */
0, /* no auxiliary buffers */
PFD_MAIN_PLANE, /* main layer */
0, /* reserved */
0, 0, 0 /* layer, visible, and damage masks (ignored) */
};
initContextWGLEW(preferredPFD);
if (numOfAASamples > 0 && !WGLEW_ARB_multisample) {
fprintf(stderr, "Warning! Unable to request a multisample framebuffer.\n");
numOfAASamples = 0;
}
if (sRGB && !(WGLEW_ARB_framebuffer_sRGB || WGLEW_EXT_framebuffer_sRGB)) {
fprintf(stderr, "Warning! Unable to request an sRGB framebuffer.\n");
sRGB = false;
}
int iPixelFormat = 0;
if (WGLEW_ARB_pixel_format)
iPixelFormat = choose_pixel_format_arb(stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB);
if (iPixelFormat == 0)
iPixelFormat = choose_pixel_format_legacy(m_hDC, preferredPFD);
return iPixelFormat;
}
#ifndef NDEBUG
static void reportContextString(const char *name, const char *dummy, const char *context)
{
fprintf(stderr, "%s: %s\n", name, context);
if (strcmp(dummy, context) != 0)
fprintf(stderr, "Warning! Dummy %s: %s\n", name, dummy);
}
#endif
GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
{
SetLastError(NO_ERROR);
HGLRC prevHGLRC = ::wglGetCurrentContext();
WIN32_CHK(GetLastError() == NO_ERROR);
HDC prevHDC = ::wglGetCurrentDC();
WIN32_CHK(GetLastError() == NO_ERROR);
#ifdef GHOST_OPENGL_ALPHA
const bool needAlpha = true;
#else
const bool needAlpha = false;
#endif
#ifdef GHOST_OPENGL_STENCIL
const bool needStencil = true;
#else
const bool needStencil = false;
#endif
#ifdef GHOST_OPENGL_SRGB
static const bool sRGB = true;
#else
static const bool sRGB = false;
#endif
int iPixelFormat = choose_pixel_format(m_stereoVisual, m_numOfAASamples, needAlpha, needStencil, sRGB);
if (iPixelFormat == 0)
goto error;
PIXELFORMATDESCRIPTOR chosenPFD;
int lastPFD = ::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &chosenPFD);
if (!WIN32_CHK(lastPFD != 0))
goto error;
if (needAlpha && chosenPFD.cAlphaBits == 0)
fprintf(stderr, "Warning! Unable to find a pixel format with an alpha channel.\n");
if (needStencil && chosenPFD.cStencilBits == 0)
fprintf(stderr, "Warning! Unable to find a pixel format with a stencil buffer.\n");
if (!WIN32_CHK(::SetPixelFormat(m_hDC, iPixelFormat, &chosenPFD)))
goto error;
activateWGLEW();
if (WGLEW_ARB_create_context) {
int profileBitCore = m_contextProfileMask & WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
int profileBitCompat = m_contextProfileMask & WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
#ifdef WITH_GLEW_ES
int profileBitES = m_contextProfileMask & WGL_CONTEXT_ES_PROFILE_BIT_EXT;
#endif
if (!WGLEW_ARB_create_context_profile && profileBitCore)
fprintf(stderr, "Warning! OpenGL core profile not available.\n");
if (!WGLEW_ARB_create_context_profile && profileBitCompat)
fprintf(stderr, "Warning! OpenGL compatibility profile not available.\n");
#ifdef WITH_GLEW_ES
if (!WGLEW_EXT_create_context_es_profile && profileBitES && m_contextMajorVersion == 1)
fprintf(stderr, "Warning! OpenGL ES profile not available.\n");
if (!WGLEW_EXT_create_context_es2_profile && profileBitES && m_contextMajorVersion == 2)
fprintf(stderr, "Warning! OpenGL ES2 profile not available.\n");
#endif
int profileMask = 0;
if (WGLEW_ARB_create_context_profile && profileBitCore)
profileMask |= profileBitCore;
if (WGLEW_ARB_create_context_profile && profileBitCompat)
profileMask |= profileBitCompat;
#ifdef WITH_GLEW_ES
if (WGLEW_EXT_create_context_es_profile && profileBitES)
profileMask |= profileBitES;
#endif
if (profileMask != m_contextProfileMask)
fprintf(stderr, "Warning! Ignoring untested OpenGL context profile mask bits.");
std::vector<int> iAttributes;
if (profileMask) {
iAttributes.push_back(WGL_CONTEXT_PROFILE_MASK_ARB);
iAttributes.push_back(profileMask);
}
if (m_contextMajorVersion != 0) {
iAttributes.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB);
iAttributes.push_back(m_contextMajorVersion);
}
if (m_contextMinorVersion != 0) {
iAttributes.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);
iAttributes.push_back(m_contextMinorVersion);
}
if (m_contextFlags != 0) {
iAttributes.push_back(WGL_CONTEXT_FLAGS_ARB);
iAttributes.push_back(m_contextFlags);
}
if (m_contextResetNotificationStrategy != 0) {
if (WGLEW_ARB_create_context_robustness) {
iAttributes.push_back(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB);
iAttributes.push_back(m_contextResetNotificationStrategy);
}
else {
fprintf(stderr, "Warning! Cannot set the reset notification strategy.");
}
}
iAttributes.push_back(0);
if (!s_singleContextMode || s_sharedHGLRC == NULL)
m_hGLRC = ::wglCreateContextAttribsARB(m_hDC, NULL, &(iAttributes[0]));
else
m_hGLRC = s_sharedHGLRC;
}
else {
if (m_contextProfileMask != 0)
fprintf(stderr, "Warning! Legacy WGL is unable to select between OpenGL profiles.");
if (m_contextMajorVersion != 0 || m_contextMinorVersion != 0)
fprintf(stderr, "Warning! Legacy WGL is unable to select between OpenGL versions.");
if (m_contextFlags != 0)
fprintf(stderr, "Warning! Legacy WGL is unable to set context flags.");
if (!s_singleContextMode || s_sharedHGLRC == NULL)
m_hGLRC = ::wglCreateContext(m_hDC);
else
m_hGLRC = s_sharedHGLRC;
}
if (!WIN32_CHK(m_hGLRC != NULL))
goto error;
if (s_sharedHGLRC == NULL)
s_sharedHGLRC = m_hGLRC;
s_sharedCount++;
if (!s_singleContextMode && s_sharedHGLRC != m_hGLRC && !WIN32_CHK(::wglShareLists(s_sharedHGLRC, m_hGLRC)))
goto error;
if (!WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC)))
goto error;
initContextGLEW();
initClearGL();
::SwapBuffers(m_hDC);
#ifndef NDEBUG
reportContextString("Vendor", m_dummyVendor, reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
reportContextString("Renderer", m_dummyRenderer, reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
reportContextString("Version", m_dummyVersion, reinterpret_cast<const char*>(glGetString(GL_VERSION)));
#endif
return GHOST_kSuccess;
error:
::wglMakeCurrent(prevHDC, prevHGLRC);
return GHOST_kFailure;
}
GHOST_TSuccess GHOST_ContextWGL::releaseNativeHandles()
{
GHOST_TSuccess success = m_hGLRC != s_sharedHGLRC || s_sharedCount == 1 ? GHOST_kSuccess : GHOST_kFailure;
m_hWnd = NULL;
m_hDC = NULL;
return success;
}

@ -0,0 +1,184 @@
/*
* ***** 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
*/
#ifndef __GHOST_CONTEXTWGL_H__
#define __GHOST_CONTEXTWGL_H__
#include "GHOST_Context.h"
#ifdef WITH_GLEW_MX
#define wglewGetContext() wglewContext
#endif
#include <GL/wglew.h>
#ifdef WITH_GLEW_MX
extern "C" WGLEWContext *wglewContext;
#endif
#ifndef GHOST_OPENGL_WGL_CONTEXT_FLAGS
#define GHOST_OPENGL_WGL_CONTEXT_FLAGS 0
#endif
#ifndef GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY
#define GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY 0
#endif
class GHOST_ContextWGL : public GHOST_Context
{
public:
/**
* Constructor.
*/
GHOST_ContextWGL(
bool stereoVisual,
GHOST_TUns16 numOfAASamples,
HWND hWnd,
HDC hDC,
int contextProfileMask,
int contextMajorVersion,
int contextMinorVersion,
int contextFlags,
int contextResetNotificationStrategy);
/**
* 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.
* \return Indication as to whether initialization has succeeded.
*/
virtual GHOST_TSuccess initializeDrawingContext();
/**
* Removes references to native handles from this context and then returns
* \return GHOST_kSuccess if it is OK for the parent to release the handles and
* GHOST_kFailure if releasing the handles will interfere with sharing
*/
virtual GHOST_TSuccess releaseNativeHandles();
/**
* Sets the swap interval for swapBuffers.
* \param interval The swap interval to use.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess setSwapInterval(int interval);
/**
* Gets the current swap interval for swapBuffers.
* \param intervalOut Variable to store the swap interval if it can be read.
* \return Whether the swap interval can be read.
*/
virtual GHOST_TSuccess getSwapInterval(int &intervalOut);
protected:
inline void activateWGLEW() const {
#ifdef WITH_GLEW_MX
wglewContext = m_wglewContext;
#endif
}
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;
const int m_contextProfileMask;
const int m_contextMajorVersion;
const int m_contextMinorVersion;
const int m_contextFlags;
const int m_contextResetNotificationStrategy;
HGLRC m_hGLRC;
#ifdef WITH_GLEW_MX
WGLEWContext *m_wglewContext;
#endif
#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__

@ -38,21 +38,22 @@
#include "GHOST_ISystem.h"
#ifdef WITH_HEADLESS
# include "GHOST_SystemNULL.h"
#elif defined(WITH_GHOST_SDL)
# include "GHOST_SystemSDL.h"
#elif defined(WIN32)
# include "GHOST_SystemWin32.h"
#ifdef WITH_X11
# include "GHOST_SystemX11.h"
#else
# ifdef __APPLE__
# include "GHOST_SystemCocoa.h"
# ifdef WITH_HEADLESS
# include "GHOST_SystemNULL.h"
# elif defined(WITH_GHOST_SDL)
# include "GHOST_SystemSDL.h"
# elif defined(WIN32)
# include "GHOST_SystemWin32.h"
# else
# include "GHOST_SystemX11.h"
# ifdef __APPLE__
# include "GHOST_SystemCocoa.h"
# endif
# endif
#endif
GHOST_ISystem *GHOST_ISystem::m_system = 0;
@ -60,19 +61,21 @@ GHOST_TSuccess GHOST_ISystem::createSystem()
{
GHOST_TSuccess success;
if (!m_system) {
#ifdef WITH_HEADLESS
m_system = new GHOST_SystemNULL();
#elif defined(WITH_GHOST_SDL)
m_system = new GHOST_SystemSDL();
#elif defined(WIN32)
m_system = new GHOST_SystemWin32();
#else
# ifdef __APPLE__
m_system = new GHOST_SystemCocoa();
# else
#ifdef WITH_X11
m_system = new GHOST_SystemX11();
#else
# ifdef WITH_HEADLESS
m_system = new GHOST_SystemNULL();
# elif defined(WITH_GHOST_SDL)
m_system = new GHOST_SystemSDL();
# elif defined(WIN32)
m_system = new GHOST_SystemWin32();
# else
# ifdef __APPLE__
m_system = new GHOST_SystemCocoa();
# endif
# endif
#endif
#endif
success = m_system != 0 ? GHOST_kSuccess : GHOST_kFailure;
}
else {

@ -254,27 +254,6 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
}
#pragma mark defines for 10.6 api not documented in 10.5
#pragma mark Utility functions
#define FIRSTFILEBUFLG 512
static bool g_hasFirstFile = false;
static char g_firstFileBuf[512];
//TODO:Need to investigate this. Function called too early in creator.c to have g_hasFirstFile == true
extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
{
if (g_hasFirstFile) {
strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1);
buf[FIRSTFILEBUFLG - 1] = '\0';
return 1;
}
else {
return 0;
}
}
#pragma mark Cocoa objects
/**
@ -338,8 +317,6 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
#pragma mark initialization/finalization
char GHOST_user_locale[128]; // Global current user locale
GHOST_SystemCocoa::GHOST_SystemCocoa()
{
int mib[2];
@ -377,15 +354,6 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
rstring = NULL;
m_ignoreWindowSizedMessages = false;
//Get current locale
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
NSLocale * myNSLocale = (NSLocale *) myCFLocale;
[myNSLocale autorelease];
NSString *nsIdentifier = [myNSLocale localeIdentifier];
strncpy(GHOST_user_locale, [nsIdentifier UTF8String], sizeof(GHOST_user_locale) - 1);
[pool drain];
}
GHOST_SystemCocoa::~GHOST_SystemCocoa()
@ -567,25 +535,21 @@ GHOST_IWindow* GHOST_SystemCocoa::createWindow(
window = new GHOST_WindowCocoa (this, title, left, bottom, width, height, state, type, stereoVisual, numOfAASamples);
if (window) {
if (window->getValid()) {
// Store the pointer to the window
GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
m_windowManager->addWindow(window);
m_windowManager->setActiveWindow(window);
//Need to tell window manager the new window is the active one (Cocoa does not send the event activate upon window creation)
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window));
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
}
else {
GHOST_PRINT("GHOST_SystemCocoa::createWindow(): window invalid\n");
delete window;
window = 0;
}
if (window->getValid()) {
// Store the pointer to the window
GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
m_windowManager->addWindow(window);
m_windowManager->setActiveWindow(window);
//Need to tell window manager the new window is the active one (Cocoa does not send the event activate upon window creation)
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window));
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
}
else {
GHOST_PRINT("GHOST_SystemCocoa::createWindow(): could not create window\n");
GHOST_PRINT("GHOST_SystemCocoa::createWindow(): window invalid\n");
delete window;
window = 0;
}
[pool drain];
return window;
}

@ -231,44 +231,36 @@ GHOST_IWindow *GHOST_SystemWin32::createWindow(
GHOST_TInt32 left, GHOST_TInt32 top,
GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state, GHOST_TDrawingContextType type,
bool stereoVisual,
bool wantStereoVisual,
const bool exclusive,
const GHOST_TUns16 numOfAASamples,
const GHOST_TUns16 wantNumOfAASamples,
const GHOST_TEmbedderWindowID parentWindow)
{
GHOST_Window *window = 0;
window = new GHOST_WindowWin32(this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples, parentWindow);
if (window) {
if (window->getValid()) {
// Store the pointer to the window
// if (state != GHOST_kWindowStateFullScreen) {
m_windowManager->addWindow(window);
m_windowManager->setActiveWindow(window);
// }
}
else {
GHOST_Window *window =
new GHOST_WindowWin32(
this,
title,
left,
top,
width,
height,
state,
type,
wantStereoVisual,
wantNumOfAASamples,
parentWindow);
// 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;
}
}
if (window->getValid()) {
// Store the pointer to the window
m_windowManager->addWindow(window);
m_windowManager->setActiveWindow(window);
}
else {
GHOST_PRINT("GHOST_SystemWin32::createWindow(): window invalid\n");
delete window;
window = 0;
}
return window;
}

@ -55,6 +55,7 @@
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h> /* allow detectable autorepeate */
#include <X11/Xutil.h>
#ifdef WITH_XF86KEYSYM
#include <X11/XF86keysym.h>

@ -34,7 +34,6 @@
#define __GHOST_SYSTEMX11_H__
#include <X11/Xlib.h>
#include <GL/glx.h>
#include "GHOST_System.h"
#include "../GHOST_Types.h"

@ -38,21 +38,23 @@
#include "GHOST_Window.h"
#include "GHOST_ContextNone.h"
#include <assert.h>
GHOST_Window::GHOST_Window(
GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
const bool stereoVisual,
const bool wantStereoVisual,
const bool exclusive,
const GHOST_TUns16 numOfAASamples)
: m_drawingContextType(type),
const GHOST_TUns16 wantNumOfAASamples)
: m_drawingContextType(GHOST_kDrawingContextTypeNone),
m_cursorVisible(true),
m_cursorGrab(GHOST_kGrabDisable),
m_cursorShape(GHOST_kStandardCursorDefault),
m_stereoVisual(stereoVisual),
m_numOfAASamples(numOfAASamples)
m_wantStereoVisual(wantStereoVisual),
m_wantNumOfAASamples(wantNumOfAASamples),
m_context(new GHOST_ContextNone(false, 0))
{
m_isUnsavedChanges = false;
m_canAcceptDragOperation = false;
@ -74,6 +76,7 @@ GHOST_Window::GHOST_Window(
GHOST_Window::~GHOST_Window()
{
delete m_context;
}
void *GHOST_Window::getOSWindow() const
@ -83,18 +86,61 @@ void *GHOST_Window::getOSWindow() const
GHOST_TSuccess GHOST_Window::setDrawingContextType(GHOST_TDrawingContextType type)
{
GHOST_TSuccess success = GHOST_kSuccess;
if (type != m_drawingContextType) {
success = removeDrawingContext();
if (success) {
success = installDrawingContext(type);
delete m_context;
m_context = NULL;
if (type != GHOST_kDrawingContextTypeNone)
m_context = newDrawingContext(type);
if (m_context != NULL) {
m_drawingContextType = type;
}
else {
m_context = new GHOST_ContextNone(m_wantStereoVisual, m_wantNumOfAASamples);
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::setSwapInterval(int interval)
{
return m_context->setSwapInterval(interval);
}
GHOST_TSuccess GHOST_Window::getSwapInterval(int& intervalOut)
{
return m_context->getSwapInterval(intervalOut);
}
GHOST_TUns16 GHOST_Window::getNumOfAASamples()
{
return m_context->getNumOfAASamples();
}
GHOST_TSuccess GHOST_Window::activateDrawingContext()
{
return m_context->activateDrawingContext();
}
GHOST_TSuccess GHOST_Window::updateDrawingContext()
{
return m_context->updateDrawingContext();
}
GHOST_TSuccess GHOST_Window::releaseNativeHandles()
{
return m_context->releaseNativeHandles();
}
GHOST_TSuccess GHOST_Window::setCursorVisibility(bool visible)

@ -36,6 +36,7 @@
#include "GHOST_IWindow.h"
class STR_String;
class GHOST_Context;
/**
* Platform independent implementation of GHOST_IWindow.
@ -49,29 +50,6 @@ class STR_String;
class GHOST_Window : public GHOST_IWindow
{
public:
/**
* \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_TWindowOrder getOrder(void) = 0;
* virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
* virtual GHOST_TSuccess swapBuffers() = 0;
* virtual GHOST_TSuccess setSwapInterval() = 0;
* virtual int getSwapInterval() = 0;
* virtual GHOST_TSuccess activateDrawingContext() = 0;
* virtual GHOST_TSuccess invalidate() = 0;
*/
/**
* Constructor.
@ -90,10 +68,9 @@ public:
GHOST_TUns32 width,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
const bool stereoVisual = false,
const bool wantStereoVisual = false,
const bool exclusive = false,
const GHOST_TUns16 numOfAASamples = 0);
const GHOST_TUns16 wantNumOfAASamples = 0);
/**
* \section Interface inherited from GHOST_IWindow left for derived class
@ -113,7 +90,7 @@ public:
* virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order) = 0;
* virtual GHOST_TSuccess swapBuffers() = 0;
* virtual GHOST_TSuccess setSwapInterval() = 0;
* virtual int getSwapInterval() = 0;
* virtual GHOST_TSuccess getSwapInterval(int& intervalOut) = 0;
* virtual GHOST_TSuccess activateDrawingContext() = 0;
* virtual GHOST_TSuccess invalidate() = 0;
*/
@ -124,6 +101,14 @@ public:
*/
virtual ~GHOST_Window();
/**
* Returns indication as to whether the window is valid.
* \return The validity of the window.
*/
virtual bool getValid() const {
return m_context != 0;
}
/**
* Returns the associated OS object/handle
* \return The associated OS object/handle
@ -213,18 +198,20 @@ public:
* \param interval The swap interval to use.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess setSwapInterval(int interval) {
return GHOST_kFailure;
}
virtual GHOST_TSuccess setSwapInterval(int interval);
/**
* Gets the current swap interval for swapBuffers.
* \return An integer.
*/
virtual int getSwapInterval() {
return 0;
}
virtual GHOST_TSuccess getSwapInterval(int& intervalOut);
/**
* Gets the current swap interval for swapBuffers.
* \return Number of AA Samples (0 if there is no multisample buffer)
*/
virtual GHOST_TUns16 getNumOfAASamples();
/**
* Tells if the ongoing drag'n'drop object can be accepted upon mouse drop
*/
@ -257,13 +244,32 @@ public:
/**
* Tries to install a rendering context in this window.
* Child classes do not need to overload this method.
* They should overload the installDrawingContext and removeDrawingContext instead.
* Child classes do not need to overload this method,
* They should overload newDrawingContext instead.
* \param type The type of rendering context installed.
* \return Indication as to whether installation has succeeded.
*/
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();
/**
* Updates the drawing context of this window. Needed
* whenever the window is changed.
* \return Indication of success.
*/
virtual GHOST_TSuccess updateDrawingContext();
/**
* Returns the window user data.
* \return The window user data.
@ -295,13 +301,7 @@ protected:
* \param type The type of rendering context installed.
* \return Indication as to whether installation has succeeded.
*/
virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type) = 0;
/**
* Removes the current drawing context.
* \return Indication as to whether removal has succeeded.
*/
virtual GHOST_TSuccess removeDrawingContext() = 0;
virtual GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type) = 0;
/**
* Sets the cursor visibility on the window using
@ -333,6 +333,9 @@ protected:
virtual GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
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. */
GHOST_TDrawingContextType m_drawingContextType;
@ -369,14 +372,11 @@ protected:
/** Stores whether this is a full screen window. */
bool m_fullScreen;
/** Stereo visual created. Only necessary for 'real' stereo support,
* ie quad buffered stereo. This is not always possible, depends on
* the graphics h/w
*/
bool m_stereoVisual;
/** Number of samples used in anti-aliasing, set to 0 if no AA **/
GHOST_TUns16 m_numOfAASamples;
/** Whether to attempt to initialize a context with a stereo framebuffer. */
bool m_wantStereoVisual;
/** Attempt to initialize a context with this many samples. */
GHOST_TUns16 m_wantNumOfAASamples;
/** Full-screen width */
GHOST_TUns32 m_fullScreenWidth;
@ -385,6 +385,9 @@ protected:
/* OSX only, retina screens */
float m_nativePixelSize;
private:
GHOST_Context *m_context;
};

@ -42,6 +42,8 @@
@class CocoaWindow;
@class CocoaOpenGLView;
@class NSCursor;
@class NSScreen;
class GHOST_SystemCocoa;
@ -53,6 +55,7 @@ class GHOST_SystemCocoa;
* which is called the gutter.
* When OpenGL contexts are active, GHOST will use AGL_BUFFER_RECT to prevent
* OpenGL drawing outside the reduced client rectangle.
* XXX jwilkins: This comment seems out of date since we neither use Carbon nor AGL
* \author Maarten Gribnau
* \date May 23, 2001
*/
@ -220,28 +223,8 @@ public:
*/
virtual GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
/**
* Swaps front and back buffers of a window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess swapBuffers();
/**
* Updates the drawing context of this window. Needed
* whenever the window is changed.
* \return Indication of success.
*/
GHOST_TSuccess updateDrawingContext();
/**
* Activates the drawing context of this window.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess activateDrawingContext();
virtual void loadCursor(bool visible, GHOST_TStandardCursor cursor) const;
const GHOST_TabletData *GetTabletData()
{
return &m_tablet;
@ -278,19 +261,13 @@ public:
bool getImmediateDraw(void) const { return m_immediateDraw; }
protected:
/**
* Tries to install a rendering context in this window.
* \param type The type of rendering context installed.
* \return Indication as to whether installation has succeeded.
*/
virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
/**
* Removes the current drawing context.
* \return Indication as to whether removal has succeeded.
* \param type The type of rendering context create.
* \return Indication of success.
*/
virtual GHOST_TSuccess removeDrawingContext();
virtual GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type);
/**
* Invalidates the contents of this window.
* \return Indication of success.
@ -330,15 +307,9 @@ protected:
/** The openGL view */
CocoaOpenGLView *m_openGLView;
/** The opgnGL drawing context */
NSOpenGLContext *m_openGLContext;
/** The mother SystemCocoa class to send events */
GHOST_SystemCocoa *m_systemCocoa;
/** The first created OpenGL context (for sharing display lists) */
static NSOpenGLContext *s_firstOpenGLcontext;
NSCursor *m_customCursor;
GHOST_TabletData m_tablet;
@ -349,4 +320,3 @@ protected:
};
#endif // __GHOST_WINDOWCOCOA_H__

@ -20,30 +20,33 @@
*
* The Original Code is: all of this file.
*
* Contributor(s): Maarten Gribnau 05/2001
Damien Plisson 10/2009
* Contributor(s): Maarten Gribnau 05/2001
* Damien Plisson 10/2009
* Jason Wilkins 02/2014
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "GHOST_WindowCocoa.h"
#include "GHOST_SystemCocoa.h"
#include "GHOST_ContextNone.h"
#include "GHOST_Debug.h"
#if defined(WITH_GL_EGL)
# include "GHOST_ContextEGL.h"
#else
# include "GHOST_ContextCGL.h"
#endif
#include <Cocoa/Cocoa.h>
#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1050
//Use of the SetSystemUIMode function (64bit compatible)
#include <Carbon/Carbon.h>
//Use of the SetSystemUIMode function (64bit compatible)
# include <Carbon/Carbon.h>
#endif
#include <OpenGL/gl.h>
#include <OpenGL/CGLRenderers.h>
/***** Multithreaded opengl code : uncomment for enabling
#include <OpenGL/OpenGL.h>
*/
#include "GHOST_WindowCocoa.h"
#include "GHOST_SystemCocoa.h"
#include "GHOST_Debug.h"
#include <sys/sysctl.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
@ -535,8 +538,6 @@ enum {
@end
#endif
NSOpenGLContext* GHOST_WindowCocoa::s_firstOpenGLcontext = nil;
GHOST_WindowCocoa::GHOST_WindowCocoa(
GHOST_SystemCocoa *systemCocoa,
const STR_String& title,
@ -548,13 +549,9 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
GHOST_TDrawingContextType type,
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)
{
NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[40];
NSOpenGLPixelFormat *pixelFormat = nil;
int i;
m_systemCocoa = systemCocoa;
m_fullScreen = false;
m_immediateDraw = false;
@ -586,105 +583,11 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
minSize.height = 240;
[m_window setContentMinSize:minSize];
setTitle(title);
// Pixel Format Attributes for the windowed NSOpenGLContext
i=0;
pixelFormatAttrsWindow[i++] = NSOpenGLPFADoubleBuffer;
// Guarantees the back buffer contents to be valid after a call to NSOpenGLContext object's flushBuffer
// needed for 'Draw Overlap' drawing method
pixelFormatAttrsWindow[i++] = NSOpenGLPFABackingStore;
// Force software OpenGL, for debugging
if (getenv("BLENDER_SOFTWAREGL")) {
pixelFormatAttrsWindow[i++] = NSOpenGLPFARendererID;
pixelFormatAttrsWindow[i++] = kCGLRendererAppleSWID;
}
else
pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated;
//pixelFormatAttrsWindow[i++] = NSOpenGLPFAAllowOfflineRenderers,; // Removed to allow 10.4 builds, and 2 GPUs rendering is not used anyway
pixelFormatAttrsWindow[i++] = NSOpenGLPFADepthSize;
pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) 32;
pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccumSize;
pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) 32;
if (stereoVisual) pixelFormatAttrsWindow[i++] = NSOpenGLPFAStereo;
if (numOfAASamples > 0) {
// Multisample anti-aliasing
pixelFormatAttrsWindow[i++] = NSOpenGLPFAMultisample;
pixelFormatAttrsWindow[i++] = NSOpenGLPFASampleBuffers;
pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) 1;
pixelFormatAttrsWindow[i++] = NSOpenGLPFASamples;
pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) numOfAASamples;
pixelFormatAttrsWindow[i++] = NSOpenGLPFANoRecovery;
}
pixelFormatAttrsWindow[i] = (NSOpenGLPixelFormatAttribute) 0;
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttrsWindow];
//Fall back to no multisampling if Antialiasing init failed
if (pixelFormat == nil) {
i=0;
pixelFormatAttrsWindow[i++] = NSOpenGLPFADoubleBuffer;
// Guarantees the back buffer contents to be valid after a call to NSOpenGLContext object's flushBuffer
// needed for 'Draw Overlap' drawing method
pixelFormatAttrsWindow[i++] = NSOpenGLPFABackingStore;
// Force software OpenGL, for debugging
if (getenv("BLENDER_SOFTWAREGL")) {
pixelFormatAttrsWindow[i++] = NSOpenGLPFARendererID;
pixelFormatAttrsWindow[i++] = kCGLRendererAppleSWID;
}
else
pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated;
//pixelFormatAttrsWindow[i++] = NSOpenGLPFAAllowOfflineRenderers,; // Removed to allow 10.4 builds, and 2 GPUs rendering is not used anyway
pixelFormatAttrsWindow[i++] = NSOpenGLPFADepthSize;
pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) 32;
pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccumSize;
pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) 32;
if (stereoVisual) pixelFormatAttrsWindow[i++] = NSOpenGLPFAStereo;
pixelFormatAttrsWindow[i] = (NSOpenGLPixelFormatAttribute) 0;
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttrsWindow];
}
if (numOfAASamples > 0) { //Set m_numOfAASamples to the actual value
GLint gli;
[pixelFormat getValues:&gli forAttribute:NSOpenGLPFASamples forVirtualScreen:0];
if (m_numOfAASamples != (GHOST_TUns16)gli) {
m_numOfAASamples = (GHOST_TUns16)gli;
printf("GHOST_Window could be created with anti-aliasing of only %i samples\n",m_numOfAASamples);
}
}
//Creates the OpenGL View inside the window
m_openGLView = [[CocoaOpenGLView alloc] initWithFrame:rect
pixelFormat:pixelFormat];
m_openGLView = [[CocoaOpenGLView alloc] initWithFrame:rect];
[m_openGLView setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
[pixelFormat release];
m_openGLContext = [m_openGLView openGLContext]; //This context will be replaced by the proper one just after
[m_window setContentView:m_openGLView];
[m_window setInitialFirstResponder:m_openGLView];
@ -694,6 +597,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
updateDrawingContext();
activateDrawingContext();
// XXX jwilkins: This seems like it belongs in GHOST_ContextCGL, but probably not GHOST_ContextEGL
if (m_systemCocoa->m_nativePixel) {
if ([m_openGLView respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
[m_openGLView setWantsBestResolutionOpenGLSurface:YES];
@ -703,6 +607,8 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
}
}
setTitle(title);
m_tablet.Active = GHOST_kTabletModeNone;
CocoaWindowDelegate *windowDelegate = [[CocoaWindowDelegate alloc] init];
@ -750,6 +656,8 @@ GHOST_WindowCocoa::~GHOST_WindowCocoa()
m_customCursor = nil;
}
releaseNativeHandles();
[m_openGLView release];
if (m_window) {
@ -774,7 +682,7 @@ GHOST_WindowCocoa::~GHOST_WindowCocoa()
bool GHOST_WindowCocoa::getValid() const
{
return (m_window != 0);
return GHOST_Window::getValid() && m_window != 0 && m_openGLView != 0;
}
void* GHOST_WindowCocoa::getOSWindow() const
@ -1266,131 +1174,95 @@ GHOST_TSuccess GHOST_WindowCocoa::setOrder(GHOST_TWindowOrder order)
#pragma mark Drawing context
/*#define WAIT_FOR_VSYNC 1*/
GHOST_TSuccess GHOST_WindowCocoa::swapBuffers()
GHOST_Context *GHOST_WindowCocoa::newDrawingContext(GHOST_TDrawingContextType type)
{
if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
if (m_openGLContext != nil) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext flushBuffer];
[pool drain];
return GHOST_kSuccess;
}
}
return GHOST_kFailure;
}
if (type == GHOST_kDrawingContextTypeOpenGL) {
#if !defined(WITH_GL_EGL)
GHOST_TSuccess GHOST_WindowCocoa::updateDrawingContext()
{
if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
if (m_openGLContext != nil) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext update];
[pool drain];
return GHOST_kSuccess;
}
}
return GHOST_kFailure;
}
GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext()
{
if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
if (m_openGLContext != nil) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[m_openGLContext makeCurrentContext];
// Disable AA by default
if (m_numOfAASamples > 0) glDisable(GL_MULTISAMPLE_ARB);
[pool drain];
return GHOST_kSuccess;
}
}
return GHOST_kFailure;
}
GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextType type)
{
GHOST_TSuccess success = GHOST_kFailure;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSOpenGLPixelFormat *pixelFormat;
NSOpenGLContext *tmpOpenGLContext;
/***** Multithreaded opengl code : uncomment for enabling
CGLContextObj cglCtx;
*/
switch (type) {
case GHOST_kDrawingContextTypeOpenGL:
if (!getValid()) break;
pixelFormat = [m_openGLView pixelFormat];
tmpOpenGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
shareContext:s_firstOpenGLcontext];
if (tmpOpenGLContext == nil) {
success = GHOST_kFailure;
break;
}
//Switch openGL to multhreaded mode
/******* Multithreaded opengl code : uncomment for enabling
cglCtx = (CGLContextObj)[tmpOpenGLContext CGLContextObj];
if (CGLEnable(cglCtx, kCGLCEMPEngine) == kCGLNoError)
printf("\nSwitched openGL to multithreaded mode\n");
*/
if (!s_firstOpenGLcontext) s_firstOpenGLcontext = tmpOpenGLContext;
#ifdef WAIT_FOR_VSYNC
{
GLint swapInt = 1;
/* wait for vsync, to avoid tearing artifacts */
[tmpOpenGLContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
}
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextCGL(
m_initStereoVisual,
m_initNumOfAASamples,
m_window,
m_openGLView,
CGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3, 2,
GHOST_OPENGL_CGL_CONTEXT_FLAGS,
GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextCGL(
m_initStereoVisual,
m_initNumOfAASamples,
m_window,
m_openGLView,
CGL_CONTEXT_ES2_PROFILE_BIT_EXT,
2, 0,
GHOST_OPENGL_CGL_CONTEXT_FLAGS,
GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextCGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_openGLView,
0, // profile bit
0, 0,
GHOST_OPENGL_CGL_CONTEXT_FLAGS,
GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY);
#else
# error
#endif
[m_openGLView setOpenGLContext:tmpOpenGLContext];
[tmpOpenGLContext setView:m_openGLView];
m_openGLContext = tmpOpenGLContext;
break;
case GHOST_kDrawingContextTypeNone:
success = GHOST_kSuccess;
break;
default:
break;
}
[pool drain];
return success;
}
GHOST_TSuccess GHOST_WindowCocoa::removeDrawingContext()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
switch (m_drawingContextType) {
case GHOST_kDrawingContextTypeOpenGL:
if (m_openGLContext) {
[m_openGLView clearGLContext];
if (s_firstOpenGLcontext == m_openGLContext) s_firstOpenGLcontext = nil;
m_openGLContext = nil;
}
[pool drain];
return GHOST_kSuccess;
case GHOST_kDrawingContextTypeNone:
[pool drain];
return GHOST_kSuccess;
break;
default:
[pool drain];
return GHOST_kFailure;
#else
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_openGLView,
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3, 2,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_openGLView,
0, // profile bit
2, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_ES_API);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_openGLView,
0, // profile bit
0, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#else
# error
#endif
#endif
if (context->initializeDrawingContext())
return context;
else
delete context;
}
return NULL;
}
#pragma mark invalidate
GHOST_TSuccess GHOST_WindowCocoa::invalidate()
{

@ -26,10 +26,11 @@
#include "GHOST_WindowSDL.h"
#include "SDL_mouse.h"
#include <GL/glew.h>
#include <assert.h>
#include "glew-mx.h"
static SDL_GLContext s_firstContext = NULL;
#include "GHOST_ContextSDL.h"
#include <assert.h>
GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system,
const STR_String& title,
@ -44,39 +45,29 @@ GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system,
const bool exclusive,
const GHOST_TUns16 numOfAASamples
)
:
GHOST_Window(width, height, state, type, stereoVisual, exclusive, numOfAASamples),
m_system(system),
m_invalid_window(false),
m_sdl_custom_cursor(NULL)
: GHOST_Window(width, height, state, stereoVisual, exclusive, numOfAASamples),
m_system(system),
m_valid_setup(false),
m_invalid_window(false),
m_sdl_custom_cursor(NULL)
{
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
if (numOfAASamples) {
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, numOfAASamples);
}
/* creating the window _must_ come after setting attributes */
m_sdl_win = SDL_CreateWindow(title,
left,
top,
width,
height,
SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
m_sdl_win = SDL_CreateWindow(
title,
left, top,
width, height,
SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
/* now set up the rendering context. */
if (setDrawingContextType(type) == GHOST_kSuccess) {
m_valid_setup = true;
GHOST_PRINT("Created window\n");
}
m_sdl_glcontext = SDL_GL_CreateContext(m_sdl_win);
//fprintf(stderr, "Ignoring Xlib error: error code %d request code %d\n",
// theEvent->error_code, theEvent->request_code);
if (exclusive) {
SDL_RaiseWindow(m_sdl_win);
}
setTitle(title);
}
@ -87,64 +78,38 @@ GHOST_WindowSDL::~GHOST_WindowSDL()
SDL_FreeCursor(m_sdl_custom_cursor);
}
if (m_sdl_glcontext != s_firstContext) {
SDL_GL_DeleteContext(m_sdl_glcontext);
}
releaseNativeHandles();
SDL_DestroyWindow(m_sdl_win);
}
GHOST_TSuccess
GHOST_WindowSDL::installDrawingContext(GHOST_TDrawingContextType type)
GHOST_Context *
GHOST_WindowSDL::newDrawingContext(GHOST_TDrawingContextType type)
{
// only support openGL for now.
GHOST_TSuccess success;
switch (type) {
case GHOST_kDrawingContextTypeOpenGL:
m_sdl_glcontext = SDL_GL_CreateContext(m_sdl_win);
if (type == GHOST_kDrawingContextTypeOpenGL) {
GHOST_Context *context = new GHOST_ContextSDL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_sdl_win,
0, // profile bit
0, 0,
GHOST_OPENGL_SDL_CONTEXT_FLAGS,
GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY);
if (m_sdl_glcontext != NULL) {
if (!s_firstContext) {
s_firstContext = m_sdl_glcontext;
}
success = (SDL_GL_MakeCurrent(m_sdl_win, m_sdl_glcontext) < 0) ?
GHOST_kFailure : GHOST_kSuccess;
}
else {
success = GHOST_kFailure;
}
break;
case GHOST_kDrawingContextTypeNone:
success = GHOST_kSuccess;
break;
default:
success = GHOST_kFailure;
if (context->initializeDrawingContext())
return context;
else
delete context;
}
return success;
return NULL;
}
GHOST_TSuccess
GHOST_WindowSDL::invalidate(void)
{
// So the idea of this function is to generate an expose event
// for the window.
// Unfortunately X does not handle expose events for you and
// it is the client's job to refresh the dirty part of the window.
// We need to queue up invalidate calls and generate GHOST events
// for them in the system.
// We implement this by setting a boolean in this class to concatenate
// all such calls into a single event for this window.
// At the same time we queue the dirty windows in the system class
// and generate events for them at the next processEvents call.
if (m_invalid_window == false) {
m_system->addDirtyWindow(this);
m_invalid_window = true;
@ -153,52 +118,6 @@ GHOST_WindowSDL::invalidate(void)
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_WindowSDL::swapBuffers()
{
if (getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL) {
SDL_GL_SwapWindow(m_sdl_win);
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess
GHOST_WindowSDL::activateDrawingContext()
{
if (m_sdl_glcontext != NULL) {
int status = SDL_GL_MakeCurrent(m_sdl_win, m_sdl_glcontext);
(void)status;
/* Disable AA by default */
if (m_numOfAASamples > 0) {
glDisable(GL_MULTISAMPLE_ARB);
}
return GHOST_kSuccess;
}
return GHOST_kFailure;
}
GHOST_TSuccess
GHOST_WindowSDL::removeDrawingContext()
{
GHOST_TSuccess success;
if (m_sdl_glcontext != NULL) {
SDL_GL_DeleteContext(m_sdl_glcontext);
success = GHOST_kSuccess;
}
else {
success = GHOST_kFailure;
}
return success;
}
GHOST_TSuccess
GHOST_WindowSDL::setState(GHOST_TWindowState state)
{
@ -236,6 +155,12 @@ GHOST_WindowSDL::getState() const
return GHOST_kWindowStateNormal;
}
bool
GHOST_WindowSDL::
getValid() const
{
return GHOST_Window::getValid() && m_valid_setup;
}
void
GHOST_WindowSDL::setTitle(const STR_String& title)
@ -638,16 +563,3 @@ GHOST_WindowSDL::setWindowCursorVisibility(bool visible)
SDL_ShowCursor(visible);
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_WindowSDL::setSwapInterval(int interval)
{
SDL_GL_SetSwapInterval(interval);
return GHOST_kSuccess;
}
int
GHOST_WindowSDL::getSwapInterval()
{
return SDL_GL_GetSwapInterval();
}

@ -30,6 +30,7 @@
#include "GHOST_Window.h"
#include "GHOST_SystemSDL.h"
#include <map>
extern "C" {
@ -47,10 +48,10 @@ class GHOST_WindowSDL : public GHOST_Window
{
private:
GHOST_SystemSDL *m_system;
bool m_valid_setup;
bool m_invalid_window;
SDL_Window *m_sdl_win;
SDL_GLContext m_sdl_glcontext;
SDL_Cursor *m_sdl_custom_cursor;
public:
@ -93,17 +94,18 @@ public:
m_invalid_window = false;
}
bool getValid() const
{
return (m_sdl_win != NULL);
}
bool getValid() const;
void getWindowBounds(GHOST_Rect& bounds) const;
void getClientBounds(GHOST_Rect& bounds) const;
protected:
GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
GHOST_TSuccess removeDrawingContext();
/**
* \param type The type of rendering context create.
* \return Indication of success.
*/
virtual GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type);
GHOST_TSuccess
setWindowCursorGrab(GHOST_TGrabCursorMode mode);
@ -150,12 +152,6 @@ protected:
clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY,
GHOST_TInt32& outX, GHOST_TInt32& outY) const;
GHOST_TSuccess
swapBuffers();
GHOST_TSuccess
activateDrawingContext();
GHOST_TSuccess
setState(GHOST_TWindowState state);
@ -172,9 +168,6 @@ protected:
GHOST_TSuccess beginFullScreen() const { return GHOST_kFailure; }
GHOST_TSuccess endFullScreen() const { return GHOST_kFailure; }
GHOST_TSuccess setSwapInterval(int interval);
int getSwapInterval();
};

@ -29,82 +29,33 @@
* \ingroup GHOST
*/
#include <string.h>
#define _USE_MATH_DEFINES
#include "GHOST_WindowWin32.h"
#include "GHOST_SystemWin32.h"
#include "GHOST_DropTargetWin32.h"
#include "GHOST_ContextNone.h"
#include "utfconv.h"
#include "utf_winfunc.h"
// Need glew for some defines
#include <GL/glew.h>
#include <GL/wglew.h>
#include <math.h>
// MSVC6 still doesn't define M_PI
#ifndef M_PI
# define M_PI 3.1415926536
#if defined(WITH_GL_EGL)
# include "GHOST_ContextEGL.h"
#else
# include "GHOST_ContextWGL.h"
#endif
// Some more multisample defines
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#include <math.h>
#include <string.h>
#include <assert.h>
const wchar_t *GHOST_WindowWin32::s_windowClassName = L"GHOST_WindowClass";
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 quality 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 */
extern "C" {
@ -120,17 +71,14 @@ GHOST_WindowWin32::GHOST_WindowWin32(
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
const bool stereoVisual,
const GHOST_TUns16 numOfAASamples,
GHOST_TEmbedderWindowID parentwindowhwnd,
GHOST_TSuccess msEnabled,
int msPixelFormat)
: GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone,
stereoVisual, false, numOfAASamples),
bool wantStereoVisual,
GHOST_TUns16 wantNumOfAASamples,
GHOST_TEmbedderWindowID parentwindowhwnd)
: GHOST_Window(width, height, state,
wantStereoVisual, false, wantNumOfAASamples),
m_inLiveResize(false),
m_system(system),
m_hDC(0),
m_hGlRc(0),
m_hasMouseCaptured(false),
m_hasGrabMouse(false),
m_nPressedButtons(0),
@ -139,18 +87,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(
m_tabletData(NULL),
m_tablet(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_stereo(stereoVisual),
m_nextWindow(NULL),
m_parentWindowHwnd(parentwindowhwnd)
{
OSVERSIONINFOEX versionInfo;
@ -286,35 +223,32 @@ GHOST_WindowWin32::GHOST_WindowWin32(
// Store the device context
m_hDC = ::GetDC(m_hWnd);
if (!s_firstHDC) {
s_firstHDC = m_hDC;
}
// Show the window
int nCmdShow;
switch (state) {
case GHOST_kWindowStateMaximized:
nCmdShow = SW_SHOWMAXIMIZED;
break;
case GHOST_kWindowStateMinimized:
nCmdShow = SW_SHOWMINIMIZED;
break;
case GHOST_kWindowStateNormal:
default:
nCmdShow = SW_SHOWNORMAL;
break;
}
GHOST_TSuccess success;
success = setDrawingContextType(type);
GHOST_TSuccess success = setDrawingContextType(type);
if (success) {
// Show the window
int nCmdShow;
switch (state) {
case GHOST_kWindowStateMaximized:
nCmdShow = SW_SHOWMAXIMIZED;
break;
case GHOST_kWindowStateMinimized:
nCmdShow = SW_SHOWMINIMIZED;
break;
case GHOST_kWindowStateNormal:
default:
nCmdShow = SW_SHOWNORMAL;
break;
}
::ShowWindow(m_hWnd, nCmdShow);
// Force an initial paint of the window
::UpdateWindow(m_hWnd);
}
else {
//invalidate the window
m_hWnd = 0;
::DestroyWindow(m_hWnd);
m_hWnd = NULL;
}
}
@ -415,14 +349,8 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
m_customCursor = NULL;
}
::wglMakeCurrent(NULL, NULL);
m_multisampleEnabled = GHOST_kFailure;
m_multisample = 0;
setDrawingContextType(GHOST_kDrawingContextTypeNone);
if (m_hDC && m_hDC != s_firstHDC) {
if (m_hWnd != NULL && m_hDC != NULL && releaseNativeHandles()) {
::ReleaseDC(m_hWnd, m_hDC);
m_hDC = 0;
}
if (m_hWnd) {
@ -438,14 +366,9 @@ GHOST_WindowWin32::~GHOST_WindowWin32()
}
}
GHOST_Window *GHOST_WindowWin32::getNextWindow()
{
return m_nextWindow;
}
bool GHOST_WindowWin32::getValid() const
{
return m_hWnd != 0;
return GHOST_Window::getValid() && m_hWnd != 0 && m_hDC != 0;
}
HWND GHOST_WindowWin32::getHWND() const
@ -678,49 +601,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)
{
if (!WGL_EXT_swap_control)
return GHOST_kFailure;
return wglSwapIntervalEXT(interval) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
int GHOST_WindowWin32::getSwapInterval()
{
if (WGL_EXT_swap_control)
return wglGetSwapIntervalEXT();
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 success;
@ -733,257 +613,93 @@ GHOST_TSuccess GHOST_WindowWin32::invalidate()
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[] = {
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB, pfd.cColorBits,
WGL_DEPTH_BITS_ARB, pfd.cDepthBits,
#ifdef GHOST_OPENGL_ALPHA
WGL_ALPHA_BITS_ARB, pfd.cAlphaBits,
GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType type)
{
if (type == GHOST_kDrawingContextTypeOpenGL) {
#if !defined(WITH_GL_EGL)
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextWGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
WGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3, 2,
GHOST_OPENGL_WGL_CONTEXT_FLAGS,
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextWGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
WGL_CONTEXT_ES2_PROFILE_BIT_EXT,
2, 0,
GHOST_OPENGL_WGL_CONTEXT_FLAGS,
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextWGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
0, // profile bit
0, 0,
GHOST_OPENGL_WGL_CONTEXT_FLAGS,
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
#else
# error
#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
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
#else
if (!wglChoosePixelFormatARB) {
m_multisampleEnabled = GHOST_kFailure;
return GHOST_kFailure;
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3, 2,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
0, // profile bit
2, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_ES_API);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_hWnd,
m_hDC,
0, // profile bit
0, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#else
# error
#endif
#endif
if (context->initializeDrawingContext())
return context;
else
delete context;
}
// iAttributes[17] is the initial multisample. If not valid try to use the closest valid value under it.
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;
return NULL;
}
void GHOST_WindowWin32::lostMouseCapture()
@ -1334,93 +1050,3 @@ GHOST_TSuccess GHOST_WindowWin32::endProgressBar()
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;
}

@ -40,13 +40,6 @@
#include "GHOST_Window.h"
#include "GHOST_TaskbarWin32.h"
#ifndef __MINGW64__
#define _WIN32_WINNT 0x501 // require Windows XP or newer
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <wintab.h>
#define PACKETDATA (PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION | PK_CURSOR)
#define PACKETMODE PK_BUTTONS
@ -80,8 +73,9 @@ public:
* \param height The height the window.
* \param state The state the window is initially opened with.
* \param type The type of drawing context installed in this window.
* \param stereoVisual Stereo visual for quad buffered stereo.
* \param numOfAASamples Number of samples used for AA (zero if no AA)
* \param wantStereoVisual Stereo visual for quad buffered stereo.
* \param wantNumOfAASamples Number of samples used for AA (zero if no AA)
* \param parentWindowHwnd
*/
GHOST_WindowWin32(
GHOST_SystemWin32 *system,
@ -92,11 +86,9 @@ public:
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
const bool stereoVisual = false,
const GHOST_TUns16 numOfAASamples = 0,
GHOST_TEmbedderWindowID parentWindowHwnd = 0,
GHOST_TSuccess msEnabled = GHOST_kFailure,
int msPixelFormat = 0
bool wantStereoVisual = false,
GHOST_TUns16 wantNumOfAASamples = 0,
GHOST_TEmbedderWindowID parentWindowHwnd = 0
);
/**
@ -105,13 +97,6 @@ public:
*/
virtual ~GHOST_WindowWin32();
/**
* Returns the window to replace this one if it's getting replaced
* \return The window replacing this one.
*/
GHOST_Window *getNextWindow();
/**
* Returns indication as to whether the window is valid.
* \return The validity of the window.
@ -208,29 +193,6 @@ public:
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.
* \param interval The swap interval to use.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess setSwapInterval(int interval);
/**
* Gets the current swap interval for swapBuffers.
* \return An integer.
*/
virtual int getSwapInterval();
/**
* Activates the drawing context of this window.
* \return Indication of success.
*/
virtual GHOST_TSuccess activateDrawingContext();
/**
* Invalidates the contents of this window.
@ -248,13 +210,6 @@ public:
*/
virtual GHOST_TSuccess endProgressBar();
/**
* Returns the name of the window class.
* \return The name of the window class.
*/
static const wchar_t *getWindowClassName() {
return s_windowClassName;
}
/**
* Register a mouse click event (should be called
@ -298,21 +253,13 @@ public:
/** if the window currently resizing */
bool m_inLiveResize;
protected:
GHOST_TSuccess initMultisample(PIXELFORMATDESCRIPTOR pfd);
private:
/**
* Tries to install a rendering context in this window.
* \param type The type of rendering context installed.
* \param type The type of rendering context create.
* \return Indication of success.
*/
virtual GHOST_TSuccess installDrawingContext(GHOST_TDrawingContextType type);
/**
* Removes the current drawing context.
* \return Indication of success.
*/
virtual GHOST_TSuccess removeDrawingContext();
virtual GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type);
/**
* Sets the cursor visibility on the window using
@ -360,12 +307,7 @@ protected:
HWND m_hWnd;
/** Device context handle. */
HDC m_hDC;
/** OpenGL rendering context. */
HGLRC m_hGlRc;
/** The first created OpenGL context (for sharing display lists) */
static HGLRC s_firsthGLRc;
/** The first created device context handle. */
static HDC s_firstHDC;
/** Flag for if window has captured the mouse */
bool m_hasMouseCaptured;
/** Flag if an operator grabs the mouse with WM_cursor_grab_enable/ungrab()
@ -393,26 +335,7 @@ protected:
LONG m_maxPressure;
LONG m_maxAzimuth, m_maxAltitude;
/** Preferred number of samples */
GHOST_TUns16 m_multisample;
/** Check if multisample is supported */
GHOST_TSuccess m_multisampleEnabled;
/** The pixelFormat to use for multisample */
int m_msPixelFormat;
/** We need to following to recreate the window */
const STR_String& m_title;
GHOST_TInt32 m_left;
GHOST_TInt32 m_top;
GHOST_TUns32 m_width;
GHOST_TUns32 m_height;
GHOST_TWindowState m_normal_state;
bool m_stereo;
/** The GHOST_System passes this to wm if this window is being replaced */
GHOST_Window *m_nextWindow;
/** Hwnd to parent window */
GHOST_TEmbedderWindowID m_parentWindowHwnd;

@ -30,23 +30,28 @@
*/
#include <GL/glxew.h>
#include "GHOST_WindowX11.h"
#include "GHOST_SystemX11.h"
#include "STR_String.h"
#include "GHOST_Debug.h"
#ifdef WITH_XDND
#include "GHOST_DropTargetX11.h"
# include "GHOST_DropTargetX11.h"
#endif
#if defined(WITH_GL_EGL)
# include "GHOST_ContextEGL.h"
#else
# include "GHOST_ContextGLX.h"
#endif
/* For standard X11 cursors */
#include <X11/cursorfont.h>
#include <X11/Xatom.h>
#if defined(__sun__) || defined(__sun) || defined(__sparc) || defined(__sparc__) || defined(_AIX)
#include <strings.h>
# include <strings.h>
#endif
#include <cstring>
@ -65,14 +70,6 @@ typedef struct {
long input_mode;
} MotifWmHints;
// Workaround for MESA bug #54080
// https://bugs.freedesktop.org/show_bug.cgi?id=54080()
#define SWAP_INTERVALS_WORKAROUND
#ifdef SWAP_INTERVALS_WORKAROUND
static bool g_swap_interval_disabled = false;
#endif // SWAP_INTERVALS_WORKAROUND
#define MWM_HINTS_DECORATIONS (1L << 1)
@ -157,13 +154,12 @@ static long BLENDER_ICON_48x48x32[] = {
};
GLXContext GHOST_WindowX11::s_firstContext = NULL;
GHOST_WindowX11::
GHOST_WindowX11(
GHOST_SystemX11 *system,
Display *display,
const STR_String& title,
const STR_String &title,
GHOST_TInt32 left,
GHOST_TInt32 top,
GHOST_TUns32 width,
@ -174,8 +170,7 @@ GHOST_WindowX11(
const bool stereoVisual,
const bool exclusive,
const GHOST_TUns16 numOfAASamples)
: GHOST_Window(width, height, state, type, stereoVisual, exclusive, numOfAASamples),
m_context(NULL),
: GHOST_Window(width, height, state, stereoVisual, exclusive, numOfAASamples),
m_display(display),
m_normal_state(GHOST_kWindowStateNormal),
m_system(system),
@ -185,97 +180,19 @@ GHOST_WindowX11(
m_custom_cursor(None),
m_visible_cursor(None)
{
/* Set up the minimum attributes that we require and see if
* X can find us a visual matching those requirements. */
int attributes[40], i, samples;
int natom;
int glxVersionMajor, glxVersionMinor; /* As in GLX major.minor */
m_visual = NULL;
if (!glXQueryVersion(m_display, &glxVersionMajor, &glxVersionMinor)) {
printf("%s:%d: X11 glXQueryVersion() failed, verify working openGL system!\n", __FILE__, __LINE__);
/* exit if this is the first window */
if (s_firstContext == NULL) {
printf("initial window could not find the GLX extension, exit!\n");
exit(1);
}
return;
}
/* Find the display with highest samples, starting at level requested */
for (samples = m_numOfAASamples; samples >= 0; samples--) {
i = 0; /* Reusing attributes array, so reset counter */
if (m_stereoVisual)
attributes[i++] = GLX_STEREO;
attributes[i++] = GLX_RGBA;
attributes[i++] = GLX_DOUBLEBUFFER;
attributes[i++] = GLX_RED_SIZE; attributes[i++] = 1;
attributes[i++] = GLX_BLUE_SIZE; attributes[i++] = 1;
attributes[i++] = GLX_GREEN_SIZE; attributes[i++] = 1;
attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1;
#ifdef GHOST_OPENGL_ALPHA
attributes[i++] = GLX_ALPHA_SIZE; attributes[i++] = 1;
#endif
/* GLX >= 1.4 required for multi-sample */
if (samples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) {
attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1;
attributes[i++] = GLX_SAMPLES; attributes[i++] = samples;
}
attributes[i] = None;
m_visual = glXChooseVisual(m_display, DefaultScreen(m_display), attributes);
/* Any sample level or even zero, which means oversampling disabled, is good
* but we need a valid visual to continue */
if (m_visual == NULL) {
if (samples == 0) {
/* All options exhausted, cannot continue */
printf("%s:%d: X11 glXChooseVisual() failed, verify working openGL system!\n", __FILE__, __LINE__);
if (s_firstContext == NULL) {
printf("initial window could not find the GLX extension, exit!\n");
exit(1);
}
return;
}
}
else {
if (m_numOfAASamples && (m_numOfAASamples > samples)) {
printf("%s:%d: oversampling requested %i but using %i samples\n",
__FILE__, __LINE__, m_numOfAASamples, samples);
}
break;
}
}
/* Create a bunch of attributes needed to create an X window. */
/* First create a colormap for the window and visual.
* This seems pretty much a legacy feature as we are in rgba mode anyway. */
unsigned int xattributes_valuemask = 0;
XSetWindowAttributes xattributes;
unsigned int xattributes_valuemask = (CWBorderPixel | CWColormap | CWEventMask);
memset(&xattributes, 0, sizeof(xattributes));
xattributes.colormap = XCreateColormap(m_display,
RootWindow(m_display, m_visual->screen),
m_visual->visual,
AllocNone
);
xattributes_valuemask |= CWBorderPixel;
xattributes.border_pixel = 0;
/* Specify which events we are interested in hearing. */
xattributes_valuemask |= CWEventMask;
xattributes.event_mask =
ExposureMask | StructureNotifyMask |
KeyPressMask | KeyReleaseMask |
@ -292,15 +209,15 @@ GHOST_WindowX11(
/* create the window! */
if (parentWindow == 0) {
m_window = XCreateWindow(m_display,
RootWindow(m_display, m_visual->screen),
RootWindow(m_display, DefaultScreen(m_display)),
left,
top,
width,
height,
0, /* no border. */
m_visual->depth,
0, /* no border. */
CopyFromParent,
InputOutput,
m_visual->visual,
CopyFromParent,
xattributes_valuemask,
&xattributes
);
@ -321,15 +238,15 @@ GHOST_WindowX11(
m_window = XCreateWindow(m_display,
parentWindow, /* reparent against embedder */
parentWindow, /* reparent against embedder */
left,
top,
width,
height,
0, /* no border. */
m_visual->depth,
0, /* no border. */
CopyFromParent,
InputOutput,
m_visual->visual,
CopyFromParent,
xattributes_valuemask,
&xattributes
);
@ -451,8 +368,6 @@ GHOST_WindowX11(
BLENDER_ICON_48x48x32[0] * BLENDER_ICON_48x48x32[1] + 2);
/* done setting the icon */
setTitle(title);
#ifdef WITH_X11_XINPUT
initXInputDevices();
@ -460,11 +375,13 @@ GHOST_WindowX11(
#endif
/* now set up the rendering context. */
if (installDrawingContext(type) == GHOST_kSuccess) {
if (setDrawingContextType(type) == GHOST_kSuccess) {
m_valid_setup = true;
GHOST_PRINT("Created window\n");
}
setTitle(title);
if (exclusive) {
XMapRaised(m_display, m_window);
}
@ -564,7 +481,7 @@ bool
GHOST_WindowX11::
getValid() const
{
return m_valid_setup;
return GHOST_Window::getValid() && m_valid_setup;
}
void
@ -685,7 +602,7 @@ screenToClient(
Window temp;
XTranslateCoordinates(m_display,
RootWindow(m_display, m_visual->screen),
RootWindow(m_display, DefaultScreen(m_display)),
m_window,
inX, inY,
&ax, &ay,
@ -708,7 +625,7 @@ clientToScreen(
XTranslateCoordinates(
m_display,
m_window,
RootWindow(m_display, m_visual->screen),
RootWindow(m_display, DefaultScreen(m_display)),
inX, inY,
&ax, &ay,
&temp);
@ -1052,7 +969,7 @@ setOrder(
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
root = RootWindow(m_display, m_visual->screen),
root = RootWindow(m_display, DefaultScreen(m_display)),
eventmask = SubstructureRedirectMask | SubstructureNotifyMask;
XSendEvent(m_display, root, False, eventmask, &xev);
@ -1077,34 +994,6 @@ setOrder(
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_WindowX11::
swapBuffers()
{
if (getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL) {
glXSwapBuffers(m_display, m_window);
return GHOST_kSuccess;
}
else {
return GHOST_kFailure;
}
}
GHOST_TSuccess
GHOST_WindowX11::
activateDrawingContext()
{
if (m_context != NULL) {
glXMakeCurrent(m_display, m_window, m_context);
/* Disable AA by default */
if (m_numOfAASamples > 0) {
glDisable(GL_MULTISAMPLE_ARB);
}
return GHOST_kSuccess;
}
return GHOST_kFailure;
}
GHOST_TSuccess
GHOST_WindowX11::
invalidate()
@ -1172,10 +1061,6 @@ GHOST_WindowX11::
XFreeCursor(m_display, m_custom_cursor);
}
if (m_context != s_firstContext) {
glXDestroyContext(m_display, m_context);
}
if (p_owner == m_window) {
XSetSelectionOwner(m_display, Primary_atom, None, CurrentTime);
}
@ -1193,88 +1078,98 @@ GHOST_WindowX11::
delete m_dropTarget;
#endif
releaseNativeHandles();
XDestroyWindow(m_display, m_window);
XFree(m_visual);
}
/**
* Tries to install a rendering context in this window.
* \param type The type of rendering context installed.
* \return Indication as to whether installation has succeeded.
*/
GHOST_TSuccess
GHOST_WindowX11::
installDrawingContext(
GHOST_TDrawingContextType type)
GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type)
{
/* only support openGL for now. */
GHOST_TSuccess success;
switch (type) {
case GHOST_kDrawingContextTypeOpenGL:
{
#ifdef WITH_X11_XINPUT
/* use our own event handlers to avoid exiting blender,
* this would happen for eg:
* if you open blender, unplug a tablet, then open a new window. */
XErrorHandler old_handler = XSetErrorHandler(GHOST_X11_ApplicationErrorHandler);
XIOErrorHandler old_handler_io = XSetIOErrorHandler(GHOST_X11_ApplicationIOErrorHandler);
if (type == GHOST_kDrawingContextTypeOpenGL) {
#if !defined(WITH_GL_EGL)
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextGLX(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
GLX_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3, 2,
GHOST_OPENGL_GLX_CONTEXT_FLAGS,
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextGLX(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
2, 0,
GHOST_OPENGL_GLX_CONTEXT_FLAGS,
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextGLX(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
0, // profile bit
0, 0,
GHOST_OPENGL_GLX_CONTEXT_FLAGS,
GHOST_OPENGL_GLX_RESET_NOTIFICATION_STRATEGY);
#else
# error
#endif
m_context = glXCreateContext(m_display, m_visual, s_firstContext, True);
if (m_context != NULL) {
if (!s_firstContext) {
s_firstContext = m_context;
}
glXMakeCurrent(m_display, m_window, m_context);
glClearColor(0.447, 0.447, 0.447, 0);
glClear(GL_COLOR_BUFFER_BIT);
success = GHOST_kSuccess;
}
else {
success = GHOST_kFailure;
}
#else
#ifdef WITH_X11_XINPUT
/* Restore handler */
(void) XSetErrorHandler(old_handler);
(void) XSetIOErrorHandler(old_handler_io);
#if defined(WITH_GL_PROFILE_CORE)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3, 2,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#elif defined(WITH_GL_PROFILE_ES20)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
0, // profile bit
2, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_ES_API);
#elif defined(WITH_GL_PROFILE_COMPAT)
GHOST_Context *context = new GHOST_ContextEGL(
m_wantStereoVisual,
m_wantNumOfAASamples,
m_window,
m_display,
0, // profile bit
0, 0,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
#else
# error
#endif
break;
}
case GHOST_kDrawingContextTypeNone:
{
success = GHOST_kSuccess;
break;
}
default:
success = GHOST_kFailure;
#endif
if (context->initializeDrawingContext())
return context;
else
delete context;
}
return success;
}
/**
* Removes the current drawing context.
* \return Indication as to whether removal has succeeded.
*/
GHOST_TSuccess
GHOST_WindowX11::
removeDrawingContext()
{
GHOST_TSuccess success;
if (m_context != NULL) {
glXDestroyContext(m_display, m_context);
success = GHOST_kSuccess;
}
else {
success = GHOST_kFailure;
}
return success;
return NULL;
}
@ -1530,72 +1425,3 @@ endFullScreen() const
return GHOST_kSuccess;
}
GHOST_TSuccess
GHOST_WindowX11::
setSwapInterval(int interval) {
if (!GLX_EXT_swap_control || !glXSwapIntervalEXT
#ifdef SWAP_INTERVALS_WORKAROUND
|| g_swap_interval_disabled
#endif // SWAP_INTERVALS_WORKAROUND
)
{
return GHOST_kFailure;
}
glXSwapIntervalEXT(m_display, m_window, interval);
return GHOST_kSuccess;
}
#ifdef SWAP_INTERVALS_WORKAROUND
static int QueryDrawable_ApplicationErrorHandler(Display *display, XErrorEvent *theEvent)
{
fprintf(stderr, "Ignoring Xlib error: error code %d request code %d\n",
theEvent->error_code, theEvent->request_code);
if (!g_swap_interval_disabled) {
fprintf(stderr, "Disabling SWAP INTERVALS extension\n");
g_swap_interval_disabled = true;
}
return 0;
}
static int QueryDrawable_ApplicationIOErrorHandler(Display *display)
{
fprintf(stderr, "Ignoring Xlib error: error IO\n");
if (!g_swap_interval_disabled) {
fprintf(stderr, "Disabling SWAP INTERVALS extension\n");
g_swap_interval_disabled = true;
}
return 0;
}
#endif // SWAP_INTERVALS_WORKAROUND
int
GHOST_WindowX11::
getSwapInterval() {
if (GLX_EXT_swap_control) {
#ifdef SWAP_INTERVALS_WORKAROUND
/* XXX: Current MESA driver will give GLXBadDrawable for all
* the glXQueryDrawable requests with direct contexts.
*
* To prevent crashes and unexpected behaviors, we will
* disable swap intervals extension if query fails here.
* (because if we will override interval without having
* old value we couldn't restore it properly).
*/
XErrorHandler old_handler = XSetErrorHandler(QueryDrawable_ApplicationErrorHandler);
XIOErrorHandler old_handler_io = XSetIOErrorHandler(QueryDrawable_ApplicationIOErrorHandler);
#endif // SWAP_INTERVALS_WORKAROUND
unsigned int value = 0;
glXQueryDrawable(m_display, m_window, GLX_SWAP_INTERVAL_EXT, &value);
#ifdef SWAP_INTERVALS_WORKAROUND
/* Restore handler */
(void) XSetErrorHandler(old_handler);
(void) XSetIOErrorHandler(old_handler_io);
#endif // SWAP_INTERVALS_WORKAROUND
return (int)value;
}
return 0;
}

@ -35,7 +35,6 @@
#include "GHOST_Window.h"
#include <X11/Xlib.h>
#include <GL/glx.h>
// For tablets
#ifdef WITH_X11_XINPUT
# include <X11/extensions/XInput.h>
@ -160,13 +159,6 @@ public:
);
GHOST_TSuccess
swapBuffers(
);
GHOST_TSuccess
activateDrawingContext(
);
GHOST_TSuccess
invalidate(
);
@ -235,37 +227,12 @@ public:
GHOST_TSuccess endFullScreen() const;
/**
* Sets the swap interval for swapBuffers.
* \param interval The swap interval to use.
* \return A boolean success indicator.
*/
virtual GHOST_TSuccess setSwapInterval(int interval);
/**
* Gets the current swap interval for swapBuffers.
* \return An integer.
*/
virtual int getSwapInterval();
protected:
/**
* Tries to install a rendering context in this window.
* \param type The type of rendering context installed.
* \return Indication as to whether installation has succeeded.
* \param type The type of rendering context create.
* \return Indication of success.
*/
GHOST_TSuccess
installDrawingContext(
GHOST_TDrawingContextType type
);
/**
* Removes the current drawing context.
* \return Indication as to whether removal has succeeded.
*/
GHOST_TSuccess
removeDrawingContext(
);
virtual GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type);
/**
* Sets the cursor visibility on the window using
@ -350,17 +317,11 @@ private:
void initXInputDevices();
#endif
GLXContext m_context;
Window m_window;
Display *m_display;
XVisualInfo *m_visual;
Display *m_display;
GHOST_TWindowState m_normal_state;
/** The first created OpenGL context (for sharing display lists) */
static GLXContext s_firstContext;
/// A pointer to the typed system class.
/** A pointer to the typed system class. */
GHOST_SystemX11 *m_system;
bool m_valid_setup;

@ -74,6 +74,12 @@ endif()
# -----------------------------------------------------------------------------
# Libraries
if(UNIX AND NOT APPLE)
set(WITH_X11 ON)
endif()
# for now... default to this
add_definitions(-DWITH_GL_PROFILE_COMPAT)
# ghost
include(${CMAKE_SOURCE_DIR}/../CMakeLists.txt)
suffix_relpaths(INC_NEW "${INC}" "../")

@ -0,0 +1,41 @@
# ***** 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) 2014, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Jason Wilkins
#
# ***** END GPL LICENSE BLOCK *****
set(INC
.
${GLEW_INCLUDE_PATH}
)
set(SRC
intern/glew-mx.c
glew-mx.h
intern/gl-deprecated.h
intern/symbol-binding.h
)
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_intern_glew_mx "${SRC}" "${INC}" "${INC_SYS}")

16
intern/glew-mx/SConscript Normal file

@ -0,0 +1,16 @@
#!/usr/bin/python
import sys
import os
Import('env')
sources = ['intern/glew-mx.c']
defs = env['BF_GL_DEFINITIONS']
incs = [
'.',
env['BF_GLEW_INC'],
]
env.BlenderLib ( 'extern_glew_mx', sources, incs, defs, libtype=['intern','player'], priority=[10, 185] )

112
intern/glew-mx/glew-mx.h Normal file

@ -0,0 +1,112 @@
/*
* ***** 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) 2014 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file glew-mx.h
* \ingroup glew-mx
*
* Support for GLEW Multiple rendering conteXts (MX)
* Maintained as a Blender Library.
*
* Different rendering contexts may have different entry points
* to extension functions of the same name. So it can cause
* problems if, for example, a second context uses a pointer to
* say, glActiveTextureARB, that was queried from the first context.
*
* GLEW has basic support for multiple contexts by enabling WITH_GLEW_MX,
* but it does not provide a full implementation. This is because
* there are too many questions about thread safety and memory
* allocation that are up to the user of GLEW.
*
* This implementation is very basic and isn't thread safe.
* For a single context the overhead should be
* no more than using GLEW without WITH_GLEW_MX enabled.
*/
#ifndef __GLEW_MX_H__
#define __GLEW_MX_H__
#ifdef WITH_GLEW_MX
/* glew itself expects this */
# define GLEW_MX 1
# define glewGetContext() (&(_mx_context->glew_context))
#endif
#include <GL/glew.h>
#ifdef __cplusplus
extern "C" {
#endif
/* MXContext is used instead of GLEWContext directly so that
extending what data is held by a context is easier.
*/
typedef struct MXContext {
#ifdef WITH_GLEW_MX
GLEWContext glew_context;
#endif
int reserved; /* structs need at least one member */
} MXContext;
#ifdef WITH_GLEW_MX
extern MXContext *_mx_context;
#endif
#include "intern/symbol-binding.h"
/* If compiling only for OpenGL 3.2 Core Profile then we should make sure
* no legacy API entries or symbolic constants are used.
*/
#if defined(WITH_GL_PROFILE_CORE) && !defined(WITH_GL_PROFILE_COMPAT) && !defined(WITH_GL_PROFILE_ES20)
# include "intern/gl-deprecated.h"
#endif
MXContext *mxCreateContext (void);
MXContext *mxGetCurrentContext (void);
void mxMakeCurrentContext(MXContext *ctx);
void mxDestroyContext (MXContext *ctx);
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) glew_chk((x), NULL, 0, NULL)
#endif
#ifdef __cplusplus
}
#endif
#endif /* __GLEW_MX_H__ */

@ -0,0 +1,872 @@
/*
* ***** 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) 2014 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file intern/gl-deprecated.h
* \ingroup glew-mx
* Utility used to check for use of deprecated functions.
*/
#ifndef __GL_DEPRECATED_H__
#define __GL_DEPRECATED_H__
// GL Version 1.0
#undef glAccum
#define glAccum DO_NOT_USE_glAccum
#undef glAlphaFunc
#define glAlphaFunc DO_NOT_USE_glAlphaFunc
#undef glBegin
#define glBegin DO_NOT_USE_glBegin
#undef glBitmap
#define glBitmap DO_NOT_USE_glBitmap
#undef glCallList
#define glCallList DO_NOT_USE_glCallList
#undef glCallLists
#define glCallLists DO_NOT_USE_glCallLists
#undef glClearAccum
#define glClearAccum DO_NOT_USE_glClearAccum
#undef glClearIndex
#define glClearIndex DO_NOT_USE_glClearIndex
#undef glClipPlane
#define glClipPlane DO_NOT_USE_glClipPlane
#undef glColor3b
#define glColor3b DO_NOT_USE_glColor3b
#undef glColor3bv
#define glColor3bv DO_NOT_USE_glColor3bv
#undef glColor3d
#define glColor3d DO_NOT_USE_glColor3d
#undef glColor3dv
#define glColor3dv DO_NOT_USE_glColor3dv
#undef glColor3f
#define glColor3f DO_NOT_USE_glColor3f
#undef glColor3fv
#define glColor3fv DO_NOT_USE_glColor3fv
#undef glColor3i
#define glColor3i DO_NOT_USE_glColor3i
#undef glColor3iv
#define glColor3iv DO_NOT_USE_glColor3iv
#undef glColor3s
#define glColor3s DO_NOT_USE_glColor3s
#undef glColor3sv
#define glColor3sv DO_NOT_USE_glColor3sv
#undef glColor3ub
#define glColor3ub DO_NOT_USE_glColor3ub
#undef glColor3ubv
#define glColor3ubv DO_NOT_USE_glColor3ubv
#undef glColor3ui
#define glColor3ui DO_NOT_USE_glColor3ui
#undef glColor3uiv
#define glColor3uiv DO_NOT_USE_glColor3uiv
#undef glColor3us
#define glColor3us DO_NOT_USE_glColor3us
#undef glColor3usv
#define glColor3usv DO_NOT_USE_glColor3usv
#undef glColor4b
#define glColor4b DO_NOT_USE_glColor4b
#undef glColor4bv
#define glColor4bv DO_NOT_USE_glColor4bv
#undef glColor4d
#define glColor4d DO_NOT_USE_glColor4d
#undef glColor4dv
#define glColor4dv DO_NOT_USE_glColor4dv
#undef glColor4f
#define glColor4f DO_NOT_USE_glColor4f
#undef glColor4fv
#define glColor4fv DO_NOT_USE_glColor4fv
#undef glColor4i
#define glColor4i DO_NOT_USE_glColor4i
#undef glColor4iv
#define glColor4iv DO_NOT_USE_glColor4iv
#undef glColor4s
#define glColor4s DO_NOT_USE_glColor4s
#undef glColor4sv
#define glColor4sv DO_NOT_USE_glColor4sv
#undef glColor4ub
#define glColor4ub DO_NOT_USE_glColor4ub
#undef glColor4ubv
#define glColor4ubv DO_NOT_USE_glColor4ubv
#undef glColor4ui
#define glColor4ui DO_NOT_USE_glColor4ui
#undef glColor4uiv
#define glColor4uiv DO_NOT_USE_glColor4uiv
#undef glColor4us
#define glColor4us DO_NOT_USE_glColor4us
#undef glColor4usv
#define glColor4usv DO_NOT_USE_glColor4usv
#undef glColorMaterial
#define glColorMaterial DO_NOT_USE_glColorMaterial
#undef glCopyPixels
#define glCopyPixels DO_NOT_USE_glCopyPixels
#undef glDeleteLists
#define glDeleteLists DO_NOT_USE_glDeleteLists
#undef glDrawPixels
#define glDrawPixels DO_NOT_USE_glDrawPixels
#undef glEdgeFlag
#define glEdgeFlag DO_NOT_USE_glEdgeFlag
#undef glEdgeFlagv
#define glEdgeFlagv DO_NOT_USE_glEdgeFlagv
#undef glEnd
#define glEnd DO_NOT_USE_glEnd
#undef glEndList
#define glEndList DO_NOT_USE_glEndList
#undef glEvalCoord1d
#define glEvalCoord1d DO_NOT_USE_glEvalCoord1d
#undef glEvalCoord1dv
#define glEvalCoord1dv DO_NOT_USE_glEvalCoord1dv
#undef glEvalCoord1f
#define glEvalCoord1f DO_NOT_USE_glEvalCoord1f
#undef glEvalCoord1fv
#define glEvalCoord1fv DO_NOT_USE_glEvalCoord1fv
#undef glEvalCoord2d
#define glEvalCoord2d DO_NOT_USE_glEvalCoord2d
#undef glEvalCoord2dv
#define glEvalCoord2dv DO_NOT_USE_glEvalCoord2dv
#undef glEvalCoord2f
#define glEvalCoord2f DO_NOT_USE_glEvalCoord2f
#undef glEvalCoord2fv
#define glEvalCoord2fv DO_NOT_USE_glEvalCoord2fv
#undef glEvalMesh1
#define glEvalMesh1 DO_NOT_USE_glEvalMesh1
#undef glEvalMesh2
#define glEvalMesh2 DO_NOT_USE_glEvalMesh2
#undef glEvalPoint1
#define glEvalPoint1 DO_NOT_USE_glEvalPoint1
#undef glEvalPoint2
#define glEvalPoint2 DO_NOT_USE_glEvalPoint2
#undef glFeedbackBuffer
#define glFeedbackBuffer DO_NOT_USE_glFeedbackBuffer
#undef glFogf
#define glFogf DO_NOT_USE_glFogf
#undef glFogfv
#define glFogfv DO_NOT_USE_glFogfv
#undef glFogi
#define glFogi DO_NOT_USE_glFogi
#undef glFogiv
#define glFogiv DO_NOT_USE_glFogiv
#undef glFrustum
#define glFrustum DO_NOT_USE_glFrustum
#undef glGenLists
#define glGenLists DO_NOT_USE_glGenLists
#undef glGetClipPlane
#define glGetClipPlane DO_NOT_USE_glGetClipPlane
#undef glGetLightfv
#define glGetLightfv DO_NOT_USE_glGetLightfv
#undef glGetLightiv
#define glGetLightiv DO_NOT_USE_glGetLightiv
#undef glGetMapdv
#define glGetMapdv DO_NOT_USE_glGetMapdv
#undef glGetMapfv
#define glGetMapfv DO_NOT_USE_glGetMapfv
#undef glGetMapiv
#define glGetMapiv DO_NOT_USE_glGetMapiv
#undef glGetMaterialfv
#define glGetMaterialfv DO_NOT_USE_glGetMaterialfv
#undef glGetMaterialiv
#define glGetMaterialiv DO_NOT_USE_glGetMaterialiv
#undef glGetPixelMapfv
#define glGetPixelMapfv DO_NOT_USE_glGetPixelMapfv
#undef glGetPixelMapuiv
#define glGetPixelMapuiv DO_NOT_USE_glGetPixelMapuiv
#undef glGetPixelMapusv
#define glGetPixelMapusv DO_NOT_USE_glGetPixelMapusv
#undef glGetPolygonStipple
#define glGetPolygonStipple DO_NOT_USE_glGetPolygonStipple
#undef glGetTexEnvfv
#define glGetTexEnvfv DO_NOT_USE_glGetTexEnvfv
#undef glGetTexEnviv
#define glGetTexEnviv DO_NOT_USE_glGetTexEnviv
#undef glGetTexGendv
#define glGetTexGendv DO_NOT_USE_glGetTexGendv
#undef glGetTexGenfv
#define glGetTexGenfv DO_NOT_USE_glGetTexGenfv
#undef glGetTexGeniv
#define glGetTexGeniv DO_NOT_USE_glGetTexGeniv
#undef glIndexMask
#define glIndexMask DO_NOT_USE_glIndexMask
#undef glIndexd
#define glIndexd DO_NOT_USE_glIndexd
#undef glIndexdv
#define glIndexdv DO_NOT_USE_glIndexdv
#undef glIndexf
#define glIndexf DO_NOT_USE_glIndexf
#undef glIndexfv
#define glIndexfv DO_NOT_USE_glIndexfv
#undef glIndexi
#define glIndexi DO_NOT_USE_glIndexi
#undef glIndexiv
#define glIndexiv DO_NOT_USE_glIndexiv
#undef glIndexs
#define glIndexs DO_NOT_USE_glIndexs
#undef glIndexsv
#define glIndexsv DO_NOT_USE_glIndexsv
#undef glInitNames
#define glInitNames DO_NOT_USE_glInitNames
#undef glIsList
#define glIsList DO_NOT_USE_glIsList
#undef glLightModelf
#define glLightModelf DO_NOT_USE_glLightModelf
#undef glLightModelfv
#define glLightModelfv DO_NOT_USE_glLightModelfv
#undef glLightModeli
#define glLightModeli DO_NOT_USE_glLightModeli
#undef glLightModeliv
#define glLightModeliv DO_NOT_USE_glLightModeliv
#undef glLightf
#define glLightf DO_NOT_USE_glLightf
#undef glLightfv
#define glLightfv DO_NOT_USE_glLightfv
#undef glLighti
#define glLighti DO_NOT_USE_glLighti
#undef glLightiv
#define glLightiv DO_NOT_USE_glLightiv
#undef glLineStipple
#define glLineStipple DO_NOT_USE_glLineStipple
#undef glListBase
#define glListBase DO_NOT_USE_glListBase
#undef glLoadIdentity
#define glLoadIdentity DO_NOT_USE_glLoadIdentity
#undef glLoadMatrixd
#define glLoadMatrixd DO_NOT_USE_glLoadMatrixd
#undef glLoadMatrixf
#define glLoadMatrixf DO_NOT_USE_glLoadMatrixf
#undef glLoadName
#define glLoadName DO_NOT_USE_glLoadName
#undef glMap1d
#define glMap1d DO_NOT_USE_glMap1d
#undef glMap1f
#define glMap1f DO_NOT_USE_glMap1f
#undef glMap2d
#define glMap2d DO_NOT_USE_glMap2d
#undef glMap2f
#define glMap2f DO_NOT_USE_glMap2f
#undef glMapGrid1d
#define glMapGrid1d DO_NOT_USE_glMapGrid1d
#undef glMapGrid1f
#define glMapGrid1f DO_NOT_USE_glMapGrid1f
#undef glMapGrid2d
#define glMapGrid2d DO_NOT_USE_glMapGrid2d
#undef glMapGrid2f
#define glMapGrid2f DO_NOT_USE_glMapGrid2f
#undef glMaterialf
#define glMaterialf DO_NOT_USE_glMaterialf
#undef glMaterialfv
#define glMaterialfv DO_NOT_USE_glMaterialfv
#undef glMateriali
#define glMateriali DO_NOT_USE_glMateriali
#undef glMaterialiv
#define glMaterialiv DO_NOT_USE_glMaterialiv
#undef glMatrixMode
#define glMatrixMode DO_NOT_USE_glMatrixMode
#undef glMultMatrixd
#define glMultMatrixd DO_NOT_USE_glMultMatrixd
#undef glMultMatrixf
#define glMultMatrixf DO_NOT_USE_glMultMatrixf
#undef glNewList
#define glNewList DO_NOT_USE_glNewList
#undef glNormal3b
#define glNormal3b DO_NOT_USE_glNormal3b
#undef glNormal3bv
#define glNormal3bv DO_NOT_USE_glNormal3bv
#undef glNormal3d
#define glNormal3d DO_NOT_USE_glNormal3d
#undef glNormal3dv
#define glNormal3dv DO_NOT_USE_glNormal3dv
#undef glNormal3f
#define glNormal3f DO_NOT_USE_glNormal3f
#undef glNormal3fv
#define glNormal3fv DO_NOT_USE_glNormal3fv
#undef glNormal3i
#define glNormal3i DO_NOT_USE_glNormal3i
#undef glNormal3iv
#define glNormal3iv DO_NOT_USE_glNormal3iv
#undef glNormal3s
#define glNormal3s DO_NOT_USE_glNormal3s
#undef glNormal3sv
#define glNormal3sv DO_NOT_USE_glNormal3sv
#undef glOrtho
#define glOrtho DO_NOT_USE_glOrtho
#undef glPassThrough
#define glPassThrough DO_NOT_USE_glPassThrough
#undef glPixelMapfv
#define glPixelMapfv DO_NOT_USE_glPixelMapfv
#undef glPixelMapuiv
#define glPixelMapuiv DO_NOT_USE_glPixelMapuiv
#undef glPixelMapusv
#define glPixelMapusv DO_NOT_USE_glPixelMapusv
#undef glPixelTransferf
#define glPixelTransferf DO_NOT_USE_glPixelTransferf
#undef glPixelTransferi
#define glPixelTransferi DO_NOT_USE_glPixelTransferi
#undef glPixelZoom
#define glPixelZoom DO_NOT_USE_glPixelZoom
#undef glPolygonStipple
#define glPolygonStipple DO_NOT_USE_glPolygonStipple
#undef glPopAttrib
#define glPopAttrib DO_NOT_USE_glPopAttrib
#undef glPopMatrix
#define glPopMatrix DO_NOT_USE_glPopMatrix
#undef glPopName
#define glPopName DO_NOT_USE_glPopName
#undef glPushAttrib
#define glPushAttrib DO_NOT_USE_glPushAttrib
#undef glPushMatrix
#define glPushMatrix DO_NOT_USE_glPushMatrix
#undef glPushName
#define glPushName DO_NOT_USE_glPushName
#undef glRasterPos2d
#define glRasterPos2d DO_NOT_USE_glRasterPos2d
#undef glRasterPos2dv
#define glRasterPos2dv DO_NOT_USE_glRasterPos2dv
#undef glRasterPos2f
#define glRasterPos2f DO_NOT_USE_glRasterPos2f
#undef glRasterPos2fv
#define glRasterPos2fv DO_NOT_USE_glRasterPos2fv
#undef glRasterPos2i
#define glRasterPos2i DO_NOT_USE_glRasterPos2i
#undef glRasterPos2iv
#define glRasterPos2iv DO_NOT_USE_glRasterPos2iv
#undef glRasterPos2s
#define glRasterPos2s DO_NOT_USE_glRasterPos2s
#undef glRasterPos2sv
#define glRasterPos2sv DO_NOT_USE_glRasterPos2sv
#undef glRasterPos3d
#define glRasterPos3d DO_NOT_USE_glRasterPos3d
#undef glRasterPos3dv
#define glRasterPos3dv DO_NOT_USE_glRasterPos3dv
#undef glRasterPos3f
#define glRasterPos3f DO_NOT_USE_glRasterPos3f
#undef glRasterPos3fv
#define glRasterPos3fv DO_NOT_USE_glRasterPos3fv
#undef glRasterPos3i
#define glRasterPos3i DO_NOT_USE_glRasterPos3i
#undef glRasterPos3iv
#define glRasterPos3iv DO_NOT_USE_glRasterPos3iv
#undef glRasterPos3s
#define glRasterPos3s DO_NOT_USE_glRasterPos3s
#undef glRasterPos3sv
#define glRasterPos3sv DO_NOT_USE_glRasterPos3sv
#undef glRasterPos4d
#define glRasterPos4d DO_NOT_USE_glRasterPos4d
#undef glRasterPos4dv
#define glRasterPos4dv DO_NOT_USE_glRasterPos4dv
#undef glRasterPos4f
#define glRasterPos4f DO_NOT_USE_glRasterPos4f
#undef glRasterPos4fv
#define glRasterPos4fv DO_NOT_USE_glRasterPos4fv
#undef glRasterPos4i
#define glRasterPos4i DO_NOT_USE_glRasterPos4i
#undef glRasterPos4iv
#define glRasterPos4iv DO_NOT_USE_glRasterPos4iv
#undef glRasterPos4s
#define glRasterPos4s DO_NOT_USE_glRasterPos4s
#undef glRasterPos4sv
#define glRasterPos4sv DO_NOT_USE_glRasterPos4sv
#undef glRectd
#define glRectd DO_NOT_USE_glRectd
#undef glRectdv
#define glRectdv DO_NOT_USE_glRectdv
#undef glRectf
#define glRectf DO_NOT_USE_glRectf
#undef glRectfv
#define glRectfv DO_NOT_USE_glRectfv
#undef glRecti
#define glRecti DO_NOT_USE_glRecti
#undef glRectiv
#define glRectiv DO_NOT_USE_glRectiv
#undef glRects
#define glRects DO_NOT_USE_glRects
#undef glRectsv
#define glRectsv DO_NOT_USE_glRectsv
#undef glRenderMode
#define glRenderMode DO_NOT_USE_glRenderMode
#undef glRotated
#define glRotated DO_NOT_USE_glRotated
#undef glRotatef
#define glRotatef DO_NOT_USE_glRotatef
#undef glScaled
#define glScaled DO_NOT_USE_glScaled
#undef glScalef
#define glScalef DO_NOT_USE_glScalef
#undef glSelectBuffer
#define glSelectBuffer DO_NOT_USE_glSelectBuffer
#undef glShadeModel
#define glShadeModel DO_NOT_USE_glShadeModel
#undef glTexCoord1d
#define glTexCoord1d DO_NOT_USE_glTexCoord1d
#undef glTexCoord1dv
#define glTexCoord1dv DO_NOT_USE_glTexCoord1dv
#undef glTexCoord1f
#define glTexCoord1f DO_NOT_USE_glTexCoord1f
#undef glTexCoord1fv
#define glTexCoord1fv DO_NOT_USE_glTexCoord1fv
#undef glTexCoord1i
#define glTexCoord1i DO_NOT_USE_glTexCoord1i
#undef glTexCoord1iv
#define glTexCoord1iv DO_NOT_USE_glTexCoord1iv
#undef glTexCoord1s
#define glTexCoord1s DO_NOT_USE_glTexCoord1s
#undef glTexCoord1sv
#define glTexCoord1sv DO_NOT_USE_glTexCoord1sv
#undef glTexCoord2d
#define glTexCoord2d DO_NOT_USE_glTexCoord2d
#undef glTexCoord2dv
#define glTexCoord2dv DO_NOT_USE_glTexCoord2dv
#undef glTexCoord2f
#define glTexCoord2f DO_NOT_USE_glTexCoord2f
#undef glTexCoord2fv
#define glTexCoord2fv DO_NOT_USE_glTexCoord2fv
#undef glTexCoord2i
#define glTexCoord2i DO_NOT_USE_glTexCoord2i
#undef glTexCoord2iv
#define glTexCoord2iv DO_NOT_USE_glTexCoord2iv
#undef glTexCoord2s
#define glTexCoord2s DO_NOT_USE_glTexCoord2s
#undef glTexCoord2sv
#define glTexCoord2sv DO_NOT_USE_glTexCoord2sv
#undef glTexCoord3d
#define glTexCoord3d DO_NOT_USE_glTexCoord3d
#undef glTexCoord3dv
#define glTexCoord3dv DO_NOT_USE_glTexCoord3dv
#undef glTexCoord3f
#define glTexCoord3f DO_NOT_USE_glTexCoord3f
#undef glTexCoord3fv
#define glTexCoord3fv DO_NOT_USE_glTexCoord3fv
#undef glTexCoord3i
#define glTexCoord3i DO_NOT_USE_glTexCoord3i
#undef glTexCoord3iv
#define glTexCoord3iv DO_NOT_USE_glTexCoord3iv
#undef glTexCoord3s
#define glTexCoord3s DO_NOT_USE_glTexCoord3s
#undef glTexCoord3sv
#define glTexCoord3sv DO_NOT_USE_glTexCoord3sv
#undef glTexCoord4d
#define glTexCoord4d DO_NOT_USE_glTexCoord4d
#undef glTexCoord4dv
#define glTexCoord4dv DO_NOT_USE_glTexCoord4dv
#undef glTexCoord4f
#define glTexCoord4f DO_NOT_USE_glTexCoord4f
#undef glTexCoord4fv
#define glTexCoord4fv DO_NOT_USE_glTexCoord4fv
#undef glTexCoord4i
#define glTexCoord4i DO_NOT_USE_glTexCoord4i
#undef glTexCoord4iv
#define glTexCoord4iv DO_NOT_USE_glTexCoord4iv
#undef glTexCoord4s
#define glTexCoord4s DO_NOT_USE_glTexCoord4s
#undef glTexCoord4sv
#define glTexCoord4sv DO_NOT_USE_glTexCoord4sv
#undef glTexEnvf
#define glTexEnvf DO_NOT_USE_glTexEnvf
#undef glTexEnvfv
#define glTexEnvfv DO_NOT_USE_glTexEnvfv
#undef glTexEnvi
#define glTexEnvi DO_NOT_USE_glTexEnvi
#undef glTexEnviv
#define glTexEnviv DO_NOT_USE_glTexEnviv
#undef glTexGend
#define glTexGend DO_NOT_USE_glTexGend
#undef glTexGendv
#define glTexGendv DO_NOT_USE_glTexGendv
#undef glTexGenf
#define glTexGenf DO_NOT_USE_glTexGenf
#undef glTexGenfv
#define glTexGenfv DO_NOT_USE_glTexGenfv
#undef glTexGeni
#define glTexGeni DO_NOT_USE_glTexGeni
#undef glTexGeniv
#define glTexGeniv DO_NOT_USE_glTexGeniv
#undef glTranslated
#define glTranslated DO_NOT_USE_glTranslated
#undef glTranslatef
#define glTranslatef DO_NOT_USE_glTranslatef
#undef glVertex2d
#define glVertex2d DO_NOT_USE_glVertex2d
#undef glVertex2dv
#define glVertex2dv DO_NOT_USE_glVertex2dv
#undef glVertex2f
#define glVertex2f DO_NOT_USE_glVertex2f
#undef glVertex2fv
#define glVertex2fv DO_NOT_USE_glVertex2fv
#undef glVertex2i
#define glVertex2i DO_NOT_USE_glVertex2i
#undef glVertex2iv
#define glVertex2iv DO_NOT_USE_glVertex2iv
#undef glVertex2s
#define glVertex2s DO_NOT_USE_glVertex2s
#undef glVertex2sv
#define glVertex2sv DO_NOT_USE_glVertex2sv
#undef glVertex3d
#define glVertex3d DO_NOT_USE_glVertex3d
#undef glVertex3dv
#define glVertex3dv DO_NOT_USE_glVertex3dv
#undef glVertex3f
#define glVertex3f DO_NOT_USE_glVertex3f
#undef glVertex3fv
#define glVertex3fv DO_NOT_USE_glVertex3fv
#undef glVertex3i
#define glVertex3i DO_NOT_USE_glVertex3i
#undef glVertex3iv
#define glVertex3iv DO_NOT_USE_glVertex3iv
#undef glVertex3s
#define glVertex3s DO_NOT_USE_glVertex3s
#undef glVertex3sv
#define glVertex3sv DO_NOT_USE_glVertex3sv
#undef glVertex4d
#define glVertex4d DO_NOT_USE_glVertex4d
#undef glVertex4dv
#define glVertex4dv DO_NOT_USE_glVertex4dv
#undef glVertex4f
#define glVertex4f DO_NOT_USE_glVertex4f
#undef glVertex4fv
#define glVertex4fv DO_NOT_USE_glVertex4fv
#undef glVertex4i
#define glVertex4i DO_NOT_USE_glVertex4i
#undef glVertex4iv
#define glVertex4iv DO_NOT_USE_glVertex4iv
#undef glVertex4s
#define glVertex4s DO_NOT_USE_glVertex4s
#undef glVertex4sv
#define glVertex4sv DO_NOT_USE_glVertex4sv
// GL Version 1.1
#undef glAreTexturesResident
#define glAreTexturesResident DO_NOT_USE_glAreTexturesResident
#undef glArrayElement
#define glArrayElement DO_NOT_USE_glArrayElement
#undef glColorPointer
#define glColorPointer DO_NOT_USE_glColorPointer
#undef glDisableClientState
#define glDisableClientState DO_NOT_USE_glDisableClientState
#undef glEdgeFlagPointer
#define glEdgeFlagPointer DO_NOT_USE_glEdgeFlagPointer
#undef glEnableClientState
#define glEnableClientState DO_NOT_USE_glEnableClientState
#undef glIndexPointer
#define glIndexPointer DO_NOT_USE_glIndexPointer
#undef glIndexub
#define glIndexub DO_NOT_USE_glIndexub
#undef glIndexubv
#define glIndexubv DO_NOT_USE_glIndexubv
#undef glInterleavedArrays
#define glInterleavedArrays DO_NOT_USE_glInterleavedArrays
#undef glNormalPointer
#define glNormalPointer DO_NOT_USE_glNormalPointer
#undef glPopClientAttrib
#define glPopClientAttrib DO_NOT_USE_glPopClientAttrib
#undef glPrioritizeTextures
#define glPrioritizeTextures DO_NOT_USE_glPrioritizeTextures
#undef glPushClientAttrib
#define glPushClientAttrib DO_NOT_USE_glPushClientAttrib
#undef glTexCoordPointer
#define glTexCoordPointer DO_NOT_USE_glTexCoordPointer
#undef glVertexPointer
#define glVertexPointer DO_NOT_USE_glVertexPointer
// GL Version1.2
#undef glColorSubTable
#define glColorSubTable DO_NOT_USE_glColorSubTable
#undef glColorTable
#define glColorTable DO_NOT_USE_glColorTable
#undef glColorTableParameterfv
#define glColorTableParameterfv DO_NOT_USE_glColorTableParameterfv
#undef glColorTableParameteriv
#define glColorTableParameteriv DO_NOT_USE_glColorTableParameteriv
#undef glConvolutionFilter1D
#define glConvolutionFilter1D DO_NOT_USE_glConvolutionFilter1D
#undef glConvolutionFilter2D
#define glConvolutionFilter2D DO_NOT_USE_glConvolutionFilter2D
#undef glConvolutionParameterf
#define glConvolutionParameterf DO_NOT_USE_glConvolutionParameterf
#undef glConvolutionParameterfv
#define glConvolutionParameterfv DO_NOT_USE_glConvolutionParameterfv
#undef glConvolutionParameteri
#define glConvolutionParameteri DO_NOT_USE_glConvolutionParameteri
#undef glConvolutionParameteriv
#define glConvolutionParameteriv DO_NOT_USE_glConvolutionParameteriv
#undef glCopyColorSubTable
#define glCopyColorSubTable DO_NOT_USE_glCopyColorSubTable
#undef glCopyColorTable
#define glCopyColorTable DO_NOT_USE_glCopyColorTable
#undef glCopyConvolutionFilter1D
#define glCopyConvolutionFilter1D DO_NOT_USE_glCopyConvolutionFilter1D
#undef glCopyConvolutionFilter2D
#define glCopyConvolutionFilter2D DO_NOT_USE_glCopyConvolutionFilter2D
#undef glGetColorTable
#define glGetColorTable DO_NOT_USE_glGetColorTable
#undef glGetColorTableParameterfv
#define glGetColorTableParameterfv DO_NOT_USE_glGetColorTableParameterfv
#undef glGetColorTableParameteriv
#define glGetColorTableParameteriv DO_NOT_USE_glGetColorTableParameteriv
#undef glGetConvolutionFilter
#define glGetConvolutionFilter DO_NOT_USE_glGetConvolutionFilter
#undef glGetConvolutionParameterfv
#define glGetConvolutionParameterfv DO_NOT_USE_glGetConvolutionParameterfv
#undef glGetConvolutionParameteriv
#define glGetConvolutionParameteriv DO_NOT_USE_glGetConvolutionParameteriv
#undef glGetHistogram
#define glGetHistogram DO_NOT_USE_glGetHistogram
#undef glGetHistogramParameterfv
#define glGetHistogramParameterfv DO_NOT_USE_glGetHistogramParameterfv
#undef glGetHistogramParameteriv
#define glGetHistogramParameteriv DO_NOT_USE_glGetHistogramParameteriv
#undef glGetMinmax
#define glGetMinmax DO_NOT_USE_glGetMinmax
#undef glGetMinmaxParameterfv
#define glGetMinmaxParameterfv DO_NOT_USE_glGetMinmaxParameterfv
#undef glGetMinmaxParameteriv
#define glGetMinmaxParameteriv DO_NOT_USE_glGetMinmaxParameteriv
#undef glGetSeparableFilter
#define glGetSeparableFilter DO_NOT_USE_glGetSeparableFilter
#undef glHistogram
#define glHistogram DO_NOT_USE_glHistogram
#undef glMinmax
#define glMinmax DO_NOT_USE_glMinmax
#undef glResetHistogram
#define glResetHistogram DO_NOT_USE_glResetHistogram
#undef glResetMinmax
#define glResetMinmax DO_NOT_USE_glResetMinmax
#undef glSeparableFilter2D
#define glSeparableFilter2D DO_NOT_USE_glSeparableFilter2D
// GL Version1.3
#undef glClientActiveTexture
#define glClientActiveTexture DO_NOT_USE_glClientActiveTexture
#undef glLoadTransposeMatrixd
#define glLoadTransposeMatrixd DO_NOT_USE_glLoadTransposeMatrixd
#undef glLoadTransposeMatrixf
#define glLoadTransposeMatrixf DO_NOT_USE_glLoadTransposeMatrixf
#undef glMultTransposeMatrixd
#define glMultTransposeMatrixd DO_NOT_USE_glMultTransposeMatrixd
#undef glMultTransposeMatrixf
#define glMultTransposeMatrixf DO_NOT_USE_glMultTransposeMatrixf
#undef glMultiTexCoord1d
#define glMultiTexCoord1d DO_NOT_USE_glMultiTexCoord1d
#undef glMultiTexCoord1dv
#define glMultiTexCoord1dv DO_NOT_USE_glMultiTexCoord1dv
#undef glMultiTexCoord1f
#define glMultiTexCoord1f DO_NOT_USE_glMultiTexCoord1f
#undef glMultiTexCoord1fv
#define glMultiTexCoord1fv DO_NOT_USE_glMultiTexCoord1fv
#undef glMultiTexCoord1i
#define glMultiTexCoord1i DO_NOT_USE_glMultiTexCoord1i
#undef glMultiTexCoord1iv
#define glMultiTexCoord1iv DO_NOT_USE_glMultiTexCoord1iv
#undef glMultiTexCoord1s
#define glMultiTexCoord1s DO_NOT_USE_glMultiTexCoord1s
#undef glMultiTexCoord1sv
#define glMultiTexCoord1sv DO_NOT_USE_glMultiTexCoord1sv
#undef glMultiTexCoord2d
#define glMultiTexCoord2d DO_NOT_USE_glMultiTexCoord2d
#undef glMultiTexCoord2dv
#define glMultiTexCoord2dv DO_NOT_USE_glMultiTexCoord2dv
#undef glMultiTexCoord2f
#define glMultiTexCoord2f DO_NOT_USE_glMultiTexCoord2f
#undef glMultiTexCoord2fv
#define glMultiTexCoord2fv DO_NOT_USE_glMultiTexCoord2fv
#undef glMultiTexCoord2i
#define glMultiTexCoord2i DO_NOT_USE_glMultiTexCoord2i
#undef glMultiTexCoord2iv
#define glMultiTexCoord2iv DO_NOT_USE_glMultiTexCoord2iv
#undef glMultiTexCoord2s
#define glMultiTexCoord2s DO_NOT_USE_glMultiTexCoord2s
#undef glMultiTexCoord2sv
#define glMultiTexCoord2sv DO_NOT_USE_glMultiTexCoord2sv
#undef glMultiTexCoord3d
#define glMultiTexCoord3d DO_NOT_USE_glMultiTexCoord3d
#undef glMultiTexCoord3dv
#define glMultiTexCoord3dv DO_NOT_USE_glMultiTexCoord3dv
#undef glMultiTexCoord3f
#define glMultiTexCoord3f DO_NOT_USE_glMultiTexCoord3f
#undef glMultiTexCoord3fv
#define glMultiTexCoord3fv DO_NOT_USE_glMultiTexCoord3fv
#undef glMultiTexCoord3i
#define glMultiTexCoord3i DO_NOT_USE_glMultiTexCoord3i
#undef glMultiTexCoord3iv
#define glMultiTexCoord3iv DO_NOT_USE_glMultiTexCoord3iv
#undef glMultiTexCoord3s
#define glMultiTexCoord3s DO_NOT_USE_glMultiTexCoord3s
#undef glMultiTexCoord3sv
#define glMultiTexCoord3sv DO_NOT_USE_glMultiTexCoord3sv
#undef glMultiTexCoord4d
#define glMultiTexCoord4d DO_NOT_USE_glMultiTexCoord4d
#undef glMultiTexCoord4dv
#define glMultiTexCoord4dv DO_NOT_USE_glMultiTexCoord4dv
#undef glMultiTexCoord4f
#define glMultiTexCoord4f DO_NOT_USE_glMultiTexCoord4f
#undef glMultiTexCoord4fv
#define glMultiTexCoord4fv DO_NOT_USE_glMultiTexCoord4fv
#undef glMultiTexCoord4i
#define glMultiTexCoord4i DO_NOT_USE_glMultiTexCoord4i
#undef glMultiTexCoord4iv
#define glMultiTexCoord4iv DO_NOT_USE_glMultiTexCoord4iv
#undef glMultiTexCoord4s
#define glMultiTexCoord4s DO_NOT_USE_glMultiTexCoord4s
#undef glMultiTexCoord4sv
#define glMultiTexCoord4sv DO_NOT_USE_glMultiTexCoord4sv
// GL Version 1.4
#undef glFogCoordPointer
#define glFogCoordPointer DO_NOT_USE_glFogCoordPointer
#undef glFogCoordd
#define glFogCoordd DO_NOT_USE_glFogCoordd
#undef glFogCoorddv
#define glFogCoorddv DO_NOT_USE_glFogCoorddv
#undef glFogCoordf
#define glFogCoordf DO_NOT_USE_glFogCoordf
#undef glFogCoordfv
#define glFogCoordfv DO_NOT_USE_glFogCoordfv
#undef glSecondaryColor3b
#define glSecondaryColor3b DO_NOT_USE_glSecondaryColor3b
#undef glSecondaryColor3bv
#define glSecondaryColor3bv DO_NOT_USE_glSecondaryColor3bv
#undef glSecondaryColor3d
#define glSecondaryColor3d DO_NOT_USE_glSecondaryColor3d
#undef glSecondaryColor3dv
#define glSecondaryColor3dv DO_NOT_USE_glSecondaryColor3dv
#undef glSecondaryColor3f
#define glSecondaryColor3f DO_NOT_USE_glSecondaryColor3f
#undef glSecondaryColor3fv
#define glSecondaryColor3fv DO_NOT_USE_glSecondaryColor3fv
#undef glSecondaryColor3i
#define glSecondaryColor3i DO_NOT_USE_glSecondaryColor3i
#undef glSecondaryColor3iv
#define glSecondaryColor3iv DO_NOT_USE_glSecondaryColor3iv
#undef glSecondaryColor3s
#define glSecondaryColor3s DO_NOT_USE_glSecondaryColor3s
#undef glSecondaryColor3sv
#define glSecondaryColor3sv DO_NOT_USE_glSecondaryColor3sv
#undef glSecondaryColor3ub
#define glSecondaryColor3ub DO_NOT_USE_glSecondaryColor3ub
#undef glSecondaryColor3ubv
#define glSecondaryColor3ubv DO_NOT_USE_glSecondaryColor3ubv
#undef glSecondaryColor3ui
#define glSecondaryColor3ui DO_NOT_USE_glSecondaryColor3ui
#undef glSecondaryColor3uiv
#define glSecondaryColor3uiv DO_NOT_USE_glSecondaryColor3uiv
#undef glSecondaryColor3us
#define glSecondaryColor3us DO_NOT_USE_glSecondaryColor3us
#undef glSecondaryColor3usv
#define glSecondaryColor3usv DO_NOT_USE_glSecondaryColor3usv
#undef glSecondaryColorPointer
#define glSecondaryColorPointer DO_NOT_USE_glSecondaryColorPointer
#undef glWindowPos2d
#define glWindowPos2d DO_NOT_USE_glWindowPos2d
#undef glWindowPos2dv
#define glWindowPos2dv DO_NOT_USE_glWindowPos2dv
#undef glWindowPos2f
#define glWindowPos2f DO_NOT_USE_glWindowPos2f
#undef glWindowPos2fv
#define glWindowPos2fv DO_NOT_USE_glWindowPos2fv
#undef glWindowPos2i
#define glWindowPos2i DO_NOT_USE_glWindowPos2i
#undef glWindowPos2iv
#define glWindowPos2iv DO_NOT_USE_glWindowPos2iv
#undef glWindowPos2s
#define glWindowPos2s DO_NOT_USE_glWindowPos2s
#undef glWindowPos2sv
#define glWindowPos2sv DO_NOT_USE_glWindowPos2sv
#undef glWindowPos3d
#define glWindowPos3d DO_NOT_USE_glWindowPos3d
#undef glWindowPos3dv
#define glWindowPos3dv DO_NOT_USE_glWindowPos3dv
#undef glWindowPos3f
#define glWindowPos3f DO_NOT_USE_glWindowPos3f
#undef glWindowPos3fv
#define glWindowPos3fv DO_NOT_USE_glWindowPos3fv
#undef glWindowPos3i
#define glWindowPos3i DO_NOT_USE_glWindowPos3i
#undef glWindowPos3iv
#define glWindowPos3iv DO_NOT_USE_glWindowPos3iv
#undef glWindowPos3s
#define glWindowPos3s DO_NOT_USE_glWindowPos3s
#undef glWindowPos3sv
#define glWindowPos3sv DO_NOT_USE_glWindowPos3sv
// Old Token Names 1.2
#undef GL_POINT_SIZE_RANGE
#define GL_POINT_SIZE_RANGE DO_NOT_USE_GL_POINT_SIZE_RANGE
#undef GL_POINT_SIZE_GRANULARITY
#define GL_POINT_SIZE_GRANULARITY DO_NOT_USE_GL_POINT_SIZE_GRANULARITY
// Old Token Names 1.5
#undef GL_CURRENT_FOG_COORDINATE
#define GL_CURRENT_FOG_COORDINATE DO_NOT_USE_GL_CURRENT_FOG_COORDINATE
#undef GL_FOG_COORDINATE
#define GL_FOG_COORDINATE DO_NOT_USE_GL_FOG_COORDINATE
#undef GL_FOG_COORDINATE_ARRAY
#define GL_FOG_COORDINATE_ARRAY DO_NOT_USE_GL_FOG_COORDINATE_ARRAY
#undef GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING
#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING DO_NOT_USE_GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING
#undef GL_FOG_COORDINATE_ARRAY_POINTER
#define GL_FOG_COORDINATE_ARRAY_POINTER DO_NOT_USE_GL_FOG_COORDINATE_ARRAY_POINTER
#undef GL_FOG_COORDINATE_ARRAY_STRIDE
#define GL_FOG_COORDINATE_ARRAY_STRIDE DO_NOT_USE_GL_FOG_COORDINATE_ARRAY_STRIDE
#undef GL_FOG_COORDINATE_ARRAY_TYPE
#define GL_FOG_COORDINATE_ARRAY_TYPE DO_NOT_USE_GL_FOG_COORDINATE_ARRAY_TYPE
#undef GL_FOG_COORDINATE_SOURCE
#define GL_FOG_COORDINATE_SOURCE DO_NOT_USE_GL_FOG_COORDINATE_SOURCE
#undef GL_SOURCE0_ALPHA
#define GL_SOURCE0_ALPHA DO_NOT_USE_GL_SOURCE0_ALPHA
#undef GL_SOURCE0_RGB
#define GL_SOURCE0_RGB DO_NOT_USE_GL_SOURCE0_RGB
#undef GL_SOURCE1_ALPHA
#define GL_SOURCE1_ALPHA DO_NOT_USE_GL_SOURCE1_ALPHA
#undef GL_SOURCE1_RGB
#define GL_SOURCE1_RGB DO_NOT_USE_GL_SOURCE1_RGB
#undef GL_SOURCE2_ALPHA
#define GL_SOURCE2_ALPHA DO_NOT_USE_GL_SOURCE2_ALPHA
#undef GL_SOURCE2_RGB
#define GL_SOURCE2_RGB DO_NOT_USE_GL_SOURCE2_RGB
// Old Token Names 3.0
#undef GL_CLIP_PLANE0
#define GL_CLIP_PLANE0 USE_GL_CLIP_DISTANCE0
#undef GL_CLIP_PLANE1
#define GL_CLIP_PLANE1 USE_GL_CLIP_DISTANCE1
#undef GL_CLIP_PLANE2
#define GL_CLIP_PLANE2 USE_GL_CLIP_DISTANCE2
#undef GL_CLIP_PLANE3
#define GL_CLIP_PLANE3 USE_GL_CLIP_DISTANCE3
#undef GL_CLIP_PLANE4
#define GL_CLIP_PLANE4 USE_GL_CLIP_DISTANCE4
#undef GL_CLIP_PLANE5
#define GL_CLIP_PLANE5 USE_GL_CLIP_DISTANCE5
#undef GL_COMPARE_R_TO_TEXTURE
#define GL_COMPARE_R_TO_TEXTURE USE_GL_COMPARE_REF_TO_TEXTURE
#undef GL_MAX_CLIP_PLANES
#define GL_MAX_CLIP_PLANES USE_GL_MAX_CLIP_DISTANCES
#undef GL_MAX_VARYING_FLOATS
#define GL_MAX_VARYING_FLOATS USE__MAX_VARYING_COMPONENTS
// Old Token Names 3.2
#undef GL_VERTEX_PROGRAM_POINT_SIZE
#define GL_VERTEX_PROGRAM_POINT_SIZE USE_GL_PROGRAM_POINT_SIZE
// Old Token Names 4.1
#undef GL_CURRENT_PROGRAM
#define GL_CURRENT_PROGRAM DO_NOT_USE_GL_CURRENT_PROGRAM
#endif /* __GL_DEPRECATED_H__ */

@ -0,0 +1,139 @@
/*
* ***** 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) 2014 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file glew-mx.c
* \ingroup glew-mx
*/
#include "glew-mx.h"
#include <stdio.h>
#include <stdlib.h>
#define CASE_CODE_RETURN_STR(code) case code: return #code;
static const char *get_glew_error_enum_string(GLenum error)
{
switch (error) {
CASE_CODE_RETURN_STR(GLEW_OK) /* also GLEW_NO_ERROR */
CASE_CODE_RETURN_STR(GLEW_ERROR_NO_GL_VERSION)
CASE_CODE_RETURN_STR(GLEW_ERROR_GL_VERSION_10_ONLY)
CASE_CODE_RETURN_STR(GLEW_ERROR_GLX_VERSION_11_ONLY)
#ifdef WITH_GLEW_ES
CASE_CODE_RETURN_STR(GLEW_ERROR_NOT_GLES_VERSION)
CASE_CODE_RETURN_STR(GLEW_ERROR_GLES_VERSION)
CASE_CODE_RETURN_STR(GLEW_ERROR_NO_EGL_VERSION)
CASE_CODE_RETURN_STR(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 = (const char *)glewGetErrorString(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 (0x%04X): %s: %s\n",
error,
code ? code : "<no symbol>",
msg ? msg : "<no message>");
#endif
}
return error;
}
#ifdef WITH_GLEW_MX
MXContext *_mx_context = NULL;
#endif
MXContext *mxCreateContext(void)
{
#if WITH_GLEW_MX
MXContext* new_ctx = calloc(1, sizeof(MXContext));
if (new_ctx != NULL) {
MXContext* cur_ctx = _mx_context;
_mx_context = new_ctx;
GLEW_CHK(glewInit());
_mx_context = cur_ctx;
}
return new_ctx;
#else
GLEW_CHK(glewInit());
return NULL;
#endif
}
MXContext *mxGetCurrentContext(void)
{
#if WITH_GLEW_MX
return _mx_context;
#else
return NULL;
#endif
}
void mxMakeCurrentContext(MXContext *ctx)
{
#if WITH_GLEW_MX
_mx_context = ctx;
#else
(void)ctx;
#endif
}
void mxDestroyContext(MXContext *ctx)
{
#if WITH_GLEW_MX
if (_mx_context == ctx)
_mx_context = NULL;
free(ctx);
#else
(void)ctx;
#endif
}

@ -0,0 +1,305 @@
/*
* ***** 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) 2014 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Jason Wilkins
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file intern/symbol-binding.h
* \ingroup glew-mx
*
* This file is for any simple stuff that is missing from GLEW when
* compiled with either the GLEW_ES_ONLY or the GLEW_NO_ES flag.
*
* Should be limited to symbolic constants.
*
* This file is NOT for checking DEPRECATED OpenGL symbolic constants.
*/
#ifndef __SYMBOL_BINDING_H__
#define __SYMBOL_BINDING_H__
#ifndef __GLEW_MX_H__
#error This file is meant to be included from glew-mx.h
#endif
#ifdef GLEW_ES_ONLY
/* ES does not support the GLdouble type. */
#ifndef GLdouble
#define GLdouble double
#endif
/*
* Need stubs for these version checks if compiling with only ES support.
* Rely on compiler to eliminate unreachable code when version checks become constants.
*/
#ifndef GLEW_VERSION_1_1
#define GLEW_VERSION_1_1 0
#endif
#ifndef GLEW_VERSION_1_2
#define GLEW_VERSION_1_2 0
#endif
#ifndef GLEW_VERSION_1_3
#define GLEW_VERSION_1_3 0
#endif
#ifndef GLEW_VERSION_1_4
#define GLEW_VERSION_1_4 0
#endif
#ifndef GLEW_VERSION_1_5
#define GLEW_VERSION_1_5 0
#endif
#ifndef GLEW_VERSION_2_0
#define GLEW_VERSION_2_0 0
#endif
#ifndef GLEW_VERSION_3_0
#define GLEW_VERSION_3_0 0
#endif
#ifndef GLEW_ARB_shader_objects
#define GLEW_ARB_shader_objects 0
#endif
#ifndef GLEW_ARB_vertex_shader
#define GLEW_ARB_vertex_shader 0
#endif
#ifndef GLEW_ARB_vertex_program
#define GLEW_ARB_vertex_program 0
#endif
#ifndef GLEW_ARB_fragment_program
#define GLEW_ARB_fragment_program 0
#endif
#ifndef GLEW_ARB_vertex_buffer_object
#define GLEW_ARB_vertex_buffer_object 0
#endif
#ifndef GLEW_ARB_framebuffer_object
#define GLEW_ARB_framebuffer_object 0
#endif
#ifndef GLEW_ARB_multitexture
#define GLEW_ARB_multitexture 0
#endif
#ifndef GLEW_EXT_framebuffer_object
#define GLEW_EXT_framebuffer_object 0
#endif
#ifndef GLEW_ARB_depth_texture
#define GLEW_ARB_depth_texture 0
#endif
#ifndef GLEW_ARB_shadow
#define GLEW_ARB_shadow 0
#endif
#ifndef GLEW_ARB_texture_float
#define GLEW_ARB_texture_float 0
#endif
#ifndef GLEW_ARB_texture_non_power_of_two
#define GLEW_ARB_texture_non_power_of_two 0
#endif
#ifndef GLEW_ARB_texture3D
#define GLEW_ARB_texture3D 0
#endif
#ifndef GLEW_EXT_texture3D
#define GLEW_EXT_texture3D 0
#endif
#ifndef GLEW_ARB_texture_rg
#define GLEW_ARB_texture_rg 0
#endif
#ifndef GLEW_ARB_texture_query_lod
#define GLEW_ARB_texture_query_lod 0
#endif
/*
* The following symbolic constants are missing from an ES only header,
* so alias them to their (same valued) extension versions which are available in the header.
*
* Be careful that this does not lead to unguarded use of what are extensions in ES!
*
* Some of these may be here simply to patch inconsistencies in the header files.
*/
#ifndef GL_TEXTURE_3D
#define GL_TEXTURE_3D GL_TEXTURE_3D_OES
#endif
#ifndef GL_TEXTURE_WRAP_R
#define GL_TEXTURE_WRAP_R GL_TEXTURE_WRAP_R_OES
#endif
#ifndef GL_TEXTURE_COMPARE_MODE
#define GL_TEXTURE_COMPARE_MODE GL_TEXTURE_COMPARE_MODE_EXT
#endif
#ifndef GL_COMPARE_REF_TO_TEXTURE
#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_REF_TO_TEXTURE_EXT
#endif
#ifndef GL_TEXTURE_COMPARE_FUNC
#define GL_TEXTURE_COMPARE_FUNC GL_TEXTURE_COMPARE_FUNC_EXT
#endif
#ifndef GL_RGBA8
#define GL_RGBA8 GL_RGBA8_OES
#endif
#ifndef GL_RGBA16F
#define GL_RGBA16F GL_RGBA16F_EXT
#endif
#ifndef GL_RG32F
#define GL_RG32F GL_RG32F_EXT
#endif
#ifndef GL_RGB8
#define GL_RGB8 GL_RGB8_OES
#endif
#ifndef GL_RG
#define GL_RG GL_RG_EXT
#endif
#ifndef GL_RED
#define GL_RED GL_RED_EXT
#endif
#ifndef GL_FRAMEBUFFER_INCOMPLETE_FORMATS
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES
#endif
#ifndef GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES
#endif
#ifndef GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES
#endif
#ifndef GL_WRITE_ONLY
#define GL_WRITE_ONLY GL_WRITE_ONLY_OES
#endif
#ifndef GLEW_ARB_vertex_array_object
#define GLEW_ARB_vertex_array_object 0
#endif
/* end of ifdef GLEW_ES_ONLY */
#elif defined(GLEW_NO_ES)
/*
* Need stubs for these version checks if compiling without any support.
* Rely on compiler to eliminate unreachable code when version checks become constants
*/
#ifndef GLEW_ES_VERSION_2_0
#define GLEW_ES_VERSION_2_0 0
#endif
#ifndef GLEW_EXT_texture_storage
#define GLEW_EXT_texture_storage 0
#endif
#ifndef GLEW_OES_framebuffer_object
#define GLEW_OES_framebuffer_object 0
#endif
#ifndef GLEW_OES_mapbuffer
#define GLEW_OES_mapbuffer 0
#endif
#ifndef GLEW_OES_required_internalformat
#define GLEW_OES_required_internalformat 0
#endif
#ifndef GLEW_EXT_color_buffer_half_float
#define GLEW_EXT_color_buffer_half_float 0
#endif
#ifndef GLEW_OES_depth_texture
#define GLEW_OES_depth_texture 0
#endif
#ifndef GLEW_EXT_shadow_samplers
#define GLEW_EXT_shadow_samplers 0
#endif
#ifndef GLEW_ARB_texture3D
#define GLEW_ARB_texture3D 0
#endif
#ifndef GLEW_OES_texture_3D
#define GLEW_OES_texture_3D 0
#endif
#ifndef GLEW_EXT_texture_rg
#define GLEW_EXT_texture_rg 0
#endif
#ifndef GLEW_OES_vertex_array_object
#define GLEW_OES_vertex_array_object 0
#endif
/*
* The following symbolic constants are missing when there is no ES support,
* so alias them to their (same valued) extension versions which are available in the header.
*
* Desktop GL typically does not have any extensions that originated from ES,
* unlike ES which has many extensions to replace what was taken out.
*
* For that reason these aliases are more likely just patching inconsistencies in the header files.
*/
#ifndef GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
#endif
#ifndef GL_FRAMEBUFFER_INCOMPLETE_FORMATS
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
#endif
#endif /* ifdef GLEW_NO_ES */
#endif /* __SYMBOL_BINDING_H__*/

@ -36,6 +36,11 @@ set(SRC
boost_locale_wrapper.h
)
if(APPLE)
# Cocoa code to read the locale on OSX
list(APPEND SRC osx_user_locale.mm)
endif()
if(WITH_HEADLESS)
add_definitions(-DWITH_HEADLESS)
endif()

@ -29,6 +29,10 @@ Import('env')
sources = env.Glob('*.cpp')
if env['OURPLATFORM'] in ['darwin']:
# Cocoa code to read user locale on OSX
sources.append('osx_user_locale.mm')
incs = '.'
defs = []

@ -65,8 +65,7 @@ void bl_locale_set(const char *locale)
}
else {
#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL)
extern char GHOST_user_locale[128]; // pulled from Ghost_SystemCocoa
std::string locale_osx = GHOST_user_locale + std::string(".UTF-8");
std::string locale_osx = osx_user_locale() + std::string(".UTF-8");
_locale = gen(locale_osx.c_str());
#else
_locale = gen("");

@ -42,7 +42,11 @@ void bl_locale_init(const char *messages_path, const char *default_domain);
void bl_locale_set(const char *locale);
const char *bl_locale_get(void);
const char *bl_locale_pgettext(const char *msgctxt, const char *msgid);
#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL)
const char* osx_user_locale(void);
#endif
#ifdef __cplusplus
}
#endif

@ -0,0 +1,22 @@
#include "boost_locale_wrapper.h"
#import <Cocoa/Cocoa.h>
#include <cstdlib>
static char* user_locale = NULL;
// get current locale
const char* osx_user_locale()
{
::free(user_locale);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
NSLocale * myNSLocale = (NSLocale *) myCFLocale;
[myNSLocale autorelease];
NSString *nsIdentifier = [myNSLocale localeIdentifier];
user_locale = ::strdup([nsIdentifier UTF8String]);
[pool drain];
return user_locale;
}

@ -25,6 +25,7 @@
set(INC
.
../glew-mx
../guardedalloc
../../source/blender/blenlib
)
@ -44,9 +45,10 @@ set(SRC
if(WITH_OPENCOLORIO)
add_definitions(
-DWITH_OCIO
-DGLEW_STATIC
)
add_definitions(${GL_DEFINITIONS})
list(APPEND INC_SYS
${OPENCOLORIO_INCLUDE_DIRS}
${GLEW_INCLUDE_PATH}

@ -30,12 +30,13 @@ Import('env')
sources = env.Glob('*.cc')
incs = '. ../guardedalloc ../../source/blender/blenlib'
defs = [ 'GLEW_STATIC' ]
defs = env['BF_GL_DEFINITIONS']
if env['WITH_BF_OCIO']:
defs.append('WITH_OCIO')
incs += ' ' + env['BF_OCIO_INC']
incs += ' ' + '#/extern/glew/include'
incs += ' ' + env['BF_GLEW_INC']
incs += ' ' + '#/intern/glew-mx'
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
incs += ' ' + env['BF_BOOST_INC']

@ -29,13 +29,6 @@
#include <sstream>
#include <string.h>
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/glew.h>
#endif
#include <OpenColorIO/OpenColorIO.h>
using namespace OCIO_NAMESPACE;

@ -37,7 +37,7 @@
#include <sstream>
#include <string.h>
#include <GL/glew.h>
#include "glew-mx.h"
#include <OpenColorIO/OpenColorIO.h>

@ -26,11 +26,13 @@ set(INC
../blenkernel
../blenlib
../editors/include
../gpu
../makesdna
../makesrna
../python
../imbuf
../../../intern/guardedalloc
../../../intern/glew-mx
../../../intern/locale
)
@ -58,7 +60,7 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
add_definitions(-DGLEW_STATIC)
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_blenfont "${SRC}" "${INC}" "${INC_SYS}")

@ -35,10 +35,12 @@ incs = [
'intern',
'#/intern/guardedalloc',
'#/intern/locale',
'#/extern/glew/include',
env['BF_GLEW_INC'],
'#/intern/glew-mx',
'../blenkernel',
'../blenlib',
'../editors/include',
'../gpu',
'../imbuf',
'../makesdna',
'../makesrna',
@ -47,7 +49,7 @@ incs = [
incs.extend(Split(env['BF_FREETYPE_INC']))
defs = ['GLEW_STATIC']
defs = env['BF_GL_DEFINITIONS']
if sys.platform == 'win32' or env['OURPLATFORM'] == 'linuxcross':
defs.append('_WIN32')

@ -38,6 +38,7 @@ set(INC
../nodes
../render/extern/include
../../../intern/guardedalloc
../../../intern/glew-mx
../../../intern/iksolver/extern
../../../intern/memutil
../../../intern/mikktspace
@ -272,7 +273,7 @@ set(SRC
intern/pbvh_intern.h
)
add_definitions(-DGLEW_STATIC)
add_definitions(${GL_DEFINITIONS})
if(WITH_AUDASPACE)
list(APPEND INC

@ -45,7 +45,8 @@ incs = [
'#/intern/raskter',
'#/intern/rigidbody',
'#/extern/bullet2/src',
'#/extern/glew/include',
env['BF_GLEW_INC'],
'#/intern/glew-mx',
'#/intern/audaspace/intern',
'#/intern/elbeem/extern',
'#/intern/iksolver/extern',
@ -65,14 +66,11 @@ incs = [
'../nodes',
'../render/extern/include',
'../windowmanager',
env['BF_OPENGL_INC'],
env['BF_ZLIB_INC'],
]
incs = ' '.join(incs)
defs = [
'GLEW_STATIC',
]
defs = env['BF_GL_DEFINITIONS']
if env['WITH_BF_SMOKE']:
defs.append('WITH_SMOKE')

@ -72,11 +72,10 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
#include "BLI_sys_types.h" /* for intptr_t support */
#include "GL/glew.h"
#include "GPU_buffers.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_glew.h"
#include "GPU_material.h"
/* very slow! enable for testing only! */

@ -34,8 +34,6 @@
* \ingroup bke
*/
#include "GL/glew.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
@ -62,6 +60,7 @@
#include "GPU_buffers.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_glew.h"
#include "GPU_material.h"
#include <string.h>

@ -41,8 +41,6 @@
* is likely to be a little slow.
*/
#include "GL/glew.h"
#include "BLI_math.h"
#include "BLI_jitter.h"
#include "BLI_bitmap.h"
@ -58,6 +56,7 @@
#include "MEM_guardedalloc.h"
#include "GPU_extensions.h"
#include "GPU_glew.h"
extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */

@ -1644,7 +1644,7 @@ void BKE_pbvh_raycast_project_ray_root (PBVH *bvh, bool original, float ray_star
}
//#include <GL/glew.h>
//#include "GPU_glew.h"
typedef struct {
DMSetMaterial setMaterial;

@ -33,8 +33,6 @@
/* Part of the code copied from elbeem fluid library, copyright by Nils Thuerey */
#include <GL/glew.h>
#include "MEM_guardedalloc.h"
#include <float.h>
@ -84,6 +82,8 @@
#include "RE_shader_ext.h"
#include "GPU_glew.h"
/* UNUSED so far, may be enabled later */
/* #define USE_SMOKE_COLLISION_DM */

@ -72,10 +72,9 @@
# include "BLI_array.h"
#endif
#include "GL/glew.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_glew.h"
#include "GPU_material.h"
#include "CCGSubSurf.h"

@ -23,10 +23,12 @@ set(INC
../../blenfont
../../blenkernel
../../blenlib
../../gpu
../../makesdna
../../makesrna
../../windowmanager
../../../../intern/guardedalloc
../../../../intern/glew-mx
)
set(INC_SYS
@ -57,4 +59,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_editor_animation "${SRC}" "${INC}" "${INC_SYS}")

@ -31,17 +31,19 @@ sources = env.Glob('*.c')
incs = [
'#/intern/guardedalloc',
'#/extern/glew/include',
env['BF_GLEW_INC'],
'#/intern/glew-mx',
'../include',
'../../blenfont',
'../../blenkernel',
'../../blenlib',
'../../gpu',
'../../makesdna',
'../../makesrna',
'../../windowmanager',
]
defs = []
defs = env['BF_GL_DEFINITIONS']
if env['WITH_BF_INTERNATIONAL']:
defs.append('WITH_INTERNATIONAL')

@ -23,11 +23,12 @@ set(INC
../../blenfont
../../blenkernel
../../blenlib
../../gpu
../../makesdna
../../makesrna
../../windowmanager
../../gpu
../../../../intern/guardedalloc
../../../../intern/glew-mx
)
set(INC_SYS
@ -74,4 +75,6 @@ if(WITH_OPENNL)
)
endif()
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_editor_armature "${SRC}" "${INC}" "${INC_SYS}")

@ -31,20 +31,21 @@ sources = env.Glob('*.c')
incs = [
'#/intern/guardedalloc',
'#/extern/glew/include',
env['BF_GLEW_INC'],
'#/intern/glew-mx',
'#/intern/opennl/extern',
'../include',
'../../blenfont',
'../../blenkernel',
'../../blenlib',
'../../gpu',
'../../makesdna',
'../../makesrna',
'../../gpu',
'../../windowmanager',
]
incs = ' '.join(incs)
defs = []
defs = env['BF_GL_DEFINITIONS']
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
incs += ' ' + env['BF_PTHREADS_INC']

@ -24,10 +24,12 @@ set(INC
../../blenkernel
../../blenlib
../../imbuf
../../gpu
../../makesdna
../../makesrna
../../windowmanager
../../../../intern/guardedalloc
../../../../intern/glew-mx
)
set(INC_SYS
@ -50,4 +52,6 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_editor_gpencil "${SRC}" "${INC}" "${INC_SYS}")

@ -31,7 +31,8 @@ sources = env.Glob('*.c')
incs = [
'#/intern/guardedalloc',
'#/extern/glew/include',
env['BF_GLEW_INC'],
'#/intern/glew-mx',
'#/intern/elbeem/extern',
'../include',
'../../blenfont',
@ -46,7 +47,7 @@ incs = [
'../../windowmanager',
]
defs = []
defs = env['BF_GL_DEFINITIONS']
if env['WITH_BF_INTERNATIONAL']:
defs.append('WITH_INTERNATIONAL')

@ -33,7 +33,7 @@
#ifndef __BIF_GL_H__
#define __BIF_GL_H__
#include "GL/glew.h"
#include "GPU_glew.h"
#ifdef __APPLE__

@ -30,6 +30,7 @@ set(INC
../../python
../../windowmanager
../../../../intern/guardedalloc
../../../../intern/glew-mx
)
set(INC_SYS
@ -70,4 +71,6 @@ if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_editor_interface "${SRC}" "${INC}" "${INC_SYS}")

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