#!/usr/bin/env python
# Mesa 3-D graphics library
#
# Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# This script is used to generate the get.c file:
# python get_gen.py > get.c
import string
GLint = 1
GLenum = 2
GLfloat = 3
GLdouble = 4
GLboolean = 5
GLfloatN = 6 # A normalized value, such as a color or depth range
GLint64 = 7
TypeStrings = {
GLint : "GLint",
GLenum : "GLenum",
GLfloat : "GLfloat",
GLdouble : "GLdouble",
GLboolean : "GLboolean",
GLint64 : "GLint64"
}
# Each entry is a tuple of:
# - the GL state name, such as GL_CURRENT_COLOR
# - the state datatype, one of GLint, GLfloat, GLboolean or GLenum
# - list of code fragments to get the state, such as ["ctx->Foo.Bar"]
# - optional extra code or empty string. If present, "CONVERSION" will be
# replaced by ENUM_TO_FLOAT, INT_TO_FLOAT, etc.
# - optional extensions to check, or None
#
StateVars = [
( "GL_ACCUM_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.accumRedBits"],
"", None ),
( "GL_ACCUM_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.accumGreenBits"],
"", None ),
( "GL_ACCUM_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.accumBlueBits"],
"", None ),
( "GL_ACCUM_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.accumAlphaBits"],
"", None ),
( "GL_ACCUM_CLEAR_VALUE", GLfloatN,
[ "ctx->Accum.ClearColor[0]",
"ctx->Accum.ClearColor[1]",
"ctx->Accum.ClearColor[2]",
"ctx->Accum.ClearColor[3]" ],
"", None ),
( "GL_ALPHA_BIAS", GLfloat, ["ctx->Pixel.AlphaBias"], "", None ),
( "GL_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.alphaBits"],
"", None ),
( "GL_ALPHA_SCALE", GLfloat, ["ctx->Pixel.AlphaScale"], "", None ),
( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", None ),
( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", None ),
( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", None ),
( "GL_ATTRIB_STACK_DEPTH", GLint, ["ctx->AttribStackDepth"], "", None ),
( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", None ),
( "GL_AUX_BUFFERS", GLint, ["ctx->DrawBuffer->Visual.numAuxBuffers"],
"", None ),
( "GL_BLEND", GLboolean, ["ctx->Color.BlendEnabled"], "", None ),
( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ),
( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
( "GL_BLEND_DST_RGB_EXT", GLenum, ["ctx->Color.BlendDstRGB"], "", None ),
( "GL_BLEND_SRC_ALPHA_EXT", GLenum, ["ctx->Color.BlendSrcA"], "", None ),
( "GL_BLEND_DST_ALPHA_EXT", GLenum, ["ctx->Color.BlendDstA"], "", None ),
( "GL_BLEND_EQUATION", GLenum, ["ctx->Color.BlendEquationRGB "], "", None),
( "GL_BLEND_EQUATION_ALPHA_EXT", GLenum, ["ctx->Color.BlendEquationA "],
"", None ),
( "GL_BLEND_COLOR_EXT", GLfloatN,
[ "ctx->Color.BlendColor[0]",
"ctx->Color.BlendColor[1]",
"ctx->Color.BlendColor[2]",
"ctx->Color.BlendColor[3]"], "", None ),
( "GL_BLUE_BIAS", GLfloat, ["ctx->Pixel.BlueBias"], "", None ),
( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", None ),
( "GL_BLUE_SCALE", GLfloat, ["ctx->Pixel.BlueScale"], "", None ),
( "GL_CLIENT_ATTRIB_STACK_DEPTH", GLint,
["ctx->ClientAttribStackDepth"], "", None ),
( "GL_CLIP_PLANE0", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 0) & 1" ], "", None ),
( "GL_CLIP_PLANE1", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 1) & 1" ], "", None ),
( "GL_CLIP_PLANE2", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 2) & 1" ], "", None ),
( "GL_CLIP_PLANE3", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 3) & 1" ], "", None ),
( "GL_CLIP_PLANE4", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 4) & 1" ], "", None ),
( "GL_CLIP_PLANE5", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 5) & 1" ], "", None ),
( "GL_COLOR_CLEAR_VALUE", GLfloatN,
[ "ctx->Color.ClearColor[0]",
"ctx->Color.ClearColor[1]",
"ctx->Color.ClearColor[2]",
"ctx->Color.ClearColor[3]" ], "", None ),
( "GL_COLOR_MATERIAL", GLboolean,
["ctx->Light.ColorMaterialEnabled"], "", None ),
( "GL_COLOR_MATERIAL_FACE", GLenum,
["ctx->Light.ColorMaterialFace"], "", None ),
( "GL_COLOR_MATERIAL_PARAMETER", GLenum,
["ctx->Light.ColorMaterialMode"], "", None ),
( "GL_COLOR_WRITEMASK", GLint,
[ "ctx->Color.ColorMask[RCOMP] ? 1 : 0",
"ctx->Color.ColorMask[GCOMP] ? 1 : 0",
"ctx->Color.ColorMask[BCOMP] ? 1 : 0",
"ctx->Color.ColorMask[ACOMP] ? 1 : 0" ], "", None ),
( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ),
( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ),
( "GL_CURRENT_COLOR", GLfloatN,
[ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]",
"ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]",
"ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]",
"ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]" ],
"FLUSH_CURRENT(ctx, 0);", None ),
( "GL_CURRENT_INDEX", GLfloat,
|