Commit c6077eca authored by Robert Menzel's avatar Robert Menzel
Browse files

OpenGL ES 2 and 3 compatibility changes

parent 72e09659
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <ACGL/OpenGL/Data/LocationMappings.hh> #include <ACGL/OpenGL/Data/LocationMappings.hh>
#include <ACGL/Base/Settings.hh> #include <ACGL/Base/Settings.hh>
#ifdef ACGL_SUPPORT_VAO #if defined( ACGL_OPENGL_SUPPORTS_VAO )
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
...@@ -74,4 +74,4 @@ protected: ...@@ -74,4 +74,4 @@ protected:
} // OpenGL } // OpenGL
} // ACGL } // ACGL
#endif // #ifdef ACGL_SUPPORT_VAO #endif // #ifdef ACGL_OPENGL_SUPPORTS_VAO
...@@ -23,11 +23,13 @@ namespace OpenGL{ ...@@ -23,11 +23,13 @@ namespace OpenGL{
//! loads the texture and creates mip maps //! loads the texture and creates mip maps
SharedTexture2D loadTexture2D(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT); SharedTexture2D loadTexture2D(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
#ifdef ACGL_OPENGL_SUPPORTS_S3TC
//! loads the texture including mipmaps from a DDS file //! loads the texture including mipmaps from a DDS file
//! supports DXT1, DXT3 and DXT5 compression //! supports DXT1, DXT3 and DXT5 compression
SharedTexture2D loadTexture2DFromDDS (const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT); SharedTexture2D loadTexture2DFromDDS (const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
SharedTexture3D loadTexture3DFromDDS (const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT); SharedTexture3D loadTexture3DFromDDS (const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
SharedTextureCubeMap loadTextureCubeMapFromDDS(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT); SharedTextureCubeMap loadTextureCubeMapFromDDS(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
#endif
} }
} }
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <ACGL/ACGL.hh> #include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh> #include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
#if defined(ACGL_OPENGL_SUPPORTS_VAO)
#include <string> #include <string>
...@@ -49,3 +50,5 @@ bool saveVertexArrayObjectToVAO(ConstSharedVertexArrayObject _vao, const std::st ...@@ -49,3 +50,5 @@ bool saveVertexArrayObjectToVAO(ConstSharedVertexArrayObject _vao, const std::st
} }
} }
#endif // ACGL_OPENGL_SUPPORTS_VAO
...@@ -64,6 +64,11 @@ const char *debugSeverityName( GLenum _type ); ...@@ -64,6 +64,11 @@ const char *debugSeverityName( GLenum _type );
//! applications can register alternative callbacks with glDebugMessageCallback ! //! applications can register alternative callbacks with glDebugMessageCallback !
void ACGLRegisterDefaultDebugCallback(); void ACGLRegisterDefaultDebugCallback();
// APIENTRY might not be defined if external GL headers are used, e.g. on OpenGL ES. In this
// case KHR_debug callbacks are likely only emulated anyways.
#ifndef APIENTRY
#define APIENTRY
#endif
//! default debug callback //! default debug callback
void APIENTRY ACGL_KHR_default_debug_callback( GLenum _source, GLenum _type, GLuint _id, GLenum _severity, GLsizei _length, const GLchar *_message, void *_userParam); void APIENTRY ACGL_KHR_default_debug_callback( GLenum _source, GLenum _type, GLuint _id, GLenum _severity, GLsizei _length, const GLchar *_message, void *_userParam);
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)) #if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR))
# if (TARGET_OS_IPHONE == 1) # if (TARGET_OS_IPHONE == 1)
# define PLATFORM_IOS # define ACGL_PLATFORM_IOS
# define ACGL_OPENGL_ES # define ACGL_OPENGL_ES
# endif # endif
#endif #endif
...@@ -60,18 +60,22 @@ ...@@ -60,18 +60,22 @@
// To compare the OpenGL version number we define a new ACGL_OPENGL_VERSION XY define here // To compare the OpenGL version number we define a new ACGL_OPENGL_VERSION XY define here
// analog to ACGL_OPENGL_VERSION_XY // analog to ACGL_OPENGL_VERSION_XY
// OpenGL ES 2.0 is the default for embedded: // OpenGL ES 3.0 is the default for embedded:
#ifdef ACGL_OPENGL_ES #ifdef ACGL_OPENGL_ES
# if defined (ACGL_OPENGLES_VERSION_30) # if defined (ACGL_OPENGLES_VERSION_30)
# define ACGL_OPENGLES_VERSION 30 # define ACGL_OPENGLES_VERSION 30
# define ACGL_OPENGL_VERSION 0 # elif defined (ACGL_OPENGLES_VERSION_31)
# else # define ACGL_OPENGLES_VERSION 31
# define ACGL_OPENGLES_VERSION_20 # elif defined (ACGL_OPENGLES_VERSION_32)
# define ACGL_OPENGLES_VERSION 20 # define ACGL_OPENGLES_VERSION 32
# define ACGL_OPENGL_VERSION 0 # else
# define ACGL_OPENGLES_VERSION_30
# define ACGL_OPENGLES_VERSION 30
# endif # endif
# define ACGL_OPENGL_VERSION 0
#else #else
// Desktop: // Desktop:
#define ACGL_OPENGLES_VERSION 0
#if defined (ACGL_OPENGL_VERSION_21) #if defined (ACGL_OPENGL_VERSION_21)
# define ACGL_OPENGL_VERSION 21 # define ACGL_OPENGL_VERSION 21
#elif defined (ACGL_OPENGL_VERSION_30) #elif defined (ACGL_OPENGL_VERSION_30)
...@@ -129,7 +133,12 @@ ...@@ -129,7 +133,12 @@
// prevents QT from redefining the debug functions // prevents QT from redefining the debug functions
#define GL_ARB_debug_output #define GL_ARB_debug_output
#define GL_KHR_debug #define GL_KHR_debug
// debug label, debug groups:
#define ACGL_OPENGL_DEBUGGER_SUPPORT #define ACGL_OPENGL_DEBUGGER_SUPPORT
// debug callbacks:
#define ACGL_OPENGL_DEBUG_CALLBACK_SUPPORT
#endif #endif
void CHECKGLERROR(); void CHECKGLERROR();
...@@ -139,21 +148,22 @@ void CHECKGLERROR(); ...@@ -139,21 +148,22 @@ void CHECKGLERROR();
#include <stdint.h> #include <stdint.h>
typedef int64_t GLint64; typedef int64_t GLint64;
#if (PLATFORM_IOS) #if defined (ACGL_PLATFORM_IOS)
//iOS: //iOS:
#if defined (ACGL_OPENGLES_VERSION_20) #if defined (ACGL_OPENGLES_VERSION_20)
#import <OpenGLES/ES1/gl.h> #import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h> #import <OpenGLES/ES1/glext.h>
#import <OpenGLES/ES2/gl.h> #import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h> #import <OpenGLES/ES2/glext.h>
#elif defined (ACGL_OPENGLES_VERSION_30)
#import <OpenGLES/ES3/gl.h>
#import <OpenGLES/ES3/glext.h>
#else #else
#error "location of ES 3 headers not known" #error "location of ES headers not known"
#endif #endif
#elif defined (PLATFORM_ANDROID) #elif defined (PLATFORM_ANDROID)
// Android: // Android:
#if defined (ACGL_OPENGLES_VERSION_20) #if defined (ACGL_OPENGLES_VERSION_20)
//#include <GLES/gl.h>
//#include <GLES/glext.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
#else #else
...@@ -163,6 +173,7 @@ void CHECKGLERROR(); ...@@ -163,6 +173,7 @@ void CHECKGLERROR();
#else #else
#error "UNKNOWN mobile plattform! Don't know what to include!" #error "UNKNOWN mobile plattform! Don't know what to include!"
#endif #endif
#else // ACGL_OPENGL_ES #else // ACGL_OPENGL_ES
// desktop: // desktop:
#ifndef __glew_h__ #ifndef __glew_h__
...@@ -242,4 +253,130 @@ void CHECKGLERROR(); ...@@ -242,4 +253,130 @@ void CHECKGLERROR();
#endif // __GLEW__ #endif // __GLEW__
#endif // ACGL_OPENGL_ES #endif // ACGL_OPENGL_ES
//
// define some known OpenGL feature availability based on the GL / GLES version
//
#if (ACGL_OPENGL_VERSION >= 20)
// for DDS support, DXT texture compression
#define ACGL_OPENGL_SUPPORTS_S3TC
#endif
#if (ACGL_OPENGL_VERSION >= 31)
#define ACGL_OPENGL_SUPPORTS_TEXTURE_BUFFER
#define ACGL_OPENGL_SUPPORTS_TEXTURE_RECTANGLE
#endif
#if (ACGL_OPENGL_VERSION >= 20)
#define ACGL_OPENGL_SUPPORTS_TEXTURE_1D
#endif
#if ((ACGL_OPENGLES_VERSION >= 30) || (ACGL_OPENGL_VERSION >= 20))
#define ACGL_OPENGL_SUPPORTS_TEXTURE_3D
#endif
#if (ACGL_OPENGL_VERSION >= 30)
#define ACGL_OPENGL_SUPPORTS_TEXTURE_1D_ARRAY
#endif
#if ((ACGL_OPENGLES_VERSION >= 30) || (ACGL_OPENGL_VERSION >= 30))
#define ACGL_OPENGL_SUPPORTS_TEXTURE_2D_ARRAY
#endif
#if ((ACGL_OPENGLES_VERSION >= 30) || (ACGL_OPENGL_VERSION >= 30))
#define ACGL_OPENGL_SUPPORTS_VAO
#endif
#ifndef ACGL_EXTENSION_LOADER_GLLOADGEN
//
// Define some constants to compile our helper functions.
// If our own loader was used we know that they are available.
//
#ifndef GL_RGB
#define GL_RGB 0x1907
#endif
#ifndef GL_RGB
#define GL_RGB 0x1908
#endif
#ifndef GL_RGB8
#define GL_RGB8 0x8051
#endif
#ifndef GL_RGBA8
#define GL_RGBA8 0x8058
#endif
#ifndef GL_SRGB
#define GL_SRGB 0x8C40
#endif
#ifndef GL_SRGB8
#define GL_SRGB8 0x8C41
#endif
#ifndef GL_SRGB_ALPHA
#define GL_SRGB_ALPHA 0x8C42
#endif
#ifndef GL_SRGB8_ALPHA8
#define GL_SRGB8_ALPHA8 0x8C43
#endif
#ifndef GL_COMPRESSED_RGB
#define GL_COMPRESSED_RGB 0x84ED
#endif
#ifndef GL_COMPRESSED_RGBA
#define GL_COMPRESSED_RGBA 0x84EE
#endif
#ifndef GL_COMPRESSED_SRGB
#define GL_COMPRESSED_SRGB 0x8C48
#endif
#ifndef GL_COMPRESSED_SRGB_ALPHA
#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
#endif
// define some KHR_debug constants in case they were not set
// this way our functions which convert the constants to strings
// will at least compile everywhere
#ifndef GL_DEBUG_SEVERITY_HIGH_ARB
// Extension: ARB_debug_output
#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146
#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148
#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147
#define GL_DEBUG_SOURCE_API_ARB 0x8246
#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A
#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B
#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248
#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249
#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247
#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D
#define GL_DEBUG_TYPE_ERROR_ARB 0x824C
#define GL_DEBUG_TYPE_OTHER_ARB 0x8251
#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250
#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F
#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E
#endif
#ifndef GL_DEBUG_SEVERITY_HIGH
// Extension: KHR_debug
#define GL_DEBUG_SEVERITY_HIGH 0x9146
#define GL_DEBUG_SEVERITY_LOW 0x9148
#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
#define GL_DEBUG_SOURCE_API 0x8246
#define GL_DEBUG_SOURCE_APPLICATION 0x824A
#define GL_DEBUG_SOURCE_OTHER 0x824B
#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
#define GL_DEBUG_TYPE_ERROR 0x824C
#define GL_DEBUG_TYPE_MARKER 0x8268
#define GL_DEBUG_TYPE_OTHER 0x8251
#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
#define GL_DEBUG_TYPE_POP_GROUP 0x826A
#define GL_DEBUG_TYPE_PORTABILITY 0x824F
#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
#endif
#endif // ACGL_EXTENSION_LOADER_GLLOADGEN
#endif // ACGL_OPENGL_GL_HH #endif // ACGL_OPENGL_GL_HH
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
*/ */
#include <ACGL/ACGL.hh> #include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Objects.hh> #include <ACGL/OpenGL/Objects.hh>
#include <ACGL/Resource/NameManager.hh> #include <ACGL/Resource/NameManager.hh>
#include <ACGL/Resource/FileManager.hh> #include <ACGL/Resource/FileManager.hh>
...@@ -21,9 +22,11 @@ namespace OpenGL{ ...@@ -21,9 +22,11 @@ namespace OpenGL{
// useful for automatically updating shader programs: // useful for automatically updating shader programs:
typedef Resource::MultiFileManager<ShaderProgram> ShaderProgramFileManager; typedef Resource::MultiFileManager<ShaderProgram> ShaderProgramFileManager;
#if defined( ACGL_OPENGL_SUPPORTS_VAO )
// same for meshes: // same for meshes:
typedef Resource::FileManager<VertexArrayObject> VAOFileManager; typedef Resource::FileManager<VertexArrayObject> VAOFileManager;
#endif
// for simple 2D (mip-mapped) textures // for simple 2D (mip-mapped) textures
typedef Resource::FileManager<Texture2D> Texture2DFileManager; typedef Resource::FileManager<Texture2D> Texture2DFileManager;
......
...@@ -175,7 +175,9 @@ public: ...@@ -175,7 +175,9 @@ public:
inline GLint getMapOffset() const { return getParameter ( GL_BUFFER_MAP_OFFSET ); } inline GLint getMapOffset() const { return getParameter ( GL_BUFFER_MAP_OFFSET ); }
inline GLint getMapLength() const { return getParameter ( GL_BUFFER_MAP_LENGTH ); } inline GLint getMapLength() const { return getParameter ( GL_BUFFER_MAP_LENGTH ); }
#endif // OpenGL >= 3.2 #endif // OpenGL >= 3.2
#if (ACGL_OPENGL_VERSION >= 20)
inline GLenum getAccess() const { return (GLenum) getParameter ( GL_BUFFER_ACCESS ); } inline GLenum getAccess() const { return (GLenum) getParameter ( GL_BUFFER_ACCESS ); }
#endif // not on ES
inline GLint getAccessFlags() const { return (GLint) getParameter ( GL_BUFFER_ACCESS_FLAGS ); } inline GLint getAccessFlags() const { return (GLint) getParameter ( GL_BUFFER_ACCESS_FLAGS ); }
inline GLboolean isMapped() const { return (GLboolean) getParameter ( GL_BUFFER_MAPPED ); } inline GLboolean isMapped() const { return (GLboolean) getParameter ( GL_BUFFER_MAPPED ); }
...@@ -286,7 +288,7 @@ public: ...@@ -286,7 +288,7 @@ public:
#endif // OpenGL >= 3.0 #endif // OpenGL >= 3.0
#ifndef ACGL_OPENGLES_VERSION_20 #if (ACGL_OPENGL_VERSION >= 20)
//! Maps the whole buffer, if using GL 3+, better use mapRange! //! Maps the whole buffer, if using GL 3+, better use mapRange!
//! _access is GL_READ_ONLY GL_WRITE_ONLY or GL_READ_WRITE //! _access is GL_READ_ONLY GL_WRITE_ONLY or GL_READ_WRITE
GLvoid *map( GLenum _target, GLenum _access ) { GLvoid *map( GLenum _target, GLenum _access ) {
......
...@@ -184,7 +184,7 @@ public: ...@@ -184,7 +184,7 @@ public:
{ {
bind(); bind();
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _renderBuffer->getObjectName() ); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _renderBuffer->getObjectName() );
#ifdef ACGL_OPENGL_ES #if (ACGL_OPENGLES_VERSION <= 20)
if( _renderBuffer->getInternalFormat() == GL_DEPTH24_STENCIL8_OES || if( _renderBuffer->getInternalFormat() == GL_DEPTH24_STENCIL8_OES ||
_renderBuffer->getInternalFormat() == GL_DEPTH_STENCIL_OES) _renderBuffer->getInternalFormat() == GL_DEPTH_STENCIL_OES)
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _renderBuffer->getObjectName() ); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _renderBuffer->getObjectName() );
...@@ -202,7 +202,7 @@ public: ...@@ -202,7 +202,7 @@ public:
{ {
bind(); bind();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, _texture->getTarget(), _texture->getObjectName(), 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, _texture->getTarget(), _texture->getObjectName(), 0);
#ifdef ACGL_OPENGL_ES #if (ACGL_OPENGLES_VERSION <= 20)
if( _texture->getInternalFormat() == GL_DEPTH24_STENCIL8_OES || if( _texture->getInternalFormat() == GL_DEPTH24_STENCIL8_OES ||
_texture->getInternalFormat() == GL_DEPTH_STENCIL_OES) _texture->getInternalFormat() == GL_DEPTH_STENCIL_OES)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, _texture->getTarget(), _texture->getObjectName(), 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, _texture->getTarget(), _texture->getObjectName(), 0);
...@@ -268,11 +268,13 @@ public: ...@@ -268,11 +268,13 @@ public:
//! clear only the depth buffer: //! clear only the depth buffer:
void clearDepthBuffer(); void clearDepthBuffer();
#if ((ACGL_OPENGLES_VERSION >= 30) || (ACGL_OPENGL_VERSION >= 20))
//! clear one specific color buffer: //! clear one specific color buffer:
void clearBuffer( const std::string &_name ); void clearBuffer( const std::string &_name );
//! clear all buffers, color and depth: //! clear all buffers, color and depth:
void clearBuffers(); void clearBuffers();
#endif
//! sets the clear color for one buffer: //! sets the clear color for one buffer:
void setClearColor( const std::string &_name, const glm::vec4 &_color ); void setClearColor( const std::string &_name, const glm::vec4 &_color );
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <ACGL/OpenGL/Tools.hh> #include <ACGL/OpenGL/Tools.hh>
#include <ACGL/OpenGL/Debug.hh> #include <ACGL/OpenGL/Debug.hh>
#ifndef ACGL_OPENGLES_VERSION_20 #if (ACGL_OPENGLES_VERSION > 20)
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
...@@ -71,8 +71,13 @@ public: ...@@ -71,8 +71,13 @@ public:
//! returns true if the result of the query is available, if not, trying to get the result will stall the CPU //! returns true if the result of the query is available, if not, trying to get the result will stall the CPU
GLboolean isResultAvailable(void) { GLboolean isResultAvailable(void) {
#if (ACGL_OPENGLES_VERSION >= 30)
GLuint resultAvailable;
glGetQueryObjectuiv(mObjectName, GL_QUERY_RESULT_AVAILABLE, &resultAvailable);
#else
GLint resultAvailable; GLint resultAvailable;
glGetQueryObjectiv(mObjectName, GL_QUERY_RESULT_AVAILABLE, &resultAvailable); glGetQueryObjectiv(mObjectName, GL_QUERY_RESULT_AVAILABLE, &resultAvailable);
#endif
return (GLboolean) resultAvailable; return (GLboolean) resultAvailable;
} }
...@@ -111,6 +116,12 @@ ACGL_SMARTPOINTER_TYPEDEFS(AsynchronousQuery) ...@@ -111,6 +116,12 @@ ACGL_SMARTPOINTER_TYPEDEFS(AsynchronousQuery)
* GL_SAMPLES_PASSED - will count the fragments * GL_SAMPLES_PASSED - will count the fragments
* GL_ANY_SAMPLES_PASSED - will just tell whether fragments have passed the z-test, not how many (0 or any number) * GL_ANY_SAMPLES_PASSED - will just tell whether fragments have passed the z-test, not how many (0 or any number)
*/ */
// On ES only ANY_SAMPLES is supported, so use this as a substitute:
#if ( !defined(GL_SAMPLES_PASSED) && (ACGL_OPENGLES_VERSION >= 30))
#define GL_SAMPLES_PASSED GL_ANY_SAMPLES_PASSED
#endif
class OcclusionQuery : public AsynchronousQuery { class OcclusionQuery : public AsynchronousQuery {
public: public:
OcclusionQuery() : AsynchronousQuery( GL_SAMPLES_PASSED ) {} OcclusionQuery() : AsynchronousQuery( GL_SAMPLES_PASSED ) {}
...@@ -120,7 +131,7 @@ public: ...@@ -120,7 +131,7 @@ public:
//! _queryType has to be GL_SAMPLES_PASSED or GL_ANY_SAMPLES_PASSED //! _queryType has to be GL_SAMPLES_PASSED or GL_ANY_SAMPLES_PASSED
void setType( GLenum _queryType ) { void setType( GLenum _queryType ) {
#if (ACGL_OPENGL_VERSION >= 33) #if (ACGL_OPENGL_VERSION < 33)
if (_queryType == GL_ANY_SAMPLES_PASSED) _queryType = GL_SAMPLES_PASSED; // GL_ANY_SAMPLES_PASSED is OpenGL 3.3 or later! But GL_SAMPLES_PASSED is a good substitute if (_queryType == GL_ANY_SAMPLES_PASSED) _queryType = GL_SAMPLES_PASSED; // GL_ANY_SAMPLES_PASSED is OpenGL 3.3 or later! But GL_SAMPLES_PASSED is a good substitute
#endif #endif
if (_queryType != GL_SAMPLES_PASSED) { if (_queryType != GL_SAMPLES_PASSED) {
......
...@@ -273,7 +273,9 @@ public: ...@@ -273,7 +273,9 @@ public:
//! sets a texture uniform to a given texture unit and also binds the texture to the same unit //! sets a texture uniform to a given texture unit and also binds the texture to the same unit
inline void setTexture (GLint _location, const ConstSharedTextureBase& _texture, GLint _unit) const { glUniform1i(_location, _unit); _texture->bind(_unit); } inline void setTexture (GLint _location, const ConstSharedTextureBase& _texture, GLint _unit) const { glUniform1i(_location, _unit); _texture->bind(_unit); }
inline void setTexture (const std::string& _nameInShader, const ConstSharedTextureBase& _texture, GLint _unit) const { setUniform( getUniformLocation(_nameInShader), (GLint) _unit); _texture->bind(_unit); } inline void setTexture (const std::string& _nameInShader, const ConstSharedTextureBase& _texture, GLint _unit) const { setUniform( getUniformLocation(_nameInShader), (GLint) _unit); _texture->bind(_unit); }
#if defined( ACGL_OPENGL_SUPPORTS_TEXTURE_BUFFER )
inline void setTexture (const std::string& _nameInShader, const ConstSharedTextureBuffer& _texture, GLint _unit) const { setUniform( getUniformLocation(_nameInShader), (GLint) _unit); _texture->bindTexture(_unit); } inline void setTexture (const std::string& _nameInShader, const ConstSharedTextureBuffer& _texture, GLint _unit) const { setUniform( getUniformLocation(_nameInShader), (GLint) _unit); _texture->bindTexture(_unit); }
#endif
#if (ACGL_OPENGL_VERSION >= 41) #if (ACGL_OPENGL_VERSION >= 41)
// DSA versions: // DSA versions:
......
...@@ -119,19 +119,20 @@ public: ...@@ -119,19 +119,20 @@ public:
inline GLenum getInternalFormat (void) const { return mInternalFormat; } inline GLenum getInternalFormat (void) const { return mInternalFormat; }
inline GLint getMinFilter (void) const { return getParameterI(GL_TEXTURE_MIN_FILTER); } inline GLint getMinFilter (void) const { return getParameterI(GL_TEXTURE_MIN_FILTER); }
inline GLint getMagFilter (void) const { return getParameterI(GL_TEXTURE_MAG_FILTER); } inline GLint getMagFilter (void) const { return getParameterI(GL_TEXTURE_MAG_FILTER); }
#if (( ACGL_OPENGLES_VERSION > 20) || (ACGL_OPENGL_VERSION > 20))
inline GLint getBaseLevel (void) const { return getParameterI(GL_TEXTURE_BASE_LEVEL); } inline GLint getBaseLevel (void) const { return getParameterI(GL_TEXTURE_BASE_LEVEL); }
inline GLint getMaxLevel (void) const { return getParameterI(GL_TEXTURE_MAX_LEVEL); } inline GLint getMaxLevel (void) const { return getParameterI(GL_TEXTURE_MAX_LEVEL); }
inline GLint getMinLOD (void) const { return getParameterI(GL_TEXTURE_MIN_LOD); } inline GLint getMinLOD (void) const { return getParameterI(GL_TEXTURE_MIN_LOD); }
inline GLint getMaxLOD (void) const { return getParameterI(GL_TEXTURE_MAX_LOD); } inline GLint getMaxLOD (void) const { return getParameterI(GL_TEXTURE_MAX_LOD); }
inline GLfloat getLODBias (void) const { return getParameterF(GL_TEXTURE_LOD_BIAS); }
inline GLenum getCompareMode (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_MODE); } inline GLenum getCompareMode (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_MODE); }
inline GLenum getCompareFunc (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_FUNC); } inline GLenum getCompareFunc (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_FUNC); }
inline glm::vec4 getBorderColor (void) const { return getParameter4F(GL_TEXTURE_BORDER_COLOR); }
#ifndef ACGL_OPENGLES_VERSION_20
inline GLenum getWrapS (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_S); } inline GLenum getWrapS (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_S); }
inline GLenum getWrapT (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_T); } inline GLenum getWrapT (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_T); }
inline GLenum getWrapR (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_R); } #endif
#endif // ACGL_OPENGLES_VERSION_20 #if (ACGL_OPENGL_VERSION > 20)
inline GLfloat getLODBias (void) const { return getParameterF(GL_TEXTURE_LOD_BIAS); }
inline glm::vec4 getBorderColor (void) const { return getParameter4F(GL_TEXTURE_BORDER_COLOR); }
#endif
inline glm::uvec3 getSize (void) const { return glm::uvec3( mWidth, mHeight, mDepth ); } inline glm::uvec3 getSize (void) const { return glm::uvec3( mWidth, mHeight, mDepth ); }
// ===================================================================================================== \/ // ===================================================================================================== \/
...@@ -157,14 +158,13 @@ public: ...@@ -157,14 +158,13 @@ public:
//! sets the magnification filter //! sets the magnification filter
void setMagFilter(GLint _value = GL_LINEAR); void setMagFilter(GLint _value = GL_LINEAR);
#ifndef ACGL_OPENGLES_VERSION_20 #if (( ACGL_OPENGLES_VERSION > 20) || (ACGL_OPENGL_VERSION > 20))
void setWrapS( GLenum _wrapS = GL_REPEAT ); void setWrapS( GLenum _wrapS = GL_REPEAT );
void setWrapT( GLenum _wrapT = GL_REPEAT ); void setWrapT( GLenum _wrapT = GL_REPEAT );
void setWrapR( GLenum _wrapR = GL_REPEAT ); void setWrapR( GLenum _wrapR = GL_REPEAT );
//! Note: The function will bind this texture! //! Note: The function will bind this texture!
void setWrap(GLenum _wrapS, GLenum _wrapT = 0, GLenum _wrapR = 0); void setWrap(GLenum _wrapS, GLenum _wrapT = 0, GLenum _wrapR = 0);
#endif
//! lowest defined mipmap level //! lowest defined mipmap level
void setBaseLevel( GLint _level = -1000 ); void setBaseLevel( GLint _level = -1000 );
...@@ -178,18 +178,21 @@ public: ...@@ -178,18 +178,21 @@ public:
//! highest mipmap level to use //! highest mipmap level to use
void setMaxLOD( GLint _lod = 1000 ); void setMaxLOD( GLint _lod = 1000 );
//! offset to add to the mipmap level calculation
void setLODBias( GLfloat _bias = 0.0f );
//! for usage of a texture with depth data //! for usage of a texture with depth data
void setCompareMode( GLenum _mode = GL_NONE ); void setCompareMode( GLenum _mode = GL_NONE );
//! for usage of a texture with depth data //! for usage of a texture with depth data
void setCompareFunc( GLenum _func = GL_LEQUAL ); void setCompareFunc( GLenum _func = GL_LEQUAL );