From c0056f76d2652de0e8a12ef783d9ab58b13d9137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 27 Apr 2014 17:35:31 +0200 Subject: [PATCH] Code reorganization. --- src/Magnum/Mesh.cpp | 70 ++++++++++++++++++++------------------------- src/Magnum/Mesh.h | 24 +++++----------- 2 files changed, 38 insertions(+), 56 deletions(-) diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index 422f32d16..1c9ee808d 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -297,44 +297,6 @@ void Mesh::bindVAO(GLuint vao) { } } -void Mesh::attributePointerInternal(const Attribute& attribute) { - (this->*Context::current()->state().mesh->attributePointerImplementation)(attribute); -} - -#ifndef MAGNUM_TARGET_GLES2 -void Mesh::attributePointerInternal(const IntegerAttribute& attribute) { - (this->*Context::current()->state().mesh->attributeIPointerImplementation)(attribute); -} - -#ifndef MAGNUM_TARGET_GLES -void Mesh::attributePointerInternal(const LongAttribute& attribute) { - (this->*Context::current()->state().mesh->attributeLPointerImplementation)(attribute); -} -#endif -#endif - -void Mesh::vertexAttribPointer(const Attribute& attribute) { - glEnableVertexAttribArray(attribute.location); - attribute.buffer->bind(Buffer::Target::Array); - glVertexAttribPointer(attribute.location, attribute.size, attribute.type, attribute.normalized, attribute.stride, reinterpret_cast(attribute.offset)); -} - -#ifndef MAGNUM_TARGET_GLES2 -void Mesh::vertexAttribPointer(const IntegerAttribute& attribute) { - glEnableVertexAttribArray(attribute.location); - attribute.buffer->bind(Buffer::Target::Array); - glVertexAttribIPointer(attribute.location, attribute.size, attribute.type, attribute.stride, reinterpret_cast(attribute.offset)); -} - -#ifndef MAGNUM_TARGET_GLES -void Mesh::vertexAttribPointer(const LongAttribute& attribute) { - glEnableVertexAttribArray(attribute.location); - attribute.buffer->bind(Buffer::Target::Array); - glVertexAttribLPointer(attribute.location, attribute.size, attribute.type, attribute.stride, reinterpret_cast(attribute.offset)); -} -#endif -#endif - void Mesh::createImplementationDefault() { _id = 0; } void Mesh::createImplementationVAO() { @@ -359,6 +321,10 @@ void Mesh::destroyImplementationVAO() { #endif } +void Mesh::attributePointerInternal(const Attribute& attribute) { + (this->*Context::current()->state().mesh->attributePointerImplementation)(attribute); +} + void Mesh::attributePointerImplementationDefault(const Attribute& attribute) { #if defined(CORRADE_TARGET_NACL) || defined(MAGNUM_TARGET_WEBGL) CORRADE_ASSERT(attribute.buffer->targetHint() == Buffer::Target::Array, @@ -385,7 +351,17 @@ void Mesh::attributePointerImplementationDSA(const Attribute& attribute) { } #endif +void Mesh::vertexAttribPointer(const Attribute& attribute) { + glEnableVertexAttribArray(attribute.location); + attribute.buffer->bind(Buffer::Target::Array); + glVertexAttribPointer(attribute.location, attribute.size, attribute.type, attribute.normalized, attribute.stride, reinterpret_cast(attribute.offset)); +} + #ifndef MAGNUM_TARGET_GLES2 +void Mesh::attributePointerInternal(const IntegerAttribute& attribute) { + (this->*Context::current()->state().mesh->attributeIPointerImplementation)(attribute); +} + void Mesh::attributePointerImplementationDefault(const IntegerAttribute& attribute) { _integerAttributes.push_back(attribute); } @@ -402,7 +378,18 @@ void Mesh::attributePointerImplementationDSA(const IntegerAttribute& attribute) } #endif +void Mesh::vertexAttribPointer(const IntegerAttribute& attribute) { + glEnableVertexAttribArray(attribute.location); + attribute.buffer->bind(Buffer::Target::Array); + glVertexAttribIPointer(attribute.location, attribute.size, attribute.type, attribute.stride, reinterpret_cast(attribute.offset)); +} +#endif + #ifndef MAGNUM_TARGET_GLES +void Mesh::attributePointerInternal(const LongAttribute& attribute) { + (this->*Context::current()->state().mesh->attributeLPointerImplementation)(attribute); +} + void Mesh::attributePointerImplementationDefault(const LongAttribute& attribute) { _longAttributes.push_back(attribute); } @@ -416,7 +403,12 @@ void Mesh::attributePointerImplementationDSA(const LongAttribute& attribute) { glEnableVertexArrayAttribEXT(_id, attribute.location); glVertexArrayVertexAttribLOffsetEXT(_id, attribute.buffer->id(), attribute.location, attribute.size, attribute.type, attribute.stride, attribute.offset); } -#endif + +void Mesh::vertexAttribPointer(const LongAttribute& attribute) { + glEnableVertexAttribArray(attribute.location); + attribute.buffer->bind(Buffer::Target::Array); + glVertexAttribLPointer(attribute.location, attribute.size, attribute.type, attribute.stride, reinterpret_cast(attribute.offset)); +} #endif void Mesh::bindIndexBufferImplementationDefault(Buffer&) {} diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index 080d85bcd..81788c55e 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -862,22 +862,6 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { static void MAGNUM_LOCAL bindVAO(GLuint vao); - void attributePointerInternal(const Attribute& attribute); - #ifndef MAGNUM_TARGET_GLES2 - void attributePointerInternal(const IntegerAttribute& attribute); - #ifndef MAGNUM_TARGET_GLES - void attributePointerInternal(const LongAttribute& attribute); - #endif - #endif - - void MAGNUM_LOCAL vertexAttribPointer(const Attribute& attribute); - #ifndef MAGNUM_TARGET_GLES2 - void MAGNUM_LOCAL vertexAttribPointer(const IntegerAttribute& attribute); - #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL vertexAttribPointer(const LongAttribute& attribute); - #endif - #endif - #ifndef MAGNUM_TARGET_GLES void drawInternal(Int count, Int baseVertex, Int instanceCount, UnsignedInt baseInstance, GLintptr indexOffset, Int indexStart, Int indexEnd); #elif !defined(MAGNUM_TARGET_GLES2) @@ -892,24 +876,30 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { void MAGNUM_LOCAL destroyImplementationDefault(); void MAGNUM_LOCAL destroyImplementationVAO(); + void attributePointerInternal(const Attribute& attribute); void MAGNUM_LOCAL attributePointerImplementationDefault(const Attribute& attribute); void MAGNUM_LOCAL attributePointerImplementationVAO(const Attribute& attribute); #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL attributePointerImplementationDSA(const Attribute& attribute); #endif + void MAGNUM_LOCAL vertexAttribPointer(const Attribute& attribute); #ifndef MAGNUM_TARGET_GLES2 + void attributePointerInternal(const IntegerAttribute& attribute); void MAGNUM_LOCAL attributePointerImplementationDefault(const IntegerAttribute& attribute); void MAGNUM_LOCAL attributePointerImplementationVAO(const IntegerAttribute& attribute); #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL attributePointerImplementationDSA(const IntegerAttribute& attribute); #endif + void MAGNUM_LOCAL vertexAttribPointer(const IntegerAttribute& attribute); + #endif #ifndef MAGNUM_TARGET_GLES + void attributePointerInternal(const LongAttribute& attribute); void MAGNUM_LOCAL attributePointerImplementationDefault(const LongAttribute& attribute); void MAGNUM_LOCAL attributePointerImplementationVAO(const LongAttribute& attribute); void MAGNUM_LOCAL attributePointerImplementationDSA(const LongAttribute& attribute); - #endif + void MAGNUM_LOCAL vertexAttribPointer(const LongAttribute& attribute); #endif void MAGNUM_LOCAL bindIndexBufferImplementationDefault(Buffer&);