Commit 5cc2583a authored by Robert Menzel's avatar Robert Menzel
Browse files

fixed 2 minor bugs on GLEW less systems, better define names

parent 48e0db85
......@@ -10,7 +10,7 @@
*
* can now be expressed as:
*
* glProgramUniformEXT( shader, 1.0f );
* glProgramUniform1f( shader, 1.0f );
*
* If you forget the glUseProgram, bad things can happen. Also: the bound shader program changed, if
* you want to set a uniform without sideeffects, you'll have to save the currently bound shader,
......@@ -53,12 +53,15 @@ void initDirectStateAccessFunctions();
//
// GLEW defines function pointers for the DSA extension functions, if there is no GLEW we have
// to it our self:
#ifndef USE_GLEW
#ifndef ACGL_USE_GLEW
#define GL_PROGRAM_MATRIX_ACGL 0x8E2D
#define GL_TRANSPOSE_PROGRAM_MATRIX_ACGL 0x8E2E
#define GL_PROGRAM_MATRIX_STACK_DEPTH_ACGL 0x8E2F
typedef ptrdiff_t GLintptr;
typedef ptrdiff_t GLsizeiptr;
typedef void (ACGLAPIENTRY* PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture);
typedef GLenum (ACGLAPIENTRY* PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target);
typedef void (ACGLAPIENTRY* PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);
......
......@@ -81,13 +81,13 @@
#endif
// always include glew unless on iOS
#define USE_GLEW
#define ACGL_USE_GLEW
#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR))
# if (TARGET_OS_IPHONE == 1)
# define PLATFORM_IOS
# define OPENGL_ES
# undef USE_GLEW // no glew support on iOS
# define ACGL_OPENGL_ES
# undef ACGL_USE_GLEW // no glew support on iOS
# endif
#else
// no iOS device...
......@@ -96,12 +96,12 @@
// maybe maemo or android: first one to program for these plattforms should add
// the correct includes here!
# error UNKNOWN mobile plattform! Dont know what to include!
# define OPENGL_ES
# define ACGL_OPENGL_ES
# endif
#endif
// we have allways to include glew first!
#ifdef USE_GLEW
#ifdef ACGL_USE_GLEW
#ifdef GLEW_LOCAL_PATH
#include GLEW_LOCAL_PATH
#else
......@@ -111,11 +111,11 @@
#include <GL/glew.h>
#endif
#endif // !GLEW_LOCAL_PATH
#endif // USE_GLEW
#endif // ACGL_USE_GLEW
#if defined(__APPLE__) || defined(MACOSX)
#ifdef OPENGL_ES
#ifdef ACGL_OPENGL_ES
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#import <OpenGLES/ES2/gl.h>
......
......@@ -170,7 +170,7 @@ public:
inline bool setDepthRenderBuffer(const ConstSharedRenderBuffer& _renderBuffer)
{
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _renderBuffer->getContext());
#ifdef OPENGL_ES
#ifdef ACGL_OPENGL_ES
if( _renderBuffer->getInternalFormat() == GL_DEPTH24_STENCIL8_OES ||
_renderBuffer->getInternalFormat() == GL_DEPTH_STENCIL_OES)
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _renderBuffer->getContext());
......@@ -186,7 +186,7 @@ public:
inline bool setDepthTexture(const ConstSharedTexture& _texture)
{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, _texture->getTarget(), _texture->getContext(), 0);
#ifdef OPENGL_ES
#ifdef ACGL_OPENGL_ES
if( _texture->getInternalFormat() == GL_DEPTH24_STENCIL8_OES ||
_texture->getInternalFormat() == GL_DEPTH_STENCIL_OES)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, _texture->getTarget(), _texture->getContext(), 0);
......
......@@ -16,7 +16,7 @@ bool init(void)
//
// init GLEW
//
#ifdef USE_GLEW
#ifdef ACGL_USE_GLEW
glewInit();
if (openGLCriticalErrorOccured()) {
Utils::error() << "could not init GLEW!" << std::endl;
......
......@@ -4,7 +4,7 @@
namespace ACGL{
namespace OpenGL{
#if (defined(OPENGL_ES) && defined(PLATFORM_IOS))
#if (defined(ACGL_OPENGL_ES) && defined(PLATFORM_IOS))
void mapProgramUniformFromEXTiOS();
#endif
void mapProgramUniformFromEXT();
......@@ -16,7 +16,7 @@ void initDirectStateAccessFunctions()
//
// Handle glProgramUniform*() calls
//
# if defined(OPENGL_ES)
# if defined(ACGL_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
......@@ -32,7 +32,7 @@ void initDirectStateAccessFunctions()
// desktop:
if (getOpenGLVersionNumber() < 41) {
// glUniformProgram*() is part of GL 4.1, so there's nothing to do from 4.1 on
# ifdef USE_GLEW
# ifdef ACGL_USE_GLEW
if (GLEW_ARB_separate_shader_objects || GLEW_EXT_direct_state_access) {
mapProgramUniformFromEXT();
} else {
......@@ -47,7 +47,7 @@ void initDirectStateAccessFunctions()
//
// other DSA functions:
//
# ifdef USE_GLEW
# ifdef ACGL_USE_GLEW
if (GLEW_EXT_direct_state_access) {
ACGL::Utils::debug() << "native EXT_direct_state_access detected" << std::endl;
} else {
......@@ -59,7 +59,7 @@ void initDirectStateAccessFunctions()
# endif
}
#if (defined(OPENGL_ES) && defined(PLATFORM_IOS))
#if (defined(ACGL_OPENGL_ES) && defined(PLATFORM_IOS))
// TODO: testing
void mapProgramUniformFromEXTiOS()
{
......@@ -387,7 +387,7 @@ void mapDSAFromEMULATION()
} // OpenGL
} // ACGL
#ifndef USE_GLEW
#ifndef ACGL_USE_GLEW
//
// Without GLEW we use our own pointers:
//
......
......@@ -79,9 +79,9 @@ uint32_t getOpenGLVersionNumber()
const GLubyte* acglErrorString( GLenum _errorCode )
{
#ifdef PLATFORM_IOS
#ifndef ACGL_USE_GLEW
// no gluErrorString on iOS
// this should only get used on OpenGL ES plattforms, so error strings from the compatibility profile
// this should only get used on OpenGL ES plattforms or if compiled without GLEW, so error strings from the compatibility profile
// are ignored. Only 3.2+ Core and ES 2.0+ errors belong here:
if (_errorCode == GL_INVALID_ENUM) { return (GLubyte*) "GL_INVALID_ENUM"; }
else if (_errorCode == GL_INVALID_VALUE) { return (GLubyte*) "GL_INVALID_VALUE"; }
......
Supports Markdown
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