X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fvertexarray.cpp;h=8381d8adb1d9663b742db5a88af857f988b6bfd0;hb=b617c5d7b5283ad260a77f01e42e6170cabbc03d;hp=ef11844466b9ff7833dcde88a53a69ff422f059d;hpb=bc3c82a86eeadde54be9fe32a8a8a76872ca99c3;p=libs%2Fgl.git diff --git a/source/vertexarray.cpp b/source/vertexarray.cpp index ef118444..8381d8ad 100644 --- a/source/vertexarray.cpp +++ b/source/vertexarray.cpp @@ -35,18 +35,18 @@ void VertexArray::use_vertex_buffer() if(vbuf && own_vbuf) return; - vbuf=new VertexBuffer(); - own_vbuf=true; + vbuf = new Buffer(ARRAY_BUFFER); + own_vbuf = true; update_data(); } -void VertexArray::use_vertex_buffer(VertexBuffer *b) +void VertexArray::use_vertex_buffer(Buffer *b) { if(own_vbuf) delete vbuf; - vbuf=b; - own_vbuf=false; + vbuf = b; + own_vbuf = false; update_data(); } @@ -64,12 +64,12 @@ void VertexArray::clear() void VertexArray::reset(const VertexFormat &f) { clear(); - format=f; - stride=get_stride(format); + format = f; + stride = get_stride(format); - bool has_gen_attrs=false; + bool has_gen_attrs = false; for(const unsigned char *c=format.begin(); (!has_gen_attrs && c!=format.end()); ++c) - has_gen_attrs=(*c>=ATTRIB1); + has_gen_attrs = (*c>=ATTRIB1); if(has_gen_attrs) static RequireExtension _ext("GL_ARB_vertex_program"); } @@ -82,14 +82,14 @@ void VertexArray::apply() const if(vbuf) vbuf->bind(); - const float *base=vbuf?0:&data[0]; - uint offset=0; - uint found=0; - uint bpv=stride*sizeof(float); + const float *base = vbuf?0:&data[0]; + unsigned offset = 0; + unsigned found = 0; + unsigned bpv = stride*sizeof(float); for(const unsigned char *c=format.begin(); c!=format.end(); ++c) { - uint sz=(*c&3)+1; - uint t=*c>>2; + unsigned sz = (*c&3)+1; + unsigned t = *c>>2; switch(t) { case 0: @@ -111,8 +111,8 @@ void VertexArray::apply() const glVertexAttribPointerARB(t-4, sz, GL_FLOAT, false, bpv, base+offset); break; } - found|=1<>i)&1, 1<>i)&1, 1<unbind(); } /** @@ -134,7 +134,7 @@ void VertexArray::update_data() if(vbuf) { vbuf->data(data.size()*sizeof(float), &data[0]); - VertexBuffer::unbind(); + vbuf->unbind(); } } @@ -152,7 +152,7 @@ void VertexArray::set_array(unsigned array, bool en, unsigned mask) const glDisableClientState(array); else glDisableVertexAttribArrayARB(array); - enabled_arrays&=~mask; + enabled_arrays &= ~mask; } else if(!(enabled_arrays&mask) && en) { @@ -160,11 +160,11 @@ void VertexArray::set_array(unsigned array, bool en, unsigned mask) const glEnableClientState(array); else glEnableVertexAttribArrayARB(array); - enabled_arrays|=mask; + enabled_arrays |= mask; } } -unsigned VertexArray::enabled_arrays=0; +unsigned VertexArray::enabled_arrays = 0; VertexArray::Loader::Loader(VertexArray &a): @@ -192,17 +192,17 @@ void array_element(int i) glArrayElement(i); } -void draw_arrays(PrimitiveType mode, int first, sizei count) +void draw_arrays(PrimitiveType mode, int first, unsigned count) { glDrawArrays(mode, first, count); } -void draw_elements(PrimitiveType mode, sizei count, DataType type, const void *indices) +void draw_elements(PrimitiveType mode, unsigned count, DataType type, const void *indices) { glDrawElements(mode, count, type, indices); } -void draw_range_elements(PrimitiveType mode, uint low, uint high, sizei count, DataType type, const void *indices) +void draw_range_elements(PrimitiveType mode, unsigned low, unsigned high, unsigned count, DataType type, const void *indices) { static RequireVersion _ver(1, 2); glDrawRangeElements(mode, low, high, count, type, indices);