Last active
December 11, 2015 14:58
-
-
Save lawrencelomax/4617449 to your computer and use it in GitHub Desktop.
Variadic Macros for Pushing and Popping GL State
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern void bilContext_glClientState(dispatch_block_t contextBlock, GLenum clientState, ... ) | |
{ | |
va_list arguments; | |
GLenum value; | |
va_start(arguments, clientState); | |
for (value = clientState; value > 0; value = va_arg(arguments, GLenum)) | |
{ | |
glEnableClientState(value); | |
} | |
va_end(arguments); | |
contextBlock(); | |
va_start(arguments, clientState); | |
for (value = clientState; value > 0; value = va_arg(arguments, GLenum)) | |
{ | |
glDisableClientState(value); | |
} | |
va_end(arguments); | |
} | |
extern void bilContext_glEnable(dispatch_block_t contextBlock, GLenum feature, ... ) | |
{ | |
va_list arguments; | |
GLenum value; | |
va_start(arguments, feature); | |
for (value = feature; value > 0; value = va_arg(arguments, GLenum)) | |
{ | |
glEnable(value); | |
} | |
va_end(arguments); | |
contextBlock(); | |
va_start(arguments, feature); | |
for (value = feature; value > 0; value = va_arg(arguments, GLenum)) | |
{ | |
glDisable(value); | |
} | |
va_end(arguments); | |
} | |
extern void bilContext_glMatrix4(dispatch_block_t contextBlock, GLKMatrix4 matrix) | |
{ | |
glPushMatrix(); | |
glMultMatrixf(matrix.m); | |
contextBlock(); | |
glPopMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This
Goes to this