Commit 02c03ef6 authored by Brian Paul's avatar Brian Paul
Browse files

Moved GL_PROGRAM_ERROR_POSITION_NV state (it's not per-program).

Finished all glGet* queries for GL_NV_vertex_program.
Improved error reporting in glEnable/Disable/Get, etc.
parent f9229862
/* $Id: context.c,v 1.171 2002/06/17 23:38:14 brianp Exp $ */
/* $Id: context.c,v 1.172 2002/06/18 16:53:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
......@@ -1446,11 +1446,12 @@ init_attrib_groups( GLcontext *ctx )
_mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable);
/* GL_NV_vertex_program */
ctx->VertexProgram.Current = NULL;
ctx->VertexProgram.CurrentID = 0;
ctx->VertexProgram.Enabled = GL_FALSE;
ctx->VertexProgram.PointSizeEnabled = GL_FALSE;
ctx->VertexProgram.TwoSideEnabled = GL_FALSE;
ctx->VertexProgram.CurrentID = 0;
ctx->VertexProgram.ErrorPos = -1;
ctx->VertexProgram.Current = NULL;
for (i = 0; i < VP_NUM_PROG_REGS / 4; i++) {
ctx->VertexProgram.TrackMatrix[i] = GL_NONE;
ctx->VertexProgram.TrackMatrixTransform[i] = GL_IDENTITY_NV;
......
/* $Id: enable.c,v 1.66 2002/06/15 03:03:07 brianp Exp $ */
/* $Id: enable.c,v 1.67 2002/06/18 16:53:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
......@@ -42,10 +42,11 @@
#endif
#define CHECK_EXTENSION(EXTNAME) \
#define CHECK_EXTENSION(EXTNAME, CAP) \
if (!ctx->Extensions.EXTNAME) { \
_mesa_error(ctx, GL_INVALID_ENUM, \
state ? "glEnableClientState": "glDisableClientState"); \
char s[100]; \
sprintf(s, "gl%sClientState(0x%x)", state ? "Enable" : "Disable", CAP);\
_mesa_error(ctx, GL_INVALID_ENUM, s); \
return; \
}
......@@ -108,7 +109,7 @@ client_state( GLcontext *ctx, GLenum cap, GLboolean state )
case GL_VERTEX_ATTRIB_ARRAY13_NV:
case GL_VERTEX_ATTRIB_ARRAY14_NV:
case GL_VERTEX_ATTRIB_ARRAY15_NV:
CHECK_EXTENSION(NV_vertex_program);
CHECK_EXTENSION(NV_vertex_program, cap);
{
GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
var = &ctx->Array.VertexAttrib[n].Enabled;
......@@ -116,7 +117,11 @@ client_state( GLcontext *ctx, GLenum cap, GLboolean state )
}
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
{
char s[100];
sprintf(s, "glEnable/DisableClientState(0x%x)", cap);
_mesa_error( ctx, GL_INVALID_ENUM, s);
}
return;
}
......@@ -159,11 +164,12 @@ _mesa_DisableClientState( GLenum cap )
#undef CHECK_EXTENSION
#define CHECK_EXTENSION(EXTNAME) \
if (!ctx->Extensions.EXTNAME) { \
_mesa_error(ctx, GL_INVALID_ENUM, \
state ? "glEnable": "glDisable"); \
return; \
#define CHECK_EXTENSION(EXTNAME, CAP) \
if (!ctx->Extensions.EXTNAME) { \
char s[100]; \
sprintf(s, "gl%s(0x%x)", state ? "Enable" : "Disable", CAP); \
_mesa_error(ctx, GL_INVALID_ENUM, s); \
return; \
}
......@@ -276,7 +282,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
ctx->Fog.Enabled = state;
break;
case GL_HISTOGRAM:
CHECK_EXTENSION(EXT_histogram);
CHECK_EXTENSION(EXT_histogram, cap);
if (ctx->Pixel.HistogramEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_PIXEL);
......@@ -640,7 +646,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_HP_occlusion_test */
case GL_OCCLUSION_TEST_HP:
CHECK_EXTENSION(HP_occlusion_test);
CHECK_EXTENSION(HP_occlusion_test, cap);
if (ctx->Depth.OcclusionTest == state)
return;
FLUSH_VERTICES(ctx, _NEW_DEPTH);
......@@ -653,7 +659,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_SGIS_pixel_texture */
case GL_PIXEL_TEXTURE_SGIS:
CHECK_EXTENSION(SGIS_pixel_texture);
CHECK_EXTENSION(SGIS_pixel_texture, cap);
if (ctx->Pixel.PixelTextureEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_PIXEL);
......@@ -662,7 +668,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_SGIX_pixel_texture */
case GL_PIXEL_TEX_GEN_SGIX:
CHECK_EXTENSION(SGIX_pixel_texture);
CHECK_EXTENSION(SGIX_pixel_texture, cap);
if (ctx->Pixel.PixelTextureEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_PIXEL);
......@@ -671,21 +677,21 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_SGI_color_table */
case GL_COLOR_TABLE_SGI:
CHECK_EXTENSION(SGI_color_table);
CHECK_EXTENSION(SGI_color_table, cap);
if (ctx->Pixel.ColorTableEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_PIXEL);
ctx->Pixel.ColorTableEnabled = state;
break;
case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
CHECK_EXTENSION(SGI_color_table);
CHECK_EXTENSION(SGI_color_table, cap);
if (ctx->Pixel.PostConvolutionColorTableEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_PIXEL);
ctx->Pixel.PostConvolutionColorTableEnabled = state;
break;
case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
CHECK_EXTENSION(SGI_color_table);
CHECK_EXTENSION(SGI_color_table, cap);
if (ctx->Pixel.PostColorMatrixColorTableEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_PIXEL);
......@@ -694,21 +700,21 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_EXT_convolution */
case GL_CONVOLUTION_1D:
CHECK_EXTENSION(EXT_convolution);
CHECK_EXTENSION(EXT_convolution, cap);
if (ctx->Pixel.Convolution1DEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_PIXEL);
ctx->Pixel.Convolution1DEnabled = state;
break;
case GL_CONVOLUTION_2D:
CHECK_EXTENSION(EXT_convolution);
CHECK_EXTENSION(EXT_convolution, cap);
if (ctx->Pixel.Convolution2DEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_PIXEL);
ctx->Pixel.Convolution2DEnabled = state;
break;
case GL_SEPARABLE_2D:
CHECK_EXTENSION(EXT_convolution);
CHECK_EXTENSION(EXT_convolution, cap);
if (ctx->Pixel.Separable2DEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_PIXEL);
......@@ -721,7 +727,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT;
CHECK_EXTENSION(ARB_texture_cube_map);
CHECK_EXTENSION(ARB_texture_cube_map, cap);
if (state)
newenabled |= TEXTURE_CUBE_BIT;
if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
......@@ -733,7 +739,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_EXT_secondary_color */
case GL_COLOR_SUM_EXT:
CHECK_EXTENSION(EXT_secondary_color);
CHECK_EXTENSION(EXT_secondary_color, cap);
if (ctx->Fog.ColorSumEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_FOG);
......@@ -750,35 +756,35 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_ARB_multisample */
case GL_MULTISAMPLE_ARB:
CHECK_EXTENSION(ARB_multisample);
CHECK_EXTENSION(ARB_multisample, cap);
if (ctx->Multisample.Enabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
ctx->Multisample.Enabled = state;
break;
case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
CHECK_EXTENSION(ARB_multisample);
CHECK_EXTENSION(ARB_multisample, cap);
if (ctx->Multisample.SampleAlphaToCoverage == state)
return;
FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
ctx->Multisample.SampleAlphaToCoverage = state;
break;
case GL_SAMPLE_ALPHA_TO_ONE_ARB:
CHECK_EXTENSION(ARB_multisample);
CHECK_EXTENSION(ARB_multisample, cap);
if (ctx->Multisample.SampleAlphaToOne == state)
return;
FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
ctx->Multisample.SampleAlphaToOne = state;
break;
case GL_SAMPLE_COVERAGE_ARB:
CHECK_EXTENSION(ARB_multisample);
CHECK_EXTENSION(ARB_multisample, cap);
if (ctx->Multisample.SampleCoverage == state)
return;
FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
ctx->Multisample.SampleCoverage = state;
break;
case GL_SAMPLE_COVERAGE_INVERT_ARB:
CHECK_EXTENSION(ARB_multisample);
CHECK_EXTENSION(ARB_multisample, cap);
if (ctx->Multisample.SampleCoverageInvert == state)
return;
FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
......@@ -787,7 +793,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_IBM_rasterpos_clip */
case GL_RASTER_POSITION_UNCLIPPED_IBM:
CHECK_EXTENSION(IBM_rasterpos_clip);
CHECK_EXTENSION(IBM_rasterpos_clip, cap);
if (ctx->Transform.RasterPositionUnclipped == state)
return;
FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
......@@ -796,7 +802,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_NV_point_sprite */
case GL_POINT_SPRITE_NV:
CHECK_EXTENSION(NV_point_sprite);
CHECK_EXTENSION(NV_point_sprite, cap);
if (ctx->Point.PointSprite == state)
return;
FLUSH_VERTICES(ctx, _NEW_POINT);
......@@ -805,21 +811,21 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
/* GL_NV_vertex_program */
case GL_VERTEX_PROGRAM_NV:
CHECK_EXTENSION(NV_vertex_program);
CHECK_EXTENSION(NV_vertex_program, cap);
if (ctx->VertexProgram.Enabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_TRANSFORM | _NEW_PROGRAM); /* XXX OK? */
ctx->VertexProgram.Enabled = state;
break;
case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
CHECK_EXTENSION(NV_vertex_program);
CHECK_EXTENSION(NV_vertex_program, cap);
if (ctx->VertexProgram.PointSizeEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_POINT | _NEW_PROGRAM);
ctx->VertexProgram.PointSizeEnabled = state;
break;
case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
CHECK_EXTENSION(NV_vertex_program);
CHECK_EXTENSION(NV_vertex_program, cap);
if (ctx->VertexProgram.TwoSideEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_PROGRAM); /* XXX OK? */
......@@ -841,7 +847,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
case GL_MAP1_VERTEX_ATTRIB13_4_NV:
case GL_MAP1_VERTEX_ATTRIB14_4_NV:
case GL_MAP1_VERTEX_ATTRIB15_4_NV:
CHECK_EXTENSION(NV_vertex_program);
CHECK_EXTENSION(NV_vertex_program, cap);
{
const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
FLUSH_VERTICES(ctx, _NEW_EVAL);
......@@ -864,7 +870,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
case GL_MAP2_VERTEX_ATTRIB13_4_NV:
case GL_MAP2_VERTEX_ATTRIB14_4_NV:
case GL_MAP2_VERTEX_ATTRIB15_4_NV:
CHECK_EXTENSION(NV_vertex_program);
CHECK_EXTENSION(NV_vertex_program, cap);
{
const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
FLUSH_VERTICES(ctx, _NEW_EVAL);
......@@ -878,7 +884,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT;
CHECK_EXTENSION(NV_texture_rectangle);
CHECK_EXTENSION(NV_texture_rectangle, cap);
if (state)
newenabled |= TEXTURE_RECT_BIT;
if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
......@@ -889,7 +895,11 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
{
char s[100];
sprintf(s, "%s(0x%x)", state ? "glEnable" : "glDisable", cap);
_mesa_error(ctx, GL_INVALID_ENUM, s);
}
return;
}
......@@ -1262,7 +1272,11 @@ _mesa_IsEnabled( GLenum cap )
}
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
{
char s[100];
sprintf(s, "glIsEnabled(0x%x)", (int) cap);
_mesa_error( ctx, GL_INVALID_ENUM, s );
}
return GL_FALSE;
}
}
This diff is collapsed.
/* $Id: mtypes.h,v 1.80 2002/06/15 03:03:08 brianp Exp $ */
/* $Id: mtypes.h,v 1.81 2002/06/18 16:53:46 brianp Exp $ */
/*
* Mesa 3-D graphics library
......@@ -1234,7 +1234,6 @@ struct vp_program
GLubyte *String; /* Original user code */
struct vp_instruction *Instructions; /* Compiled instructions */
GLenum Target; /* GL_VERTEX_PROGRAM_NV or GL_VERTEX_STATE_PROGRAM_NV */
GLint ErrorPos; /* Position in string where error was detected */
GLint RefCount; /* Since programs can be shared among contexts */
GLboolean IsPositionInvariant; /* GL_NV_vertex_program1_1 */
GLboolean Resident;
......@@ -1252,6 +1251,7 @@ struct vertex_program_state
GLboolean PointSizeEnabled; /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
GLboolean TwoSideEnabled; /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
GLuint CurrentID; /* currently bound program's ID */
GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_NV */
struct vp_program *Current; /* ptr to currently bound program */
struct vp_machine Machine; /* machine state */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment