mirror of
https://github.com/mumble-voip/mumble.git
synced 2025-10-26 11:19:16 +00:00
Disable vertex attrib arrays in overlay_gl (fixes #1298)
This is a fix for the OpenGL overlay which disables and enables the vertex attrib arrays inside drawContext. The problem it fixes is that some games leave some of the arrays enabled between frames, which I think (not an OpenGL expert) causes the input to the vertex shader to essentially be arbitrary.
This commit is contained in:
parent
1749ef46df
commit
6e9a7e7cb1
@ -93,6 +93,9 @@ typedef struct _Context {
|
||||
|
||||
clock_t timeT;
|
||||
unsigned int frameCount;
|
||||
|
||||
GLint maxVertexAttribs;
|
||||
GLboolean* vertexAttribStates;
|
||||
} Context;
|
||||
|
||||
static const char vshader[] = ""
|
||||
@ -193,6 +196,9 @@ static void newContext(Context * ctx) {
|
||||
glAttachShader(ctx->uiProgram, vs);
|
||||
glAttachShader(ctx->uiProgram, fs);
|
||||
glLinkProgram(ctx->uiProgram);
|
||||
|
||||
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &ctx->maxVertexAttribs);
|
||||
ctx->vertexAttribStates = (GLboolean*)calloc(ctx->maxVertexAttribs, sizeof(GLboolean));
|
||||
}
|
||||
|
||||
static void releaseMem(Context *ctx) {
|
||||
@ -556,6 +562,16 @@ static void drawContext(Context * ctx, int width, int height) {
|
||||
glDisable(GL_VERTEX_PROGRAM_ARB);
|
||||
glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
GLint enabled;
|
||||
for (i=0;i<ctx->maxVertexAttribs;++i) {
|
||||
enabled = GL_FALSE;
|
||||
glGetVertexAttribiv((GLuint)i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled);
|
||||
if (enabled == GL_TRUE) {
|
||||
glDisableVertexAttribArray((GLuint)i);
|
||||
ctx->vertexAttribStates[i] = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
glUseProgram(ctx->uiProgram);
|
||||
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
@ -589,6 +605,13 @@ static void drawContext(Context * ctx, int width, int height) {
|
||||
if (vbobound != 0)
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbobound);
|
||||
|
||||
for (i=0;i<ctx->maxVertexAttribs;++i) {
|
||||
if (ctx->vertexAttribStates[i] == GL_TRUE) {
|
||||
glEnableVertexAttribArray((GLuint)i);
|
||||
ctx->vertexAttribStates[i] = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user