X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbatch.cpp;h=859a6ad5468f0783240d094075063d276764ac0f;hb=3b6bbeda80d1db44348243c855bc433be23b949e;hp=e097fd6365d52b65db4a8d37110ef0f3010a7ccf;hpb=f1b12c992db974c679d85ae6ec22cd318199d0d5;p=libs%2Fgl.git diff --git a/source/batch.cpp b/source/batch.cpp index e097fd63..859a6ad5 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "batch.h" #include "bindable.h" @@ -59,9 +60,10 @@ 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); + /* Make sure we have glEnable/DisableClientState to go with + NV_primitive_restart */ + if(NV_primitive_restart) + (bool)MSP_legacy_features; } Batch::~Batch() @@ -242,16 +244,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); }