From b9844472a5ec8fad571809409f6ed4203531d825 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 17 Oct 2014 14:18:27 +0300 Subject: [PATCH] Fallback to glDrawElements if EXT_draw_range_elements is unavailable --- source/batch.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/batch.cpp b/source/batch.cpp index e097fd63..3cb0a6ce 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -59,9 +59,6 @@ Batch::Batch(PrimitiveType t): max_index(0), restart(false) { - /* XXX Should probably provide a fallback to glDrawElements since this class - is pretty much required to render anything. */ - static Require _req(EXT_draw_range_elements); } Batch::~Batch() @@ -242,16 +239,22 @@ void Batch::draw() const } Buffer *ibuf = get_buffer(); + const void *data_ptr; BindRestore _bind_ibuf(ibuf, ELEMENT_ARRAY_BUFFER); if(ibuf) { if(dirty) update_buffer(); - glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, reinterpret_cast(get_offset())); + data_ptr = reinterpret_cast(get_offset()); } else - glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, &data[0]); + data_ptr = &data[0]; + + if(EXT_draw_range_elements) + glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, data_ptr); + else + glDrawElements(prim_type, size(), data_type, data_ptr); } -- 2.43.0