void crStateMakeCurrent( CRContext *ctx ) { CRContext *current = GetCurrentContext(); if (ctx == NULL) ctx = defaultContext; if (current == ctx) return; /* no-op */ CRASSERT(ctx); if (current) { /* Check to see if the differencer exists first, we may not have one, aka the packspu */ if (diff_api.AlphaFunc) crStateSwitchContext( current, ctx ); } #ifdef CHROMIUM_THREADSAFE crSetTSD(&__contextTSD, ctx); #else __currentContext = ctx; #endif /* ensure matrix state is also current */ crStateMatrixMode(ctx->transform.matrixMode); }
void crStateDestroyContext( CRContext *ctx ) { CRContext *current = GetCurrentContext(); if (current == ctx) { /* destroying the current context - have to be careful here */ CRASSERT(defaultContext); /* Check to see if the differencer exists first, we may not have one, aka the packspu */ if (diff_api.AlphaFunc) crStateSwitchContext(current, defaultContext); #ifdef CHROMIUM_THREADSAFE SetCurrentContext(defaultContext); #else __currentContext = defaultContext; #endif /* ensure matrix state is also current */ crStateMatrixMode(defaultContext->transform.matrixMode); } g_availableContexts[ctx->id] = 0; #ifdef CHROMIUM_THREADSAFE VBoxTlsRefRelease(ctx); #else crStateFreeContext(ctx); #endif }