X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fimmediate.cpp;h=e12ac9b53ca01ec2b3d9b73a86898605d60c724d;hb=dc1d1159a61f378bda11e5989ad694a86b9a3c77;hp=f341397492a7a2b92d5673685ccb790e9cbeb44c;hpb=85facfb688035b5bbc9a3a87d080582fbf34930b;p=libs%2Fgl.git diff --git a/source/immediate.cpp b/source/immediate.cpp index f3413974..e12ac9b5 100644 --- a/source/immediate.cpp +++ b/source/immediate.cpp @@ -11,41 +11,22 @@ namespace Msp { namespace GL { Immediate::Immediate(VertexFormat f): - array(f), - in_batch(false), - n_vertices(0) + PrimitiveBuilder(array), + array(f) { } -void Immediate::begin(PrimitiveType t) +void Immediate::end_() { - type=t; - in_batch=true; - n_vertices=0; - builder=array.modify(); -} - -void Immediate::end() -{ - builder=0; - array.apply(); - glDrawArrays(type, 0, n_vertices); + draw_elements(type, indices.size(), &indices[0]); array.clear(); - in_batch=false; + indices.clear(); } -void Immediate::vertex_(float x, float y, float z, float w) +void Immediate::element_(unsigned i) { - if(!in_batch) - throw InvalidState("Vertex specification not between begin and end"); - - builder->texcoord(ts, tt, tr,tq); - builder->color(cr, cg, cb, ca); - builder->normal(nx, ny, nz); - builder->vertex(x, y, z, w); - - ++n_vertices; + indices.push_back(i); } } // namespace GL