X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fvertexsetup.cpp;h=81d2261e6aa78b55b3240e231ea72b25232bea60;hp=8498e043dde57d48c758e4a83957caf2f77e384b;hb=e92de029768eef5f0fd744329e589161b46d0762;hpb=9904aa3d09458098541fdce0114785d6bce1777f diff --git a/source/core/vertexsetup.cpp b/source/core/vertexsetup.cpp index 8498e043..81d2261e 100644 --- a/source/core/vertexsetup.cpp +++ b/source/core/vertexsetup.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "buffer.h" #include "deviceinfo.h" @@ -45,6 +46,8 @@ void VertexSetup::set_format(const VertexFormat &vfmt) if(!vertex_format.empty()) throw invalid_operation("VertexSetup::set_format"); + require_format(vfmt); + vertex_format = vfmt; } @@ -55,6 +58,9 @@ void VertexSetup::set_format_instanced(const VertexFormat &vfmt, const VertexFor if(!vertex_format.empty()) throw invalid_operation("VertexSetup::set_format"); + require_format(vfmt); + require_format(ifmt); + vertex_format = vfmt; inst_format = ifmt; } @@ -108,6 +114,16 @@ bool VertexSetup::verify_format(const VertexFormat &fmt) return true; } +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); + + if(has_int) + static Require _req(EXT_gpu_shader4); +} + void VertexSetup::update() const { static bool direct = ARB_direct_state_access && ARB_vertex_attrib_binding; @@ -146,17 +162,24 @@ void VertexSetup::update_vertex_array(const VertexArray &array, unsigned binding for(const UInt16 *a=fmt.begin(); a!=fmt.end(); ++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) { - glVertexArrayAttribFormat(id, sem, cc, type, true, offset); + if(integer) + glVertexArrayAttribIFormat(id, sem, cc, type, offset); + else + glVertexArrayAttribFormat(id, sem, cc, type, true, offset); glVertexArrayAttribBinding(id, sem, binding); glEnableVertexArrayAttrib(id, sem); } else { - glVertexAttribPointer(sem, cc, type, true, stride, reinterpret_cast(offset)); + if(integer) + glVertexAttribIPointer(sem, cc, type, stride, reinterpret_cast(offset)); + else + glVertexAttribPointer(sem, cc, type, true, stride, reinterpret_cast(offset)); if(ARB_instanced_arrays) glVertexAttribDivisor(sem, divisor); glEnableVertexAttribArray(sem);