Commit c6077eca authored by Robert Menzel's avatar Robert Menzel

OpenGL ES 2 and 3 compatibility changes

parent 72e09659
......@@ -20,7 +20,7 @@
#include <ACGL/OpenGL/Data/LocationMappings.hh>
#include <ACGL/Base/Settings.hh>
#ifdef ACGL_SUPPORT_VAO
#if defined( ACGL_OPENGL_SUPPORTS_VAO )
namespace ACGL{
namespace OpenGL{
......@@ -74,4 +74,4 @@ protected:
} // OpenGL
} // ACGL
#endif // #ifdef ACGL_SUPPORT_VAO
#endif // #ifdef ACGL_OPENGL_SUPPORTS_VAO
......@@ -23,11 +23,13 @@ namespace OpenGL{
//! loads the texture and creates mip maps
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
//! supports DXT1, DXT3 and DXT5 compression
SharedTexture2D loadTexture2DFromDDS (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);
#endif
}
}
......@@ -8,6 +8,7 @@
#include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
#if defined(ACGL_OPENGL_SUPPORTS_VAO)
#include <string>
......@@ -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 );
//! applications can register alternative callbacks with glDebugMessageCallback !
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
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 @@
#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR))
# if (TARGET_OS_IPHONE == 1)
# define PLATFORM_IOS
# define ACGL_PLATFORM_IOS
# define ACGL_OPENGL_ES
# endif
#endif
......@@ -60,18 +60,22 @@
// To compare the OpenGL version number we define a new ACGL_OPENGL_VERSION XY define here
// 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
# if defined (ACGL_OPENGLES_VERSION_30)
# define ACGL_OPENGLES_VERSION 30
# define ACGL_OPENGL_VERSION 0
# else
# define ACGL_OPENGLES_VERSION_20
# define ACGL_OPENGLES_VERSION 20
# define ACGL_OPENGL_VERSION 0
# elif defined (ACGL_OPENGLES_VERSION_31)
# define ACGL_OPENGLES_VERSION 31
# elif defined (ACGL_OPENGLES_VERSION_32)
# define ACGL_OPENGLES_VERSION 32
# else
# define ACGL_OPENGLES_VERSION_30
# define ACGL_OPENGLES_VERSION 30
# endif
# define ACGL_OPENGL_VERSION 0
#else
// Desktop:
#define ACGL_OPENGLES_VERSION 0
#if defined (ACGL_OPENGL_VERSION_21)
# define ACGL_OPENGL_VERSION 21
#elif defined (ACGL_OPENGL_VERSION_30)
......@@ -129,7 +133,12 @@
// prevents QT from redefining the debug functions
#define GL_ARB_debug_output
#define GL_KHR_debug
// debug label, debug groups:
#define ACGL_OPENGL_DEBUGGER_SUPPORT
// debug callbacks:
#define ACGL_OPENGL_DEBUG_CALLBACK_SUPPORT
#endif
void CHECKGLERROR();
......@@ -139,21 +148,22 @@ void CHECKGLERROR();
#include <stdint.h>
typedef int64_t GLint64;
#if (PLATFORM_IOS)
#if defined (ACGL_PLATFORM_IOS)
//iOS:
#if defined (ACGL_OPENGLES_VERSION_20)
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#elif defined (ACGL_OPENGLES_VERSION_30)
#import <OpenGLES/ES3/gl.h>
#import <OpenGLES/ES3/glext.h>
#else
#error "location of ES 3 headers not known"
#error "location of ES headers not known"
#endif
#elif defined (PLATFORM_ANDROID)
// Android:
#if defined (ACGL_OPENGLES_VERSION_20)
//#include <GLES/gl.h>
//#include <GLES/glext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
......@@ -163,6 +173,7 @@ void CHECKGLERROR();
#else
#error "UNKNOWN mobile plattform! Don't know what to include!"
#endif
#else // ACGL_OPENGL_ES
// desktop:
#ifndef __glew_h__
......@@ -242,4 +253,130 @@ void CHECKGLERROR();
#endif // __GLEW__
#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
......@@ -11,6 +11,7 @@
*/
#include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Objects.hh>
#include <ACGL/Resource/NameManager.hh>
#include <ACGL/Resource/FileManager.hh>
......@@ -21,9 +22,11 @@ namespace OpenGL{
// useful for automatically updating shader programs:
typedef Resource::MultiFileManager<ShaderProgram> ShaderProgramFileManager;
#if defined( ACGL_OPENGL_SUPPORTS_VAO )
// same for meshes:
typedef Resource::FileManager<VertexArrayObject> VAOFileManager;
#endif
// for simple 2D (mip-mapped) textures
typedef Resource::FileManager<Texture2D> Texture2DFileManager;
......
......@@ -175,7 +175,9 @@ public:
inline GLint getMapOffset() const { return getParameter ( GL_BUFFER_MAP_OFFSET ); }
inline GLint getMapLength() const { return getParameter ( GL_BUFFER_MAP_LENGTH ); }
#endif // OpenGL >= 3.2
#if (ACGL_OPENGL_VERSION >= 20)
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 GLboolean isMapped() const { return (GLboolean) getParameter ( GL_BUFFER_MAPPED ); }
......@@ -286,7 +288,7 @@ public:
#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!
//! _access is GL_READ_ONLY GL_WRITE_ONLY or GL_READ_WRITE
GLvoid *map( GLenum _target, GLenum _access ) {
......
......@@ -184,7 +184,7 @@ public:
{
bind();
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 ||
_renderBuffer->getInternalFormat() == GL_DEPTH_STENCIL_OES)
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _renderBuffer->getObjectName() );
......@@ -202,7 +202,7 @@ public:
{
bind();
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 ||
_texture->getInternalFormat() == GL_DEPTH_STENCIL_OES)
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, _texture->getTarget(), _texture->getObjectName(), 0);
......@@ -268,11 +268,13 @@ public:
//! clear only the depth buffer:
void clearDepthBuffer();
#if ((ACGL_OPENGLES_VERSION >= 30) || (ACGL_OPENGL_VERSION >= 20))
//! clear one specific color buffer:
void clearBuffer( const std::string &_name );
//! clear all buffers, color and depth:
void clearBuffers();
#endif
//! sets the clear color for one buffer:
void setClearColor( const std::string &_name, const glm::vec4 &_color );
......
......@@ -14,7 +14,7 @@
#include <ACGL/OpenGL/Tools.hh>
#include <ACGL/OpenGL/Debug.hh>
#ifndef ACGL_OPENGLES_VERSION_20
#if (ACGL_OPENGLES_VERSION > 20)
namespace ACGL{
namespace OpenGL{
......@@ -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
GLboolean isResultAvailable(void) {
#if (ACGL_OPENGLES_VERSION >= 30)
GLuint resultAvailable;
glGetQueryObjectuiv(mObjectName, GL_QUERY_RESULT_AVAILABLE, &resultAvailable);
#else
GLint resultAvailable;
glGetQueryObjectiv(mObjectName, GL_QUERY_RESULT_AVAILABLE, &resultAvailable);
#endif
return (GLboolean) resultAvailable;
}
......@@ -111,6 +116,12 @@ ACGL_SMARTPOINTER_TYPEDEFS(AsynchronousQuery)
* 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)
*/
// 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 {
public:
OcclusionQuery() : AsynchronousQuery( GL_SAMPLES_PASSED ) {}
......@@ -120,7 +131,7 @@ public:
//! _queryType has to be GL_SAMPLES_PASSED or GL_ANY_SAMPLES_PASSED
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
#endif
if (_queryType != GL_SAMPLES_PASSED) {
......
......@@ -273,7 +273,9 @@ public:
//! 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 (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); }
#endif
#if (ACGL_OPENGL_VERSION >= 41)
// DSA versions:
......
......@@ -119,19 +119,20 @@ public:
inline GLenum getInternalFormat (void) const { return mInternalFormat; }
inline GLint getMinFilter (void) const { return getParameterI(GL_TEXTURE_MIN_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 getMaxLevel (void) const { return getParameterI(GL_TEXTURE_MAX_LEVEL); }
inline GLint getMinLOD (void) const { return getParameterI(GL_TEXTURE_MIN_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 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 getWrapT (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_T); }
inline GLenum getWrapR (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_R); }
#endif // ACGL_OPENGLES_VERSION_20
#endif
#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 ); }
// ===================================================================================================== \/
......@@ -157,14 +158,13 @@ public:
//! sets the magnification filter
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 setWrapT( GLenum _wrapT = GL_REPEAT );
void setWrapR( GLenum _wrapR = GL_REPEAT );
//! Note: The function will bind this texture!
void setWrap(GLenum _wrapS, GLenum _wrapT = 0, GLenum _wrapR = 0);
#endif
//! lowest defined mipmap level
void setBaseLevel( GLint _level = -1000 );
......@@ -178,18 +178,21 @@ public:
//! highest mipmap level to use
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
void setCompareMode( GLenum _mode = GL_NONE );
//! for usage of a texture with depth data
void setCompareFunc( GLenum _func = GL_LEQUAL );
#endif
#if (ACGL_OPENGL_VERSION > 20)
//! offset to add to the mipmap level calculation
void setLODBias( GLfloat _bias = 0.0f );
//! color that is sampled outside range if wrap is set to GL_CLAMP_TO_BORDER
void setBorderColor(const glm::vec4& _color = glm::vec4(0.0));
#endif
//! _sampleCount = 1.0 to deactivate anisotrop filtering, maximum is often 16. If a value is too high it will get clamped to the maximum
void setAnisotropicFilter( GLfloat _sampleCount );
......@@ -240,15 +243,19 @@ protected:
//! to be used by subclasses, will not check if usage is meaningfull for the
//! texture target, this has to be checked by the subclass (this is why this
//! function is private here)
#if defined (ACGL_OPENGL_SUPPORTS_TEXTURE_1D)
void texImage1D( const SharedTextureData &_data, GLint _mipmapLevel );
void texSubImage1D( const SharedTextureData &_data, GLint _mipmapLevel, uint32_t _offset = 0 );
#endif
void texImage2D( const SharedTextureData &_data, GLint _mipmapLevel );
void texSubImage2D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec2 _offset = glm::uvec2(0) );
#if defined (ACGL_OPENGL_SUPPORTS_TEXTURE_3D)
void texImage3D( const SharedTextureData &_data, GLint _mipmapLevel );
void texSubImage3D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec3 _offset = glm::uvec3(0) );
#endif
//! returns true if space for the texture was allocated
bool textureStorageIsAllocated()
{
......@@ -272,6 +279,7 @@ ACGL_SMARTPOINTER_TYPEDEFS(TextureBase)
// GL_TEXTURE_BINDING_CUBE_MAP x
// GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
#if defined(ACGL_OPENGL_SUPPORTS_TEXTURE_RECTANGLE)
/**
* In contrast to 'normal' textures these can't have mipmaps and are accessed in the shader by
* pixel-coordinates instead of texture coordinates from 0 to 1.
......@@ -305,8 +313,9 @@ private:
void generateMipmaps(void) { ACGL::Utils::error() << "Rectangle Textures don't support MipMaps!" << std::endl; }
};
ACGL_SMARTPOINTER_TYPEDEFS(TextureRectangle)
#endif
#if defined(ACGL_OPENGL_SUPPORTS_TEXTURE_1D)
/**
* 1D textures.
* can be used as general purpose data for a shader if texture filtering is wanted, otherwise look
......@@ -331,7 +340,7 @@ protected:
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture1D)
#endif
/**
* "Normal" 2D texture.
......@@ -356,7 +365,7 @@ protected:
ACGL_SMARTPOINTER_TYPEDEFS(Texture2D)
#if defined(ACGL_OPENGL_SUPPORTS_TEXTURE_3D)
/**
* 3D volume texture.
*/
......@@ -381,8 +390,10 @@ protected:
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture3D)
#endif
#if defined (ACGL_OPENGL_SUPPORTS_TEXTURE_1D_ARRAY)
/**
* Array of 1D textures, technically a 2D texture but without filtering between array layers.
*/
......@@ -407,8 +418,10 @@ protected:
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture1DArray)
#endif
#if defined (ACGL_OPENGL_SUPPORTS_TEXTURE_2D_ARRAY)
/**
* A "stack" of 2D textures. Each must have the same size.
* Can be used to access many texture in a shader without having to deal with the
......@@ -434,7 +447,7 @@ protected:
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture2DArray)
#endif
/**
* For environmant mapping.
......
......@@ -28,7 +28,7 @@
#include <cassert>
#if (ACGL_OPENGL_VERSION >= 31)
#if defined( ACGL_OPENGL_SUPPORTS_TEXTURE_BUFFER )
namespace ACGL{
namespace OpenGL{
......
......@@ -29,7 +29,7 @@
#include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/GL.hh>
#if (ACGL_OPENGL_VERSION >= 30)
#if defined (ACGL_OPENGL_SUPPORTS_VAO)
#include <ACGL/Base/Macros.hh>
#include <ACGL/OpenGL/Tools.hh>
......@@ -45,7 +45,6 @@ namespace OpenGL{
// if a VAO is present either because GL 3.0+ is present or because extensions are expected, signal this using this define
// for classes that expect VAO to be present!
#define ACGL_SUPPORT_VAO
class VertexArrayObject
{
ACGL_NOT_COPYABLE(VertexArrayObject)
......@@ -266,12 +265,15 @@ public:
#endif
}
#if (ACGL_OPENGL_VERSION >= 20)
// not on OpenGL ES
//! dispatch multiple draw commands with different parameters, for drawing the same object multiple times, use drawArrays to use instancing
//! first and count are arrays of the size primcount (so primcount chunks are beeing rendered)
inline void multiDrawArrays( GLint *first, GLsizei *count, GLsizei primcount ) const
{
glMultiDrawArrays( mMode, first, count, primcount );
}
#endif
#if (ACGL_OPENGL_VERSION >= 40)
//! with a parameter struct:
......@@ -315,14 +317,16 @@ public:
glDrawElements(mMode, getIndexCount(), getIndexType(), (GLvoid*)NULL);
}
#if (ACGL_OPENGL_VERSION >= 20)
// not on OpenGL ES
//! count and indices are arrays of the size primcount (so primcount chunks are beeing rendered)
inline void multiDrawElements( GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount ) const
{
glMultiDrawElements( mMode, count, type, indices, primcount );
}
#endif
inline void drawRangeElements( GLuint start,
GLsizei count )
inline void drawRangeElements( GLuint start, GLsizei count )
{
glDrawRangeElements( mMode, start, getIndexCount(), count, getIndexType(), NULL);
}
......@@ -404,6 +408,6 @@ ACGL_SMARTPOINTER_TYPEDEFS(VertexArrayObject)
} // OpenGL
} // ACGL
#endif // OpenGL 3.0
#endif // ACGL_OPENGL_SUPPORTS_VAO
#endif // ACGL_OPENGL_OBJECTS_VERTEXARRAYOBJECT_HH
......@@ -35,6 +35,8 @@
#endif
*/
#ifdef ACGL_OPENGL_SUPPORTS_S3TC
namespace nv_dds
{
// surface description flags
......@@ -354,3 +356,5 @@ namespace nv_dds
};
}
#endif
#endif
......@@ -7,7 +7,7 @@
#include <ACGL/OpenGL/Creator/VertexArrayObjectCreator.hh>
#include <ACGL/OpenGL/Data/VertexArrayObjectLoadStore.hh>
#ifdef ACGL_SUPPORT_VAO
#if defined( ACGL_OPENGL_SUPPORTS_VAO )
using namespace ACGL;
using namespace ACGL::OpenGL;
......@@ -54,5 +54,5 @@ bool VertexArrayObjectCreator::update(SharedVertexArrayObject &vao)
return true;
}
#endif // #ifdef ACGL_SUPPORT_VAO
#endif // #ifdef ACGL_OPENGL_SUPPORTS_VAO
......@@ -21,16 +21,20 @@ GLenum formatToSRGB(GLenum _format)
case GL_RGBA8: return GL_SRGB8_ALPHA8;
case GL_COMPRESSED_RGB: return GL_COMPRESSED_SRGB;
case GL_COMPRESSED_RGBA: return GL_COMPRESSED_SRGB_ALPHA;
#if defined(ACGL_OPENGL_SUPPORTS_ETC)
case GL_COMPRESSED_RGB8_ETC2: return GL_COMPRESSED_SRGB8_ETC2;
case GL_COMPRESSED_RGBA8_ETC2_EAC: return GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: return GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
#endif
#if defined(ACGL_OPENGL_SUPPORTS_S3TC)
// EXT_texture_sRGB, EXT_texture_compression_s3tc
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
#endif
// OpenGL 4.2?
//case GL_COMPRESSED_RGBA_BPTC_UNORM: return GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM;
}
......
......@@ -210,7 +210,7 @@ SharedGeometryData loadGeometryDataFromATB(const std::string& _filename, const s
data->mAttributes.push_back(attributeDescription);
data->setStrideSize(attributeDimension * sizeof(GLfloat));
data->setSize(abDataSize * sizeof(GLfloat));
data->setSize( (GLsizei) (abDataSize * sizeof(GLfloat)) );
data->setData((GLubyte*)abData);
return data;
......
......@@ -417,8 +417,8 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
data->mAttributes.push_back(attrNormal);
}
data->setStrideSize(strideSize);
data->setSize(abDataElements * sizeof(GLfloat));
data->setStrideSize( (GLsizei) strideSize);
data->setSize( (GLsizei) abDataElements * sizeof(GLfloat));
data->setData((GLubyte*)abData);
setlocale( LC_NUMERIC, currentLocale ); // restore old locale
......
......@@ -64,7 +64,7 @@ namespace
std::vector<std::string> componentsString = ACGL::Utils::StringHelpers::split(vertexString, '/', false);
IndexTuple indexTuple;
for(int i = 0; i < std::min<int>(componentsString.size(), 3); ++i)
for(int i = 0; i < std::min<int>((int)componentsString.size(), 3); ++i)
{
std::string& componentString = componentsString[i];
int index = atoi(componentString.c_str());
......@@ -374,8 +374,8 @@ SharedGeometryData loadGeometryDataFromVAP(const std::string& _filename, bool _c
append<GLint>(it, index.metaData.w);
}
data->setStrideSize(strideSize);
data->setSize(abDataSize);
data->setStrideSize( (GLsizei) strideSize);
data->setSize( (GLsizei) abDataSize);
data->setData((GLubyte*)abData);
return data;
......
......@@ -68,6 +68,7 @@ size_t TextureData::getSizeInBytes() const
bool TextureData::dataIsCompressed() const
{
#if defined (ACGL_OPENGL_SUPPORTS_S3TC)
if (mFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT || mFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) {
// BC 1 aka DXT 1
return true;
......@@ -80,7 +81,9 @@ bool TextureData::dataIsCompressed() const
} else if (mFormat == GL_COMPRESSED_RED_RGTC1 || mFormat == GL_COMPRESSED_SIGNED_RED_RGTC1)