Browse Source

ARB_direct_state_access support for creating meshes.

pull/69/head
Vladimír Vondruš 12 years ago
parent
commit
e4119157b6
  1. 8
      src/Magnum/Implementation/MeshState.cpp
  2. 9
      src/Magnum/Mesh.cpp
  3. 12
      src/Magnum/Mesh.h

8
src/Magnum/Implementation/MeshState.cpp

@ -96,6 +96,14 @@ MeshState::MeshState(Context& context, std::vector<std::string>& extensions): cu
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES
/* DSA create implementation (other cases handled above) */
if(context.isExtensionSupported<Extensions::GL::ARB::direct_state_access>()) {
extensions.push_back(Extensions::GL::ARB::direct_state_access::string());
createImplementation = &Mesh::createImplementationVAODSA;
}
#endif
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
/* Multi draw implementation on ES */ /* Multi draw implementation on ES */
if(context.isExtensionSupported<Extensions::GL::EXT::multi_draw_arrays>()) { if(context.isExtensionSupported<Extensions::GL::EXT::multi_draw_arrays>()) {

9
src/Magnum/Mesh.cpp

@ -335,7 +335,6 @@ void Mesh::createImplementationDefault() {
} }
void Mesh::createImplementationVAO() { void Mesh::createImplementationVAO() {
_created = false;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glGenVertexArrays(1, &_id); glGenVertexArrays(1, &_id);
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL)
@ -343,9 +342,17 @@ void Mesh::createImplementationVAO() {
#else #else
CORRADE_ASSERT_UNREACHABLE(); CORRADE_ASSERT_UNREACHABLE();
#endif #endif
_created = false;
CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding);
} }
#ifndef MAGNUM_TARGET_GLES
void Mesh::createImplementationVAODSA() {
glCreateVertexArrays(1, &_id);
_created = true;
}
#endif
void Mesh::destroyImplementationDefault() {} void Mesh::destroyImplementationDefault() {}
void Mesh::destroyImplementationVAO() { void Mesh::destroyImplementationVAO() {

12
src/Magnum/Mesh.h

@ -424,8 +424,11 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* *
* If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL
* ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is
* available, vertex array object is created. * available, vertex array object is created. If @extension{ARB,direct_state_access}
* @see @ref setPrimitive(), @ref setCount(), @fn_gl{GenVertexArrays} * (part of OpenGL 4.5) is not supported, the vertex array object is
* created on first use.
* @see @ref setPrimitive(), @ref setCount(), @fn_gl{CreateVertexArrays},
* eventually @fn_gl{GenVertexArrays}
*/ */
explicit Mesh(MeshPrimitive primitive = MeshPrimitive::Triangles); explicit Mesh(MeshPrimitive primitive = MeshPrimitive::Triangles);
@ -440,7 +443,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
* *
* If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL
* ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is
* available, vertex array object is deleted. * available, associated vertex array object is deleted.
* @see @fn_gl{DeleteVertexArrays} * @see @fn_gl{DeleteVertexArrays}
*/ */
~Mesh(); ~Mesh();
@ -954,6 +957,9 @@ class MAGNUM_EXPORT Mesh: public AbstractObject {
void MAGNUM_LOCAL createImplementationDefault(); void MAGNUM_LOCAL createImplementationDefault();
void MAGNUM_LOCAL createImplementationVAO(); void MAGNUM_LOCAL createImplementationVAO();
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL createImplementationVAODSA();
#endif
void MAGNUM_LOCAL destroyImplementationDefault(); void MAGNUM_LOCAL destroyImplementationDefault();
void MAGNUM_LOCAL destroyImplementationVAO(); void MAGNUM_LOCAL destroyImplementationVAO();

Loading…
Cancel
Save