diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/varray.c | 8 | ||||
-rw-r--r-- | src/mesa/main/varray.h | 16 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 66a3ef119af..81f71f8265e 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -784,13 +784,7 @@ static const GLfloat * get_current_attrib(struct gl_context *ctx, GLuint index, const char *function) { if (index == 0) { - /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES - * 2.0. Note that we cannot just check for API_OPENGL_CORE here because - * that will erroneously allow this usage in a 3.0 forward-compatible - * context too. - */ - if ((ctx->API != API_OPENGL_CORE || ctx->Version < 31) - && ctx->API != API_OPENGLES2) { + if (_mesa_attr_zero_aliases_vertex(ctx)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(index==0)", function); return NULL; } diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index bc820ed2357..d10f78e64a3 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -106,6 +106,22 @@ _mesa_update_client_array(struct gl_context *ctx, _mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj); } +static inline bool +_mesa_attr_zero_aliases_vertex(struct gl_context *ctx) +{ + const bool is_forward_compatible_context = + ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; + + /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES + * 2.0. Note that we cannot just check for API_OPENGL_COMPAT here because + * that will erroneously allow this usage in a 3.0 forward-compatible + * context too. + */ + return (ctx->API == API_OPENGLES + || (ctx->API == API_OPENGL_COMPAT + && !is_forward_compatible_context)); +} + extern void GLAPIENTRY _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); |