https://developer.blender.org/D643 Separates graphics context creation from window code in Ghost so that they can vary separately.master
parent
a8705e99ee
commit
8d084e8c8f
@ -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
|
||||
)
|
||||
|
@ -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}")
|
@ -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] )
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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__
|
@ -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}")
|
@ -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] )
|
@ -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__*/
|
@ -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;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue