Commit 48e0db85 authored by Robert Menzel's avatar Robert Menzel

Improved glProgramUniform support

* OpenGL 4.1 style glProgramUniform functions are provided as mappings
  from an extension or emulation
* mapping functions now consider OpenGL ES and native support for iOS 5
* ShaderProgram uses glProgramUniform instead of the EXT version like
  in OpenGL 4.1
* Easy to query OpenGL version numbers in OpenGL::Tools added
* clean up in ACGL::init()
* namespaces in the extension file
parent 4e55450d
......@@ -22,6 +22,9 @@
#include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/GL.hh>
namespace ACGL{
namespace OpenGL{
/*
* This should get called AFTER glewInit but BEFORE any ACGL or DSA *EXT functions get called.
* Normally this gets called by acglInit!
......@@ -31,6 +34,8 @@
*/
void initDirectStateAccessFunctions();
} // OpenGL
} // ACGL
//
// On some windows configurations ACGLAPIENTRYcan be defined wrong which leads to compile
......@@ -489,6 +494,9 @@ extern PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC glVertexArrayVertexOffsetEXT;
#endif
namespace ACGL{
namespace OpenGL{
//
// Emulation functions
//
......@@ -706,7 +714,8 @@ void ACGLAPIENTRY glVertexArrayVertexAttribIOffsetEMULATION (GLuint vaobj, GLuin
void ACGLAPIENTRY glVertexArrayVertexAttribOffsetEMULATION (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset);
void ACGLAPIENTRY glVertexArrayVertexOffsetEMULATION (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);
} // OpenGL
} // ACGL
#endif // ACGL_OPENGL_EXT_DIRECT_STATE_ACCESS_HH
......@@ -125,18 +125,18 @@ public:
//DSA versions:
inline void setProgramUniform (GLint _location, GLint _v) const { glProgramUniform1iEXT (mContext, _location, _v); }
inline void setProgramUniform (GLint _location, GLfloat _v) const { glProgramUniform1fEXT (mContext, _location, _v); }
inline void setProgramUniform (GLint _location, GLint _v) const { glProgramUniform1i (mContext, _location, _v); }
inline void setProgramUniform (GLint _location, GLfloat _v) const { glProgramUniform1f (mContext, _location, _v); }
inline void setProgramUniform (GLint _location, const glm::vec2& _v) const { glProgramUniform2fvEXT(mContext, _location, 1, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::vec3& _v) const { glProgramUniform3fvEXT(mContext, _location, 1, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::vec4& _v) const { glProgramUniform4fvEXT(mContext, _location, 1, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::vec2& _v) const { glProgramUniform2fv(mContext, _location, 1, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::vec3& _v) const { glProgramUniform3fv(mContext, _location, 1, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::vec4& _v) const { glProgramUniform4fv(mContext, _location, 1, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::mat2& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix2fvEXT(mContext, _location, 1, _transpose, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::mat3& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix3fvEXT(mContext, _location, 1, _transpose, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::mat4& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix4fvEXT(mContext, _location, 1, _transpose, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::mat2& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix2fv(mContext, _location, 1, _transpose, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::mat3& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix3fv(mContext, _location, 1, _transpose, glm::value_ptr(_v)); }
inline void setProgramUniform (GLint _location, const glm::mat4& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix4fv(mContext, _location, 1, _transpose, glm::value_ptr(_v)); }
inline void setTextureDSA (GLint _location, const ConstSharedTexture& _texture, GLenum _unit = 0) const { glProgramUniform1iEXT(mContext, _location, _unit); _texture->bind(_unit); }
inline void setProgramTexture (GLint _location, const ConstSharedTexture& _texture, GLenum _unit = 0) const { glProgramUniform1i(mContext, _location, _unit); _texture->bind(_unit); }
// =================================================================================================== \/
// ============================================================================== HIGH LEVEL FUNCTIONS \/
......@@ -168,7 +168,7 @@ public:
inline void setProgramUniform (const std::string& _nameInShader, const glm::mat3& _v, GLboolean _transpose = GL_FALSE) const { setProgramUniform( getUniformLocation(_nameInShader), _v); }
inline void setProgramUniform (const std::string& _nameInShader, const glm::mat4& _v, GLboolean _transpose = GL_FALSE) const { setProgramUniform( getUniformLocation(_nameInShader), _v); }
inline void setTextureDSA (const std::string& _nameInShader, const ConstSharedTexture& _texture, GLenum _unit = 0) const { setProgramUniform( getUniformLocation(_nameInShader), (GLint) _unit); _texture->bind(_unit); }
inline void setProgramTexture (const std::string& _nameInShader, const ConstSharedTexture& _texture, GLenum _unit = 0) const { setProgramUniform( getUniformLocation(_nameInShader), (GLint) _unit); _texture->bind(_unit); }
// =================================================================================================== \/
......
......@@ -7,7 +7,7 @@
#define ACGL_OPENGL_TOOLS_HH
/*
* Some OpeGL related helper functions.
* Some OpenGL related helper functions.
* All the error checking functions are in here.
*/
......@@ -33,6 +33,12 @@ inline GLint getGLTypeSize ( GLenum _type )
return 0;
}
uint32_t getOpenGLMinorVersionNumber();
uint32_t getOpenGLMajorVersionNumber();
// returns the combined version number as 10*major + minor for easy comparing
uint32_t getOpenGLVersionNumber();
// for every OpenGL error enum this will return a human readable version of it
// similar to gluErrorString, but that function is not available on all plattforms
// (read: iOS)
......
......@@ -7,7 +7,6 @@
#include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Tools.hh>
#include <stdlib.h>
namespace ACGL
{
......@@ -20,7 +19,7 @@ bool init(void)
#ifdef USE_GLEW
glewInit();
if (openGLCriticalErrorOccured()) {
ACGL::Utils::error() << "could not init GLEW!" << std::endl;
Utils::error() << "could not init GLEW!" << std::endl;
return false;
}
#endif
......@@ -28,46 +27,21 @@ bool init(void)
//
// check OpenGL version
//
Utils::debug() << "OpenGL Version: " << OpenGL::getOpenGLMajorVersionNumber() << "." << OpenGL::getOpenGLMinorVersionNumber() << std::endl;
float openGLVersionF = atof( (const char*) glGetString(GL_VERSION) );
GLint openGLmajorVersion;
GLint openGLminorVersion;
if (openGLVersionF < 3.0) {
if (openGLVersionF >= 2.1) {
openGLmajorVersion = 2;
openGLminorVersion = 1;
} else {
ACGL::Utils::error() << "OpenGL version " << openGLVersionF << " not supported!" << std::endl;
return false;
}
} else {
// OpenGL 3.0 is needed for this (saves us float/ascii to int conversion)
glGetIntegerv(GL_MAJOR_VERSION, &openGLmajorVersion);
glGetIntegerv(GL_MINOR_VERSION, &openGLminorVersion);
}
if (openGLRareErrorOccured()) {
ACGL::Utils::error() << "could not query OpenGL version!" << std::endl;
return false;
}
ACGL::Utils::debug() << "OpenGL Version: " << openGLmajorVersion << "." << openGLminorVersion << std::endl;
uint32_t openGLVersion = (openGLmajorVersion*10 + openGLminorVersion);
if (openGLVersion < ACGL_OPENGL_VERSION) {
ACGL::Utils::error() << "At compile time an OpenGL context of version " << ACGL_OPENGL_VERSION
<< " was requested, but the current context only supports " << openGLVersion << std::endl;
//return false;
if (OpenGL::getOpenGLVersionNumber() < ACGL_OPENGL_VERSION) {
Utils::error() << "At compile time an OpenGL context of version " << ACGL_OPENGL_VERSION
<< " was requested, but the current context only supports " << OpenGL::getOpenGLVersionNumber() << std::endl;
return false;
}
//
// Init DirectStateAccess functions:
// (using the extension versions or our own (slower) emulation)
//
initDirectStateAccessFunctions();
OpenGL::initDirectStateAccessFunctions();
return true;
}
};
}
#include "ACGL/OpenGL/EXT_direct_state_access.hh"
#include <ACGL/OpenGL/Tools.hh>
void mapEmulationToEXTPointers();
namespace ACGL{
namespace OpenGL{
#if (defined(OPENGL_ES) && defined(PLATFORM_IOS))
void mapProgramUniformFromEXTiOS();
#endif
void mapProgramUniformFromEXT();
void mapProgramUniformFromEMULATION();
void mapDSAFromEMULATION();
void initDirectStateAccessFunctions()
{
if (GLEW_EXT_direct_state_access) {
ACGL::Utils::debug() << "native EXT_direct_state_access detected" << std::endl;
} else {
ACGL::Utils::message() << "EXT_direct_state_access has to be emulated - some of the functions could be missing..." << std::endl;
mapEmulationToEXTPointers();
}
//
// Handle glProgramUniform*() calls
//
# if defined(OPENGL_ES)
# if ( defined(PLATFORM_IOS) && defined(GL_EXT_separate_shader_objects) )
// iOS >= 5.0 with 2011 hardware should implement the seperate_shader_objects
// extension which provides glProgramUniform*EXT calls
mapProgramUniformFromEXTiOS();
# else
// old iOS versions and other OpenGL ES implementations have to emulate the
// calls to glProgramUniform*()
mapProgramUniformFromEMULATION();
# endif
// other OpenGL ES targets:
mapProgramUniformFromEMULATION();
# else
// desktop:
if (getOpenGLVersionNumber() < 41) {
// glUniformProgram*() is part of GL 4.1, so there's nothing to do from 4.1 on
# ifdef USE_GLEW
if (GLEW_ARB_separate_shader_objects || GLEW_EXT_direct_state_access) {
mapProgramUniformFromEXT();
} else {
mapProgramUniformFromEMULATION();
}
# else
mapProgramUniformFromEMULATION();
# endif
}
# endif
//
// other DSA functions:
//
# ifdef USE_GLEW
if (GLEW_EXT_direct_state_access) {
ACGL::Utils::debug() << "native EXT_direct_state_access detected" << std::endl;
} else {
ACGL::Utils::message() << "EXT_direct_state_access has to be emulated - some of the functions could be missing..." << std::endl;
mapDSAFromEMULATION();
}
# else
mapDSAFromEMULATION();
# endif
}
#if (defined(OPENGL_ES) && defined(PLATFORM_IOS))
// TODO: testing
void mapProgramUniformFromEXTiOS()
{
glProgramUniform1f = glProgramUniform1fEXT;
glProgramUniform1fv = glProgramUniform1fvEXT;
glProgramUniform1i = glProgramUniform1iEXT;
glProgramUniform1iv = glProgramUniform1ivEXT;
glProgramUniform2f = glProgramUniform2fEXT;
glProgramUniform2fv = glProgramUniform2fvEXT;
glProgramUniform2i = glProgramUniform2iEXT;
glProgramUniform2iv = glProgramUniform2ivEXT;
glProgramUniform3f = glProgramUniform3fEXT;
glProgramUniform3fv = glProgramUniform3fvEXT;
glProgramUniform3i = glProgramUniform3iEXT;
glProgramUniform3iv = glProgramUniform3ivEXT;
glProgramUniform4f = glProgramUniform4fEXT;
glProgramUniform4fv = glProgramUniform4fvEXT;
glProgramUniform4i = glProgramUniform4iEXT;
glProgramUniform4iv = glProgramUniform4ivEXT;
glProgramUniformMatrix2fv = glProgramUniformMatrix2fvEXT;
glProgramUniformMatrix3fv = glProgramUniformMatrix3fvEXT;
glProgramUniformMatrix4fv = glProgramUniformMatrix4fvEXT;
}
#endif
void mapProgramUniformFromEXT()
{
glProgramUniform1f = glProgramUniform1fEXT;
glProgramUniform1fv = glProgramUniform1fvEXT;
glProgramUniform1i = glProgramUniform1iEXT;
glProgramUniform1iv = glProgramUniform1ivEXT;
glProgramUniform1ui = glProgramUniform1uiEXT;
glProgramUniform1uiv = glProgramUniform1uivEXT;
glProgramUniform2f = glProgramUniform2fEXT;
glProgramUniform2fv = glProgramUniform2fvEXT;
glProgramUniform2i = glProgramUniform2iEXT;
glProgramUniform2iv = glProgramUniform2ivEXT;
glProgramUniform2ui = glProgramUniform2uiEXT;
glProgramUniform2uiv = glProgramUniform2uivEXT;
glProgramUniform3f = glProgramUniform3fEXT;
glProgramUniform3fv = glProgramUniform3fvEXT;
glProgramUniform3i = glProgramUniform3iEXT;
glProgramUniform3iv = glProgramUniform3ivEXT;
glProgramUniform3ui = glProgramUniform3uiEXT;
glProgramUniform3uiv = glProgramUniform3uivEXT;
glProgramUniform4f = glProgramUniform4fEXT;
glProgramUniform4fv = glProgramUniform4fvEXT;
glProgramUniform4i = glProgramUniform4iEXT;
glProgramUniform4iv = glProgramUniform4ivEXT;
glProgramUniform4ui = glProgramUniform4uiEXT;
glProgramUniform4uiv = glProgramUniform4uivEXT;
glProgramUniformMatrix2fv = glProgramUniformMatrix2fvEXT;
glProgramUniformMatrix2x3fv = glProgramUniformMatrix2x3fvEXT;
glProgramUniformMatrix2x4fv = glProgramUniformMatrix2x4fvEXT;
glProgramUniformMatrix3fv = glProgramUniformMatrix3fvEXT;
glProgramUniformMatrix3x2fv = glProgramUniformMatrix3x2fvEXT;
glProgramUniformMatrix3x4fv = glProgramUniformMatrix3x4fvEXT;
glProgramUniformMatrix4fv = glProgramUniformMatrix4fvEXT;
glProgramUniformMatrix4x2fv = glProgramUniformMatrix4x2fvEXT;
glProgramUniformMatrix4x3fv = glProgramUniformMatrix4x3fvEXT;
}
void mapProgramUniformFromEMULATION()
{
glProgramUniform1f = glProgramUniform1fEMULATION;
glProgramUniform1fv = glProgramUniform1fvEMULATION;
glProgramUniform1i = glProgramUniform1iEMULATION;
glProgramUniform1iv = glProgramUniform1ivEMULATION;
glProgramUniform1ui = glProgramUniform1uiEMULATION;
glProgramUniform1uiv = glProgramUniform1uivEMULATION;
glProgramUniform2f = glProgramUniform2fEMULATION;
glProgramUniform2fv = glProgramUniform2fvEMULATION;
glProgramUniform2i = glProgramUniform2iEMULATION;
glProgramUniform2iv = glProgramUniform2ivEMULATION;
glProgramUniform2ui = glProgramUniform2uiEMULATION;
glProgramUniform2uiv = glProgramUniform2uivEMULATION;
glProgramUniform3f = glProgramUniform3fEMULATION;
glProgramUniform3fv = glProgramUniform3fvEMULATION;
glProgramUniform3i = glProgramUniform3iEMULATION;
glProgramUniform3iv = glProgramUniform3ivEMULATION;
glProgramUniform3ui = glProgramUniform3uiEMULATION;
glProgramUniform3uiv = glProgramUniform3uivEMULATION;
glProgramUniform4f = glProgramUniform4fEMULATION;
glProgramUniform4fv = glProgramUniform4fvEMULATION;
glProgramUniform4i = glProgramUniform4iEMULATION;
glProgramUniform4iv = glProgramUniform4ivEMULATION;
glProgramUniform4ui = glProgramUniform4uiEMULATION;
glProgramUniform4uiv = glProgramUniform4uivEMULATION;
glProgramUniformMatrix2fv = glProgramUniformMatrix2fvEMULATION;
glProgramUniformMatrix2x3fv = glProgramUniformMatrix2x3fvEMULATION;
glProgramUniformMatrix2x4fv = glProgramUniformMatrix2x4fvEMULATION;
glProgramUniformMatrix3fv = glProgramUniformMatrix3fvEMULATION;
glProgramUniformMatrix3x2fv = glProgramUniformMatrix3x2fvEMULATION;
glProgramUniformMatrix3x4fv = glProgramUniformMatrix3x4fvEMULATION;
glProgramUniformMatrix4fv = glProgramUniformMatrix4fvEMULATION;
glProgramUniformMatrix4x2fv = glProgramUniformMatrix4x2fvEMULATION;
glProgramUniformMatrix4x3fv = glProgramUniformMatrix4x3fvEMULATION;
//
// just to be sure the EXT versions are also defined
// (we can't put them in mapDSAFromEMULATION in case they are defined
// from the GLEW_ARB_separate_shader_objects extension!)
//
glProgramUniform1fEXT = glProgramUniform1fEMULATION;
glProgramUniform1fvEXT = glProgramUniform1fvEMULATION;
glProgramUniform1iEXT = glProgramUniform1iEMULATION;
glProgramUniform1ivEXT = glProgramUniform1ivEMULATION;
glProgramUniform1uiEXT = glProgramUniform1uiEMULATION;
glProgramUniform1uivEXT = glProgramUniform1uivEMULATION;
glProgramUniform2fEXT = glProgramUniform2fEMULATION;
glProgramUniform2fvEXT = glProgramUniform2fvEMULATION;
glProgramUniform2iEXT = glProgramUniform2iEMULATION;
glProgramUniform2ivEXT = glProgramUniform2ivEMULATION;
glProgramUniform2uiEXT = glProgramUniform2uiEMULATION;
glProgramUniform2uivEXT = glProgramUniform2uivEMULATION;
glProgramUniform3fEXT = glProgramUniform3fEMULATION;
glProgramUniform3fvEXT = glProgramUniform3fvEMULATION;
glProgramUniform3iEXT = glProgramUniform3iEMULATION;
glProgramUniform3ivEXT = glProgramUniform3ivEMULATION;
glProgramUniform3uiEXT = glProgramUniform3uiEMULATION;
glProgramUniform3uivEXT = glProgramUniform3uivEMULATION;
glProgramUniform4fEXT = glProgramUniform4fEMULATION;
glProgramUniform4fvEXT = glProgramUniform4fvEMULATION;
glProgramUniform4iEXT = glProgramUniform4iEMULATION;
glProgramUniform4ivEXT = glProgramUniform4ivEMULATION;
glProgramUniform4uiEXT = glProgramUniform4uiEMULATION;
glProgramUniform4uivEXT = glProgramUniform4uivEMULATION;
glProgramUniformMatrix2fvEXT = glProgramUniformMatrix2fvEMULATION;
glProgramUniformMatrix2x3fvEXT = glProgramUniformMatrix2x3fvEMULATION;
glProgramUniformMatrix2x4fvEXT = glProgramUniformMatrix2x4fvEMULATION;
glProgramUniformMatrix3fvEXT = glProgramUniformMatrix3fvEMULATION;
glProgramUniformMatrix3x2fvEXT = glProgramUniformMatrix3x2fvEMULATION;
glProgramUniformMatrix3x4fvEXT = glProgramUniformMatrix3x4fvEMULATION;
glProgramUniformMatrix4fvEXT = glProgramUniformMatrix4fvEMULATION;
glProgramUniformMatrix4x2fvEXT = glProgramUniformMatrix4x2fvEMULATION;
glProgramUniformMatrix4x3fvEXT = glProgramUniformMatrix4x3fvEMULATION;
}
void mapEmulationToEXTPointers()
void mapDSAFromEMULATION()
{
glBindMultiTextureEXT = glBindMultiTextureEMULATION;
glCheckNamedFramebufferStatusEXT = glCheckNamedFramebufferStatusEMULATION;
......@@ -168,39 +354,7 @@ void mapEmulationToEXTPointers()
glNamedRenderbufferStorageEXT = glNamedRenderbufferStorageEMULATION;
glNamedRenderbufferStorageMultisampleCoverageEXT = glNamedRenderbufferStorageMultisampleCoverageEMULATION;
glNamedRenderbufferStorageMultisampleEXT = glNamedRenderbufferStorageMultisampleEMULATION;
glProgramUniform1fEXT = glProgramUniform1fEMULATION;
glProgramUniform1fvEXT = glProgramUniform1fvEMULATION;
glProgramUniform1iEXT = glProgramUniform1iEMULATION;
glProgramUniform1ivEXT = glProgramUniform1ivEMULATION;
glProgramUniform1uiEXT = glProgramUniform1uiEMULATION;
glProgramUniform1uivEXT = glProgramUniform1uivEMULATION;
glProgramUniform2fEXT = glProgramUniform2fEMULATION;
glProgramUniform2fvEXT = glProgramUniform2fvEMULATION;
glProgramUniform2iEXT = glProgramUniform2iEMULATION;
glProgramUniform2ivEXT = glProgramUniform2ivEMULATION;
glProgramUniform2uiEXT = glProgramUniform2uiEMULATION;
glProgramUniform2uivEXT = glProgramUniform2uivEMULATION;
glProgramUniform3fEXT = glProgramUniform3fEMULATION;
glProgramUniform3fvEXT = glProgramUniform3fvEMULATION;
glProgramUniform3iEXT = glProgramUniform3iEMULATION;
glProgramUniform3ivEXT = glProgramUniform3ivEMULATION;
glProgramUniform3uiEXT = glProgramUniform3uiEMULATION;
glProgramUniform3uivEXT = glProgramUniform3uivEMULATION;
glProgramUniform4fEXT = glProgramUniform4fEMULATION;
glProgramUniform4fvEXT = glProgramUniform4fvEMULATION;
glProgramUniform4iEXT = glProgramUniform4iEMULATION;
glProgramUniform4ivEXT = glProgramUniform4ivEMULATION;
glProgramUniform4uiEXT = glProgramUniform4uiEMULATION;
glProgramUniform4uivEXT = glProgramUniform4uivEMULATION;
glProgramUniformMatrix2fvEXT = glProgramUniformMatrix2fvEMULATION;
glProgramUniformMatrix2x3fvEXT = glProgramUniformMatrix2x3fvEMULATION;
glProgramUniformMatrix2x4fvEXT = glProgramUniformMatrix2x4fvEMULATION;
glProgramUniformMatrix3fvEXT = glProgramUniformMatrix3fvEMULATION;
glProgramUniformMatrix3x2fvEXT = glProgramUniformMatrix3x2fvEMULATION;
glProgramUniformMatrix3x4fvEXT = glProgramUniformMatrix3x4fvEMULATION;
glProgramUniformMatrix4fvEXT = glProgramUniformMatrix4fvEMULATION;
glProgramUniformMatrix4x2fvEXT = glProgramUniformMatrix4x2fvEMULATION;
glProgramUniformMatrix4x3fvEXT = glProgramUniformMatrix4x3fvEMULATION;
glPushClientAttribDefaultEXT = glPushClientAttribDefaultEMULATION;
glTextureBufferEXT = glTextureBufferEMULATION;
glTextureImage1DEXT = glTextureImage1DEMULATION;
......@@ -230,6 +384,9 @@ void mapEmulationToEXTPointers()
glVertexArrayVertexOffsetEXT = glVertexArrayVertexOffsetEMULATION;
}
} // OpenGL
} // ACGL
#ifndef USE_GLEW
//
// Without GLEW we use our own pointers:
......@@ -452,6 +609,8 @@ PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC glVertexArrayVertexOffsetEXT;
namespace ACGL{
namespace OpenGL{
////////////////////////////////////////////////////////////////////////////////////////////////////
// The emulation functions:
// Note: not all are implemented yet ;-)
......@@ -1366,6 +1525,9 @@ void glVertexArrayVertexAttribOffsetEMULATION (GLuint vaobj, GLuint buffer, GLui
void glVertexArrayVertexOffsetEMULATION (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset) { ACGL::Utils::error() << "NOT IMPLEMENTED YET" << std::endl; }
} // OpenGL
} // ACGL
......@@ -9,6 +9,74 @@
namespace ACGL{
namespace OpenGL{
//
// This is a "private" function that should not be called from outside of this file.
//
// glGetIntegerv(GL_MAJOR_VERSION... and glGetIntegerv(GL_MINOR_VERSION... are great, but
// require OpenGL 3.0 and are not supported on ES :-( so the VERSION string has to get parsed...
//
// OpenGL spec:
// The VERSION ... strings are laid out as follows:
// <version number><space><vendor-specific information>
//
// OpenGL ES spec:
// The VERSION string is laid out as follows:
// "OpenGL ES N.M vendor-specific information"
//
// both specs:
// The version number is either of the form major_number.minor_number or
// major_number.minor_number.release_number, where the numbers all have one or more digits.
//
uint32_t privateGetOpenGLVersion( int _type )
{
static uint32_t OGLminor = 0;
static uint32_t OGLmajor = 0;
static uint32_t OGLversion = 0;
if (OGLversion == 0) {
// calculate the version numbers once:
// NOTE: similar to GLEW we assume here, that the minor and major numbers
// only have one digit. We also ignore release numbers. This will fail e.g. for OpenGL 10.0
const GLubyte* versionString;
versionString = glGetString(GL_VERSION);
if (openGLRareErrorOccured()) {
ACGL::Utils::error() << "could not query OpenGL version!" << std::endl;
return false;
}
int positionOfFirstDot = 0;
while ((versionString[positionOfFirstDot] != '\0') && (versionString[positionOfFirstDot] != '.')) ++positionOfFirstDot;
OGLmajor = versionString[positionOfFirstDot-1] - '0';
OGLminor = versionString[positionOfFirstDot+1] - '0';
if (OGLmajor < 0 || OGLmajor > 9) OGLmajor = 0;
if (OGLminor < 0 || OGLminor > 9) OGLminor = 0;
OGLversion = OGLmajor*10 + OGLminor;
}
switch (_type) {
case 0: return OGLminor;
case 1: return OGLmajor;
default: return OGLversion;
};
}
uint32_t getOpenGLMinorVersionNumber()
{
return privateGetOpenGLVersion( 0 );
}
uint32_t getOpenGLMajorVersionNumber()
{
return privateGetOpenGLVersion( 1 );
}
uint32_t getOpenGLVersionNumber()
{
return privateGetOpenGLVersion( 2 );
}
const GLubyte* acglErrorString( GLenum _errorCode )
{
#ifdef PLATFORM_IOS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment