diff --git a/include/ACGL/ACGL.hh b/include/ACGL/ACGL.hh index 670d2a04caeefd127efb9abd946cb174192669e4..dba172ffa1085433f4642476852d6e7da967c35b 100644 --- a/include/ACGL/ACGL.hh +++ b/include/ACGL/ACGL.hh @@ -7,6 +7,8 @@ #ifndef ACGL_ACGL_HH #define ACGL_ACGL_HH +#include <ACGL/Base/OSDetection.hh> + /*! * Include this in all ACGL (header)-files. It will include stuff that is used in * almost every file: diff --git a/include/ACGL/Base/CompileTimeSettings.hh b/include/ACGL/Base/CompileTimeSettings.hh index 54b76e3c451d4601363c5a74385be9cf0f67365a..5c6769ef20fe06b59e53c07fdece601c3d654c89 100644 --- a/include/ACGL/Base/CompileTimeSettings.hh +++ b/include/ACGL/Base/CompileTimeSettings.hh @@ -37,8 +37,6 @@ #define ACGL_DEBUG #endif -//#error foo - /* * Map CMake generated error-level defines to internally used, more readable defines */ diff --git a/include/ACGL/Base/OSDetection.hh b/include/ACGL/Base/OSDetection.hh new file mode 100644 index 0000000000000000000000000000000000000000..553db5f1e749a980c9e94fc490eb73f5f33e7f9c --- /dev/null +++ b/include/ACGL/Base/OSDetection.hh @@ -0,0 +1,23 @@ +/*********************************************************************** + * Copyright 2015-2015 Computer Graphics Group RWTH Aachen University. * + * All rights reserved. * + * Distributed under the terms of the MIT License (see LICENSE.TXT). * + **********************************************************************/ + +#pragma once + +// Android autodetection: +#ifdef __ANDROID__ +# define ACGL_PLATFORM_ANDROID +#endif + +// If we're compiling for an Apple system we need this to distinquish between Mac and iOS: +#ifdef __APPLE__ +# include <TargetConditionals.h> +#endif + +#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)) +# if (TARGET_OS_IPHONE == 1) +# define ACGL_PLATFORM_IOS +# endif +#endif diff --git a/include/ACGL/OpenGL/Debug.hh b/include/ACGL/OpenGL/Debug.hh index 223fc0d2b0d925f0da0011618595b71a456c5eaf..893980d06a133b20d765b3c9e08a031b009b141e 100644 --- a/include/ACGL/OpenGL/Debug.hh +++ b/include/ACGL/OpenGL/Debug.hh @@ -26,7 +26,7 @@ public: }; -#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT +#if (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGL_VERSION >= 32)) // only for internal use! // THE_GL_TYPE has to be: // GL_BUFFER, GL_SHADER, GL_PROGRAM, GL_VERTEX_ARRAY, GL_QUERY, GL_PROGRAM_PIPELINE, @@ -49,6 +49,26 @@ std::string getObjectLabelT( GLuint _objectName ) return labelName; } +#elif (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (GL_EXT_debug_label == 1)) + // OpenGL ES with extensions: + template <unsigned int THE_GL_TYPE> + void setObjectLabelT( GLuint _objectName, const std::string &_label ) { + glLabelObjectEXT( THE_GL_TYPE, _objectName, 0, _label.c_str() ); + } + + template <unsigned int THE_GL_TYPE> + std::string getObjectLabelT( GLuint _objectName ) + { + GLsizei labelLenght; + glGetObjectLabelEXT(THE_GL_TYPE, _objectName, 0, &labelLenght, NULL); + GLchar *tmp = new GLchar[labelLenght+1]; // +1 to have space for the 0-termination + + glGetObjectLabelEXT(THE_GL_TYPE, _objectName, labelLenght+1, NULL, tmp); + std::string labelName(tmp); + delete[] tmp; + + return labelName; + } #endif //! converts a KHR debug source enum to a human readable string diff --git a/include/ACGL/OpenGL/GL.hh b/include/ACGL/OpenGL/GL.hh index 622c586f801368d2f596c0d892aa6709b496bd06..e33682cfd17bbdec3cf56ceb1286865626e310fb 100644 --- a/include/ACGL/OpenGL/GL.hh +++ b/include/ACGL/OpenGL/GL.hh @@ -7,6 +7,8 @@ #ifndef ACGL_OPENGL_GL_HH #define ACGL_OPENGL_GL_HH +#include <ACGL/Base/OSDetection.hh> + /* * This simple OpenGL wrapper is used to include OpenGL (and if needed GLEW) * on different platforms. @@ -39,22 +41,8 @@ * (full/compatibility profile). */ -// Android autodetection: -#ifdef __ANDROID__ +#if (defined(ACGL_PLATFORM_IOS) || defined(ACGL_PLATFORM_ANDROID)) # define ACGL_OPENGL_ES -# define PLATFORM_ANDROID -#endif - -// If we're compiling for an Apple system we need this to distinquish between Mac and iOS: -#ifdef __APPLE__ -# include <TargetConditionals.h> -#endif - -#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)) -# if (TARGET_OS_IPHONE == 1) -# define ACGL_PLATFORM_IOS -# define ACGL_OPENGL_ES -# endif #endif // To compare the OpenGL version number we define a new ACGL_OPENGL_VERSION XY define here @@ -130,15 +118,15 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #if ACGL_OPENGL_VERSION > 32 -// prevents QT from redefining the debug functions -#define GL_ARB_debug_output -#define GL_KHR_debug + // 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 label, debug groups: + #define ACGL_OPENGL_DEBUGGER_SUPPORT -// debug callbacks: -#define ACGL_OPENGL_DEBUG_CALLBACK_SUPPORT + // debug callbacks: + #define ACGL_OPENGL_DEBUG_CALLBACK_SUPPORT #endif void CHECKGLERROR(); @@ -158,10 +146,11 @@ void CHECKGLERROR(); #elif defined (ACGL_OPENGLES_VERSION_30) #import <OpenGLES/ES3/gl.h> #import <OpenGLES/ES3/glext.h> + #define ACGL_OPENGL_DEBUGGER_SUPPORT #else #error "location of ES headers not known" #endif - #elif defined (PLATFORM_ANDROID) + #elif defined (ACGL_PLATFORM_ANDROID) // Android: #if defined (ACGL_OPENGLES_VERSION_20) #include <GLES2/gl2.h> diff --git a/include/ACGL/OpenGL/Objects/Buffer.hh b/include/ACGL/OpenGL/Objects/Buffer.hh index aae4aca6ff13c84ae2405127b77fa7ce87fe8202..db2a4c0fc2ea15da4d93053df94fb119f7f94bd6 100644 --- a/include/ACGL/OpenGL/Objects/Buffer.hh +++ b/include/ACGL/OpenGL/Objects/Buffer.hh @@ -114,9 +114,12 @@ public: public: // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and* // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise! -#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT +#if (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGL_VERSION >= 32)) void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_BUFFER>(getObjectName(),_label); } std::string getObjectLabel() { return getObjectLabelT<GL_BUFFER>(getObjectName()); } +#elif (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGLES_VERSION >= 10)) + void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_BUFFER_OBJECT_EXT>(getObjectName(),_label); } + std::string getObjectLabel() { return getObjectLabelT<GL_BUFFER_OBJECT_EXT>(getObjectName()); } #else void setObjectLabel( const std::string & ) {} std::string getObjectLabel() { return ""; } diff --git a/include/ACGL/OpenGL/Objects/Query.hh b/include/ACGL/OpenGL/Objects/Query.hh index 8d0b5eef2cd0aa361c477b65518b531c0716fecb..de5444ef818612f8a6adc3786d7e3e23bfde660d 100644 --- a/include/ACGL/OpenGL/Objects/Query.hh +++ b/include/ACGL/OpenGL/Objects/Query.hh @@ -52,9 +52,12 @@ public: public: // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and* // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise! -#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT +#if (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGL_VERSION >= 32)) void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_QUERY>(getObjectName(),_label); } std::string getObjectLabel() { return getObjectLabelT<GL_QUERY>(getObjectName()); } +#elif (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGLES_VERSION >= 10)) + void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_QUERY_OBJECT_EXT>(getObjectName(),_label); } + std::string getObjectLabel() { return getObjectLabelT<GL_QUERY_OBJECT_EXT>(getObjectName()); } #else void setObjectLabel( const std::string & ) {} std::string getObjectLabel() { return ""; } diff --git a/include/ACGL/OpenGL/Objects/Shader.hh b/include/ACGL/OpenGL/Objects/Shader.hh index 7b67837aff40fba97c2f1d546d52d141210a495f..86feadc8bc20076d5a596eb63241253ea2395423 100644 --- a/include/ACGL/OpenGL/Objects/Shader.hh +++ b/include/ACGL/OpenGL/Objects/Shader.hh @@ -62,9 +62,12 @@ public: public: // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and* // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise! -#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT +#if (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGL_VERSION >= 32)) void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_SHADER>(getObjectName(),_label); } std::string getObjectLabel() { return getObjectLabelT<GL_SHADER>(getObjectName()); } +#elif (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGLES_VERSION >= 10)) + void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_SHADER_OBJECT_EXT>(getObjectName(),_label); } + std::string getObjectLabel() { return getObjectLabelT<GL_SHADER_OBJECT_EXT>(getObjectName()); } #else void setObjectLabel( const std::string & ) {} std::string getObjectLabel() { return ""; } diff --git a/include/ACGL/OpenGL/Objects/ShaderProgram.hh b/include/ACGL/OpenGL/Objects/ShaderProgram.hh index 8d020f9022e5e974a820f0794876cab78383617e..bd977ca75aef61f014ae95a31ab4268273626d29 100644 --- a/include/ACGL/OpenGL/Objects/ShaderProgram.hh +++ b/include/ACGL/OpenGL/Objects/ShaderProgram.hh @@ -90,9 +90,12 @@ public: public: // Sets and gets a label visible inside of a OpenGL debugger if KHR_debug is supported at runtime *and* // if ACGL_OPENGL_DEBUGGER_SUPPORT was defined during compile time. Does nothing otherwise! -#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT +#if (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGL_VERSION >= 32)) void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_PROGRAM>(getObjectName(),_label); } std::string getObjectLabel() { return getObjectLabelT<GL_PROGRAM>(getObjectName()); } +#elif (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGLES_VERSION >= 10)) + void setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_PROGRAM_OBJECT_EXT>(getObjectName(),_label); } + std::string getObjectLabel() { return getObjectLabelT<GL_PROGRAM_OBJECT_EXT>(getObjectName()); } #else void setObjectLabel( const std::string & ) {} std::string getObjectLabel() { return ""; } diff --git a/include/ACGL/Utils/FileHelpers.hh b/include/ACGL/Utils/FileHelpers.hh index db77aaacf726a0acf120d9f497164cbbb0389220..9318525da45381e60acb07d3c1e588a167960d50 100644 --- a/include/ACGL/Utils/FileHelpers.hh +++ b/include/ACGL/Utils/FileHelpers.hh @@ -47,6 +47,9 @@ namespace FileHelpers */ std::string getDeviceDependentPathFor( const std::string &resource ); + // resource path is important on iOS, "" everywhere else + std::string getDeviceResourcePath(); + typedef time_t FileModificationTime; /* diff --git a/include/ACGL/Utils/FileHelpersiOS.h b/include/ACGL/Utils/FileHelpersiOS.h index 6ec8598b5c54cefcdf771e3f102dd5e162b0534c..719464a5cc11fc7eb6abb95488dcbc0f322a64bc 100644 --- a/include/ACGL/Utils/FileHelpersiOS.h +++ b/include/ACGL/Utils/FileHelpersiOS.h @@ -1,11 +1,6 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University // -// All rights reserved. // -//////////////////////////////////////////////////////////////////////////////// - -/* - * FileHelpersiOS.h - * iOS-Test - * - */ +/*********************************************************************** + * Copyright 2011-2015 Computer Graphics Group RWTH Aachen University. * + * All rights reserved. * + * Distributed under the terms of the MIT License (see LICENSE.TXT). * + **********************************************************************/ diff --git a/src/ACGL/ACGL.cc b/src/ACGL/ACGL.cc index 540d68b4a7b807bdad144c3e3e40e3831507409f..eaaf2d57c16c20eba727e4b0bad9a34c5a7b86a9 100644 --- a/src/ACGL/ACGL.cc +++ b/src/ACGL/ACGL.cc @@ -46,13 +46,14 @@ bool init( bool forceDebuggingContext ) // // check OpenGL version // - Utils::debug() << "OpenGL Version: " << OpenGL::getOpenGLMajorVersionNumber() << "." << OpenGL::getOpenGLMinorVersionNumber() << std::endl; - #ifdef ACGL_OPENGL_ES + Utils::debug() << "OpenGL ES Version: "; unsigned int versionToTest = ACGL_OPENGLES_VERSION ; #else + Utils::debug() << "OpenGL Version: "; unsigned int versionToTest = ACGL_OPENGL_VERSION ; #endif + Utils::debug() << OpenGL::getOpenGLMajorVersionNumber() << "." << OpenGL::getOpenGLMinorVersionNumber() << std::endl; if (OpenGL::getOpenGLVersionNumber() < versionToTest) { Utils::error() << "At compile time an OpenGL context of version " << versionToTest diff --git a/src/ACGL/OpenGL/Creator/ShaderParser.cc b/src/ACGL/OpenGL/Creator/ShaderParser.cc index c535847aa1e0095632949ff64ae0dd57c6e9ab99..5a704339cb83d5c825c0fbdf8de136c735dbb1d4 100644 --- a/src/ACGL/OpenGL/Creator/ShaderParser.cc +++ b/src/ACGL/OpenGL/Creator/ShaderParser.cc @@ -97,9 +97,18 @@ void ShaderParser::parse(const std::string &_filename) //readin( "./"+path+"/"+file ); readin( _filename ); +#ifndef ACGL_OPENGL_ES if (mMaxVersion > 110) { mSources[0] = "#version "+StringHelpers::toString(mMaxVersion)+"\n"; } +#else +#if (ACGL_OPENGLES_VERSION == 20) + mSources[0] = "#version 200 es\n"; +#else + mSources[0] = "#version 300 es\n"; +#endif + mSources[0] = mSources[0]+"#define ACGL_OPENGL_ES\n"; +#endif } int ShaderParser::registerSourceFile(const std::string &_name) diff --git a/src/ACGL/OpenGL/Debug.cc b/src/ACGL/OpenGL/Debug.cc index 57e2e9591981bc9605b535bef468be5b276f72ee..2396ff1792334624bb559df21afa61025e4a8ce8 100644 --- a/src/ACGL/OpenGL/Debug.cc +++ b/src/ACGL/OpenGL/Debug.cc @@ -17,7 +17,8 @@ using namespace ACGL::Utils; namespace ACGL{ namespace OpenGL{ -#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT +#if (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGL_VERSION >= 32)) +// desktop with native support GLDebugAnnotation::GLDebugAnnotation( const char *_message ) { GLuint messageID = 0; @@ -29,6 +30,17 @@ GLDebugAnnotation::~GLDebugAnnotation() glPopDebugGroup(); } +#elif (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (GL_EXT_debug_marker == 1)) +// OpenGL ES with extension: +GLDebugAnnotation::GLDebugAnnotation( const char *_message ) +{ + glPushGroupMarkerEXT( 0, _message ); +} + +GLDebugAnnotation::~GLDebugAnnotation() +{ + glPopGroupMarkerEXT(); +} #else GLDebugAnnotation::GLDebugAnnotation( const char *_message ){} GLDebugAnnotation::~GLDebugAnnotation(){} diff --git a/src/ACGL/OpenGL/Objects/Texture.cc b/src/ACGL/OpenGL/Objects/Texture.cc index 4852f8cf4733bbb7e6b5c61380baf8b283383f46..b4da281c69f6f7548f1ee5340b624aded47b765f 100644 --- a/src/ACGL/OpenGL/Objects/Texture.cc +++ b/src/ACGL/OpenGL/Objects/Texture.cc @@ -278,22 +278,26 @@ GLuint TextureBase::bindAndGetOldTexture() const GLenum TextureBase::getCompatibleFormat( GLenum _internalFormat ) { -#if ((ACGL_OPENGLES_VERSION >= 30) || (ACGL_OPENGL_VERSION >= 20)) +#if ((ACGL_OPENGLES_VERSION >= 20)) + if ( (_internalFormat == GL_ALPHA) || (_internalFormat == GL_RGB) || (_internalFormat == GL_RGBA) + || (_internalFormat == GL_LUMINANCE) || (_internalFormat == GL_LUMINANCE_ALPHA)) { + return _internalFormat; + } else { + ACGL::Utils::error() << "Unsupported format for ES" << std::endl; + } +#else + // Desktop OpenGL if (_internalFormat == GL_DEPTH24_STENCIL8) { return GL_DEPTH_STENCIL; } -#endif if ( _internalFormat == GL_DEPTH_COMPONENT || _internalFormat == GL_DEPTH_COMPONENT16 -#if ((ACGL_OPENGLES_VERSION >= 30) || (ACGL_OPENGL_VERSION >= 20)) || _internalFormat == GL_DEPTH_COMPONENT24 || _internalFormat == GL_DEPTH_COMPONENT32F -#endif ) { return GL_DEPTH_COMPONENT; } -#if ((ACGL_OPENGLES_VERSION >= 30) || (ACGL_OPENGL_VERSION >= 20)) if ( _internalFormat == GL_R8I || _internalFormat == GL_R8UI || _internalFormat == GL_R16I @@ -328,7 +332,7 @@ GLenum TextureBase::getCompatibleFormat( GLenum _internalFormat ) GLenum TextureBase::getCompatibleType( GLenum _internalFormat ) { -#if ((ACGL_OPENGLES_VERSION >= 30) || (ACGL_OPENGL_VERSION >= 20)) +#if (ACGL_OPENGL_VERSION >= 20) if (_internalFormat == GL_DEPTH24_STENCIL8) { return GL_UNSIGNED_INT_24_8; } @@ -360,7 +364,7 @@ GLenum TextureBase::getCompatibleType( GLenum _internalFormat ) } #endif // not sure if this works for all formats: - return GL_BYTE; + return GL_UNSIGNED_BYTE; } @@ -738,6 +742,16 @@ void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLe void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel ) { +#if (ACGL_OPENGLES_VERSION >= 10) + if (mInternalFormat != _data->getFormat()) { + ACGL::Utils::error() << "On ES the internal and external formats must match, chaning internal format" << std::endl; + mInternalFormat = _data->getFormat(); + } + if ((_data->getType() != GL_UNSIGNED_BYTE) && (_data->getType() != GL_UNSIGNED_SHORT_5_6_5) + && (_data->getType() != GL_UNSIGNED_SHORT_4_4_4_4) && (_data->getType() != GL_UNSIGNED_SHORT_5_5_5_1)) { + ACGL::Utils::error() << "External type is unsupported on ES, this might fail!" << std::endl; + } +#endif bind(); mWidth = _data->getWidth(); mHeight = _data->getHeight(); @@ -756,6 +770,17 @@ void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec2 _offset ) { +#if (ACGL_OPENGLES_VERSION >= 10) + if (mInternalFormat != _data->getFormat()) { + ACGL::Utils::error() << "On ES the internal and external formats must match, chaning internal format" << std::endl; + mInternalFormat = _data->getFormat(); + } + if ((_data->getType() != GL_UNSIGNED_BYTE) && (_data->getType() != GL_UNSIGNED_SHORT_5_6_5) + && (_data->getType() != GL_UNSIGNED_SHORT_4_4_4_4) && (_data->getType() != GL_UNSIGNED_SHORT_5_5_5_1)) { + ACGL::Utils::error() << "External type is unsupported on ES, this might fail!" << std::endl; + } +#endif + bind(); GLsizei w = std::min( mWidth, _data->getWidth() ); GLsizei h = std::max( std::min( mHeight, _data->getHeight() ), 1); @@ -774,6 +799,17 @@ void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLe #if defined (ACGL_OPENGL_SUPPORTS_TEXTURE_3D) void TextureBase::texImage3D( const SharedTextureData &_data, GLint _mipmapLevel ) { +#if (ACGL_OPENGLES_VERSION >= 10) + if (mInternalFormat != _data->getFormat()) { + ACGL::Utils::error() << "On ES the internal and external formats must match, chaning internal format" << std::endl; + mInternalFormat = _data->getFormat(); + } + if ((_data->getType() != GL_UNSIGNED_BYTE) && (_data->getType() != GL_UNSIGNED_SHORT_5_6_5) + && (_data->getType() != GL_UNSIGNED_SHORT_4_4_4_4) && (_data->getType() != GL_UNSIGNED_SHORT_5_5_5_1)) { + ACGL::Utils::error() << "External type is unsupported on ES, this might fail!" << std::endl; + } +#endif + bind(); mWidth = _data->getWidth(); mHeight = _data->getHeight(); @@ -793,6 +829,17 @@ void TextureBase::texImage3D( const SharedTextureData &_data, GLint _mipmapLevel void TextureBase::texSubImage3D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec3 _offset ) { +#if (ACGL_OPENGLES_VERSION >= 10) + if (mInternalFormat != _data->getFormat()) { + ACGL::Utils::error() << "On ES the internal and external formats must match, chaning internal format" << std::endl; + mInternalFormat = _data->getFormat(); + } + if ((_data->getType() != GL_UNSIGNED_BYTE) && (_data->getType() != GL_UNSIGNED_SHORT_5_6_5) + && (_data->getType() != GL_UNSIGNED_SHORT_4_4_4_4) && (_data->getType() != GL_UNSIGNED_SHORT_5_5_5_1)) { + ACGL::Utils::error() << "External type is unsupported on ES, this might fail!" << std::endl; + } +#endif + bind(); GLsizei w = std::min( mWidth, _data->getWidth() ); GLsizei h = std::max( std::min( mHeight, _data->getHeight() ), 1); diff --git a/src/ACGL/OpenGL/Objects/VertexArrayObject.cc b/src/ACGL/OpenGL/Objects/VertexArrayObject.cc index 85ae8a00af414158f20eb011955931cc3bc206af..0f60efada3c0ed2eaf90f9afe625ad765d505231 100644 --- a/src/ACGL/OpenGL/Objects/VertexArrayObject.cc +++ b/src/ACGL/OpenGL/Objects/VertexArrayObject.cc @@ -25,7 +25,7 @@ VertexArrayObject::VertexArrayObject( GLenum _mode ) : mAttributes.resize( maxAttributes ); // reserve probably 16 slots, the size() can now be used to query the MAX_VERTEX_ATTRIBS } -#ifdef ACGL_OPENGL_DEBUGGER_SUPPORT +#if (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGL_VERSION >= 32)) void VertexArrayObject::setObjectLabel( const std::string &_label ) { setObjectLabelT<GL_VERTEX_ARRAY>(getObjectName(),_label); @@ -35,6 +35,16 @@ std::string VertexArrayObject::getObjectLabel() { return getObjectLabelT<GL_VERTEX_ARRAY>(getObjectName()); } +#elif (defined(ACGL_OPENGL_DEBUGGER_SUPPORT) && (ACGL_OPENGLES_VERSION >= 10)) +void VertexArrayObject::setObjectLabel( const std::string &_label ) +{ + setObjectLabelT<GL_VERTEX_ARRAY_OBJECT_EXT>(getObjectName(),_label); +} + +std::string VertexArrayObject::getObjectLabel() +{ + return getObjectLabelT<GL_VERTEX_ARRAY_OBJECT_EXT>(getObjectName()); +} #else void VertexArrayObject::setObjectLabel( const std::string & ) {} std::string VertexArrayObject::getObjectLabel() { return ""; } diff --git a/src/ACGL/OpenGL/Tools.cc b/src/ACGL/OpenGL/Tools.cc index 99b8ec138e18885516a8234b4dc4c8394ea5cd3c..e4f7b654013c211f5ac729127f5a422f0866420e 100644 --- a/src/ACGL/OpenGL/Tools.cc +++ b/src/ACGL/OpenGL/Tools.cc @@ -189,7 +189,7 @@ uint32_t getOpenGLVersionNumber() bool doesSupportGeometryShader() { #if defined(ACGL_OPENGL_ES) - #if (ACGL_OPENGL_ES_VERSION < 32)) + #if (ACGL_OPENGL_ES_VERSION < 32) return false; #else return true; @@ -203,7 +203,7 @@ bool doesSupportGeometryShader() bool doesSupportTessellationShader() { #if defined(ACGL_OPENGL_ES) - #if (ACGL_OPENGL_ES_VERSION < 32)) + #if (ACGL_OPENGL_ES_VERSION < 32) return false; #else return true; @@ -217,7 +217,7 @@ bool doesSupportTessellationShader() bool doesSupportComputeShader() { #if defined(ACGL_OPENGL_ES) - #if (ACGL_OPENGL_ES_VERSION < 31)) + #if (ACGL_OPENGL_ES_VERSION < 31) return false; #else return true; diff --git a/src/ACGL/Utils/FileHelpers.cc b/src/ACGL/Utils/FileHelpers.cc index ea1d13e26d9b1487dd4a38ec7839f555a8b8a922..2c65e0bf664342801177f0c0f08e87e67b66807d 100644 --- a/src/ACGL/Utils/FileHelpers.cc +++ b/src/ACGL/Utils/FileHelpers.cc @@ -100,6 +100,8 @@ namespace FileHelpers { return resource; } + + std::string getDeviceResourcePath() {return "";} #endif diff --git a/src/ACGL/Utils/FileHelpersiOS.mm b/src/ACGL/Utils/FileHelpersiOS.mm index 46218c3744b1bb6fee04351b0353a8c3d660b0ab..d5159f3db167f62231a163facb194352c9702d25 100644 --- a/src/ACGL/Utils/FileHelpersiOS.mm +++ b/src/ACGL/Utils/FileHelpersiOS.mm @@ -1,25 +1,34 @@ -//////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University // -// All rights reserved. // -//////////////////////////////////////////////////////////////////////////////// - -/* - * FileHelpersiOS.c - * iOS-Test - * - * - */ +/*********************************************************************** + * Copyright 2011-2015 Computer Graphics Group RWTH Aachen University. * + * All rights reserved. * + * Distributed under the terms of the MIT License (see LICENSE.TXT). * + **********************************************************************/ #include <ACGL/Utils/FileHelpers.hh> #import <UIKit/UIKit.h> +namespace ACGL{ +namespace Utils{ +namespace FileHelpers{ + std::string getDeviceDependentPathFor( const std::string &resource ) { NSString *res = [NSString stringWithFormat:@"%s", resource.c_str() ]; NSString *path = [[NSBundle mainBundle] pathForResource: res ofType: nil ]; - + if (path) { - return std::string( [path cStringUsingEncoding:1] ); + return std::string( [path cStringUsingEncoding:1] ); } return ""; // file not found +} + + std::string getDeviceResourcePath() + { + NSString *path = [[NSBundle mainBundle] resourcePath]; + + return std::string( [path cStringUsingEncoding:1] )+"/"; + } + +} +} }