From 1db2ffbc1b69069eca39f786cacc45dbb02c3052 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 7 Nov 2016 12:26:05 -0800 Subject: [core] Use gl::Program to resolve some rough edges in the GL binding types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Extract `ignore` util to separate header. * `Segment` now tracks offset and length of indices, rather than primitives. This is more natural. * Introduce `VertexVector` and `IndexVector` types. These types carry information about the intended draw mode (`Triangles`, `LineStrip`, etc.), and ensure that elements are always appended in a group size appropriate for that draw mode, for both indexed and unindexed rendering. * `Program`, rather than `Drawable`, is now the unifying object for draw calls. `Program` is the best place to type check the draw call, because it is typed to carry information about the intended primitive, vertex type, attributes, and uniforms. * Use the debug shaders for debug tile rendering, like gl-js. * Fix the draw mode for background. It was drawing triangle strips with a triangles array. Surprised this didn’t cause issues. Now it’s type checked. --- src/mbgl/gl/context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mbgl/gl/context.cpp') diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index b12c77c1a1..c4485ad0fd 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -533,9 +533,9 @@ void Context::draw(const Drawable& drawable) { if (drawable.indexBuffer) { MBGL_CHECK_ERROR(glDrawElements( static_cast(primitiveType), - static_cast(drawable.primitiveSize / sizeof(uint16_t) * segment.primitiveLength), + static_cast(segment.indexLength), GL_UNSIGNED_SHORT, - reinterpret_cast(drawable.primitiveSize * segment.primitiveOffset))); + reinterpret_cast(sizeof(uint16_t) * segment.indexOffset))); } else { MBGL_CHECK_ERROR(glDrawArrays( static_cast(primitiveType), -- cgit v1.2.1