Skip to content
Permalink
Browse files

Port 6e9a7e7 to the OS X overlay.

  • Loading branch information...
mkrautz committed Feb 5, 2015
1 parent 8e3168b commit f4568b9e46bb7c68dff36a2818a1e1798f2d5d1d
Showing with 23 additions and 1 deletion.
  1. +23 −1 macx/overlay/overlay.m
@@ -81,7 +81,9 @@
unsigned int uiMappedLength;
clock_t timeT;
unsigned int frameCount;


GLint maxVertexAttribs;
GLboolean* vertexAttribStates;
} Context;

static const char vshader[] = ""
@@ -164,6 +166,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) {
@@ -542,6 +547,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);
@@ -575,6 +590,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();

0 comments on commit f4568b9

Please sign in to comment.
You can’t perform that action at this time.