/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 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"),
/*
* Fixed point arithmetic macros
*/
-#ifdef FIXED_14
-#define FIXED_ONE 0x00004000
-#define FIXED_HALF 0x00002000
-#define FIXED_FRAC_MASK 0x00003FFF
-#define FIXED_SCALE 16384.0f
-#define FIXED_SHIFT 14
-#else
-#define FIXED_ONE 0x00000800
-#define FIXED_HALF 0x00000400
-#define FIXED_FRAC_MASK 0x000007FF
-#define FIXED_SCALE 2048.0f
-#define FIXED_SHIFT 11
-#endif
+#define FIXED_FRAC_BITS 11
+
+#define FIXED_SHIFT FIXED_FRAC_BITS
+#define FIXED_ONE (1 << FIXED_SHIFT)
+#define FIXED_HALF (1 << (FIXED_SHIFT-1))
+#define FIXED_FRAC_MASK (FIXED_ONE - 1)
#define FIXED_INT_MASK (~FIXED_FRAC_MASK)
#define FIXED_EPSILON 1
+#define FIXED_SCALE ((float) FIXED_ONE)
#define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
#define IntToFixed(I) ((I) << FIXED_SHIFT)
#define FixedToInt(X) ((X) >> FIXED_SHIFT)
#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
+/* Fragment programs use a different but related set of attributes:
+ */
+
+/* Fragment input registers / attributes */
+#define FRAG_ATTRIB_WPOS 0
+#define FRAG_ATTRIB_COL0 1
+#define FRAG_ATTRIB_COL1 2
+#define FRAG_ATTRIB_FOGC 3
+#define FRAG_ATTRIB_TEX0 4
+#define FRAG_ATTRIB_TEX1 5
+#define FRAG_ATTRIB_TEX2 6
+#define FRAG_ATTRIB_TEX3 7
+#define FRAG_ATTRIB_TEX4 8
+#define FRAG_ATTRIB_TEX5 9
+#define FRAG_ATTRIB_TEX6 10
+#define FRAG_ATTRIB_TEX7 11
+
+/* Bitmasks for the above */
+#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
+#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
+#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
+#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
+#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
+#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
+#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
+#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
+#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
+#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
+#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
+#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
+
+#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
+ FRAG_BIT_TEX1| \
+ FRAG_BIT_TEX2| \
+ FRAG_BIT_TEX3| \
+ FRAG_BIT_TEX4| \
+ FRAG_BIT_TEX5| \
+ FRAG_BIT_TEX6| \
+ FRAG_BIT_TEX7)
+
+
/**
* Maximum number of temporary vertices required for clipping.
GLenum BlendDstRGB; /**< Blending destination operator */
GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */
GLenum BlendDstA; /**< GL_INGR_blend_func_separate */
- GLenum BlendEquation; /**< Blending equation */
+ GLenum BlendEquationRGB; /**< Blending equation */
+ GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */
GLfloat BlendColor[4]; /**< Blending color */
/*@}*/
#define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
#define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
+
/**
- * Texel fetch function prototype.
+ * Texel fetch function prototype. We use texel fetch functions to
+ * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
+ * texture images. These functions help to isolate us from the gritty
+ * details of all the various texture image encodings.
*
* \param texImage texture image.
* \param col texel column.
* \param row texel row.
- * \param img texel level.
- * \param texelOut output texel. If \p texImage is color-index, \p texelOut
- * returns <tt>GLchan[1]</tt>. If \p texImage is depth, \p texelOut returns
- * <tt>GLfloat[1]</tt>. Otherwise, \p texelOut returns <tt>GLchan[4]</tt>.
+ * \param img texel image level/layer.
+ * \param texelOut output texel (up to 4 GLchans)
+ */
+typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ GLchan *texelOut );
+
+/**
+ * As above, but returns floats.
+ * Used for depth component images and for upcoming signed/float
+ * texture images.
*/
-typedef void (*FetchTexelFunc)( const struct gl_texture_image *texImage,
- GLint col, GLint row, GLint img,
- GLvoid *texelOut );
+typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ GLfloat *texelOut );
/**
* Texture format record
* \name Texel fetch function pointers
*/
/*@{*/
- FetchTexelFunc FetchTexel1D;
- FetchTexelFunc FetchTexel2D;
- FetchTexelFunc FetchTexel3D;
+ FetchTexelFuncC FetchTexel1D;
+ FetchTexelFuncC FetchTexel2D;
+ FetchTexelFuncC FetchTexel3D;
+ FetchTexelFuncF FetchTexel1Df;
+ FetchTexelFuncF FetchTexel2Df;
+ FetchTexelFuncF FetchTexel3Df;
/*@}*/
};
const struct gl_texture_format *TexFormat;
- FetchTexelFunc FetchTexel; /**< Texel fetch function pointer */
+ FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
+ FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
GLboolean IsCompressed; /**< GL_ARB_texture_compression */
GLuint CompressedSize; /**< GL_ARB_texture_compression */
/*@}*/
};
+#define FACE_POS_X 0
+#define FACE_NEG_X 1
+#define FACE_POS_Y 2
+#define FACE_NEG_Y 3
+#define FACE_POS_Z 4
+#define FACE_NEG_Z 5
+#define MAX_FACES 6
/**
* Texture object record
GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLboolean _IsPowerOfTwo; /**< Are all image dimensions powers of two? */
- struct gl_texture_image *Image[MAX_TEXTURE_LEVELS];
-
- /**
- * \name Texture cube faces
- *
- * Image[] is alias for *PosX[MAX_TEXTURE_LEVELS];
- */
- /*@{*/
- struct gl_texture_image *NegX[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *PosY[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *NegY[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *PosZ[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *NegZ[MAX_TEXTURE_LEVELS];
- /*@}*/
+ struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
/** GL_EXT_paletted_texture */
struct gl_color_table Palette;
/*@}*/
};
+/**
+ * Texture combine environment state.
+ *
+ * \todo
+ * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
+ * structure will need to be expanded for 4 elements.
+ */
+struct gl_tex_env_combine_state {
+ GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+ GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+ GLenum SourceRGB[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
+ GLenum SourceA[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
+ GLenum OperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
+ GLenum OperandA[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
+ GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
+ GLuint ScaleShiftA; /**< 0, 1 or 2 */
+ GLuint _NumArgsRGB; /**< Number of inputs used for the combine mode. */
+ GLuint _NumArgsA; /**< Number of inputs used for the combine mode. */
+};
/**
* Texture unit record
/**
* \name GL_EXT_texture_env_combine
*/
- /*@{*/
- GLenum CombineModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
- GLenum CombineModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
- GLenum CombineSourceRGB[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
- GLenum CombineSourceA[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
- GLenum CombineOperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
- GLenum CombineOperandA[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
- GLuint CombineScaleShiftRGB; /**< 0, 1 or 2 */
- GLuint CombineScaleShiftA; /**< 0, 1 or 2 */
- /*@}*/
+ struct gl_tex_env_combine_state Combine;
+
+ /**
+ * Derived state based on \c EnvMode and the \c BaseFormat of the
+ * currently enabled texture.
+ */
+ struct gl_tex_env_combine_state _EnvMode;
+
+ /**
+ * Currently enabled combiner state. This will point to either
+ * \c Combine or \c _EnvMode.
+ */
+ struct gl_tex_env_combine_state *_CurrentCombine;
struct gl_texture_object *Current1D;
struct gl_texture_object *Current2D;
struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX]; /**< GL_NV_vertex_program */
- GLint TexCoordInterleaveFactor;
GLint ActiveTexture; /**< Client Active Texture */
GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
/** \name Software alpha planes */
/*@{*/
- GLvoid *FrontLeftAlpha; /**< array [Width*Height] of GLubyte */
- GLvoid *BackLeftAlpha; /**< array [Width*Height] of GLubyte */
- GLvoid *FrontRightAlpha; /**< array [Width*Height] of GLubyte */
- GLvoid *BackRightAlpha; /**< array [Width*Height] of GLubyte */
+ GLchan *FrontLeftAlpha; /**< array [Width*Height] of GLchan */
+ GLchan *BackLeftAlpha; /**< array [Width*Height] of GLchan */
+ GLchan *FrontRightAlpha; /**< array [Width*Height] of GLchan */
+ GLchan *BackRightAlpha; /**< array [Width*Height] of GLchan */
/*@}*/
/**
GLboolean ARB_texture_env_dot3;
GLboolean ARB_texture_mirrored_repeat;
GLboolean ARB_texture_non_power_of_two;
+ GLboolean ARB_transpose_matrix;
GLboolean ARB_vertex_buffer_object;
GLboolean ARB_vertex_program;
GLboolean ARB_window_pos;
- GLboolean ATI_texture_mirror_once;
- GLboolean ATI_texture_env_combine3;
+ GLboolean EXT_abgr;
+ GLboolean EXT_bgra;
GLboolean EXT_blend_color;
+ GLboolean EXT_blend_equation_separate;
GLboolean EXT_blend_func_separate;
GLboolean EXT_blend_logic_op;
GLboolean EXT_blend_minmax;
GLboolean EXT_blend_subtract;
+ GLboolean EXT_clip_volume_hint;
GLboolean EXT_convolution;
GLboolean EXT_compiled_vertex_array;
+ GLboolean EXT_copy_texture;
GLboolean EXT_depth_bounds_test;
+ GLboolean EXT_draw_range_elements;
GLboolean EXT_fog_coord;
GLboolean EXT_histogram;
GLboolean EXT_multi_draw_arrays;
GLboolean EXT_paletted_texture;
+ GLboolean EXT_packed_pixels;
GLboolean EXT_point_parameters;
+ GLboolean EXT_polygon_offset;
+ GLboolean EXT_rescale_normal;
GLboolean EXT_shadow_funcs;
GLboolean EXT_secondary_color;
+ GLboolean EXT_separate_specular_color;
GLboolean EXT_shared_texture_palette;
GLboolean EXT_stencil_wrap;
GLboolean EXT_stencil_two_side;
+ GLboolean EXT_subtexture;
+ GLboolean EXT_texture;
+ GLboolean EXT_texture_object;
GLboolean EXT_texture3D;
GLboolean EXT_texture_compression_s3tc;
GLboolean EXT_texture_env_add;
GLboolean EXT_texture_filter_anisotropic;
GLboolean EXT_texture_lod_bias;
GLboolean EXT_texture_mirror_clamp;
+ GLboolean EXT_vertex_array;
GLboolean EXT_vertex_array_set;
+ /* vendor extensions */
+ GLboolean APPLE_client_storage;
+ GLboolean APPLE_packed_pixels;
+ GLboolean ATI_texture_mirror_once;
+ GLboolean ATI_texture_env_combine3;
GLboolean HP_occlusion_test;
GLboolean IBM_rasterpos_clip;
GLboolean IBM_multimode_draw_arrays;
GLboolean MESA_ycbcr_texture;
GLboolean NV_blend_square;
GLboolean NV_fragment_program;
+ GLboolean NV_light_max_exponent;
GLboolean NV_point_sprite;
+ GLboolean NV_texgen_reflection;
GLboolean NV_texture_rectangle;
GLboolean NV_vertex_program;
GLboolean NV_vertex_program1_1;
GLboolean SGIS_generate_mipmap;
GLboolean SGIS_pixel_texture;
GLboolean SGIS_texture_edge_clamp;
+ GLboolean SGIS_texture_lod;
GLboolean SGIX_depth_texture;
GLboolean SGIX_pixel_texture;
GLboolean SGIX_shadow;
GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
GLboolean TDFX_texture_compression_FXT1;
- GLboolean APPLE_client_storage;
GLboolean S3_s3tc;
/*@}*/
/* The extension string */
/**
* \name Bits to indicate what state has changed.
*
- * 6 unused flags.
+ * 4 unused flags.
*/
/*@{*/
#define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
-#define _NEW_ARRAY_ATTRIB_0 0x1 /* alias conventional arrays */
+#define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
#define _NEW_ARRAY_ALL 0xffffffff
*/
/*@{*/
#define _DD_NEW_FLATSHADE _NEW_LIGHT
-#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
+#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
#define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
#define _DD_NEW_TRI_UNFILLED _NEW_POLYGON