diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index 7f99a768d..31f85dcf0 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -320,9 +320,9 @@ OpenGL function | Matching API @def_gl{MAX_COLOR_TEXTURE_SAMPLES}, \n @def_gl{MAX_DEPTH_TEXTURE_SAMPLES}, \n @def_gl{MAX_INTEGER_SAMPLES} | @ref AbstractTexture::maxColorSamples(), \n @ref AbstractTexture::maxDepthSamples(), \n @ref AbstractTexture::maxIntegerSamples() @def_gl{MAX_DRAW_BUFFERS} | @ref AbstractFramebuffer::maxDrawBuffers() @def_gl{MAX_DUAL_SOURCE_DRAW_BUFFERS} | @ref AbstractFramebuffer::maxDualSourceDrawBuffers() +@def_gl{MAX_ELEMENT_INDEX} | @ref Mesh::maxElementIndex() @def_gl{MAX_ELEMENTS_INDICES} | @ref Mesh::maxElementsIndices() @def_gl{MAX_ELEMENTS_VERTICES} | @ref Mesh::maxElementsVertices() -@def_gl{MAX_ELEMENT_INDEX} | | @def_gl{MAX_FRAMEBUFFER_HEIGHT} | | @def_gl{MAX_FRAMEBUFFER_LAYERS} | | @def_gl{MAX_FRAMEBUFFER_SAMPLES} | | diff --git a/src/Magnum/Implementation/MeshState.cpp b/src/Magnum/Implementation/MeshState.cpp index 308099769..d7297925b 100644 --- a/src/Magnum/Implementation/MeshState.cpp +++ b/src/Magnum/Implementation/MeshState.cpp @@ -35,7 +35,7 @@ namespace Magnum { namespace Implementation { MeshState::MeshState(Context& context, std::vector& extensions): currentVAO(0) #ifndef MAGNUM_TARGET_GLES2 - , maxElementsIndices(0), maxElementsVertices(0) + , maxElementIndex{0}, maxElementsIndices{0}, maxElementsVertices{0} #endif { #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Implementation/MeshState.h b/src/Magnum/Implementation/MeshState.h index 0b0349cec..9095a6ff0 100644 --- a/src/Magnum/Implementation/MeshState.h +++ b/src/Magnum/Implementation/MeshState.h @@ -64,6 +64,7 @@ struct MeshState { GLuint currentVAO; #ifndef MAGNUM_TARGET_GLES2 + GLint64 maxElementIndex; GLint maxElementsIndices, maxElementsVertices; #endif }; diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index 0a2794e63..b530fc704 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -41,6 +41,21 @@ namespace Magnum { Int Mesh::maxVertexAttributes() { return AbstractShaderProgram::maxVertexAttributes(); } #ifndef MAGNUM_TARGET_GLES2 +Long Mesh::maxElementIndex() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current()->isExtensionSupported()) + return 0xFFFFFFFFl; + #endif + + GLint64& value = Context::current()->state().mesh->maxElementIndex; + + /* Get the value, if not already cached */ + if(value == 0) + glGetInteger64v(GL_MAX_ELEMENT_INDEX, &value); + + return value; +} + Int Mesh::maxElementsIndices() { GLint& value = Context::current()->state().mesh->maxElementsIndices; diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index b79df2367..7de09d816 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -375,6 +375,19 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { static Int maxVertexAttributes(); #ifndef MAGNUM_TARGET_GLES2 + /** + * @brief Max supported index value + * + * The result is cached, repeated queries don't result in repeated + * OpenGL calls. If extension @extension{ARB,ES3_compatibility} (part + * of OpenGL 4.3) is not available, returns max representable 32-bit + * value (@f$ 2^32 - 1 @f$). + * @see @ref setIndexBuffer(), @fn_gl{Get} with @def_gl{MAX_ELEMENT_INDEX} + * @requires_gles30 No upper limit is specified for index values in + * OpenGL ES 2.0 + */ + static Long maxElementIndex(); + /** * @brief Max recommended index count * @@ -744,9 +757,9 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is * available, the vertex array object is used to hold the parameters. * - * @see @ref maxElementsIndices(), @ref maxElementsVertices(), - * @ref setCount(), @ref isIndexed(), @fn_gl{BindVertexArray}, - * @fn_gl{BindBuffer} + * @see @ref maxElementIndex(), @ref maxElementsIndices(), + * @ref maxElementsVertices(), @ref setCount(), @ref isIndexed(), + * @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} */ Mesh& setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end); diff --git a/src/Magnum/Platform/magnum-info.cpp b/src/Magnum/Platform/magnum-info.cpp index d36e4e059..1b164d895 100644 --- a/src/Magnum/Platform/magnum-info.cpp +++ b/src/Magnum/Platform/magnum-info.cpp @@ -291,6 +291,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat _l(AbstractFramebuffer::maxDrawBuffers()) _l(Framebuffer::maxColorAttachments()) #ifndef MAGNUM_TARGET_GLES2 + _l(Mesh::maxElementIndex()) _l(Mesh::maxElementsIndices()) _l(Mesh::maxElementsVertices()) #endif