From: Mikko Rasa Date: Fri, 17 Oct 2014 11:18:27 +0000 (+0300) Subject: Fallback to glDrawElements if EXT_draw_range_elements is unavailable X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b9844472a5ec8fad571809409f6ed4203531d825;p=libs%2Fgl.git Fallback to glDrawElements if EXT_draw_range_elements is unavailable --- 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); }