Browse Source

Added Mesh::maxElementIndex() limit query.

pull/68/head
Vladimír Vondruš 12 years ago
parent
commit
e193aa15c7
  1. 2
      doc/opengl-mapping.dox
  2. 2
      src/Magnum/Implementation/MeshState.cpp
  3. 1
      src/Magnum/Implementation/MeshState.h
  4. 15
      src/Magnum/Mesh.cpp
  5. 19
      src/Magnum/Mesh.h
  6. 1
      src/Magnum/Platform/magnum-info.cpp

2
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} | |

2
src/Magnum/Implementation/MeshState.cpp

@ -35,7 +35,7 @@ namespace Magnum { namespace Implementation {
MeshState::MeshState(Context& context, std::vector<std::string>& extensions): currentVAO(0)
#ifndef MAGNUM_TARGET_GLES2
, maxElementsIndices(0), maxElementsVertices(0)
, maxElementIndex{0}, maxElementsIndices{0}, maxElementsVertices{0}
#endif
{
#ifndef MAGNUM_TARGET_GLES

1
src/Magnum/Implementation/MeshState.h

@ -64,6 +64,7 @@ struct MeshState {
GLuint currentVAO;
#ifndef MAGNUM_TARGET_GLES2
GLint64 maxElementIndex;
GLint maxElementsIndices, maxElementsVertices;
#endif
};

15
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<Extensions::GL::ARB::ES3_compatibility>())
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;

19
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);

1
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

Loading…
Cancel
Save