65 #define ITEM_STATEFLAG(NAME) StateFlag NAME
66 #define ITEM_CLIENTSTATEFLAG(NAME) bool NAME
67 #define ITEM_SPECIAL(NAME, TYPE, _) TYPE NAME
68 #define ITEM_INT(NAME) GLint NAME
70 #include "OOOpenGLStates.tbl"
77 #undef ITEM_CLIENTSTATEFLAG
108 OOGL(glGetBooleanv(GL_DEPTH_WRITEMASK, &value));
113#define SetState_DEPTH_WRITEMASK(VALUE) OOGL(glDepthMask(VALUE))
115#define SetState_SHADE_MODEL(VALUE) OOGL(glShadeModel(VALUE))
123 OOGL(glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &value));
128#define SetState_TEXTURE_ENV_MODE(VALUE) OOGL(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, VALUE))
137 OOGL(glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &value));
142#define SetState_ACTIVE_TEXTURE(VALUE) OOGL(glActiveTextureARB(VALUE))
150 OOGL(glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE_ARB, &value));
155#define SetState_CLIENT_ACTIVE_TEXTURE(VALUE) OOGL(glClientActiveTextureARB(VALUE))
168 OOGL(glCullFace(value));
171#define SetState_FRONT_FACE(VALUE) OOGL(glFrontFace(VALUE))
174#if OO_GL_STATE_VERIFICATION
214static const char *sLatestFunction =
"<none yet>";
215static unsigned sLatestLine;
216static const char *sPreviousFunction =
"<none yet>";
217static unsigned sPreviousLine;
218static bool sGLFunctionTracking =
true;
222 if (sGLFunctionTracking)
224 if (
function != sLatestFunction)
226 sPreviousFunction = sLatestFunction;
227 sPreviousLine = sLatestLine;
228 sLatestFunction =
function;
242 sGLFunctionTracking = value;
285 static const char *name =
"<current state>";
287 NSCParameterAssert(state != NULL);
289 memset(state, 0,
sizeof *state);
292 #define ITEM_STATEFLAG(NAME) OOGL(state->NAME = glIsEnabled(GL_##NAME))
293 #define ITEM_CLIENTSTATEFLAG(NAME) OOGL(state->NAME = glIsEnabled(GL_##NAME))
294 #define ITEM_SPECIAL(NAME, _, __) state->NAME = GetState_##NAME()
295 #define ITEM_INT(NAME) OOGL(glGetIntegerv(GL_##NAME, &state->NAME))
297 #include "OOOpenGLStates.tbl"
302 #undef ITEM_STATEFLAG
303 #undef ITEM_CLIENTSTATEFLAG
311 NSCParameterAssert(a != NULL && b != NULL);
313 #define ITEM_STATEFLAG(NAME) do { if (a->NAME != b->NAME && a->NAME != kStateMaybe && b->NAME != kStateMaybe) return false; } while (0)
314 #define ITEM_CLIENTSTATEFLAG(NAME) do { if (a->NAME != b->NAME) return false; } while (0)
315 #define ITEM_SPECIAL(NAME, _, __) do { if (a->NAME != b->NAME) return false; } while (0)
316 #define ITEM_INT(NAME) do { if (a->NAME != b->NAME) return false; } while (0)
318 #include "OOOpenGLStates.tbl"
320 #undef ITEM_STATEFLAG
321 #undef ITEM_CLIENTSTATEFLAG
350 #define TEST_ITEM(NAME_, DISP_) \
351 if (currentState.NAME_ != expectedState->NAME_) \
353 OOLog(kOOLogOpenGLVerifyDump, @"GL_%@ should be %@ but is %@.", @#NAME_, DISP_(expectedState->NAME_), DISP_(currentState.NAME_)); \
356 #define ITEM_STATEFLAG(NAME) if (expectedState->NAME != kStateMaybe) { TEST_ITEM(NAME, OOGLFlagToString) }
357 #define ITEM_CLIENTSTATEFLAG(NAME) TEST_ITEM(NAME, OOGLFlagToString)
358 #define ITEM_SPECIAL(NAME, _, __) TEST_ITEM(NAME, OOGLFlagToString)
359 #define ITEM_INT(NAME) TEST_ITEM(NAME, OOGLEnumToString)
361 #include "OOOpenGLStates.tbl"
368 #undef ITEM_STATEFLAG
369 #undef ITEM_CLIENTSTATEFLAG
406 NSCParameterAssert(sourceState != NULL && targetState != NULL);
409 #define ITEM_STATEFLAG(NAME) \
410 if (sourceState->NAME != targetState->NAME && sourceState->NAME != kStateMaybe && targetState->NAME != kStateMaybe) \
412 if (targetState->NAME) \
414 OOGL(glEnable(GL_##NAME)); \
418 OOGL(glDisable(GL_##NAME)); \
421 #define ITEM_CLIENTSTATEFLAG(NAME) \
422 if (sourceState->NAME != targetState->NAME) \
424 if (targetState->NAME) \
426 OOGL(glEnableClientState(GL_##NAME)); \
430 OOGL(glDisableClientState(GL_##NAME)); \
433 #define ITEM_SPECIAL(NAME, TYPE, _) \
434 if (sourceState->NAME != targetState->NAME) \
436 SetState_##NAME(targetState->NAME); \
438 #define ITEM_INT(NAME) \
439 if (sourceState->NAME != targetState->NAME) \
441 SetState_##NAME(targetState->NAME); \
444 #include "OOOpenGLStates.tbl"
455 #undef ITEM_STATEFLAG
456 #undef ITEM_CLIENTSTATEFLAG
472 [OPENGL_STATE_INTERNAL_USE_ONLY] =
474 .name =
"<canonical initial state>",
485 .COLOR_MATERIAL =
false,
486 .SHADE_MODEL = GL_SMOOTH,
487 .TEXTURE_ENV_MODE = GL_MODULATE,
488 .ACTIVE_TEXTURE = GL_TEXTURE0,
489 .CLIENT_ACTIVE_TEXTURE = GL_TEXTURE0,
492 .BLEND_DST = GL_ZERO,
494 .VERTEX_ARRAY =
false,
495 .NORMAL_ARRAY =
false,
496 .COLOR_ARRAY =
false,
497 .INDEX_ARRAY =
false,
498 .TEXTURE_COORD_ARRAY =
false,
499 .EDGE_FLAG_ARRAY =
false,
501 .RESCALE_NORMAL =
false,
503 .DEPTH_WRITEMASK =
true,
505 .CULL_FACE_MODE = GL_BACK,
506 .FRONT_FACE = GL_CCW,
508 [OPENGL_STATE_OPAQUE] =
510 .name =
"OPENGL_STATE_OPAQUE",
524 .COLOR_MATERIAL =
false,
525 .SHADE_MODEL = GL_SMOOTH,
526 .TEXTURE_ENV_MODE = GL_MODULATE,
527 .ACTIVE_TEXTURE = GL_TEXTURE0,
528 .CLIENT_ACTIVE_TEXTURE = GL_TEXTURE0,
530 .BLEND_SRC = GL_SRC_ALPHA,
531 .BLEND_DST = GL_ONE_MINUS_SRC_ALPHA,
533 .VERTEX_ARRAY =
true,
534 .NORMAL_ARRAY =
true,
535 .COLOR_ARRAY =
false,
536 .INDEX_ARRAY =
false,
537 .TEXTURE_COORD_ARRAY =
false,
538 .EDGE_FLAG_ARRAY =
false,
540 .RESCALE_NORMAL =
false,
542 .DEPTH_WRITEMASK =
true,
544 .CULL_FACE_MODE = GL_BACK,
545 .FRONT_FACE = GL_CCW,
547 [OPENGL_STATE_TRANSLUCENT_PASS] =
549 .name =
"OPENGL_STATE_TRANSLUCENT_PASS",
560 .COLOR_MATERIAL =
false,
561 .SHADE_MODEL = GL_SMOOTH,
562 .TEXTURE_ENV_MODE = GL_MODULATE,
563 .ACTIVE_TEXTURE = GL_TEXTURE0,
564 .CLIENT_ACTIVE_TEXTURE = GL_TEXTURE0,
566 .BLEND_SRC = GL_SRC_ALPHA,
567 .BLEND_DST = GL_ONE_MINUS_SRC_ALPHA,
569 .VERTEX_ARRAY =
false,
570 .NORMAL_ARRAY =
false,
571 .COLOR_ARRAY =
false,
572 .INDEX_ARRAY =
false,
573 .TEXTURE_COORD_ARRAY =
false,
574 .EDGE_FLAG_ARRAY =
false,
576 .RESCALE_NORMAL =
false,
578 .DEPTH_WRITEMASK =
false,
580 .CULL_FACE_MODE = GL_BACK,
581 .FRONT_FACE = GL_CCW,
583 [OPENGL_STATE_ADDITIVE_BLENDING] =
585 .name =
"OPENGL_STATE_ADDITIVE_BLENDING",
596 .COLOR_MATERIAL =
false,
597 .SHADE_MODEL = GL_SMOOTH,
598 .TEXTURE_ENV_MODE = GL_MODULATE,
599 .ACTIVE_TEXTURE = GL_TEXTURE0,
600 .CLIENT_ACTIVE_TEXTURE = GL_TEXTURE0,
602 .BLEND_SRC = GL_SRC_ALPHA,
605 .VERTEX_ARRAY =
true,
606 .NORMAL_ARRAY =
false,
607 .COLOR_ARRAY =
false,
608 .INDEX_ARRAY =
false,
609 .TEXTURE_COORD_ARRAY =
false,
610 .EDGE_FLAG_ARRAY =
false,
612 .RESCALE_NORMAL =
false,
614 .DEPTH_WRITEMASK =
false,
616 .CULL_FACE_MODE = GL_BACK,
617 .FRONT_FACE = GL_CCW,
619 [OPENGL_STATE_OVERLAY] =
621 .name =
"OPENGL_STATE_OVERLAY",
632 .COLOR_MATERIAL =
false,
633 .SHADE_MODEL = GL_SMOOTH,
634 .TEXTURE_ENV_MODE = GL_MODULATE,
635 .ACTIVE_TEXTURE = GL_TEXTURE0,
636 .CLIENT_ACTIVE_TEXTURE = GL_TEXTURE0,
638 .BLEND_SRC = GL_SRC_ALPHA,
639 .BLEND_DST = GL_ONE_MINUS_SRC_ALPHA,
641 .VERTEX_ARRAY =
false,
642 .NORMAL_ARRAY =
false,
643 .COLOR_ARRAY =
false,
644 .INDEX_ARRAY =
false,
645 .TEXTURE_COORD_ARRAY =
false,
646 .EDGE_FLAG_ARRAY =
false,
648 .RESCALE_NORMAL =
false,
650 .DEPTH_WRITEMASK =
false,
652 .CULL_FACE_MODE = GL_BACK,
653 .FRONT_FACE = GL_CCW,
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
#define OOLog(class, format,...)
#define OO_ENTER_OPENGL()
static const OOOpenGLState kStandardStates[OPENGL_STATE_INTERNAL_USE_ONLY+1]
static bool GetState_DEPTH_WRITEMASK(void)
static void SetState_CLIENT_ACTIVE_TEXTURE(GLenum value)
static NSString *const kOOLogOpenGLVerifyDump
static GLenum GetState_CLIENT_ACTIVE_TEXTURE(void)
static void SetFunctionTracking(bool value)
void OOResetGLStateVerifier(void)
static void GetCurrentOpenGLState(OOOpenGLState *state) NONNULL_FUNC
static void VerifyOpenGLStateInternal(const char *caller, const char *nominalCaller, unsigned line) NONNULL_FUNC
static GLenum GetState_ACTIVE_TEXTURE(void)
static GLenum GetState_TEXTURE_ENV_MODE(void)
static void SetState_ACTIVE_TEXTURE(GLenum value)
static OOOpenGLStateID sCurrentStateID
static bool StatesEqual(const OOOpenGLState *a, const OOOpenGLState *b) NONNULL_FUNC
static void SetState_CULL_FACE_MODE(GLint value)
static void SwitchOpenGLStateInternal(const OOOpenGLState *sourceState, const OOOpenGLState *targetState) NONNULL_FUNC
void OOVerifyOpenGLState_(const char *function, unsigned line)
void OOSetOpenGLState_(OOOpenGLStateID state, const char *function, unsigned line)
static void OOGLNoteCurrentFunction(const char *function, unsigned line)
NSString * OOGLEnumToString(GLenum value)
@ OPENGL_STATE_INTERNAL_USE_ONLY
#define OOSetOpenGLState(STATE)