Browse Source

Fixed OpenGL ES 2.0 compatibility.

Issues related to lack of glDrawRangeElements().
pull/23/head
Vladimír Vondruš 13 years ago
parent
commit
2ab37ba2a1
  1. 7
      src/Mesh.cpp
  2. 8
      src/Mesh.h
  3. 13
      src/MeshView.cpp
  4. 12
      src/MeshView.h

7
src/Mesh.cpp

@ -136,7 +136,12 @@ Mesh& Mesh::setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type, Unsi
return *this;
}
void Mesh::drawInternal(Int firstVertex, Int vertexCount, GLintptr indexOffset, Int indexCount, Int indexStart, Int indexEnd) {
#ifndef MAGNUM_TARGET_GLES2
void Mesh::drawInternal(Int firstVertex, Int vertexCount, GLintptr indexOffset, Int indexCount, Int indexStart, Int indexEnd)
#else
void Mesh::drawInternal(Int firstVertex, Int vertexCount, GLintptr indexOffset, Int indexCount)
#endif
{
/* Nothing to draw */
if(!vertexCount && !indexCount) return;

8
src/Mesh.h

@ -597,7 +597,11 @@ class MAGNUM_EXPORT Mesh {
* is available), @fn_gl{DrawArrays} or @fn_gl{DrawElements}/@fn_gl{DrawRangeElements}.
*/
void draw() {
#ifndef MAGNUM_TARGET_GLES2
drawInternal(0, _vertexCount, _indexOffset, _indexCount, _indexStart, _indexEnd);
#else
drawInternal(0, _vertexCount, _indexOffset, _indexCount);
#endif
}
private:
@ -722,7 +726,11 @@ class MAGNUM_EXPORT Mesh {
#endif
#endif
#ifndef MAGNUM_TARGET_GLES2
void drawInternal(Int firstVertex, Int vertexCount, GLintptr indexOffset, Int indexCount, Int indexStart, Int indexEnd);
#else
void drawInternal(Int firstVertex, Int vertexCount, GLintptr indexOffset, Int indexCount);
#endif
typedef void(Mesh::*CreateImplementation)();
void MAGNUM_LOCAL createImplementationDefault();

13
src/MeshView.cpp

@ -28,16 +28,27 @@
namespace Magnum {
MeshView& MeshView::setIndexRange(Int first, Int count, UnsignedInt start, UnsignedInt end) {
#ifndef MAGNUM_TARGET_GLES2
MeshView& MeshView::setIndexRange(Int first, Int count, UnsignedInt start, UnsignedInt end)
#else
MeshView& MeshView::setIndexRange(Int first, Int count, UnsignedInt, UnsignedInt)
#endif
{
_indexOffset = first*_original->indexSize();
_indexCount = count;
#ifndef MAGNUM_TARGET_GLES2
_indexStart = start;
_indexEnd = end;
#endif
return *this;
}
void MeshView::draw() {
#ifndef MAGNUM_TARGET_GLES2
_original->drawInternal(_firstVertex, _vertexCount, _indexOffset, _indexCount, _indexStart, _indexEnd);
#else
_original->drawInternal(_firstVertex, _vertexCount, _indexOffset, _indexCount);
#endif
}
}

12
src/MeshView.h

@ -100,7 +100,9 @@ class MAGNUM_EXPORT MeshView {
* @return Reference to self (for method chaining)
*
* Specifying `0` for both @p start and @p end behaves the same as
* @ref setIndexRange(Int, Int).
* @ref setIndexRange(Int, Int). On OpenGL ES 2.0 this function behaves
* always as @ref setIndexRange(Int, Int), as this functionality is
* not available there.
*/
MeshView& setIndexRange(Int first, Int count, UnsignedInt start, UnsignedInt end);
@ -129,10 +131,16 @@ class MAGNUM_EXPORT MeshView {
Int _firstVertex, _vertexCount, _indexCount;
GLintptr _indexOffset;
#ifndef MAGNUM_TARGET_GLES2
UnsignedInt _indexStart, _indexEnd;
#endif
};
inline MeshView::MeshView(Mesh& original): _original(&original), _firstVertex(0), _vertexCount(0), _indexCount(0), _indexOffset(0), _indexStart(0), _indexEnd(0) {}
inline MeshView::MeshView(Mesh& original): _original(&original), _firstVertex(0), _vertexCount(0), _indexCount(0), _indexOffset(0)
#ifndef MAGNUM_TARGET_GLES2
, _indexStart(0), _indexEnd(0)
#endif
{}
}

Loading…
Cancel
Save