/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include <stdio.h>
#include "state.h"
#include "state/cr_statetypes.h"
#include "state_internals.h"
#include "cr_error.h"
#include "cr_mem.h"
/**
* \mainpage state_tracker
*
* \section StateTrackerIntroduction Introduction
*
* Chromium consists of all the top-level files in the cr
* directory. The state_tracker module basically takes care of API dispatch,
* and OpenGL state management.
*
*
*/
{
int i;
a->attribStackDepth = 0;
a->accumBufferStackDepth = 0;
a->colorBufferStackDepth = 0;
a->currentStackDepth = 0;
a->depthBufferStackDepth = 0;
a->enableStackDepth = 0;
for ( i = 0 ; i < CR_MAX_ATTRIB_STACK_DEPTH ; i++)
{
}
a->evalStackDepth = 0;
a->fogStackDepth = 0;
a->lightingStackDepth = 0;
a->lineStackDepth = 0;
a->listStackDepth = 0;
a->pixelModeStackDepth = 0;
a->pointStackDepth = 0;
a->polygonStackDepth = 0;
a->polygonStippleStackDepth = 0;
a->scissorStackDepth = 0;
a->stencilBufferStackDepth = 0;
a->textureStackDepth = 0;
a->transformStackDepth = 0;
a->viewportStackDepth = 0;
}
/*@todo check if NV rect needed too*/
static void
{
}
static void
{
if (copyName)
{
}
#ifdef CR_OPENGL_VERSION_1_2
#endif
#endif
}
{
CRContext *g = GetCurrentContext();
CRAttribState *a = &(g->attrib);
unsigned int i;
if (g->current.inBeginEnd)
{
return;
}
{
return;
}
FLUSH();
if (mask & GL_ACCUM_BUFFER_BIT)
{
a->accumBufferStackDepth++;
}
if (mask & GL_COLOR_BUFFER_BIT)
{
#if defined(CR_EXT_blend_func_separate)
#endif
#ifdef CR_EXT_blend_color
#endif
#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op)
#endif
a->colorBufferStackDepth++;
}
if (mask & GL_CURRENT_BIT)
{
for (i = 0 ; i < CR_MAX_VERTEX_ATTRIBS ; i++)
{
}
a->currentStackDepth++;
}
if (mask & GL_DEPTH_BUFFER_BIT)
{
a->depthBufferStackDepth++;
}
if (mask & GL_ENABLE_BIT)
{
{
a->enableStack[a->enableStackDepth].clip = (GLboolean *) crCalloc( g->limits.maxClipPlanes * sizeof( GLboolean ));
}
{
a->enableStack[a->enableStackDepth].light = (GLboolean *) crCalloc( g->limits.maxLights * sizeof( GLboolean ));
}
for (i = 0 ; i < g->limits.maxClipPlanes ; i++)
{
}
{
}
for (i = 0 ; i < GLEVAL_TOT ; i++)
{
}
for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++)
#endif
#ifdef CR_OPENGL_VERSION_1_2
#endif
for (i = 0 ; i < g->limits.maxTextureUnits; i++)
{
#ifdef CR_OPENGL_VERSION_1_2
#endif
#ifdef CR_ARB_texture_cube_map
#endif
#ifdef CR_NV_texture_rectangle
#endif
}
a->enableStackDepth++;
}
if (mask & GL_EVAL_BIT)
{
for (i = 0 ; i < GLEVAL_TOT ; i++)
{
sizeof (GLfloat);
gleval_sizes[i] * sizeof (GLfloat);
}
a->evalStackDepth++;
}
if (mask & GL_FOG_BIT)
{
a->fogStackDepth++;
}
if (mask & GL_HINT_BIT)
{
#ifdef CR_EXT_clip_volume_hint
#endif
#ifdef CR_ARB_texture_compression
#endif
#ifdef CR_SGIS_generate_mipmap
#endif
a->hintStackDepth++;
}
if (mask & GL_LIGHTING_BIT)
{
{
a->lightingStack[a->lightingStackDepth].light = (CRLight *) crCalloc( g->limits.maxLights * sizeof( CRLight ));
}
#if defined(CR_EXT_separate_specular_color) || defined(CR_OPENGL_VERSION_1_2)
a->lightingStack[a->lightingStackDepth].lightModelColorControlEXT = g->lighting.lightModelColorControlEXT;
#endif
{
a->lightingStack[a->lightingStackDepth].light[i].spotDirection = g->lighting.light[i].spotDirection;
a->lightingStack[a->lightingStackDepth].light[i].constantAttenuation = g->lighting.light[i].constantAttenuation;
a->lightingStack[a->lightingStackDepth].light[i].linearAttenuation = g->lighting.light[i].linearAttenuation;
a->lightingStack[a->lightingStackDepth].light[i].quadraticAttenuation = g->lighting.light[i].quadraticAttenuation;
}
for (i = 0 ; i < 2 ; i++)
{
}
a->lightingStackDepth++;
}
if (mask & GL_LINE_BIT)
{
a->lineStackDepth++;
}
if (mask & GL_LIST_BIT)
{
a->listStackDepth++;
}
if (mask & GL_PIXEL_MODE_BIT)
{
a->pixelModeStackDepth++;
}
if (mask & GL_POINT_BIT)
{
for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++)
#endif
a->pointStackDepth++;
}
if (mask & GL_POLYGON_BIT)
{
a->polygonStackDepth++;
}
if (mask & GL_POLYGON_STIPPLE_BIT)
{
crMemcpy( a->polygonStippleStack[a->polygonStippleStackDepth].pattern, g->polygon.stipple, 32*sizeof(GLint) );
a->polygonStippleStackDepth++;
}
if (mask & GL_SCISSOR_BIT)
{
a->scissorStackDepth++;
}
if (mask & GL_STENCIL_BUFFER_BIT)
{
for (i = 0; i < CRSTATE_STENCIL_BUFFER_COUNT; ++i)
{
a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].passDepthFail = g->stencil.buffers[i].passDepthFail;
a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].passDepthPass = g->stencil.buffers[i].passDepthPass;
}
a->stencilBufferStackDepth++;
}
if (mask & GL_TEXTURE_BIT)
{
for (i = 0 ; i < g->limits.maxTextureUnits ; i++)
{
/* per-unit state */
/* texture object state */
#ifdef CR_OPENGL_VERSION_1_2
#endif
#ifdef CR_ARB_texture_cube_map
#endif
#ifdef CR_NV_texture_rectangle
#endif
}
a->textureStackDepth++;
}
if (mask & GL_TRANSFORM_BIT)
{
{
a->transformStack[a->transformStackDepth].clip = (GLboolean *) crCalloc( g->limits.maxClipPlanes * sizeof( GLboolean ));
}
{
a->transformStack[a->transformStackDepth].clipPlane = (GLvectord *) crCalloc( g->limits.maxClipPlanes * sizeof( GLvectord ));
}
for (i = 0 ; i < g->limits.maxClipPlanes ; i++)
{
}
#ifdef CR_OPENGL_VERSION_1_2
#endif
a->transformStackDepth++;
}
if (mask & GL_VIEWPORT_BIT)
{
a->viewportStackDepth++;
}
}
{
CRContext *g = GetCurrentContext();
CRAttribState *a = &(g->attrib);
unsigned int i;
if (g->current.inBeginEnd)
{
return;
}
if (a->attribStackDepth == 0)
{
return;
}
FLUSH();
if (mask & GL_ACCUM_BUFFER_BIT)
{
if (a->accumBufferStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty accum buffer stack!" );
return;
}
a->accumBufferStackDepth--;
}
if (mask & GL_COLOR_BUFFER_BIT)
{
if (a->colorBufferStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty color buffer stack!" );
return;
}
a->colorBufferStackDepth--;
#if defined(CR_EXT_blend_func_separate)
#endif
#ifdef CR_EXT_blend_color
#endif
#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op)
#endif
#ifdef CR_EXT_blend_color
#endif
#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op)
#endif
}
if (mask & GL_CURRENT_BIT)
{
if (a->currentStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty current stack!" );
return;
}
a->currentStackDepth--;
for (i = 0 ; i < CR_MAX_VERTEX_ATTRIBS ; i++)
{
}
}
if (mask & GL_DEPTH_BUFFER_BIT)
{
if (a->depthBufferStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty depth buffer stack!" );
return;
}
a->depthBufferStackDepth--;
}
if (mask & GL_ENABLE_BIT)
{
if (a->enableStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty enable stack!" );
return;
}
a->enableStackDepth--;
for (i = 0 ; i < g->limits.maxClipPlanes ; i++)
{
}
{
}
for (i = 0 ; i < GLEVAL_TOT ; i++)
{
}
#ifdef CR_ARB_point_sprite
for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++)
#endif
#ifdef CR_OPENGL_VERSION_1_2
#endif
for (i = 0 ; i < g->limits.maxTextureUnits; i++)
{
#ifdef CR_OPENGL_VERSION_1_2
#endif
#ifdef CR_ARB_texture_cube_map
#endif
#ifdef CR_NV_texture_rectangle
#endif
}
for (i = 0 ; i < g->limits.maxTextureUnits ; i++)
{
}
}
if (mask & GL_EVAL_BIT)
{
if (a->evalStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty eval stack!" );
return;
}
a->evalStackDepth--;
for (i = 0 ; i < GLEVAL_TOT ; i++)
{
int size2 = a->evalStack[a->evalStackDepth].eval2D[i].uorder * a->evalStack[a->evalStackDepth].eval2D[i].vorder * gleval_sizes[i] * sizeof (GLfloat);
}
for (i = 0; i < GLEVAL_TOT; i++) {
}
}
if (mask & GL_FOG_BIT)
{
if (a->fogStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty fog stack!" );
return;
}
a->fogStackDepth--;
}
if (mask & GL_HINT_BIT)
{
if (a->hintStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty hint stack!" );
return;
}
a->hintStackDepth--;
#ifdef CR_EXT_clip_volume_hint
#endif
#ifdef CR_ARB_texture_compression
#endif
#ifdef CR_SGIS_generate_mipmap
#endif
}
if (mask & GL_LIGHTING_BIT)
{
if (a->lightingStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty lighting stack!" );
return;
}
a->lightingStackDepth--;
#if defined(CR_EXT_separate_specular_color) || defined(CR_OPENGL_VERSION_1_2)
g->lighting.lightModelColorControlEXT = a->lightingStack[a->lightingStackDepth].lightModelColorControlEXT;
#endif
{
g->lighting.light[i].spotDirection = a->lightingStack[a->lightingStackDepth].light[i].spotDirection;
g->lighting.light[i].constantAttenuation = a->lightingStack[a->lightingStackDepth].light[i].constantAttenuation;
g->lighting.light[i].linearAttenuation = a->lightingStack[a->lightingStackDepth].light[i].linearAttenuation;
g->lighting.light[i].quadraticAttenuation = a->lightingStack[a->lightingStackDepth].light[i].quadraticAttenuation;
}
for (i = 0 ; i < 2 ; i++)
{
}
{
}
}
if (mask & GL_LINE_BIT)
{
if (a->lineStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty line stack!" );
return;
}
a->lineStackDepth--;
}
if (mask & GL_LIST_BIT)
{
if (a->listStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty list stack!" );
return;
}
a->listStackDepth--;
}
if (mask & GL_PIXEL_MODE_BIT)
{
if (a->pixelModeStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty pixel mode stack!" );
return;
}
a->pixelModeStackDepth--;
}
if (mask & GL_POINT_BIT)
{
if (a->pointStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty point stack!" );
return;
}
a->pointStackDepth--;
for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) {
}
#endif
}
if (mask & GL_POLYGON_BIT)
{
if (a->polygonStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty polygon stack!" );
return;
}
a->polygonStackDepth--;
}
if (mask & GL_POLYGON_STIPPLE_BIT)
{
if (a->polygonStippleStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty polygon stipple stack!" );
return;
}
a->polygonStippleStackDepth--;
crMemcpy( g->polygon.stipple, a->polygonStippleStack[a->polygonStippleStackDepth].pattern, 32*sizeof(GLint) );
}
if (mask & GL_SCISSOR_BIT)
{
if (a->scissorStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty scissor stack!" );
return;
}
a->scissorStackDepth--;
}
if (mask & GL_STENCIL_BUFFER_BIT)
{
if (a->stencilBufferStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty stencil stack!" );
return;
}
a->stencilBufferStackDepth--;
for (i = 0; i < CRSTATE_STENCIL_BUFFER_COUNT; ++i)
{
g->stencil.buffers[i].passDepthFail = a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].passDepthFail;
g->stencil.buffers[i].passDepthPass = a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].passDepthPass;
}
for (i = 0; i < CRSTATE_STENCIL_BUFFER_REF_COUNT; ++i)
{
}
}
if (mask & GL_TEXTURE_BIT)
{
if (a->textureStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty texture stack!" );
return;
}
a->textureStackDepth--;
for (i = 0 ; i < g->limits.maxTextureUnits ; i++)
{
/* first, restore the bindings! */
#ifdef CR_OPENGL_VERSION_1_2
#endif
#ifdef CR_ARB_texture_cube_map
g->texture.unit[i].currentTextureCubeMap = crStateTextureGet(GL_TEXTURE_CUBE_MAP_ARB, tState->unit[i].SavedCubeMap.id);
#endif
#ifdef CR_NV_texture_rectangle
g->texture.unit[i].currentTextureRect = crStateTextureGet(GL_TEXTURE_CUBE_MAP_ARB, tState->unit[i].SavedRect.id);
#endif
}
for (i = 0 ; i < g->limits.maxTextureUnits ; i++)
{
}
for (i = 0 ; i < g->limits.maxTextureUnits ; i++)
{
#ifdef CR_ARB_texture_cube_map
#endif
#ifdef CR_NV_texture_rectangle
#endif
#ifdef CR_ARB_texture_cube_map
#endif
#ifdef CR_NV_texture_rectangle
#endif
}
}
if (mask & GL_TRANSFORM_BIT)
{
if (a->transformStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty transform stack!" );
return;
}
a->transformStackDepth--;
for (i = 0 ; i < g->limits.maxClipPlanes ; i++)
{
}
#ifdef CR_OPENGL_VERSION_1_2
#endif
}
if (mask & GL_VIEWPORT_BIT)
{
if (a->viewportStackDepth == 0)
{
crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty viewport stack!" );
return;
}
a->viewportStackDepth--;
}
}
{
{
crWarning( "Trying to switch contexts when the attribute stacks "
"weren't empty. Currently, this is not supported." );
}
(void) bb;
(void) bitID;
}