diff options
author | Marek Olšák <[email protected]> | 2012-10-30 14:44:22 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-11-06 01:13:48 +0100 |
commit | acf438f5375e2426386694e541b843dc6f8fd11a (patch) | |
tree | 6aaa04f8419661892a74168d144537905efac8a2 /src/mesa/vbo/vbo_context.h | |
parent | a196f43596f6cb85a8f3e446596a2fb8e0ee7872 (diff) |
vbo: fix glVertexAttribI* functions
The functions were broken, because they converted ints to floats.
Now we can finally advertise OpenGL 3.0. ;)
In this commit, the vbo module also tracks the type for each attrib
in addition to the size. It can be one of FLOAT, INT, UNSIGNED_INT.
The little ugliness is the vertex attribs are declared as floats even though
there may be integer values. The code just copies integer values into them
without any conversion.
This implementation passes the glVertexAttribI piglit test which I am going
to commit in piglit soon. The test covers vertex arrays, immediate mode and
display lists.
NOTE: This is a candidate for the stable branches.
Reviewed-by: Brian Paul <[email protected]>
v2: cosmetic changes as suggested by Brian
Diffstat (limited to 'src/mesa/vbo/vbo_context.h')
-rw-r--r-- | src/mesa/vbo/vbo_context.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h index c896f1196f7..1ff6ec0004e 100644 --- a/src/mesa/vbo/vbo_context.h +++ b/src/mesa/vbo/vbo_context.h @@ -147,4 +147,47 @@ vbo_draw_method(struct vbo_context *vbo, enum draw_method method) } } +/** + * Return if format is integer. The immediate mode commands only emit floats + * for non-integer types, thus everything else is integer. + */ +static inline GLboolean +vbo_attrtype_to_integer_flag(GLenum format) +{ + switch (format) { + case GL_FLOAT: + return GL_FALSE; + case GL_INT: + case GL_UNSIGNED_INT: + return GL_TRUE; + default: + ASSERT(0); + return GL_FALSE; + } +} + + +/** + * Return default component values for the given format. + * The return type is an array of floats, because that's how we declare + * the vertex storage despite the fact we sometimes store integers in there. + */ +static inline const GLfloat * +vbo_get_default_vals_as_float(GLenum format) +{ + static const GLfloat default_float[4] = { 0, 0, 0, 1 }; + static const GLint default_int[4] = { 0, 0, 0, 1 }; + + switch (format) { + case GL_FLOAT: + return default_float; + case GL_INT: + case GL_UNSIGNED_INT: + return (const GLfloat*)default_int; + default: + ASSERT(0); + return NULL; + } +} + #endif |