| Summary: | Render calls do not encapsulate glEnable/DisableVertexAttribArray properly | ||
|---|---|---|---|
| Product: | SDL | Reporter: | noone <annoyingbugzilla> |
| Component: | render | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED WONTFIX | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | ||
| Version: | 2.0.1 | ||
| Hardware: | All | ||
| OS: | All | ||
SDL assumes that when you're using the render API that you're not doing other 3D calls, as an optimization. If you do need to do other 3D calls you should set and restore your state appropriately. That said, I'm not opposed to a patch that implements encapsulation the way you describe as long as it doesn't negatively impact performance. We won't fix this in SDL for performance reasons. Code that interoperates with SDL rendering should do it's own state push/pop to make sure everything is correct and consistent. |
Example from current 2.0.1 source code version SDL_render_gles2.c: static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) { GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLfloat vertices[8]; int idx; if (GLES2_SetDrawingState(renderer) < 0) { return -1; } /* Emit a line loop for each rectangle */ for (idx = 0; idx < count; ++idx) { const SDL_FRect *rect = &rects[idx]; GLfloat xMin = rect->x; GLfloat xMax = (rect->x + rect->w); GLfloat yMin = rect->y; GLfloat yMax = (rect->y + rect->h); vertices[0] = xMin; vertices[1] = yMin; vertices[2] = xMax; vertices[3] = yMin; vertices[4] = xMin; vertices[5] = yMax; vertices[6] = xMax; vertices[7] = yMax; data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } return GL_CheckError("", renderer); } ------- If I do call glDisableVertexAttribArray(0) before this code is run, glVertexAttribPointer will fail. All OpenGL vertex attrib calls should properly encapsulated in glEnable/glDisable before using attrib data. Does not fail on all system as some drivers behave different on disabling attrib 0, but encapsulation will solve this issue always.