Skip to content

Commit

Permalink
Only return the captured color after we have checked for OpenGL errors
Browse files Browse the repository at this point in the history
  • Loading branch information
codeincontext committed Jul 1, 2011
1 parent be2553d commit feda5d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions MacLight/OpenGLScreenReader.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ - (NSColor *)readPartialScreenToBuffer: (size_t) width bufferHeight:(size_t) hei
int32_t avRed = (sumRed / sampleCount) & 0x000000ff;
int32_t avGreen = (sumGreen / sampleCount) & 0x000000ff;
int32_t avBlue = (sumBlue / sampleCount) & 0x000000ff;

return [NSColor colorWithDeviceRed: avRed/255.0 green: avGreen/255.0 blue: avBlue/255.0 alpha: 1.0];

glPopClientAttrib();

//Check for OpenGL errors
GLenum theError = GL_NO_ERROR;
theError = glGetError();
NSAssert( theError == GL_NO_ERROR, @"OpenGL error 0x%04X", theError);

return [NSColor colorWithDeviceRed: avRed/255.0 green: avGreen/255.0 blue: avBlue/255.0 alpha: 1.0];
}


Expand Down

0 comments on commit feda5d7

Please sign in to comment.