X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fvertexsetup.cpp;h=0971aed1c62f08c8c2823e873bcf86ce5ba15ba4;hb=a4d83d3748cdde8cf30683d36a040d3dfacfd693;hp=81d2261e6aa78b55b3240e231ea72b25232bea60;hpb=e92de029768eef5f0fd744329e589161b46d0762;p=libs%2Fgl.git diff --git a/source/core/vertexsetup.cpp b/source/core/vertexsetup.cpp index 81d2261e..0971aed1 100644 --- a/source/core/vertexsetup.cpp +++ b/source/core/vertexsetup.cpp @@ -107,8 +107,8 @@ bool VertexSetup::verify_format(const VertexFormat &fmt) unsigned max_attribs = Limits::get_global().max_vertex_attributes; - for(const UInt16 *a=fmt.begin(); a!=fmt.end(); ++a) - if(get_attribute_semantic(*a)>=max_attribs) + for(VertexAttribute a: fmt) + if(get_attribute_semantic(a)>=max_attribs) return false; return true; @@ -117,8 +117,8 @@ bool VertexSetup::verify_format(const VertexFormat &fmt) void VertexSetup::require_format(const VertexFormat &fmt) { bool has_int = false; - for(const UInt16 *a=fmt.begin(); a!=fmt.end(); ++a) - has_int = has_int | is_integer_attribute(*a); + for(VertexAttribute a: fmt) + has_int = has_int | is_integer_attribute(a); if(has_int) static Require _req(EXT_gpu_shader4); @@ -148,7 +148,10 @@ void VertexSetup::update() const void VertexSetup::update_vertex_array(const VertexArray &array, unsigned binding, unsigned divisor, bool direct) const { if(!direct) + { + Buffer::unbind_scratch(); glBindBuffer(GL_ARRAY_BUFFER, array.get_buffer()->get_id()); + } const VertexFormat &fmt = array.get_format(); unsigned stride = fmt.stride(); @@ -159,12 +162,12 @@ void VertexSetup::update_vertex_array(const VertexArray &array, unsigned binding } unsigned offset = 0; - for(const UInt16 *a=fmt.begin(); a!=fmt.end(); ++a) + for(VertexAttribute a: fmt) { - unsigned sem = get_attribute_semantic(*a); - bool integer = is_integer_attribute(*a); - GLenum type = get_gl_type(get_attribute_source_type(*a)); - unsigned cc = get_attribute_component_count(*a); + unsigned sem = get_attribute_semantic(a); + bool integer = is_integer_attribute(a); + GLenum type = get_gl_type(get_attribute_source_type(a)); + unsigned cc = get_attribute_component_count(a); if(direct) { if(integer) @@ -184,7 +187,7 @@ void VertexSetup::update_vertex_array(const VertexArray &array, unsigned binding glVertexAttribDivisor(sem, divisor); glEnableVertexAttribArray(sem); } - offset += get_attribute_size(*a); + offset += get_attribute_size(a); } if(!direct) @@ -204,15 +207,15 @@ void VertexSetup::unload() glBindVertexArray(id); glBindBuffer(GL_ARRAY_BUFFER, 0); - for(const UInt16 *a=vertex_format.begin(); a!=vertex_format.end(); ++a) + for(VertexAttribute a: vertex_format) { - unsigned sem = get_attribute_semantic(*a); + unsigned sem = get_attribute_semantic(a); glDisableVertexAttribArray(sem); glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, 0); } - for(const UInt16 *a=inst_format.begin(); a!=inst_format.end(); ++a) + for(VertexAttribute a: inst_format) { - unsigned sem = get_attribute_semantic(*a); + unsigned sem = get_attribute_semantic(a); glDisableVertexAttribArray(sem); glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, 0); }