diff options
author | Brian Paul <[email protected]> | 1999-11-11 01:22:25 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 1999-11-11 01:22:25 +0000 |
commit | fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5 (patch) | |
tree | fb9ea4452e1f65c6e3c11ee4c4f17c023f8262e5 /src/mesa/main | |
parent | 06ac59281bdad6679fb1941e31e3c4df1c12cede (diff) |
first big check-in of new Mesa 3.3 code
Diffstat (limited to 'src/mesa/main')
63 files changed, 5378 insertions, 3946 deletions
diff --git a/src/mesa/main/Makefile.X11 b/src/mesa/main/Makefile.X11 index da5dc4549e3..d026075c8e4 100644 --- a/src/mesa/main/Makefile.X11 +++ b/src/mesa/main/Makefile.X11 @@ -1,7 +1,7 @@ -# $Id: Makefile.X11,v 1.6 1999/10/08 09:27:09 keithw Exp $ +# $Id: Makefile.X11,v 1.7 1999/11/11 01:22:28 brianp Exp $ # Mesa 3-D graphics library -# Version: 3.1 +# Version: 3.3 # Copyright (C) 1995-1999 Brian Paul # Makefile for core library @@ -18,13 +18,13 @@ VPATH = RCS INCDIR = ../include LIBDIR = ../lib + CORE_SOURCES = \ + glapi.c \ + glapinoop.c \ accum.c \ alpha.c \ alphabuf.c \ - api1.c \ - api2.c \ - apiext.c \ attrib.c \ bbox.c \ bitmap.c \ @@ -37,6 +37,7 @@ CORE_SOURCES = \ cva.c \ debug_xform.c \ depth.c \ + dispatch.c \ dlist.c \ drawpix.c \ enable.c \ @@ -49,18 +50,19 @@ CORE_SOURCES = \ glmisc.c \ hash.c \ image.c \ + imaging.c \ light.c \ lines.c \ logic.c \ masking.c \ matrix.c \ + mem.c \ mmath.c \ mthreads.c \ pb.c \ pixel.c \ pipeline.c \ points.c \ - pointers.c \ polygon.c \ quads.c \ rastpos.c \ diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c index 68e567bdf1e..1e8cce0ec34 100644 --- a/src/mesa/main/accum.c +++ b/src/mesa/main/accum.c @@ -1,4 +1,4 @@ -/* $Id: accum.c,v 1.10 1999/11/08 07:36:43 brianp Exp $ */ +/* $Id: accum.c,v 1.11 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -25,22 +25,13 @@ */ -/* $XFree86: xc/lib/GL/mesa/src/accum.c,v 1.3 1999/04/04 00:20:17 dawes Exp $ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <limits.h> -#include <stdlib.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "accum.h" #include "context.h" -#include "macros.h" +#include "mem.h" #include "masking.h" #include "span.h" #include "types.h" @@ -101,9 +92,10 @@ void gl_alloc_accum_buffer( GLcontext *ctx ) -void gl_ClearAccum( GLcontext *ctx, - GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) +void +_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glAccum"); ctx->Accum.ClearColor[0] = CLAMP( red, -1.0, 1.0 ); @@ -139,8 +131,10 @@ static void rescale_accum( GLcontext *ctx ) -void gl_Accum( GLcontext *ctx, GLenum op, GLfloat value ) +void +_mesa_Accum( GLenum op, GLfloat value ) { + GET_CURRENT_CONTEXT(ctx); GLuint xpos, ypos, width, height, width4; GLfloat acc_scale; GLubyte rgba[MAX_WIDTH][4]; diff --git a/src/mesa/main/accum.h b/src/mesa/main/accum.h index dd641da456a..0f2263bd49c 100644 --- a/src/mesa/main/accum.h +++ b/src/mesa/main/accum.h @@ -1,4 +1,4 @@ -/* $Id: accum.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: accum.h,v 1.2 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -38,14 +38,15 @@ extern void gl_alloc_accum_buffer( GLcontext *ctx ); -extern void gl_Accum( GLcontext *ctx, GLenum op, GLfloat value ); +extern void gl_clear_accum_buffer( GLcontext *ctx ); -extern void gl_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green, - GLfloat blue, GLfloat alpha ); +extern void +_mesa_Accum( GLenum op, GLfloat value ); -extern void gl_clear_accum_buffer( GLcontext *ctx ); +extern void +_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); #endif diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index e346538eead..4ca036110af 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,4 +1,4 @@ -/* $Id: attrib.c,v 1.10 1999/11/08 15:28:08 brianp Exp $ */ +/* $Id: attrib.c,v 1.11 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -25,23 +25,16 @@ */ - -#include <stdlib.h> - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <stdio.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "attrib.h" #include "context.h" #include "glmisc.h" #include "enable.h" #include "enums.h" -#include "macros.h" +#include "mem.h" #include "simple_list.h" #include "texstate.h" #include "types.h" @@ -92,11 +85,7 @@ static void copy_texobj_state( struct gl_texture_object *dest, dest->P = src->P; dest->M = src->M; dest->MinMagThresh = src->MinMagThresh; - memcpy( dest->Palette, src->Palette, - sizeof(GLubyte) * MAX_TEXTURE_PALETTE_SIZE * 4 ); - dest->PaletteSize = src->PaletteSize; - dest->PaletteIntFormat = src->PaletteIntFormat; - dest->PaletteFormat = src->PaletteFormat; + dest->Palette = src->Palette; dest->Complete = src->Complete; dest->SampleFunc = src->SampleFunc; } @@ -431,7 +420,7 @@ void gl_PopAttrib( GLcontext* ctx ) MEMCPY( &ctx->Color, attr->data, sizeof(struct gl_colorbuffer_attrib) ); if (ctx->Color.DrawBuffer != oldDrawBuffer) { - gl_DrawBuffer(ctx, ctx->Color.DrawBuffer); + _mesa_DrawBuffer( ctx->Color.DrawBuffer); } if ((ctx->Color.AlphaFunc != oldAlphaFunc || ctx->Color.AlphaRef != oldAlphaRef) && @@ -471,7 +460,7 @@ void gl_PopAttrib( GLcontext* ctx ) #define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \ if ((VALUE) != (NEWVALUE)) { \ - gl_set_enable( ctx, ENUM, (NEWVALUE) ); \ + _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \ } TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST); @@ -481,7 +470,7 @@ void gl_PopAttrib( GLcontext* ctx ) GLuint i; for (i=0;i<MAX_CLIP_PLANES;i++) { if (ctx->Transform.ClipEnabled[i] != enable->ClipPlane[i]) - gl_set_enable( ctx, (GLenum) (GL_CLIP_PLANE0 + i), enable->ClipPlane[i] ); + _mesa_set_enable( ctx, (GLenum) (GL_CLIP_PLANE0 + i), enable->ClipPlane[i] ); } } TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial, GL_COLOR_MATERIAL); @@ -742,8 +731,8 @@ void gl_PopAttrib( GLcontext* ctx ) struct gl_viewport_attrib *v = (struct gl_viewport_attrib *)attr->data; - gl_Viewport( ctx, v->X, v->Y, v->Width, v->Height ); - gl_DepthRange( ctx, v->Near, v->Far ); + _mesa_Viewport( v->X, v->Y, v->Width, v->Height ); + _mesa_DepthRange( v->Near, v->Far ); break; } default: @@ -857,3 +846,37 @@ void gl_PopClientAttrib( GLcontext *ctx ) ctx->NewState = NEW_ALL; } + + +void +_mesa_PushAttrib( GLbitfield mask ) +{ + GET_CURRENT_CONTEXT(ctx); + gl_PushAttrib(ctx, mask); +} + + +void +_mesa_PopAttrib( void ) +{ + GET_CURRENT_CONTEXT(ctx); + gl_PopAttrib(ctx); +} + + +void +_mesa_PushClientAttrib( GLbitfield mask ) +{ + GET_CURRENT_CONTEXT(ctx); + gl_PushClientAttrib(ctx, mask); +} + + +void +_mesa_PopClientAttrib( void ) +{ + GET_CURRENT_CONTEXT(ctx); + gl_PopClientAttrib(ctx); +} + + diff --git a/src/mesa/main/attrib.h b/src/mesa/main/attrib.h index 0661c261230..91301dcb6d3 100644 --- a/src/mesa/main/attrib.h +++ b/src/mesa/main/attrib.h @@ -1,8 +1,8 @@ -/* $Id: attrib.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: attrib.h,v 1.2 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef ATTRIB_H #define ATTRIB_h @@ -44,4 +41,17 @@ extern void gl_PushClientAttrib( GLcontext *ctx, GLbitfield mask ); extern void gl_PopClientAttrib( GLcontext *ctx ); +extern void +_mesa_PushAttrib( GLbitfield mask ); + +extern void +_mesa_PopAttrib( void ); + +extern void +_mesa_PushClientAttrib( GLbitfield mask ); + +extern void +_mesa_PopClientAttrib( void ); + + #endif diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 357d1265c2f..4dac9a4f6a7 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -1,4 +1,4 @@ -/* $Id: blend.c,v 1.7 1999/11/08 15:28:08 brianp Exp $ */ +/* $Id: blend.c,v 1.8 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -29,13 +29,7 @@ #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <stdio.h> -#include <assert.h> -#include <stdlib.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "alphabuf.h" #include "blend.h" #include "context.h" @@ -47,8 +41,9 @@ #endif -void gl_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor ) +void _mesa_BlendFunc( GLenum sfactor, GLenum dfactor ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glBlendFunc"); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) @@ -108,9 +103,10 @@ void gl_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor ) /* GL_INGR_blend_func_separate */ void -gl_BlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ) +_mesa_BlendFuncSeparateINGR( GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glBlendFuncSeparate"); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) @@ -214,8 +210,10 @@ gl_BlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB, GLenum dfactorRGB, /* This is really an extension function! */ -void gl_BlendEquation( GLcontext *ctx, GLenum mode ) +void +_mesa_BlendEquationEXT( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glBlendEquation"); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) @@ -256,9 +254,10 @@ void gl_BlendEquation( GLcontext *ctx, GLenum mode ) -void gl_BlendColor( GLcontext *ctx, GLclampf red, GLclampf green, - GLclampf blue, GLclampf alpha ) +void +_mesa_BlendColorEXT( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) { + GET_CURRENT_CONTEXT(ctx); ctx->Color.BlendColor[0] = CLAMP( red, 0.0F, 1.0F ); ctx->Color.BlendColor[1] = CLAMP( green, 0.0F, 1.0F ); ctx->Color.BlendColor[2] = CLAMP( blue, 0.0F, 1.0F ); diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h index 837ea9d6bf2..8396880eae8 100644 --- a/src/mesa/main/blend.h +++ b/src/mesa/main/blend.h @@ -1,4 +1,4 @@ -/* $Id: blend.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: blend.h,v 1.2 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -25,9 +25,6 @@ */ - - - #ifndef BLEND_H #define BLEND_H @@ -48,21 +45,20 @@ gl_blend_pixels( GLcontext *ctx, extern void -gl_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor ); +_mesa_BlendFunc( GLenum sfactor, GLenum dfactor ); extern void -gl_BlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA ); +_mesa_BlendFuncSeparateINGR( GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA ); extern void -gl_BlendEquation( GLcontext *ctx, GLenum mode ); +_mesa_BlendEquationEXT( GLenum mode ); extern void -gl_BlendColor( GLcontext *ctx, GLclampf red, GLclampf green, - GLclampf blue, GLclampf alpha ); +_mesa_BlendColorEXT(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); #endif diff --git a/src/mesa/main/clip.c b/src/mesa/main/clip.c index d93e50958ae..acecb60b6bf 100644 --- a/src/mesa/main/clip.c +++ b/src/mesa/main/clip.c @@ -1,8 +1,8 @@ -/* $Id: clip.c,v 1.4 1999/11/08 07:36:43 brianp Exp $ */ +/* $Id: clip.c,v 1.5 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,18 +25,10 @@ */ - - - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <string.h> -#include <stdlib.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "clip.h" #include "context.h" #include "macros.h" @@ -130,9 +122,17 @@ static clip_interp_func clip_interp_tab[0x40]; -void gl_ClipPlane( GLcontext* ctx, GLenum plane, const GLfloat *equation ) +void +_mesa_ClipPlane( GLenum plane, const GLdouble *eq ) { + GET_CURRENT_CONTEXT(ctx); GLint p; + GLfloat equation[4]; + + equation[0] = eq[0]; + equation[1] = eq[1]; + equation[2] = eq[2]; + equation[3] = eq[3]; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glClipPlane"); @@ -183,8 +183,10 @@ void gl_update_userclip( GLcontext *ctx ) } } -void gl_GetClipPlane( GLcontext* ctx, GLenum plane, GLdouble *equation ) +void +_mesa_GetClipPlane( GLenum plane, GLdouble *equation ) { + GET_CURRENT_CONTEXT(ctx); GLint p; ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetClipPlane"); diff --git a/src/mesa/main/clip.h b/src/mesa/main/clip.h index b8ea954dca4..abf2f7e9ce0 100644 --- a/src/mesa/main/clip.h +++ b/src/mesa/main/clip.h @@ -1,4 +1,4 @@ -/* $Id: clip.h,v 1.2 1999/09/18 20:41:22 keithw Exp $ */ +/* $Id: clip.h,v 1.3 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -63,11 +63,9 @@ extern GLuint gl_userclip_point( GLcontext* ctx, const GLfloat v[] ); extern void gl_user_cliptest( struct vertex_buffer *VB ); -extern void gl_ClipPlane( GLcontext* ctx, - GLenum plane, const GLfloat *equation ); +extern void _mesa_ClipPlane( GLenum plane, const GLdouble *equation ); -extern void gl_GetClipPlane( GLcontext* ctx, - GLenum plane, GLdouble *equation ); +extern void _mesa_GetClipPlane( GLenum plane, GLdouble *equation ); /* diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index f0744ae1cf9..798eda44c8c 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -1,4 +1,4 @@ -/* $Id: colortab.c,v 1.3 1999/11/08 07:36:43 brianp Exp $ */ +/* $Id: colortab.c,v 1.4 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -23,20 +23,15 @@ * 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. */ -/* $XFree86: xc/lib/GL/mesa/src/colortab.c,v 1.2 1999/04/04 00:20:21 dawes Exp $ */ - - - #ifdef PC_HEADER #include "all.h" #else -#ifdef XFree86Server -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "colortab.h" #include "context.h" +#include "image.h" #include "macros.h" #endif @@ -45,7 +40,8 @@ /* * Return GL_TRUE if k is a power of two, else return GL_FALSE. */ -static GLboolean power_of_two( GLint k ) +static GLboolean +power_of_two( GLint k ) { GLint i, m = 1; for (i=0; i<32; i++) { @@ -57,7 +53,8 @@ static GLboolean power_of_two( GLint k ) } -static GLint decode_internal_format( GLint format ) +static GLint +decode_internal_format( GLint format ) { switch (format) { case GL_ALPHA: @@ -114,81 +111,95 @@ static GLint decode_internal_format( GLint format ) } -void gl_ColorTable( GLcontext *ctx, GLenum target, - GLenum internalFormat, struct gl_image *table ) +void +_mesa_ColorTable( GLenum target, GLenum internalFormat, + GLsizei width, GLenum format, GLenum type, + const GLvoid *table ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *texObj; + struct gl_palette *palette; GLboolean proxy = GL_FALSE; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorTable"); - if (decode_internal_format(internalFormat) < 0) { - gl_error( ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)" ); - return; - } - switch (target) { case GL_TEXTURE_1D: texObj = texUnit->CurrentD[1]; + palette = &texObj->Palette; break; case GL_TEXTURE_2D: texObj = texUnit->CurrentD[2]; + palette = &texObj->Palette; break; - case GL_TEXTURE_3D_EXT: + case GL_TEXTURE_3D: texObj = texUnit->CurrentD[3]; + palette = &texObj->Palette; break; case GL_PROXY_TEXTURE_1D: texObj = ctx->Texture.Proxy1D; + palette = &texObj->Palette; proxy = GL_TRUE; break; case GL_PROXY_TEXTURE_2D: texObj = ctx->Texture.Proxy2D; + palette = &texObj->Palette; proxy = GL_TRUE; break; - case GL_PROXY_TEXTURE_3D_EXT: + case GL_PROXY_TEXTURE_3D: texObj = ctx->Texture.Proxy3D; + palette = &texObj->Palette; proxy = GL_TRUE; break; case GL_SHARED_TEXTURE_PALETTE_EXT: texObj = NULL; + palette = &ctx->Texture.Palette; break; default: - gl_error(ctx, GL_INVALID_ENUM, "glColorTableEXT(target)"); + gl_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); return; } - /* internalformat = just like glTexImage */ + assert(palette); + + if (!gl_is_legal_format_and_type(format, type)) { + gl_error(ctx, GL_INVALID_ENUM, "glColorTable(format or type)"); + return; + } + + if (decode_internal_format(internalFormat) < 0) { + gl_error( ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)" ); + return; + } - if (table->Width < 1 || table->Width > MAX_TEXTURE_PALETTE_SIZE - || !power_of_two(table->Width)) { - gl_error(ctx, GL_INVALID_VALUE, "glColorTableEXT(width)"); + if (width < 1 || width > MAX_TEXTURE_PALETTE_SIZE || !power_of_two(width)) { + gl_error(ctx, GL_INVALID_VALUE, "glColorTable(width)"); if (proxy) { - texObj->PaletteSize = 0; - texObj->PaletteIntFormat = (GLenum) 0; - texObj->PaletteFormat = (GLenum) 0; + palette->Size = 0; + palette->IntFormat = (GLenum) 0; + palette->Format = (GLenum) 0; } return; } + palette->Size = width; + palette->IntFormat = internalFormat; + palette->Format = (GLenum) decode_internal_format(internalFormat); + if (!proxy) { + _mesa_unpack_ubyte_color_span(ctx, width, palette->Format, + palette->Table, /* dest */ + format, type, table, + &ctx->Unpack, GL_FALSE); + } if (texObj) { /* per-texture object palette */ - texObj->PaletteSize = table->Width; - texObj->PaletteIntFormat = internalFormat; - texObj->PaletteFormat = (GLenum) decode_internal_format(internalFormat); - if (!proxy) { - MEMCPY(texObj->Palette, table->Data, table->Width*table->Components); - if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); - } + if (ctx->Driver.UpdateTexturePalette) { + (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); } } else { /* shared texture palette */ - ctx->Texture.PaletteSize = table->Width; - ctx->Texture.PaletteIntFormat = internalFormat; - ctx->Texture.PaletteFormat = (GLenum) decode_internal_format(internalFormat); - MEMCPY(ctx->Texture.Palette, table->Data, table->Width*table->Components); if (ctx->Driver.UpdateTexturePalette) { (*ctx->Driver.UpdateTexturePalette)( ctx, NULL ); } @@ -197,38 +208,172 @@ void gl_ColorTable( GLcontext *ctx, GLenum target, -void gl_ColorSubTable( GLcontext *ctx, GLenum target, - GLsizei start, struct gl_image *data ) +void +_mesa_ColorSubTable( GLenum target, GLsizei start, + GLsizei count, GLenum format, GLenum type, + const GLvoid *table ) { - /* XXX TODO */ - gl_problem(ctx, "glColorSubTableEXT not implemented"); - (void) target; - (void) start; - (void) data; + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + struct gl_texture_object *texObj; + struct gl_palette *palette; + GLint comps; + GLubyte *dest; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorSubTable"); + + switch (target) { + case GL_TEXTURE_1D: + texObj = texUnit->CurrentD[1]; + palette = &texObj->Palette; + break; + case GL_TEXTURE_2D: + texObj = texUnit->CurrentD[2]; + palette = &texObj->Palette; + break; + case GL_TEXTURE_3D: + texObj = texUnit->CurrentD[3]; + palette = &texObj->Palette; + break; + case GL_SHARED_TEXTURE_PALETTE_EXT: + texObj = NULL; + palette = &ctx->Texture.Palette; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); + return; + } + + assert(palette); + + if (!gl_is_legal_format_and_type(format, type)) { + gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(format or type)"); + return; + } + + if (count < 1) { + gl_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)"); + return; + } + + comps = gl_components_in_format(format); + assert(comps > 0); /* error should be caught sooner */ + + if (start + count > palette->Size) { + gl_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)"); + return; + } + dest = palette->Table + start * comps * sizeof(GLubyte); + _mesa_unpack_ubyte_color_span(ctx, count, palette->Format, dest, + format, type, table, + &ctx->Unpack, GL_FALSE); + + if (texObj) { + /* per-texture object palette */ + if (ctx->Driver.UpdateTexturePalette) { + (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); + } + } + else { + /* shared texture palette */ + if (ctx->Driver.UpdateTexturePalette) { + (*ctx->Driver.UpdateTexturePalette)( ctx, NULL ); + } + } } -void gl_GetColorTable( GLcontext *ctx, GLenum target, GLenum format, - GLenum type, GLvoid *table ) +void +_mesa_GetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *table ) { + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + struct gl_palette *palette; + GLubyte rgba[MAX_TEXTURE_PALETTE_SIZE][4]; + GLint i; + ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetBooleanv"); switch (target) { case GL_TEXTURE_1D: + palette = &texUnit->CurrentD[1]->Palette; break; case GL_TEXTURE_2D: + palette = &texUnit->CurrentD[2]->Palette; break; - case GL_TEXTURE_3D_EXT: + case GL_TEXTURE_3D: + palette = &texUnit->CurrentD[3]->Palette; break; case GL_SHARED_TEXTURE_PALETTE_EXT: + palette = &ctx->Texture.Palette; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); + return; + } + + assert(palette); + + switch (palette->Format) { + case GL_ALPHA: + for (i = 0; i < palette->Size; i++) { + rgba[i][RCOMP] = 0; + rgba[i][GCOMP] = 0; + rgba[i][BCOMP] = 0; + rgba[i][ACOMP] = palette->Table[i]; + } + break; + case GL_LUMINANCE: + for (i = 0; i < palette->Size; i++) { + rgba[i][RCOMP] = palette->Table[i]; + rgba[i][GCOMP] = palette->Table[i]; + rgba[i][BCOMP] = palette->Table[i]; + rgba[i][ACOMP] = 255; + } + break; + case GL_LUMINANCE_ALPHA: + for (i = 0; i < palette->Size; i++) { + rgba[i][RCOMP] = palette->Table[i*2+0]; + rgba[i][GCOMP] = palette->Table[i*2+0]; + rgba[i][BCOMP] = palette->Table[i*2+0]; + rgba[i][ACOMP] = palette->Table[i*2+1]; + } + break; + case GL_INTENSITY: + for (i = 0; i < palette->Size; i++) { + rgba[i][RCOMP] = palette->Table[i]; + rgba[i][GCOMP] = palette->Table[i]; + rgba[i][BCOMP] = palette->Table[i]; + rgba[i][ACOMP] = 255; + } + break; + case GL_RGB: + for (i = 0; i < palette->Size; i++) { + rgba[i][RCOMP] = palette->Table[i*3+0]; + rgba[i][GCOMP] = palette->Table[i*3+1]; + rgba[i][BCOMP] = palette->Table[i*3+2]; + rgba[i][ACOMP] = 255; + } + break; + case GL_RGBA: + for (i = 0; i < palette->Size; i++) { + rgba[i][RCOMP] = palette->Table[i*4+0]; + rgba[i][GCOMP] = palette->Table[i*4+1]; + rgba[i][BCOMP] = palette->Table[i*4+2]; + rgba[i][ACOMP] = palette->Table[i*4+3]; + } break; default: - gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableEXT(target)"); + gl_problem(ctx, "bad palette format in glGetColorTable"); return; } - gl_problem(ctx, "glGetColorTableEXT not implemented!"); + gl_pack_rgba_span(ctx, palette->Size, (const GLubyte (*)[]) rgba, + format, type, table, &ctx->Pack, GL_FALSE); + + gl_problem(ctx, "glGetColorTable not implemented!"); (void) format; (void) type; (void) table; @@ -236,37 +381,37 @@ void gl_GetColorTable( GLcontext *ctx, GLenum target, GLenum format, -void gl_GetColorTableParameterfv( GLcontext *ctx, GLenum target, - GLenum pname, GLfloat *params ) +void +_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) { GLint iparams[10]; - - gl_GetColorTableParameteriv( ctx, target, pname, iparams ); + _mesa_GetColorTableParameteriv( target, pname, iparams ); *params = (GLfloat) iparams[0]; } -void gl_GetColorTableParameteriv( GLcontext *ctx, GLenum target, - GLenum pname, GLint *params ) +void +_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_object *texObj; + struct gl_palette *palette; ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameter"); switch (target) { case GL_TEXTURE_1D: - texObj = texUnit->CurrentD[1]; + palette = &texUnit->CurrentD[1]->Palette; break; case GL_TEXTURE_2D: - texObj = texUnit->CurrentD[2]; + palette = &texUnit->CurrentD[2]->Palette; break; - case GL_TEXTURE_3D_EXT: - texObj = texUnit->CurrentD[3]; + case GL_TEXTURE_3D: + palette = &texUnit->CurrentD[3]->Palette; break; case GL_SHARED_TEXTURE_PALETTE_EXT: - texObj = NULL; + palette = &ctx->Texture.Palette; break; default: gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); @@ -274,34 +419,28 @@ void gl_GetColorTableParameteriv( GLcontext *ctx, GLenum target, } switch (pname) { - case GL_COLOR_TABLE_FORMAT_EXT: - if (texObj) - *params = texObj->PaletteIntFormat; - else - *params = ctx->Texture.PaletteIntFormat; - break; - case GL_COLOR_TABLE_WIDTH_EXT: - if (texObj) - *params = texObj->PaletteSize; - else - *params = ctx->Texture.PaletteSize; - break; - case GL_COLOR_TABLE_RED_SIZE_EXT: + case GL_COLOR_TABLE_FORMAT: + *params = palette->IntFormat; + break; + case GL_COLOR_TABLE_WIDTH: + *params = palette->Size; + break; + case GL_COLOR_TABLE_RED_SIZE: *params = 8; break; - case GL_COLOR_TABLE_GREEN_SIZE_EXT: + case GL_COLOR_TABLE_GREEN_SIZE: *params = 8; break; - case GL_COLOR_TABLE_BLUE_SIZE_EXT: + case GL_COLOR_TABLE_BLUE_SIZE: *params = 8; break; - case GL_COLOR_TABLE_ALPHA_SIZE_EXT: + case GL_COLOR_TABLE_ALPHA_SIZE: *params = 8; break; - case GL_COLOR_TABLE_LUMINANCE_SIZE_EXT: + case GL_COLOR_TABLE_LUMINANCE_SIZE: *params = 8; break; - case GL_COLOR_TABLE_INTENSITY_SIZE_EXT: + case GL_COLOR_TABLE_INTENSITY_SIZE: *params = 8; break; default: diff --git a/src/mesa/main/colortab.h b/src/mesa/main/colortab.h index 8e75f13dac7..633d342dc48 100644 --- a/src/mesa/main/colortab.h +++ b/src/mesa/main/colortab.h @@ -1,4 +1,4 @@ -/* $Id: colortab.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: colortab.h,v 1.2 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -25,9 +25,6 @@ */ - - - #ifndef COLORTAB_H #define COLORTAB_H @@ -35,21 +32,25 @@ #include "types.h" -extern void gl_ColorTable( GLcontext *ctx, GLenum target, - GLenum internalformat, - struct gl_image *table ); +extern void +_mesa_ColorTable( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, GLenum type, + const GLvoid *table ); -extern void gl_ColorSubTable( GLcontext *ctx, GLenum target, - GLsizei start, struct gl_image *data ); +extern void +_mesa_ColorSubTable( GLenum target, GLsizei start, + GLsizei count, GLenum format, GLenum type, + const GLvoid *table ); -extern void gl_GetColorTable( GLcontext *ctx, GLenum target, GLenum format, - GLenum type, GLvoid *table ); +extern void +_mesa_GetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *table ); -extern void gl_GetColorTableParameterfv( GLcontext *ctx, GLenum target, - GLenum pname, GLfloat *params ); +extern void +_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ); -extern void gl_GetColorTableParameteriv( GLcontext *ctx, GLenum target, - GLenum pname, GLint *params ); +extern void +_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ); #endif diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 0b35aba7dc6..9affa9c4d3d 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -1,8 +1,8 @@ -/* $Id: config.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: config.h,v 1.2 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,10 +25,6 @@ */ - - - - /* * Tunable configuration parameters. */ @@ -42,13 +38,11 @@ #include "conf.h" #endif + /* - * * OpenGL implementation limits - * */ - /* Maximum modelview matrix stack depth: */ #define MAX_MODELVIEW_STACK_DEPTH 32 @@ -116,10 +110,9 @@ #define MAX_ARRAY_LOCK_SIZE 3000 + /* - * * Mesa-specific parameters - * */ @@ -129,6 +122,9 @@ #define ACCUM_BITS 16 +/* + * Bits per depth buffer value: 16 or 32 + */ #ifdef MESAD3D /* Mesa / Direct3D driver only */ extern float g_DepthScale, g_MaxDepth; @@ -136,9 +132,6 @@ # define DEPTH_SCALE g_DepthScale # define MAX_DEPTH g_MaxDepth #else - /* - * Bits per depth buffer value: 16 or 32 - */ # define DEPTH_BITS 16 # if DEPTH_BITS==16 # define MAX_DEPTH 0xffff @@ -201,19 +194,6 @@ #define VB_SIZE (VB_MAX + VB_MAX_CLIPPED_VERTS) -/* - * - * For X11 driver only: - * - */ - -/* - * When defined, use 6x6x6 dithering instead of 5x9x5. - * 5x9x5 better for general colors, 6x6x6 better for grayscale. - */ -/*#define DITHER666*/ - - typedef struct gl_context GLcontext; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 628e7341916..cf8bb8bd479 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,8 +1,8 @@ -/* $Id: context.c,v 1.18 1999/11/08 07:36:43 brianp Exp $ */ +/* $Id: context.c,v 1.19 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,8 +25,6 @@ */ -/* $XFree86: xc/lib/GL/mesa/src/context.c,v 1.4 1999/04/04 00:20:21 dawes Exp $ */ - /* * If multi-threading is enabled (-DTHREADS) then each thread has it's * own rendering context. A thread obtains the pointer to its GLcontext @@ -36,42 +34,34 @@ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "accum.h" #include "alphabuf.h" -#include "api.h" #include "clip.h" #include "context.h" #include "cva.h" #include "depth.h" +#include "dispatch.h" #include "dlist.h" #include "eval.h" #include "enums.h" #include "extensions.h" #include "fog.h" +#include "glapi.h" #include "hash.h" #include "light.h" #include "lines.h" #include "dlist.h" #include "macros.h" #include "matrix.h" +#include "mem.h" #include "mmath.h" #include "pb.h" #include "pipeline.h" #include "points.h" -#include "pointers.h" #include "quads.h" #include "shade.h" #include "simple_list.h" @@ -95,40 +85,6 @@ #endif -/* - * Memory allocation functions. Called via the MALLOC, CALLOC and - * FREE macros when DEBUG symbol is defined. - * You might want to set breakpoints on these functions or plug in - * other memory allocation functions. The Mesa sources should only - * use the MALLOC and FREE macros (which could also be overriden). - * - * XXX these functions should probably go into a new glmemory.c file. - */ - -/* - * Allocate memory (uninitialized) - */ -void *gl_malloc(size_t bytes) -{ - return malloc(bytes); -} - -/* - * Allocate memory and initialize to zero. - */ -void *gl_calloc(size_t bytes) -{ - return calloc(1, bytes); -} - -/* - * Free memory - */ -void gl_free(void *ptr) -{ - free(ptr); -} - /**********************************************************************/ /***** Context and Thread management *****/ @@ -157,7 +113,7 @@ static void set_thread_context( GLcontext *ctx ) { #else /* One Current Context pointer for all threads in the address space */ -GLcontext *CC = NULL; +GLcontext *_mesa_current_context = NULL; struct immediate *CURRENT_INPUT = NULL; #endif /*THREADS*/ @@ -578,7 +534,6 @@ static void init_1d_map( struct gl_1d_map *map, int n, const float *initial ) for (i=0;i<n;i++) map->Points[i] = initial[i]; } - map->Retain = GL_FALSE; } @@ -597,10 +552,20 @@ static void init_2d_map( struct gl_2d_map *map, int n, const float *initial ) for (i=0;i<n;i++) map->Points[i] = initial[i]; } - map->Retain = GL_FALSE; } +static void init_palette( struct gl_palette *p ) +{ + p->Table[0] = 255; + p->Table[1] = 255; + p->Table[2] = 255; + p->Table[3] = 255; + p->Size = 1; + p->IntFormat = GL_RGBA; + p->Format = GL_RGBA; +} + /* * Initialize a gl_context structure to default values. @@ -929,14 +894,7 @@ static void initialize_context( GLcontext *ctx ) for (i=0; i<MAX_TEXTURE_UNITS; i++) init_texture_unit( ctx, i ); - ctx->Texture.SharedPalette = GL_FALSE; - ctx->Texture.Palette[0] = 255; - ctx->Texture.Palette[1] = 255; - ctx->Texture.Palette[2] = 255; - ctx->Texture.Palette[3] = 255; - ctx->Texture.PaletteSize = 1; - ctx->Texture.PaletteIntFormat = GL_RGBA; - ctx->Texture.PaletteFormat = GL_RGBA; + init_palette(&ctx->Texture.Palette); /* Transformation group */ ctx->Transform.MatrixMode = GL_MODELVIEW; @@ -1331,13 +1289,10 @@ GLcontext *gl_create_context( GLvisual *visual, ctx->Driver.ReadDepthSpanFloat = gl_read_depth_span_float; ctx->Driver.ReadDepthSpanInt = gl_read_depth_span_int; - - #ifdef PROFILE init_timings( ctx ); #endif -#ifdef GL_VERSION_1_1 if (!alloc_proxy_textures(ctx)) { free_shared_state(ctx, ctx->Shared); FREE(ctx->VB); @@ -1345,10 +1300,11 @@ GLcontext *gl_create_context( GLvisual *visual, FREE(ctx); return NULL; } -#endif - gl_init_api_function_pointers( ctx ); - ctx->API = ctx->Exec; /* GL_EXECUTE is default */ + /* setup API dispatch tables */ + _mesa_init_exec_table( &ctx->Exec ); + _mesa_init_dlist_table( &ctx->Save ); + ctx->CurrentDispatch = &ctx->Exec; return ctx; } @@ -1462,8 +1418,8 @@ void gl_destroy_context( GLcontext *ctx ) FREE( (void *) ctx ); #ifndef THREADS - if (ctx==CC) { - CC = NULL; + if (ctx == _mesa_current_context) { + _mesa_current_context = NULL; CURRENT_INPUT = NULL; } #endif @@ -1532,37 +1488,42 @@ void gl_destroy_framebuffer( GLframebuffer *buffer ) /* * Set the current context, binding the given frame buffer to the context. */ -void gl_make_current( GLcontext *ctx, GLframebuffer *buffer ) +void gl_make_current( GLcontext *newCtx, GLframebuffer *buffer ) { - GET_CONTEXT; + GET_CURRENT_CONTEXT(oldCtx); /* Flush the old context */ - if (CC) { - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(CC, "gl_make_current"); + if (oldCtx) { + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(oldCtx, "gl_make_current"); } #ifdef THREADS /* TODO: unbind old buffer from context? */ - set_thread_context( ctx ); + set_thread_context( newCtx ); #else - if (CC && CC->Buffer) { + if (oldCtx && oldCtx->Buffer) { /* unbind frame buffer from context */ - CC->Buffer = NULL; + oldCtx->Buffer = NULL; } - CC = ctx; - if (ctx) { - SET_IMMEDIATE(ctx, ctx->input); + _mesa_current_context = newCtx; + if (newCtx) { + SET_IMMEDIATE(newCtx, newCtx->input); } #endif + if (newCtx) + _glapi_set_dispatch(newCtx->CurrentDispatch); + else + _glapi_set_dispatch(NULL); /* none current */ + if (MESA_VERBOSE) fprintf(stderr, "gl_make_current()\n"); - if (ctx && buffer) { - /* TODO: check if ctx and buffer's visual match??? */ - ctx->Buffer = buffer; /* Bind the frame buffer to the context */ - ctx->NewState = NEW_ALL; /* just to be safe */ - gl_update_state( ctx ); + if (newCtx && buffer) { + /* TODO: check if newCtx and buffer's visual match??? */ + newCtx->Buffer = buffer; /* Bind the frame buffer to the context */ + newCtx->NewState = NEW_ALL; /* just to be safe */ + gl_update_state( newCtx ); } } @@ -1575,7 +1536,7 @@ GLcontext *gl_get_current_context( void ) #ifdef THREADS return gl_get_thread_context(); #else - return CC; + return _mesa_current_context; #endif } @@ -1659,27 +1620,74 @@ void gl_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask ) } +/* + * This should be called by device drivers just before they do a + * swapbuffers. Any pending rendering commands will be executed. + */ +void +_mesa_swapbuffers(GLcontext *ctx) +{ + FLUSH_VB( ctx, "swap buffers" ); +} + /* - * Someday a GLS library or OpenGL-like debugger may call this function - * to register it's own set of API entry points. - * Input: ctx - the context to set API pointers for - * api - if NULL, restore original API pointers - * else, set API function table to this table. + * Return pointer to this context's current API dispatch table. + * It'll either be the immediate-mode execute dispatcher or the + * display list compile dispatcher. */ -void gl_set_api_table( GLcontext *ctx, const struct gl_api_table *api ) +struct _glapi_table * +_mesa_get_dispatch(GLcontext *ctx) +{ + return ctx->CurrentDispatch; +} + + + +void +_mesa_ResizeBuffersMESA( void ) { - if (api) { - MEMCPY( &ctx->API, api, sizeof(struct gl_api_table) ); + GET_CURRENT_CONTEXT(ctx); + + GLuint buf_width, buf_height; + + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "glResizeBuffersMESA\n"); + + /* ask device driver for size of output buffer */ + (*ctx->Driver.GetBufferSize)( ctx, &buf_width, &buf_height ); + + /* see if size of device driver's color buffer (window) has changed */ + if (ctx->Buffer->Width == (GLint) buf_width && + ctx->Buffer->Height == (GLint) buf_height) + return; + + ctx->NewState |= NEW_RASTER_OPS; /* to update scissor / window bounds */ + + /* save buffer size */ + ctx->Buffer->Width = buf_width; + ctx->Buffer->Height = buf_height; + + /* Reallocate other buffers if needed. */ + if (ctx->Visual->DepthBits>0) { + /* reallocate depth buffer */ + (*ctx->Driver.AllocDepthBuffer)( ctx ); } - else { - MEMCPY( &ctx->API, &ctx->Exec, sizeof(struct gl_api_table) ); + if (ctx->Visual->StencilBits>0) { + /* reallocate stencil buffer */ + gl_alloc_stencil_buffer( ctx ); + } + if (ctx->Visual->AccumBits>0) { + /* reallocate accum buffer */ + gl_alloc_accum_buffer( ctx ); + } + if (ctx->Visual->SoftwareAlpha) { + gl_alloc_alpha_buffers( ctx ); } } - /**********************************************************************/ /***** Miscellaneous functions *****/ /**********************************************************************/ @@ -1801,66 +1809,6 @@ void gl_error( GLcontext *ctx, GLenum error, const char *s ) -/* - * Execute a glGetError command - */ -GLenum gl_GetError( GLcontext *ctx ) -{ - GLenum e = ctx->ErrorValue; - - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL( ctx, "glGetError", (GLenum) 0); - - if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glGetError <-- %s\n", gl_lookup_enum_by_nr(e)); - - ctx->ErrorValue = (GLenum) GL_NO_ERROR; - return e; -} - - - -void gl_ResizeBuffersMESA( GLcontext *ctx ) -{ - GLuint buf_width, buf_height; - - if (MESA_VERBOSE & VERBOSE_API) - fprintf(stderr, "glResizeBuffersMESA\n"); - - /* ask device driver for size of output buffer */ - (*ctx->Driver.GetBufferSize)( ctx, &buf_width, &buf_height ); - - /* see if size of device driver's color buffer (window) has changed */ - if (ctx->Buffer->Width == (GLint) buf_width && - ctx->Buffer->Height == (GLint) buf_height) - return; - - ctx->NewState |= NEW_RASTER_OPS; /* to update scissor / window bounds */ - - /* save buffer size */ - ctx->Buffer->Width = buf_width; - ctx->Buffer->Height = buf_height; - - /* Reallocate other buffers if needed. */ - if (ctx->Visual->DepthBits>0) { - /* reallocate depth buffer */ - (*ctx->Driver.AllocDepthBuffer)( ctx ); - } - if (ctx->Visual->StencilBits>0) { - /* reallocate stencil buffer */ - gl_alloc_stencil_buffer( ctx ); - } - if (ctx->Visual->AccumBits>0) { - /* reallocate accum buffer */ - gl_alloc_accum_buffer( ctx ); - } - if (ctx->Visual->SoftwareAlpha) { - gl_alloc_alpha_buffers( ctx ); - } -} - - - - /**********************************************************************/ /***** State update logic *****/ /**********************************************************************/ diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index f136da42b2d..1da01fbb79b 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -1,8 +1,8 @@ -/* $Id: context.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: context.h,v 1.2 1999/11/11 01:22:25 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef CONTEXT_H #define CONTEXT_H @@ -35,18 +32,35 @@ #include "types.h" - #ifdef THREADS /* * A seperate GLcontext for each thread */ extern GLcontext *gl_get_thread_context( void ); + +#define GET_IMMEDIATE struct immediate *IM = (gl_get_thread_context())->input; +#define SET_IMMEDIATE(ctx, im) \ +do { \ + ctx->input = im; \ +} while (0) + + #else /* * All threads use same pointer to current context. */ - extern GLcontext *CC; + extern GLcontext *_mesa_current_context; extern struct immediate *CURRENT_INPUT; + #define GET_CURRENT_CONTEXT(C) GLcontext *C = _mesa_current_context + +#define GET_IMMEDIATE struct immediate *IM = CURRENT_INPUT +#define SET_IMMEDIATE(ctx, im) \ +do { \ + ctx->input = im; \ + CURRENT_INPUT = im; \ +} while (0) + + #endif @@ -124,14 +138,18 @@ extern GLcontext *gl_get_current_context(void); extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); -extern void gl_set_api_table( GLcontext *ctx, const struct gl_api_table *api ); +extern void +_mesa_swapbuffers(GLcontext *ctx); + +extern struct _glapi_table * +_mesa_get_dispatch(GLcontext *ctx); /* * GL_MESA_resize_buffers extension */ -extern void gl_ResizeBuffersMESA( GLcontext *ctx ); +extern void _mesa_ResizeBuffersMESA( void ); @@ -146,8 +164,6 @@ extern void gl_warning( const GLcontext *ctx, const char *s ); extern void gl_error( GLcontext *ctx, GLenum error, const char *s ); extern void gl_compile_error( GLcontext *ctx, GLenum error, const char *s ); -extern GLenum gl_GetError( GLcontext *ctx ); - extern void gl_update_state( GLcontext *ctx ); diff --git a/src/mesa/main/depth.c b/src/mesa/main/depth.c index e05f1f45eba..dcd84f58480 100644 --- a/src/mesa/main/depth.c +++ b/src/mesa/main/depth.c @@ -1,8 +1,8 @@ -/* $Id: depth.c,v 1.8 1999/11/08 07:36:43 brianp Exp $ */ +/* $Id: depth.c,v 1.9 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -24,28 +24,14 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -/* $XFree86: xc/lib/GL/mesa/src/depth.c,v 1.3 1999/04/04 00:20:22 dawes Exp $ */ - -/* - * Depth buffer functions - */ - -#include <stdlib.h> - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <stdio.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "enums.h" #include "depth.h" -#include "macros.h" +#include "mem.h" #include "types.h" #endif @@ -57,8 +43,10 @@ -void gl_ClearDepth( GLcontext* ctx, GLclampd depth ) +void +_mesa_ClearDepth( GLclampd depth ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glClearDepth"); ctx->Depth.Clear = (GLfloat) CLAMP( depth, 0.0, 1.0 ); if (ctx->Driver.ClearDepth) @@ -67,8 +55,10 @@ void gl_ClearDepth( GLcontext* ctx, GLclampd depth ) -void gl_DepthFunc( GLcontext* ctx, GLenum func ) +void +_mesa_DepthFunc( GLenum func ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDepthFunc"); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) @@ -108,8 +98,10 @@ void gl_DepthFunc( GLcontext* ctx, GLenum func ) -void gl_DepthMask( GLcontext* ctx, GLboolean flag ) +void +_mesa_DepthMask( GLboolean flag ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDepthMask"); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) diff --git a/src/mesa/main/depth.h b/src/mesa/main/depth.h index 86706ee2147..9749905d2c4 100644 --- a/src/mesa/main/depth.h +++ b/src/mesa/main/depth.h @@ -1,9 +1,8 @@ - -/* $Id: depth.h,v 1.2 1999/10/08 09:27:10 keithw Exp $ */ +/* $Id: depth.h,v 1.3 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -26,9 +25,6 @@ */ - - - #ifndef DEPTH_H #define DEPTH_H @@ -90,10 +86,16 @@ extern void gl_alloc_depth_buffer( GLcontext* ctx ); extern void gl_clear_depth_buffer( GLcontext* ctx ); -extern void gl_ClearDepth( GLcontext* ctx, GLclampd depth ); -extern void gl_DepthFunc( GLcontext* ctx, GLenum func ); +extern void +_mesa_ClearDepth( GLclampd depth ); + +extern void +_mesa_DepthFunc( GLenum func ); + + +extern void +_mesa_DepthMask( GLboolean flag ); -extern void gl_DepthMask( GLcontext* ctx, GLboolean flag ); #endif diff --git a/src/mesa/main/dispatch.c b/src/mesa/main/dispatch.c new file mode 100644 index 00000000000..4aaa01559ed --- /dev/null +++ b/src/mesa/main/dispatch.c @@ -0,0 +1,546 @@ +/* $Id: dispatch.c,v 1.1 1999/11/11 01:22:26 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 3.3 + * + * Copyright (C) 1999 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. + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "glheader.h" +#include "accum.h" +#include "alpha.h" +#include "attrib.h" +#include "bitmap.h" +#include "blend.h" +#include "clip.h" +#include "context.h" +#include "colortab.h" +#include "copypix.h" +#include "cva.h" +#include "depth.h" +#include "dlist.h" +#include "drawpix.h" +#include "enable.h" +#include "eval.h" +#include "feedback.h" +#include "fog.h" +#include "get.h" +#include "glmisc.h" +#include "imaging.h" +#include "light.h" +#include "lines.h" +#include "logic.h" +#include "masking.h" +#include "matrix.h" +#include "pixel.h" +#include "points.h" +#include "polygon.h" +#include "rastpos.h" +#include "readpix.h" +#include "rect.h" +#include "scissor.h" +#include "stencil.h" +#include "teximage.h" +#include "texobj.h" +#include "texstate.h" +#include "types.h" +#include "varray.h" +#include "vbfill.h" +#include "winpos.h" +#endif + + +/* + * Initialize the given dispatch table with pointers to Mesa's + * immediate-mode commands. + */ +void +_mesa_init_exec_table(struct _glapi_table *exec) +{ + exec->Accum = _mesa_Accum; + exec->AlphaFunc = _mesa_AlphaFunc; + exec->Begin = _mesa_Begin; + exec->Bitmap = _mesa_Bitmap; + exec->BlendFunc = _mesa_BlendFunc; + exec->CallList = _mesa_CallList; + exec->CallLists = _mesa_CallLists; + exec->Clear = _mesa_Clear; + exec->ClearAccum = _mesa_ClearAccum; + exec->ClearColor = _mesa_ClearColor; + exec->ClearDepth = _mesa_ClearDepth; + exec->ClearIndex = _mesa_ClearIndex; + exec->ClearStencil = _mesa_ClearStencil; + exec->ClipPlane = _mesa_ClipPlane; + exec->Color3b = _mesa_Color3b; + exec->Color3bv = _mesa_Color3bv; + exec->Color3d = _mesa_Color3d; + exec->Color3dv = _mesa_Color3dv; + exec->Color3f = _mesa_Color3f; + exec->Color3fv = _mesa_Color3fv; + exec->Color3i = _mesa_Color3i; + exec->Color3iv = _mesa_Color3iv; + exec->Color3s = _mesa_Color3s; + exec->Color3sv = _mesa_Color3sv; + exec->Color3ub = _mesa_Color3ub; + exec->Color3ubv = _mesa_Color3ubv; + exec->Color3ui = _mesa_Color3ui; + exec->Color3uiv = _mesa_Color3uiv; + exec->Color3us = _mesa_Color3us; + exec->Color3usv = _mesa_Color3usv; + exec->Color4b = _mesa_Color4b; + exec->Color4bv = _mesa_Color4bv; + exec->Color4d = _mesa_Color4d; + exec->Color4dv = _mesa_Color4dv; + exec->Color4f = _mesa_Color4f; + exec->Color4fv = _mesa_Color4fv; + exec->Color4i = _mesa_Color4i; + exec->Color4iv = _mesa_Color4iv; + exec->Color4s = _mesa_Color4s; + exec->Color4sv = _mesa_Color4sv; + exec->Color4ub = _mesa_Color4ub; + exec->Color4ubv = _mesa_Color4ubv; + exec->Color4ui = _mesa_Color4ui; + exec->Color4uiv = _mesa_Color4uiv; + exec->Color4us = _mesa_Color4us; + exec->Color4usv = _mesa_Color4usv; + exec->ColorMask = _mesa_ColorMask; + exec->ColorMaterial = _mesa_ColorMaterial; + exec->CopyPixels = _mesa_CopyPixels; + exec->CullFace = _mesa_CullFace; + exec->DeleteLists = _mesa_DeleteLists; + exec->DepthFunc = _mesa_DepthFunc; + exec->DepthMask = _mesa_DepthMask; + exec->DepthRange = _mesa_DepthRange; + exec->Disable = _mesa_Disable; + exec->DrawBuffer = _mesa_DrawBuffer; + exec->DrawPixels = _mesa_DrawPixels; + exec->EdgeFlag = _mesa_EdgeFlag; + exec->EdgeFlagv = _mesa_EdgeFlagv; + exec->Enable = _mesa_Enable; + exec->End = _mesa_End; + exec->EndList = _mesa_EndList; + exec->EvalCoord1d = _mesa_EvalCoord1d; + exec->EvalCoord1dv = _mesa_EvalCoord1dv; + exec->EvalCoord1f = _mesa_EvalCoord1f; + exec->EvalCoord1fv = _mesa_EvalCoord1fv; + exec->EvalCoord2d = _mesa_EvalCoord2d; + exec->EvalCoord2dv = _mesa_EvalCoord2dv; + exec->EvalCoord2f = _mesa_EvalCoord2f; + exec->EvalCoord2fv = _mesa_EvalCoord2fv; + exec->EvalMesh1 = _mesa_EvalMesh1; + exec->EvalMesh2 = _mesa_EvalMesh2; + exec->EvalPoint1 = _mesa_EvalPoint1; + exec->EvalPoint2 = _mesa_EvalPoint2; + exec->FeedbackBuffer = _mesa_FeedbackBuffer; + exec->Finish = _mesa_Finish; + exec->Flush = _mesa_Flush; + exec->Fogf = _mesa_Fogf; + exec->Fogfv = _mesa_Fogfv; + exec->Fogi = _mesa_Fogi; + exec->Fogiv = _mesa_Fogiv; + exec->FrontFace = _mesa_FrontFace; + exec->Frustum = _mesa_Frustum; + exec->GenLists = _mesa_GenLists; + exec->GetBooleanv = _mesa_GetBooleanv; + exec->GetClipPlane = _mesa_GetClipPlane; + exec->GetDoublev = _mesa_GetDoublev; + exec->GetError = _mesa_GetError; + exec->GetFloatv = _mesa_GetFloatv; + exec->GetIntegerv = _mesa_GetIntegerv; + exec->GetLightfv = _mesa_GetLightfv; + exec->GetLightiv = _mesa_GetLightiv; + exec->GetMapdv = _mesa_GetMapdv; + exec->GetMapfv = _mesa_GetMapfv; + exec->GetMapiv = _mesa_GetMapiv; + exec->GetMaterialfv = _mesa_GetMaterialfv; + exec->GetMaterialiv = _mesa_GetMaterialiv; + exec->GetPixelMapfv = _mesa_GetPixelMapfv; + exec->GetPixelMapuiv = _mesa_GetPixelMapuiv; + exec->GetPixelMapusv = _mesa_GetPixelMapusv; + exec->GetPolygonStipple = _mesa_GetPolygonStipple; + exec->GetString = _mesa_GetString; + exec->GetTexEnvfv = _mesa_GetTexEnvfv; + exec->GetTexEnviv = _mesa_GetTexEnviv; + exec->GetTexGendv = _mesa_GetTexGendv; + exec->GetTexGenfv = _mesa_GetTexGenfv; + exec->GetTexGeniv = _mesa_GetTexGeniv; + exec->GetTexImage = _mesa_GetTexImage; + exec->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv; + exec->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv; + exec->GetTexParameterfv = _mesa_GetTexParameterfv; + exec->GetTexParameteriv = _mesa_GetTexParameteriv; + exec->Hint = _mesa_Hint; + exec->IndexMask = _mesa_IndexMask; + exec->Indexd = _mesa_Indexd; + exec->Indexdv = _mesa_Indexdv; + exec->Indexf = _mesa_Indexf; + exec->Indexfv = _mesa_Indexfv; + exec->Indexi = _mesa_Indexi; + exec->Indexiv = _mesa_Indexiv; + exec->Indexs = _mesa_Indexs; + exec->Indexsv = _mesa_Indexsv; + exec->InitNames = _mesa_InitNames; + exec->IsEnabled = _mesa_IsEnabled; + exec->IsList = _mesa_IsList; + exec->LightModelf = _mesa_LightModelf; + exec->LightModelfv = _mesa_LightModelfv; + exec->LightModeli = _mesa_LightModeli; + exec->LightModeliv = _mesa_LightModeliv; + exec->Lightf = _mesa_Lightf; + exec->Lightfv = _mesa_Lightfv; + exec->Lighti = _mesa_Lighti; + exec->Lightiv = _mesa_Lightiv; + exec->LineStipple = _mesa_LineStipple; + exec->LineWidth = _mesa_LineWidth; + exec->ListBase = _mesa_ListBase; + exec->LoadIdentity = _mesa_LoadIdentity; + exec->LoadMatrixd = _mesa_LoadMatrixd; + exec->LoadMatrixf = _mesa_LoadMatrixf; + exec->LoadName = _mesa_LoadName; + exec->LogicOp = _mesa_LogicOp; + exec->Map1d = _mesa_Map1d; + exec->Map1f = _mesa_Map1f; + exec->Map2d = _mesa_Map2d; + exec->Map2f = _mesa_Map2f; + exec->MapGrid1d = _mesa_MapGrid1d; + exec->MapGrid1f = _mesa_MapGrid1f; + exec->MapGrid2d = _mesa_MapGrid2d; + exec->MapGrid2f = _mesa_MapGrid2f; + exec->Materialf = _mesa_Materialf; + exec->Materialfv = _mesa_Materialfv; + exec->Materiali = _mesa_Materiali; + exec->Materialiv = _mesa_Materialiv; + exec->MatrixMode = _mesa_MatrixMode; + exec->MultMatrixd = _mesa_MultMatrixd; + exec->MultMatrixf = _mesa_MultMatrixf; + exec->NewList = _mesa_NewList; + exec->Normal3b = _mesa_Normal3b; + exec->Normal3bv = _mesa_Normal3bv; + exec->Normal3d = _mesa_Normal3d; + exec->Normal3dv = _mesa_Normal3dv; + exec->Normal3f = _mesa_Normal3f; + exec->Normal3fv = _mesa_Normal3fv; + exec->Normal3i = _mesa_Normal3i; + exec->Normal3iv = _mesa_Normal3iv; + exec->Normal3s = _mesa_Normal3s; + exec->Normal3sv = _mesa_Normal3sv; + exec->Ortho = _mesa_Ortho; + exec->PassThrough = _mesa_PassThrough; + exec->PixelMapfv = _mesa_PixelMapfv; + exec->PixelMapuiv = _mesa_PixelMapuiv; + exec->PixelMapusv = _mesa_PixelMapusv; + exec->PixelStoref = _mesa_PixelStoref; + exec->PixelStorei = _mesa_PixelStorei; + exec->PixelTransferf = _mesa_PixelTransferf; + exec->PixelTransferi = _mesa_PixelTransferi; + exec->PixelZoom = _mesa_PixelZoom; + exec->PointSize = _mesa_PointSize; + exec->PolygonMode = _mesa_PolygonMode; + exec->PolygonOffset = _mesa_PolygonOffset; + exec->PolygonStipple = _mesa_PolygonStipple; + exec->PopAttrib = _mesa_PopAttrib; + exec->PopMatrix = _mesa_PopMatrix; + exec->PopName = _mesa_PopName; + exec->PushAttrib = _mesa_PushAttrib; + exec->PushMatrix = _mesa_PushMatrix; + exec->PushName = _mesa_PushName; + exec->RasterPos2d = _mesa_RasterPos2d; + exec->RasterPos2dv = _mesa_RasterPos2dv; + exec->RasterPos2f = _mesa_RasterPos2f; + exec->RasterPos2fv = _mesa_RasterPos2fv; + exec->RasterPos2i = _mesa_RasterPos2i; + exec->RasterPos2iv = _mesa_RasterPos2iv; + exec->RasterPos2s = _mesa_RasterPos2s; + exec->RasterPos2sv = _mesa_RasterPos2sv; + exec->RasterPos3d = _mesa_RasterPos3d; + exec->RasterPos3dv = _mesa_RasterPos3dv; + exec->RasterPos3f = _mesa_RasterPos3f; + exec->RasterPos3fv = _mesa_RasterPos3fv; + exec->RasterPos3i = _mesa_RasterPos3i; + exec->RasterPos3iv = _mesa_RasterPos3iv; + exec->RasterPos3s = _mesa_RasterPos3s; + exec->RasterPos3sv = _mesa_RasterPos3sv; + exec->RasterPos4d = _mesa_RasterPos4d; + exec->RasterPos4dv = _mesa_RasterPos4dv; + exec->RasterPos4f = _mesa_RasterPos4f; + exec->RasterPos4fv = _mesa_RasterPos4fv; + exec->RasterPos4i = _mesa_RasterPos4i; + exec->RasterPos4iv = _mesa_RasterPos4iv; + exec->RasterPos4s = _mesa_RasterPos4s; + exec->RasterPos4sv = _mesa_RasterPos4sv; + exec->ReadBuffer = _mesa_ReadBuffer; + exec->ReadPixels = _mesa_ReadPixels; + exec->Rectd = _mesa_Rectd; + exec->Rectdv = _mesa_Rectdv; + exec->Rectf = _mesa_Rectf; + exec->Rectfv = _mesa_Rectfv; + exec->Recti = _mesa_Recti; + exec->Rectiv = _mesa_Rectiv; + exec->Rects = _mesa_Rects; + exec->Rectsv = _mesa_Rectsv; + exec->RenderMode = _mesa_RenderMode; + exec->Rotated = _mesa_Rotated; + exec->Rotatef = _mesa_Rotatef; + exec->Scaled = _mesa_Scaled; + exec->Scalef = _mesa_Scalef; + exec->Scissor = _mesa_Scissor; + exec->SelectBuffer = _mesa_SelectBuffer; + exec->ShadeModel = _mesa_ShadeModel; + exec->StencilFunc = _mesa_StencilFunc; + exec->StencilMask = _mesa_StencilMask; + exec->StencilOp = _mesa_StencilOp; + exec->TexCoord1d = _mesa_TexCoord1d; + exec->TexCoord1dv = _mesa_TexCoord1dv; + exec->TexCoord1f = _mesa_TexCoord1f; + exec->TexCoord1fv = _mesa_TexCoord1fv; + exec->TexCoord1i = _mesa_TexCoord1i; + exec->TexCoord1iv = _mesa_TexCoord1iv; + exec->TexCoord1s = _mesa_TexCoord1s; + exec->TexCoord1sv = _mesa_TexCoord1sv; + exec->TexCoord2d = _mesa_TexCoord2d; + exec->TexCoord2dv = _mesa_TexCoord2dv; + exec->TexCoord2f = _mesa_TexCoord2f; + exec->TexCoord2fv = _mesa_TexCoord2fv; + exec->TexCoord2i = _mesa_TexCoord2i; + exec->TexCoord2iv = _mesa_TexCoord2iv; + exec->TexCoord2s = _mesa_TexCoord2s; + exec->TexCoord2sv = _mesa_TexCoord2sv; + exec->TexCoord3d = _mesa_TexCoord3d; + exec->TexCoord3dv = _mesa_TexCoord3dv; + exec->TexCoord3f = _mesa_TexCoord3f; + exec->TexCoord3fv = _mesa_TexCoord3fv; + exec->TexCoord3i = _mesa_TexCoord3i; + exec->TexCoord3iv = _mesa_TexCoord3iv; + exec->TexCoord3s = _mesa_TexCoord3s; + exec->TexCoord3sv = _mesa_TexCoord3sv; + exec->TexCoord4d = _mesa_TexCoord4d; + exec->TexCoord4dv = _mesa_TexCoord4dv; + exec->TexCoord4f = _mesa_TexCoord4f; + exec->TexCoord4fv = _mesa_TexCoord4fv; + exec->TexCoord4i = _mesa_TexCoord4i; + exec->TexCoord4iv = _mesa_TexCoord4iv; + exec->TexCoord4s = _mesa_TexCoord4s; + exec->TexCoord4sv = _mesa_TexCoord4sv; + exec->TexEnvf = _mesa_TexEnvf; + exec->TexEnvfv = _mesa_TexEnvfv; + exec->TexEnvi = _mesa_TexEnvi; + exec->TexEnviv = _mesa_TexEnviv; + exec->TexGend = _mesa_TexGend; + exec->TexGendv = _mesa_TexGendv; + exec->TexGenf = _mesa_TexGenf; + exec->TexGenfv = _mesa_TexGenfv; + exec->TexGeni = _mesa_TexGeni; + exec->TexGeniv = _mesa_TexGeniv; + exec->TexImage1D = _mesa_TexImage1D; + exec->TexImage2D = _mesa_TexImage2D; + exec->TexParameterf = _mesa_TexParameterf; + exec->TexParameterfv = _mesa_TexParameterfv; + exec->TexParameteri = _mesa_TexParameteri; + exec->TexParameteriv = _mesa_TexParameteriv; + exec->Translated = _mesa_Translated; + exec->Translatef = _mesa_Translatef; + exec->Vertex2d = _mesa_Vertex2d; + exec->Vertex2dv = _mesa_Vertex2dv; + exec->Vertex2f = _mesa_Vertex2f; + exec->Vertex2fv = _mesa_Vertex2fv; + exec->Vertex2i = _mesa_Vertex2i; + exec->Vertex2iv = _mesa_Vertex2iv; + exec->Vertex2s = _mesa_Vertex2s; + exec->Vertex2sv = _mesa_Vertex2sv; + exec->Vertex3d = _mesa_Vertex3d; + exec->Vertex3dv = _mesa_Vertex3dv; + exec->Vertex3f = _mesa_Vertex3f; + exec->Vertex3fv = _mesa_Vertex3fv; + exec->Vertex3i = _mesa_Vertex3i; + exec->Vertex3iv = _mesa_Vertex3iv; + exec->Vertex3s = _mesa_Vertex3s; + exec->Vertex3sv = _mesa_Vertex3sv; + exec->Vertex4d = _mesa_Vertex4d; + exec->Vertex4dv = _mesa_Vertex4dv; + exec->Vertex4f = _mesa_Vertex4f; + exec->Vertex4fv = _mesa_Vertex4fv; + exec->Vertex4i = _mesa_Vertex4i; + exec->Vertex4iv = _mesa_Vertex4iv; + exec->Vertex4s = _mesa_Vertex4s; + exec->Vertex4sv = _mesa_Vertex4sv; + exec->Viewport = _mesa_Viewport; + +#ifdef _GLAPI_VERSION_1_1 + exec->AreTexturesResident = _mesa_AreTexturesResident; + exec->ArrayElement = _mesa_ArrayElement; + exec->BindTexture = _mesa_BindTexture; + exec->ColorPointer = _mesa_ColorPointer; + exec->CopyTexImage1D = _mesa_CopyTexImage1D; + exec->CopyTexImage2D = _mesa_CopyTexImage2D; + exec->CopyTexSubImage1D = _mesa_CopyTexSubImage1D; + exec->CopyTexSubImage2D = _mesa_CopyTexSubImage2D; + exec->DeleteTextures = _mesa_DeleteTextures; + exec->DisableClientState = _mesa_DisableClientState; + exec->DrawArrays = _mesa_DrawArrays; + exec->DrawElements = _mesa_DrawElements; + exec->EdgeFlagPointer = _mesa_EdgeFlagPointer; + exec->EnableClientState = _mesa_EnableClientState; + exec->GenTextures = _mesa_GenTextures; + exec->GetPointerv = _mesa_GetPointerv; + exec->IndexPointer = _mesa_IndexPointer; + exec->Indexub = _mesa_Indexub; + exec->Indexubv = _mesa_Indexubv; + exec->InterleavedArrays = _mesa_InterleavedArrays; + exec->IsTexture = _mesa_IsTexture; + exec->NormalPointer = _mesa_NormalPointer; + exec->PopClientAttrib = _mesa_PopClientAttrib; + exec->PrioritizeTextures = _mesa_PrioritizeTextures; + exec->PushClientAttrib = _mesa_PushClientAttrib; + exec->TexCoordPointer = _mesa_TexCoordPointer; + exec->TexSubImage1D = _mesa_TexSubImage1D; + exec->TexSubImage2D = _mesa_TexSubImage2D; + exec->VertexPointer = _mesa_VertexPointer; +#endif + +#ifdef _GLAPI_VERSION_1_2 + exec->CopyTexSubImage3D = _mesa_CopyTexSubImage3D; + exec->DrawRangeElements = _mesa_DrawRangeElements; + exec->TexImage3D = _mesa_TexImage3D; + exec->TexSubImage3D = _mesa_TexSubImage3D; +#endif + + /* OpenGL 1.2 GL_ARB_imaging */ +#ifdef _GLAPI_ARB_imaging + exec->BlendColor = _mesa_BlendColor; + exec->BlendEquation = _mesa_BlendEquation; + exec->ColorSubTable = _mesa_ColorSubTable; + exec->ColorTable = _mesa_ColorTable; + exec->ColorTableParameterfv = _mesa_ColorTableParameterfv; + exec->ColorTableParameteriv = _mesa_ColorTableParameteriv; + exec->ConvolutionFilter1D = _mesa_ConvolutionFilter1D; + exec->ConvolutionFilter2D = _mesa_ConvolutionFilter2D; + exec->ConvolutionParameterf = _mesa_ConvolutionParameterf; + exec->ConvolutionParameterfv = _mesa_ConvolutionParameterfv; + exec->ConvolutionParameteri = _mesa_ConvolutionParameteri; + exec->ConvolutionParameteriv = _mesa_ConvolutionParameteriv; + exec->CopyColorSubTable = _mesa_CopyColorSubTable; + exec->CopyColorTable = _mesa_CopyColorTable; + exec->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D; + exec->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D; + exec->GetColorTable = _mesa_GetColorTable; + exec->GetColorTableParameterfv = _mesa_GetColorTableParameterfv; + exec->GetColorTableParameteriv = _mesa_GetColorTableParameteriv; + exec->GetConvolutionFilter = _mesa_GetConvolutionFilter; + exec->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv; + exec->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv; + exec->GetHistogram = _mesa_GetHistogram; + exec->GetHistogramParameterfv = _mesa_GetHistogramParameterfv; + exec->GetHistogramParameteriv = _mesa_GetHistogramParameteriv; + exec->GetMinmax = _mesa_GetMinmax; + exec->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv; + exec->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv; + exec->GetSeparableFilter = _mesa_GetSeparableFilter; + exec->Histogram = _mesa_Histogram; + exec->Minmax = _mesa_Minmax; + exec->ResetHistogram = _mesa_ResetHistogram; + exec->ResetMinmax = _mesa_ResetMinmax; + exec->SeparableFilter2D = _mesa_SeparableFilter2D; +#endif + +#ifdef _GLAPI_EXT_color_table + exec->ColorTableEXT = _mesa_ColorTable; + exec->ColorSubTableEXT = _mesa_ColorSubTable; + exec->GetColorTableEXT = _mesa_GetColorTable; + exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; + exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; +#endif + +#ifdef _GLAPI_EXT_compiled_vertex_array + exec->LockArraysEXT = _mesa_LockArraysEXT; + exec->UnlockArraysEXT = _mesa_UnlockArraysEXT; +#endif + +#ifdef _GLAPI_EXT_point_parameters + exec->PointParameterfEXT = _mesa_PointParameterfEXT; + exec->PointParameterfvEXT = _mesa_PointParameterfvEXT; +#endif + +#ifdef _GLAPI_EXT_polygon_offset + exec->PolygonOffsetEXT = _mesa_PolygonOffsetEXT; +#endif + +#ifdef _GLAPI_EXT_blend_minmax + exec->BlendEquationEXT = _mesa_BlendEquationEXT; +#endif + +#ifdef _GLAPI_EXT_blend_color + exec->BlendColorEXT = _mesa_BlendColorEXT; +#endif + +#ifdef _GLAPI_ARB_multitexture + exec->ActiveTextureARB = _mesa_ActiveTextureARB; + exec->ClientActiveTextureARB = _mesa_ClientActiveTextureARB; + exec->MultiTexCoord1dARB = _mesa_MultiTexCoord1dARB; + exec->MultiTexCoord1dvARB = _mesa_MultiTexCoord1dvARB; + exec->MultiTexCoord1fARB = _mesa_MultiTexCoord1fARB; + exec->MultiTexCoord1fvARB = _mesa_MultiTexCoord1fvARB; + exec->MultiTexCoord1iARB = _mesa_MultiTexCoord1iARB; + exec->MultiTexCoord1ivARB = _mesa_MultiTexCoord1ivARB; + exec->MultiTexCoord1sARB = _mesa_MultiTexCoord1sARB; + exec->MultiTexCoord1svARB = _mesa_MultiTexCoord1svARB; + exec->MultiTexCoord2dARB = _mesa_MultiTexCoord2dARB; + exec->MultiTexCoord2dvARB = _mesa_MultiTexCoord2dvARB; + exec->MultiTexCoord2fARB = _mesa_MultiTexCoord2fARB; + exec->MultiTexCoord2fvARB = _mesa_MultiTexCoord2fvARB; + exec->MultiTexCoord2iARB = _mesa_MultiTexCoord2iARB; + exec->MultiTexCoord2ivARB = _mesa_MultiTexCoord2ivARB; + exec->MultiTexCoord2sARB = _mesa_MultiTexCoord2sARB; + exec->MultiTexCoord2svARB = _mesa_MultiTexCoord2svARB; + exec->MultiTexCoord3dARB = _mesa_MultiTexCoord3dARB; + exec->MultiTexCoord3dvARB = _mesa_MultiTexCoord3dvARB; + exec->MultiTexCoord3fARB = _mesa_MultiTexCoord3fARB; + exec->MultiTexCoord3fvARB = _mesa_MultiTexCoord3fvARB; + exec->MultiTexCoord3iARB = _mesa_MultiTexCoord3iARB; + exec->MultiTexCoord3ivARB = _mesa_MultiTexCoord3ivARB; + exec->MultiTexCoord3sARB = _mesa_MultiTexCoord3sARB; + exec->MultiTexCoord3svARB = _mesa_MultiTexCoord3svARB; + exec->MultiTexCoord4dARB = _mesa_MultiTexCoord4dARB; + exec->MultiTexCoord4dvARB = _mesa_MultiTexCoord4dvARB; + exec->MultiTexCoord4fARB = _mesa_MultiTexCoord4fARB; + exec->MultiTexCoord4fvARB = _mesa_MultiTexCoord4fvARB; + exec->MultiTexCoord4iARB = _mesa_MultiTexCoord4iARB; + exec->MultiTexCoord4ivARB = _mesa_MultiTexCoord4ivARB; + exec->MultiTexCoord4sARB = _mesa_MultiTexCoord4sARB; + exec->MultiTexCoord4svARB = _mesa_MultiTexCoord4svARB; +#endif + +#ifdef _GLAPI_INGR_blend_func_separate + exec->BlendFuncSeparateINGR = _mesa_BlendFuncSeparateINGR; +#endif + +#ifdef _GLAPI_MESA_window_pos + exec->WindowPos4fMESA = _mesa_WindowPos4fMESA; +#endif + +#ifdef _GLAPI_MESA_resize_buffers + exec->ResizeBuffersMESA = _mesa_ResizeBuffersMESA; +#endif +} + diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index c3d3167f618..5e8c203d886 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -1,8 +1,8 @@ -/* $Id: dlist.c,v 1.15 1999/11/09 17:00:25 keithw Exp $ */ +/* $Id: dlist.c,v 1.16 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,21 +25,11 @@ */ -/* $XFree86: xc/lib/GL/mesa/src/dlist.c,v 1.3 1999/04/04 00:20:22 dawes Exp $ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "accum.h" -#include "api.h" #include "alpha.h" #include "attrib.h" #include "bitmap.h" @@ -49,6 +39,7 @@ #include "colortab.h" #include "context.h" #include "copypix.h" +#include "cva.h" #include "depth.h" #include "drawpix.h" #include "enable.h" @@ -61,6 +52,7 @@ #include "glmisc.h" #include "hash.h" #include "image.h" +#include "imaging.h" #include "light.h" #include "lines.h" #include "dlist.h" @@ -68,6 +60,7 @@ #include "macros.h" #include "masking.h" #include "matrix.h" +#include "mem.h" #include "pipeline.h" #include "pixel.h" #include "points.h" @@ -159,7 +152,6 @@ typedef enum { OPCODE_COPY_PIXELS, OPCODE_COPY_TEX_IMAGE1D, OPCODE_COPY_TEX_IMAGE2D, - OPCODE_COPY_TEX_IMAGE3D, OPCODE_COPY_TEX_SUB_IMAGE1D, OPCODE_COPY_TEX_SUB_IMAGE2D, OPCODE_COPY_TEX_SUB_IMAGE3D, @@ -357,27 +349,27 @@ void gl_destroy_list( GLcontext *ctx, GLuint list ) n += InstSize[n[0].opcode]; break; case OPCODE_MAP1: - gl_free_control_points( ctx, n[1].e, (GLfloat *) n[6].data ); + FREE(n[6].data); n += InstSize[n[0].opcode]; break; case OPCODE_MAP2: - gl_free_control_points( ctx, n[1].e, (GLfloat *) n[10].data ); + FREE(n[10].data); n += InstSize[n[0].opcode]; break; case OPCODE_DRAW_PIXELS: - gl_free_image( (struct gl_image *) n[1].data ); + FREE( n[5].data ); n += InstSize[n[0].opcode]; break; case OPCODE_BITMAP: - gl_free_image( (struct gl_image *) n[7].data ); + FREE( n[7].data ); n += InstSize[n[0].opcode]; break; case OPCODE_COLOR_TABLE: - gl_free_image( (struct gl_image *) n[3].data ); + FREE( n[6].data ); n += InstSize[n[0].opcode]; break; case OPCODE_COLOR_SUB_TABLE: - gl_free_image( (struct gl_image *) n[3].data ); + FREE( n[6].data ); n += InstSize[n[0].opcode]; break; case OPCODE_POLYGON_STIPPLE: @@ -385,27 +377,27 @@ void gl_destroy_list( GLcontext *ctx, GLuint list ) n += InstSize[n[0].opcode]; break; case OPCODE_TEX_IMAGE1D: - FREE( n[8]. data ); + FREE(n[8].data); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_IMAGE2D: - FREE( n[9].data ); + FREE( n[9]. data ); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_IMAGE3D: - FREE( n[10].data ); + FREE( n[10]. data ); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_SUB_IMAGE1D: - FREE( n[7].data ); + FREE(n[7].data); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_SUB_IMAGE2D: - FREE( n[9].data ); + FREE(n[9].data); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_SUB_IMAGE3D: - FREE( n[11].data ); + FREE(n[11].data); n += InstSize[n[0].opcode]; break; case OPCODE_CONTINUE: @@ -514,8 +506,8 @@ void gl_init_lists( void ) InstSize[OPCODE_CLIP_PLANE] = 6; InstSize[OPCODE_COLOR_MASK] = 5; InstSize[OPCODE_COLOR_MATERIAL] = 3; - InstSize[OPCODE_COLOR_TABLE] = 4; - InstSize[OPCODE_COLOR_SUB_TABLE] = 4; + InstSize[OPCODE_COLOR_TABLE] = 7; + InstSize[OPCODE_COLOR_SUB_TABLE] = 7; InstSize[OPCODE_COPY_PIXELS] = 6; InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8; InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9; @@ -528,7 +520,7 @@ void gl_init_lists( void ) InstSize[OPCODE_DEPTH_RANGE] = 3; InstSize[OPCODE_DISABLE] = 2; InstSize[OPCODE_DRAW_BUFFER] = 2; - InstSize[OPCODE_DRAW_PIXELS] = 2; + InstSize[OPCODE_DRAW_PIXELS] = 6; InstSize[OPCODE_ENABLE] = 2; InstSize[OPCODE_EVALCOORD1] = 2; InstSize[OPCODE_EVALCOORD2] = 3; @@ -613,8 +605,9 @@ void gl_init_lists( void ) -static void save_Accum( GLcontext *ctx, GLenum op, GLfloat value ) +static void save_Accum( GLenum op, GLfloat value ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_ACCUM, 2 ); @@ -623,13 +616,14 @@ static void save_Accum( GLcontext *ctx, GLenum op, GLfloat value ) n[2].f = value; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Accum)( ctx, op, value ); + (*ctx->Exec.Accum)( op, value ); } } -static void save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref ) +static void save_AlphaFunc( GLenum func, GLclampf ref ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 ); @@ -638,12 +632,20 @@ static void save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref ) n[2].f = (GLfloat) ref; } if (ctx->ExecuteFlag) { - (*ctx->Exec.AlphaFunc)( ctx, func, ref ); + (*ctx->Exec.AlphaFunc)( func, ref ); } } -static void save_BindTexture( GLcontext *ctx, GLenum target, GLuint texture ) + +static void save_Begin( GLenum mode ) +{ + _mesa_Begin(mode); /* special case */ +} + + +static void save_BindTexture( GLenum target, GLuint texture ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 ); @@ -652,44 +654,43 @@ static void save_BindTexture( GLcontext *ctx, GLenum target, GLuint texture ) n[2].ui = texture; } if (ctx->ExecuteFlag) { - (*ctx->Exec.BindTexture)( ctx, target, texture ); + (*ctx->Exec.BindTexture)( target, texture ); } } -static void save_Bitmap( GLcontext *ctx, - GLsizei width, GLsizei height, +static void save_Bitmap( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, - const GLubyte *bitmap, - const struct gl_pixelstore_attrib *packing ) + const GLubyte *pixels ) { + GET_CURRENT_CONTEXT(ctx); + GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack ); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_BITMAP, 7 ); if (n) { - struct gl_image *image = gl_unpack_bitmap( ctx, width, height, - bitmap, packing ); - if (image) { - image->RefCount = 1; - } n[1].i = (GLint) width; n[2].i = (GLint) height; n[3].f = xorig; n[4].f = yorig; n[5].f = xmove; n[6].f = ymove; - n[7].data = (void *) image; + n[7].data = image; + } + else if (image) { + FREE(image); } if (ctx->ExecuteFlag) { - (*ctx->Exec.Bitmap)( ctx, width, height, - xorig, yorig, xmove, ymove, bitmap, packing ); + (*ctx->Exec.Bitmap)( width, height, + xorig, yorig, xmove, ymove, pixels ); } } -static void save_BlendEquation( GLcontext *ctx, GLenum mode ) +static void save_BlendEquation( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_BLEND_EQUATION, 1 ); @@ -697,13 +698,14 @@ static void save_BlendEquation( GLcontext *ctx, GLenum mode ) n[1].e = mode; } if (ctx->ExecuteFlag) { - (*ctx->Exec.BlendEquation)( ctx, mode ); + (*ctx->Exec.BlendEquationEXT)( mode ); } } -static void save_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor ) +static void save_BlendFunc( GLenum sfactor, GLenum dfactor ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 ); @@ -712,15 +714,15 @@ static void save_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor ) n[2].e = dfactor; } if (ctx->ExecuteFlag) { - (*ctx->Exec.BlendFunc)( ctx, sfactor, dfactor ); + (*ctx->Exec.BlendFunc)( sfactor, dfactor ); } } -static void save_BlendFuncSeparate( GLcontext *ctx, - GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorA, GLenum dfactorA) +static void save_BlendFuncSeparateINGR(GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorA, GLenum dfactorA) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 ); @@ -731,15 +733,16 @@ static void save_BlendFuncSeparate( GLcontext *ctx, n[4].e = dfactorA; } if (ctx->ExecuteFlag) { - (*ctx->Exec.BlendFuncSeparate)( ctx, sfactorRGB, dfactorRGB, - sfactorA, dfactorA); + (*ctx->Exec.BlendFuncSeparateINGR)( sfactorRGB, dfactorRGB, + sfactorA, dfactorA); } } -static void save_BlendColor( GLcontext *ctx, GLfloat red, GLfloat green, - GLfloat blue, GLfloat alpha ) +static void save_BlendColor( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 ); @@ -750,13 +753,14 @@ static void save_BlendColor( GLcontext *ctx, GLfloat red, GLfloat green, n[4].f = alpha; } if (ctx->ExecuteFlag) { - (*ctx->Exec.BlendColor)( ctx, red, green, blue, alpha ); + (*ctx->Exec.BlendColorEXT)( red, green, blue, alpha ); } } -static void save_CallList( GLcontext *ctx, GLuint list ) +static void save_CallList( GLuint list ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 ); @@ -764,14 +768,14 @@ static void save_CallList( GLcontext *ctx, GLuint list ) n[1].ui = list; } if (ctx->ExecuteFlag) { - (*ctx->Exec.CallList)( ctx, list ); + (*ctx->Exec.CallList)( list ); } } -static void save_CallLists( GLcontext *ctx, - GLsizei n, GLenum type, const GLvoid *lists ) +static void save_CallLists( GLsizei n, GLenum type, const GLvoid *lists ) { + GET_CURRENT_CONTEXT(ctx); GLint i; FLUSH_VB(ctx, "dlist"); @@ -783,13 +787,14 @@ static void save_CallLists( GLcontext *ctx, } } if (ctx->ExecuteFlag) { - (*ctx->Exec.CallLists)( ctx, n, type, lists ); + (*ctx->Exec.CallLists)( n, type, lists ); } } -static void save_Clear( GLcontext *ctx, GLbitfield mask ) +static void save_Clear( GLbitfield mask ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_CLEAR, 1 ); @@ -797,14 +802,15 @@ static void save_Clear( GLcontext *ctx, GLbitfield mask ) n[1].bf = mask; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Clear)( ctx, mask ); + (*ctx->Exec.Clear)( mask ); } } -static void save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green, - GLfloat blue, GLfloat alpha ) +static void save_ClearAccum( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 ); @@ -815,14 +821,15 @@ static void save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green, n[4].f = alpha; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ClearAccum)( ctx, red, green, blue, alpha ); + (*ctx->Exec.ClearAccum)( red, green, blue, alpha ); } } -static void save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green, - GLclampf blue, GLclampf alpha ) +static void save_ClearColor( GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 ); @@ -833,13 +840,14 @@ static void save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green, n[4].f = alpha; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ClearColor)( ctx, red, green, blue, alpha ); + (*ctx->Exec.ClearColor)( red, green, blue, alpha ); } } -static void save_ClearDepth( GLcontext *ctx, GLclampd depth ) +static void save_ClearDepth( GLclampd depth ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 ); @@ -847,13 +855,14 @@ static void save_ClearDepth( GLcontext *ctx, GLclampd depth ) n[1].f = (GLfloat) depth; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ClearDepth)( ctx, depth ); + (*ctx->Exec.ClearDepth)( depth ); } } -static void save_ClearIndex( GLcontext *ctx, GLfloat c ) +static void save_ClearIndex( GLfloat c ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 ); @@ -861,13 +870,14 @@ static void save_ClearIndex( GLcontext *ctx, GLfloat c ) n[1].f = c; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ClearIndex)( ctx, c ); + (*ctx->Exec.ClearIndex)( c ); } } -static void save_ClearStencil( GLcontext *ctx, GLint s ) +static void save_ClearStencil( GLint s ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 ); @@ -875,13 +885,14 @@ static void save_ClearStencil( GLcontext *ctx, GLint s ) n[1].i = s; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ClearStencil)( ctx, s ); + (*ctx->Exec.ClearStencil)( s ); } } -static void save_ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *equ ) +static void save_ClipPlane( GLenum plane, const GLdouble *equ ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 ); @@ -893,15 +904,16 @@ static void save_ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *equ ) n[5].f = equ[3]; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ClipPlane)( ctx, plane, equ ); + (*ctx->Exec.ClipPlane)( plane, equ ); } } -static void save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha ) +static void save_ColorMask( GLboolean red, GLboolean green, + GLboolean blue, GLboolean alpha ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 ); @@ -912,13 +924,14 @@ static void save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green, n[4].b = alpha; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ColorMask)( ctx, red, green, blue, alpha ); + (*ctx->Exec.ColorMask)( red, green, blue, alpha ); } } -static void save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ) +static void save_ColorMaterial( GLenum face, GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 ); @@ -927,57 +940,80 @@ static void save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ) n[2].e = mode; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ColorMaterial)( ctx, face, mode ); + (*ctx->Exec.ColorMaterial)( face, mode ); } } -static void save_ColorTable( GLcontext *ctx, GLenum target, GLenum internalFormat, - struct gl_image *table ) +static void save_ColorTable( GLenum target, GLenum internalFormat, + GLsizei width, GLenum format, GLenum type, + const GLvoid *table ) { - Node *n; - FLUSH_VB(ctx, "dlist"); - n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 3 ); - if (n) { - n[1].e = target; - n[2].e = internalFormat; - n[3].data = (GLvoid *) table; - if (table) { - /* must retain this image */ - table->RefCount = 1; - } + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_1D || + target == GL_PROXY_TEXTURE_2D || + target == GL_PROXY_TEXTURE_3D) { + /* execute immediately */ + (*ctx->Exec.ColorTableEXT)( target, internalFormat, width, + format, type, table ); } - if (ctx->ExecuteFlag) { - (*ctx->Exec.ColorTable)( ctx, target, internalFormat, table ); + else { + GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, table, + &ctx->Unpack); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 6 ); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].e = format; + n[5].e = type; + n[6].data = image; + } + else if (image) { + FREE(image); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.ColorTableEXT)( target, internalFormat, width, + format, type, table ); + } } } -static void save_ColorSubTable( GLcontext *ctx, GLenum target, - GLsizei start, struct gl_image *data ) +static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *table) { + GET_CURRENT_CONTEXT(ctx); + GLvoid *image = _mesa_unpack_image(count, 1, 1, format, type, table, + &ctx->Unpack); Node *n; FLUSH_VB(ctx, "dlist"); - n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 3 ); + n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 6 ); if (n) { n[1].e = target; n[2].i = start; - n[3].data = (GLvoid *) data; - if (data) { - /* must retain this image */ - data->RefCount = 1; - } + n[3].i = count; + n[4].e = format; + n[5].e = type; + n[6].data = image; + } + else if (image) { + FREE(image); } if (ctx->ExecuteFlag) { - (*ctx->Exec.ColorSubTable)( ctx, target, start, data ); + (*ctx->Exec.ColorSubTableEXT)(target, start, count, format, type, table); } } -static void save_CopyPixels( GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height, GLenum type ) +static void save_CopyPixels( GLint x, GLint y, + GLsizei width, GLsizei height, GLenum type ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 ); @@ -989,18 +1025,17 @@ static void save_CopyPixels( GLcontext *ctx, GLint x, GLint y, n[5].e = type; } if (ctx->ExecuteFlag) { - (*ctx->Exec.CopyPixels)( ctx, x, y, width, height, type ); + (*ctx->Exec.CopyPixels)( x, y, width, height, type ); } } -static void save_CopyTexImage1D( GLcontext *ctx, - GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, GLsizei width, - GLint border ) +static void +save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLint border ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 ); @@ -1014,18 +1049,19 @@ static void save_CopyTexImage1D( GLcontext *ctx, n[7].i = border; } if (ctx->ExecuteFlag) { - (*ctx->Exec.CopyTexImage1D)( ctx, target, level, internalformat, - x, y, width, border ); + (*ctx->Exec.CopyTexImage1D)( target, level, internalformat, + x, y, width, border ); } } -static void save_CopyTexImage2D( GLcontext *ctx, - GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, GLsizei width, - GLsizei height, GLint border ) +static void +save_CopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, GLsizei width, + GLsizei height, GLint border ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 ); @@ -1040,18 +1076,19 @@ static void save_CopyTexImage2D( GLcontext *ctx, n[8].i = border; } if (ctx->ExecuteFlag) { - (*ctx->Exec.CopyTexImage2D)( ctx, target, level, internalformat, - x, y, width, height, border ); + (*ctx->Exec.CopyTexImage2D)( target, level, internalformat, + x, y, width, height, border ); } } -static void save_CopyTexSubImage1D( GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, - GLsizei width ) +static void +save_CopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 ); @@ -1064,17 +1101,18 @@ static void save_CopyTexSubImage1D( GLcontext *ctx, n[6].i = width; } if (ctx->ExecuteFlag) { - (*ctx->Exec.CopyTexSubImage1D)( ctx, target, level, xoffset, x, y, width ); + (*ctx->Exec.CopyTexSubImage1D)( target, level, xoffset, x, y, width ); } } -static void save_CopyTexSubImage2D( GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLint height ) +static void +save_CopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLint height ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 ); @@ -1089,19 +1127,19 @@ static void save_CopyTexSubImage2D( GLcontext *ctx, n[8].i = height; } if (ctx->ExecuteFlag) { - (*ctx->Exec.CopyTexSubImage2D)( ctx, target, level, xoffset, yoffset, + (*ctx->Exec.CopyTexSubImage2D)( target, level, xoffset, yoffset, x, y, width, height ); } } -static void save_CopyTexSubImage3D( GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint zoffset, - GLint x, GLint y, - GLsizei width, GLint height ) +static void +save_CopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, + GLsizei width, GLint height ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 ); @@ -1117,14 +1155,16 @@ static void save_CopyTexSubImage3D( GLcontext *ctx, n[9].i = height; } if (ctx->ExecuteFlag) { - (*ctx->Exec.CopyTexSubImage3D)(ctx, target, level, xoffset, yoffset, - zoffset, x, y, width, height ); + (*ctx->Exec.CopyTexSubImage3D)( target, level, + xoffset, yoffset, zoffset, + x, y, width, height ); } } -static void save_CullFace( GLcontext *ctx, GLenum mode ) +static void save_CullFace( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 ); @@ -1132,13 +1172,14 @@ static void save_CullFace( GLcontext *ctx, GLenum mode ) n[1].e = mode; } if (ctx->ExecuteFlag) { - (*ctx->Exec.CullFace)( ctx, mode ); + (*ctx->Exec.CullFace)( mode ); } } -static void save_DepthFunc( GLcontext *ctx, GLenum func ) +static void save_DepthFunc( GLenum func ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 ); @@ -1146,13 +1187,14 @@ static void save_DepthFunc( GLcontext *ctx, GLenum func ) n[1].e = func; } if (ctx->ExecuteFlag) { - (*ctx->Exec.DepthFunc)( ctx, func ); + (*ctx->Exec.DepthFunc)( func ); } } -static void save_DepthMask( GLcontext *ctx, GLboolean mask ) +static void save_DepthMask( GLboolean mask ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 ); @@ -1160,13 +1202,14 @@ static void save_DepthMask( GLcontext *ctx, GLboolean mask ) n[1].b = mask; } if (ctx->ExecuteFlag) { - (*ctx->Exec.DepthMask)( ctx, mask ); + (*ctx->Exec.DepthMask)( mask ); } } -static void save_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval ) +static void save_DepthRange( GLclampd nearval, GLclampd farval ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 ); @@ -1175,13 +1218,14 @@ static void save_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval ) n[2].f = (GLfloat) farval; } if (ctx->ExecuteFlag) { - (*ctx->Exec.DepthRange)( ctx, nearval, farval ); + (*ctx->Exec.DepthRange)( nearval, farval ); } } -static void save_Disable( GLcontext *ctx, GLenum cap ) +static void save_Disable( GLenum cap ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_DISABLE, 1 ); @@ -1189,13 +1233,14 @@ static void save_Disable( GLcontext *ctx, GLenum cap ) n[1].e = cap; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Disable)( ctx, cap ); + (*ctx->Exec.Disable)( cap ); } } -static void save_DrawBuffer( GLcontext *ctx, GLenum mode ) +static void save_DrawBuffer( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 ); @@ -1203,31 +1248,41 @@ static void save_DrawBuffer( GLcontext *ctx, GLenum mode ) n[1].e = mode; } if (ctx->ExecuteFlag) { - (*ctx->Exec.DrawBuffer)( ctx, mode ); + (*ctx->Exec.DrawBuffer)( mode ); } } -static void save_DrawPixels( GLcontext *ctx, struct gl_image *image ) +static void save_DrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); + GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, + pixels, &ctx->Unpack); Node *n; FLUSH_VB(ctx, "dlist"); - n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 1 ); + n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 5 ); if (n) { - n[1].data = (GLvoid *) image; + n[1].i = width; + n[2].i = height; + n[3].e = format; + n[4].e = type; + n[5].data = image; } - if (image) { - image->RefCount = 1; + else if (image) { + FREE(image); } if (ctx->ExecuteFlag) { - (*ctx->Exec.DrawPixels)( ctx, image ); + (*ctx->Exec.DrawPixels)( width, height, format, type, pixels ); } } -static void save_Enable( GLcontext *ctx, GLenum cap ) +static void save_Enable( GLenum cap ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_ENABLE, 1 ); @@ -1235,15 +1290,15 @@ static void save_Enable( GLcontext *ctx, GLenum cap ) n[1].e = cap; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Enable)( ctx, cap ); + (*ctx->Exec.Enable)( cap ); } } -static void save_EvalMesh1( GLcontext *ctx, - GLenum mode, GLint i1, GLint i2 ) +static void save_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 ); @@ -1253,14 +1308,15 @@ static void save_EvalMesh1( GLcontext *ctx, n[3].i = i2; } if (ctx->ExecuteFlag) { - (*ctx->Exec.EvalMesh1)( ctx, mode, i1, i2 ); + (*ctx->Exec.EvalMesh1)( mode, i1, i2 ); } } -static void save_EvalMesh2( GLcontext *ctx, +static void save_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 ); @@ -1272,15 +1328,16 @@ static void save_EvalMesh2( GLcontext *ctx, n[5].i = j2; } if (ctx->ExecuteFlag) { - (*ctx->Exec.EvalMesh2)( ctx, mode, i1, i2, j1, j2 ); + (*ctx->Exec.EvalMesh2)( mode, i1, i2, j1, j2 ); } } -static void save_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) +static void save_Fogfv( GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_FOG, 5 ); @@ -1292,13 +1349,51 @@ static void save_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) n[5].f = params[3]; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Fogfv)( ctx, pname, params ); + (*ctx->Exec.Fogfv)( pname, params ); } } -static void save_FrontFace( GLcontext *ctx, GLenum mode ) +static void save_Fogf( GLenum pname, GLfloat param ) +{ + save_Fogfv(pname, ¶m); +} + + +static void save_Fogiv(GLenum pname, const GLint *params ) { + GLfloat p[4]; + switch (pname) { + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + p[0] = (GLfloat) *params; + break; + case GL_FOG_COLOR: + p[0] = INT_TO_FLOAT( params[0] ); + p[1] = INT_TO_FLOAT( params[1] ); + p[2] = INT_TO_FLOAT( params[2] ); + p[3] = INT_TO_FLOAT( params[3] ); + break; + default: + /* Error will be caught later in gl_Fogfv */ + ; + } + save_Fogfv(pname, p); +} + + +void save_Fogi(GLenum pname, GLint param ) +{ + save_Fogiv(pname, ¶m); +} + + +static void save_FrontFace( GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 ); @@ -1306,15 +1401,16 @@ static void save_FrontFace( GLcontext *ctx, GLenum mode ) n[1].e = mode; } if (ctx->ExecuteFlag) { - (*ctx->Exec.FrontFace)( ctx, mode ); + (*ctx->Exec.FrontFace)( mode ); } } -static void save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right, +static void save_Frustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 ); @@ -1327,13 +1423,14 @@ static void save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right, n[6].f = farval; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Frustum)( ctx, left, right, bottom, top, nearval, farval ); + (*ctx->Exec.Frustum)( left, right, bottom, top, nearval, farval ); } } -static GLboolean save_Hint( GLcontext *ctx, GLenum target, GLenum mode ) +static void save_Hint( GLenum target, GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_HINT, 2 ); @@ -1342,15 +1439,15 @@ static GLboolean save_Hint( GLcontext *ctx, GLenum target, GLenum mode ) n[2].e = mode; } if (ctx->ExecuteFlag) { - return (*ctx->Exec.Hint)( ctx, target, mode ); + (*ctx->Exec.Hint)( target, mode ); } - return GL_TRUE; /* not queried */ } -static void save_IndexMask( GLcontext *ctx, GLuint mask ) +static void save_IndexMask( GLuint mask ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 ); @@ -1358,44 +1455,129 @@ static void save_IndexMask( GLcontext *ctx, GLuint mask ) n[1].ui = mask; } if (ctx->ExecuteFlag) { - (*ctx->Exec.IndexMask)( ctx, mask ); + (*ctx->Exec.IndexMask)( mask ); } } -static void save_InitNames( GLcontext *ctx ) +static void save_InitNames( void ) { + GET_CURRENT_CONTEXT(ctx); FLUSH_VB(ctx, "dlist"); (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 ); if (ctx->ExecuteFlag) { - (*ctx->Exec.InitNames)( ctx ); + (*ctx->Exec.InitNames)(); } } -static void save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname, - const GLfloat *params, GLint numparams ) +static void save_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_LIGHT, 6 ); if (OPCODE_LIGHT) { - GLint i; + GLint i, nParams; n[1].e = light; n[2].e = pname; - for (i=0;i<numparams;i++) { + switch (pname) { + case GL_AMBIENT: + nParams = 4; + break; + case GL_DIFFUSE: + nParams = 4; + break; + case GL_SPECULAR: + nParams = 4; + break; + case GL_POSITION: + nParams = 4; + break; + case GL_SPOT_DIRECTION: + nParams = 3; + break; + case GL_SPOT_EXPONENT: + nParams = 1; + break; + case GL_SPOT_CUTOFF: + nParams = 1; + break; + case GL_CONSTANT_ATTENUATION: + nParams = 1; + break; + case GL_LINEAR_ATTENUATION: + nParams = 1; + break; + case GL_QUADRATIC_ATTENUATION: + nParams = 1; + break; + default: + nParams = 0; + } + for (i = 0; i < nParams; i++) { n[3+i].f = params[i]; } } if (ctx->ExecuteFlag) { - (*ctx->Exec.Lightfv)( ctx, light, pname, params, numparams ); + (*ctx->Exec.Lightfv)( light, pname, params ); + } +} + + +static void save_Lightf( GLenum light, GLenum pname, GLfloat params ) +{ + save_Lightfv(light, pname, ¶ms); +} + + +static void save_Lightiv( GLenum light, GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_POSITION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + fparam[3] = (GLfloat) params[3]; + break; + case GL_SPOT_DIRECTION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* error will be caught later in gl_Lightfv */ + ; } + save_Lightfv( light, pname, fparam ); +} + + +static void save_Lighti( GLenum light, GLenum pname, GLint param ) +{ + save_Lightiv( light, pname, ¶m ); } -static void save_LightModelfv( GLcontext *ctx, - GLenum pname, const GLfloat *params ) +static void save_LightModelfv( GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 ); @@ -1407,13 +1589,49 @@ static void save_LightModelfv( GLcontext *ctx, n[5].f = params[3]; } if (ctx->ExecuteFlag) { - (*ctx->Exec.LightModelfv)( ctx, pname, params ); + (*ctx->Exec.LightModelfv)( pname, params ); } } -static void save_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern ) +static void save_LightModelf( GLenum pname, GLfloat param ) +{ + save_LightModelfv(pname, ¶m); +} + + +static void save_LightModeliv( GLenum pname, const GLint *params ) { + GLfloat fparam[4]; + switch (pname) { + case GL_LIGHT_MODEL_AMBIENT: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + case GL_LIGHT_MODEL_TWO_SIDE: + case GL_LIGHT_MODEL_COLOR_CONTROL: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* Error will be caught later in gl_LightModelfv */ + ; + } + save_LightModelfv(pname, fparam); +} + + +static void save_LightModeli( GLenum pname, GLint param ) +{ + save_LightModeliv(pname, ¶m); +} + + +static void save_LineStipple( GLint factor, GLushort pattern ) +{ + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 ); @@ -1422,13 +1640,14 @@ static void save_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern ) n[2].us = pattern; } if (ctx->ExecuteFlag) { - (*ctx->Exec.LineStipple)( ctx, factor, pattern ); + (*ctx->Exec.LineStipple)( factor, pattern ); } } -static void save_LineWidth( GLcontext *ctx, GLfloat width ) +static void save_LineWidth( GLfloat width ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 ); @@ -1436,13 +1655,14 @@ static void save_LineWidth( GLcontext *ctx, GLfloat width ) n[1].f = width; } if (ctx->ExecuteFlag) { - (*ctx->Exec.LineWidth)( ctx, width ); + (*ctx->Exec.LineWidth)( width ); } } -static void save_ListBase( GLcontext *ctx, GLuint base ) +static void save_ListBase( GLuint base ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 ); @@ -1450,23 +1670,25 @@ static void save_ListBase( GLcontext *ctx, GLuint base ) n[1].ui = base; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ListBase)( ctx, base ); + (*ctx->Exec.ListBase)( base ); } } -static void save_LoadIdentity( GLcontext *ctx ) +static void save_LoadIdentity( void ) { + GET_CURRENT_CONTEXT(ctx); FLUSH_VB(ctx, "dlist"); (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 ); if (ctx->ExecuteFlag) { - (*ctx->Exec.LoadIdentity)( ctx ); + (*ctx->Exec.LoadIdentity)(); } } -static void save_LoadMatrixf( GLcontext *ctx, const GLfloat *m ) +static void save_LoadMatrixf( const GLfloat *m ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 ); @@ -1477,13 +1699,25 @@ static void save_LoadMatrixf( GLcontext *ctx, const GLfloat *m ) } } if (ctx->ExecuteFlag) { - (*ctx->Exec.LoadMatrixf)( ctx, m ); + (*ctx->Exec.LoadMatrixf)( m ); } } -static void save_LoadName( GLcontext *ctx, GLuint name ) +static void save_LoadMatrixd( const GLdouble *m ) { + GLfloat f[16]; + GLint i; + for (i = 0; i < 16; i++) { + f[i] = m[i]; + } + save_LoadMatrixf(f); +} + + +static void save_LoadName( GLuint name ) +{ + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 ); @@ -1491,13 +1725,14 @@ static void save_LoadName( GLcontext *ctx, GLuint name ) n[1].ui = name; } if (ctx->ExecuteFlag) { - (*ctx->Exec.LoadName)( ctx, name ); + (*ctx->Exec.LoadName)( name ); } } -static void save_LogicOp( GLcontext *ctx, GLenum opcode ) +static void save_LogicOp( GLenum opcode ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 ); @@ -1505,64 +1740,120 @@ static void save_LogicOp( GLcontext *ctx, GLenum opcode ) n[1].e = opcode; } if (ctx->ExecuteFlag) { - (*ctx->Exec.LogicOp)( ctx, opcode ); + (*ctx->Exec.LogicOp)( opcode ); } } -static void save_Map1f( GLcontext *ctx, - GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat *points, GLboolean retain ) +static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble *points) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_MAP1, 6 ); + if (n) { + GLfloat *pnts = gl_copy_map_points1d( target, stride, order, points ); + n[1].e = target; + n[2].f = u1; + n[3].f = u2; + n[4].i = _mesa_evaluator_components(target); /* stride */ + n[5].i = order; + n[6].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Map1d)( target, u1, u2, stride, order, points ); + } +} + +static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat *points) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_MAP1, 6 ); if (n) { + GLfloat *pnts = gl_copy_map_points1f( target, stride, order, points ); n[1].e = target; n[2].f = u1; n[3].f = u2; - n[4].i = stride; + n[4].i = _mesa_evaluator_components(target); /* stride */ n[5].i = order; - n[6].data = (void *) points; + n[6].data = (void *) pnts; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec.Map1f)( target, u1, u2, stride, order, points ); + } +} + + +static void save_Map2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_MAP2, 10 ); + if (n) { + GLfloat *pnts = gl_copy_map_points2d( target, ustride, uorder, + vstride, vorder, points ); + n[1].e = target; + n[2].f = u1; + n[3].f = u2; + n[4].f = v1; + n[5].f = v2; + /* XXX verify these strides are correct */ + n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/ + n[7].i = _mesa_evaluator_components(target); /*vstride*/ + n[8].i = uorder; + n[9].i = vorder; + n[10].data = (void *) pnts; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Map1f)( ctx, target, u1, u2, stride, order, points, GL_TRUE ); + (*ctx->Exec.Map2d)( target, + u1, u2, ustride, uorder, + v1, v2, vstride, vorder, points ); } - (void) retain; } -static void save_Map2f( GLcontext *ctx, GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat *points, GLboolean retain ) +static void save_Map2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_MAP2, 10 ); if (n) { + GLfloat *pnts = gl_copy_map_points2f( target, ustride, uorder, + vstride, vorder, points ); n[1].e = target; n[2].f = u1; n[3].f = u2; n[4].f = v1; n[5].f = v2; - n[6].i = ustride; - n[7].i = vstride; + /* XXX verify these strides are correct */ + n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/ + n[7].i = _mesa_evaluator_components(target); /*vstride*/ n[8].i = uorder; n[9].i = vorder; - n[10].data = (void *) points; + n[10].data = (void *) pnts; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Map2f)( ctx, target, - u1, u2, ustride, uorder, - v1, v2, vstride, vorder, points, GL_TRUE ); + (*ctx->Exec.Map2f)( target, u1, u2, ustride, uorder, + v1, v2, vstride, vorder, points ); } - (void) retain; } -static void save_MapGrid1f( GLcontext *ctx, GLint un, GLfloat u1, GLfloat u2 ) +static void save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 ); @@ -1572,15 +1863,21 @@ static void save_MapGrid1f( GLcontext *ctx, GLint un, GLfloat u1, GLfloat u2 ) n[3].f = u2; } if (ctx->ExecuteFlag) { - (*ctx->Exec.MapGrid1f)( ctx, un, u1, u2 ); + (*ctx->Exec.MapGrid1f)( un, u1, u2 ); } } -static void save_MapGrid2f( GLcontext *ctx, - GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2 ) +static void save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) { + save_MapGrid1f(un, u1, u2); +} + + +static void save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ) +{ + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 ); @@ -1593,13 +1890,22 @@ static void save_MapGrid2f( GLcontext *ctx, n[6].f = v2; } if (ctx->ExecuteFlag) { - (*ctx->Exec.MapGrid2f)( ctx, un, u1, u2, vn, v1, v2 ); + (*ctx->Exec.MapGrid2f)( un, u1, u2, vn, v1, v2 ); } } -static void save_MatrixMode( GLcontext *ctx, GLenum mode ) + +static void save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ) { + save_MapGrid2f(un, u1, u2, vn, v1, v2); +} + + +static void save_MatrixMode( GLenum mode ) +{ + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 ); @@ -1607,13 +1913,14 @@ static void save_MatrixMode( GLcontext *ctx, GLenum mode ) n[1].e = mode; } if (ctx->ExecuteFlag) { - (*ctx->Exec.MatrixMode)( ctx, mode ); + (*ctx->Exec.MatrixMode)( mode ); } } -static void save_MultMatrixf( GLcontext *ctx, const GLfloat *m ) +static void save_MultMatrixf( const GLfloat *m ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 ); @@ -1624,13 +1931,25 @@ static void save_MultMatrixf( GLcontext *ctx, const GLfloat *m ) } } if (ctx->ExecuteFlag) { - (*ctx->Exec.MultMatrixf)( ctx, m ); + (*ctx->Exec.MultMatrixf)( m ); + } +} + + +static void save_MultMatrixd( const GLdouble *m ) +{ + GLfloat f[16]; + GLint i; + for (i = 0; i < 16; i++) { + f[i] = m[i]; } + save_MultMatrixf(f); } -static void save_NewList( GLcontext *ctx, GLuint list, GLenum mode ) +static void save_NewList( GLuint list, GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); /* It's an error to call this function while building a display list */ gl_error( ctx, GL_INVALID_OPERATION, "glNewList" ); (void) list; @@ -1639,10 +1958,11 @@ static void save_NewList( GLcontext *ctx, GLuint list, GLenum mode ) -static void save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right, +static void save_Ortho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_ORTHO, 6 ); @@ -1655,14 +1975,14 @@ static void save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right, n[6].f = farval; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Ortho)( ctx, left, right, bottom, top, nearval, farval ); + (*ctx->Exec.Ortho)( left, right, bottom, top, nearval, farval ); } } -static void save_PixelMapfv( GLcontext *ctx, - GLenum map, GLint mapsize, const GLfloat *values ) +static void save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 ); @@ -1673,13 +1993,50 @@ static void save_PixelMapfv( GLcontext *ctx, MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) ); } if (ctx->ExecuteFlag) { - (*ctx->Exec.PixelMapfv)( ctx, map, mapsize, values ); + (*ctx->Exec.PixelMapfv)( map, mapsize, values ); + } +} + + +static void save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values ) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLint i; + if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { + for (i=0;i<mapsize;i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + for (i=0;i<mapsize;i++) { + fvalues[i] = UINT_TO_FLOAT( values[i] ); + } + } + save_PixelMapfv(map, mapsize, fvalues); +} + + +static void save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLint i; + if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { + for (i=0;i<mapsize;i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + for (i=0;i<mapsize;i++) { + fvalues[i] = USHORT_TO_FLOAT( values[i] ); + } } + save_PixelMapfv(map, mapsize, fvalues); } -static void save_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param ) +static void save_PixelTransferf( GLenum pname, GLfloat param ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 ); @@ -1688,13 +2045,20 @@ static void save_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param ) n[2].f = param; } if (ctx->ExecuteFlag) { - (*ctx->Exec.PixelTransferf)( ctx, pname, param ); + (*ctx->Exec.PixelTransferf)( pname, param ); } } -static void save_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor ) +static void save_PixelTransferi( GLenum pname, GLint param ) { + save_PixelTransferf( pname, (GLfloat) param ); +} + + +static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor ) +{ + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 ); @@ -1703,14 +2067,14 @@ static void save_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor ) n[2].f = yfactor; } if (ctx->ExecuteFlag) { - (*ctx->Exec.PixelZoom)( ctx, xfactor, yfactor ); + (*ctx->Exec.PixelZoom)( xfactor, yfactor ); } } -static void save_PointParameterfvEXT( GLcontext *ctx, GLenum pname, - const GLfloat *params) +static void save_PointParameterfvEXT( GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 ); @@ -1721,13 +2085,20 @@ static void save_PointParameterfvEXT( GLcontext *ctx, GLenum pname, n[4].f = params[2]; } if (ctx->ExecuteFlag) { - (*ctx->Exec.PointParameterfvEXT)( ctx, pname, params ); + (*ctx->Exec.PointParameterfvEXT)( pname, params ); } } -static void save_PointSize( GLcontext *ctx, GLfloat size ) +static void save_PointParameterfEXT( GLenum pname, GLfloat param ) +{ + save_PointParameterfvEXT(pname, ¶m); +} + + +static void save_PointSize( GLfloat size ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 ); @@ -1735,13 +2106,14 @@ static void save_PointSize( GLcontext *ctx, GLfloat size ) n[1].f = size; } if (ctx->ExecuteFlag) { - (*ctx->Exec.PointSize)( ctx, size ); + (*ctx->Exec.PointSize)( size ); } } -static void save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ) +static void save_PolygonMode( GLenum face, GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 ); @@ -1750,7 +2122,7 @@ static void save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ) n[2].e = mode; } if (ctx->ExecuteFlag) { - (*ctx->Exec.PolygonMode)( ctx, face, mode ); + (*ctx->Exec.PolygonMode)( face, mode ); } } @@ -1758,8 +2130,9 @@ static void save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ) /* * Polygon stipple must have been upacked already! */ -static void save_PolygonStipple( GLcontext *ctx, const GLuint *pattern ) +static void save_PolygonStipple( const GLubyte *pattern ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 ); @@ -1770,13 +2143,14 @@ static void save_PolygonStipple( GLcontext *ctx, const GLuint *pattern ) MEMCPY( data, pattern, 32 * 4 ); } if (ctx->ExecuteFlag) { - (*ctx->Exec.PolygonStipple)( ctx, pattern ); + (*ctx->Exec.PolygonStipple)( (GLubyte*) pattern ); } } -static void save_PolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units ) +static void save_PolygonOffset( GLfloat factor, GLfloat units ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 ); @@ -1785,45 +2159,54 @@ static void save_PolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units ) n[2].f = units; } if (ctx->ExecuteFlag) { - (*ctx->Exec.PolygonOffset)( ctx, factor, units ); + (*ctx->Exec.PolygonOffset)( factor, units ); } } -static void save_PopAttrib( GLcontext *ctx ) +static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) { + save_PolygonOffset(factor, DEPTH_SCALE * bias); +} + + +static void save_PopAttrib( void ) +{ + GET_CURRENT_CONTEXT(ctx); FLUSH_VB(ctx, "dlist"); (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 ); if (ctx->ExecuteFlag) { - (*ctx->Exec.PopAttrib)( ctx ); + (*ctx->Exec.PopAttrib)(); } } -static void save_PopMatrix( GLcontext *ctx ) +static void save_PopMatrix( void ) { + GET_CURRENT_CONTEXT(ctx); FLUSH_VB(ctx, "dlist"); (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 ); if (ctx->ExecuteFlag) { - (*ctx->Exec.PopMatrix)( ctx ); + (*ctx->Exec.PopMatrix)(); } } -static void save_PopName( GLcontext *ctx ) +static void save_PopName( void ) { + GET_CURRENT_CONTEXT(ctx); FLUSH_VB(ctx, "dlist"); (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 ); if (ctx->ExecuteFlag) { - (*ctx->Exec.PopName)( ctx ); + (*ctx->Exec.PopName)(); } } -static void save_PrioritizeTextures( GLcontext *ctx, - GLsizei num, const GLuint *textures, - const GLclampf *priorities ) +static void save_PrioritizeTextures( GLsizei num, const GLuint *textures, + const GLclampf *priorities ) { + GET_CURRENT_CONTEXT(ctx); GLint i; FLUSH_VB(ctx, "dlist"); @@ -1836,13 +2219,14 @@ static void save_PrioritizeTextures( GLcontext *ctx, } } if (ctx->ExecuteFlag) { - (*ctx->Exec.PrioritizeTextures)( ctx, num, textures, priorities ); + (*ctx->Exec.PrioritizeTextures)( num, textures, priorities ); } } -static void save_PushAttrib( GLcontext *ctx, GLbitfield mask ) +static void save_PushAttrib( GLbitfield mask ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 ); @@ -1850,23 +2234,25 @@ static void save_PushAttrib( GLcontext *ctx, GLbitfield mask ) n[1].bf = mask; } if (ctx->ExecuteFlag) { - (*ctx->Exec.PushAttrib)( ctx, mask ); + (*ctx->Exec.PushAttrib)( mask ); } } -static void save_PushMatrix( GLcontext *ctx ) +static void save_PushMatrix( void ) { + GET_CURRENT_CONTEXT(ctx); FLUSH_VB(ctx, "dlist"); (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 ); if (ctx->ExecuteFlag) { - (*ctx->Exec.PushMatrix)( ctx ); + (*ctx->Exec.PushMatrix)(); } } -static void save_PushName( GLcontext *ctx, GLuint name ) +static void save_PushName( GLuint name ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 ); @@ -1874,14 +2260,14 @@ static void save_PushName( GLcontext *ctx, GLuint name ) n[1].ui = name; } if (ctx->ExecuteFlag) { - (*ctx->Exec.PushName)( ctx, name ); + (*ctx->Exec.PushName)( name ); } } -static void save_RasterPos4f( GLcontext *ctx, - GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 ); @@ -1892,13 +2278,129 @@ static void save_RasterPos4f( GLcontext *ctx, n[4].f = w; } if (ctx->ExecuteFlag) { - (*ctx->Exec.RasterPos4f)( ctx, x, y, z, w ); + (*ctx->Exec.RasterPos4f)( x, y, z, w ); } } +void save_RasterPos2d(GLdouble x, GLdouble y) +{ + save_RasterPos4f(x, y, 0.0F, 1.0F); +} + +void save_RasterPos2f(GLfloat x, GLfloat y) +{ + save_RasterPos4f(x, y, 0.0F, 1.0F); +} + +void save_RasterPos2i(GLint x, GLint y) +{ + save_RasterPos4f(x, y, 0.0F, 1.0F); +} + +void save_RasterPos2s(GLshort x, GLshort y) +{ + save_RasterPos4f(x, y, 0.0F, 1.0F); +} + +void save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) +{ + save_RasterPos4f(x, y, z, 1.0F); +} + +void save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) +{ + save_RasterPos4f(x, y, z, 1.0F); +} + +void save_RasterPos3i(GLint x, GLint y, GLint z) +{ + save_RasterPos4f(x, y, z, 1.0F); +} + +void save_RasterPos3s(GLshort x, GLshort y, GLshort z) +{ + save_RasterPos4f(x, y, z, 1.0F); +} + +void save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_RasterPos4f(x, y, z, w); +} + +void save_RasterPos4i(GLint x, GLint y, GLint z, GLint w) +{ + save_RasterPos4f(x, y, z, w); +} + +void save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + save_RasterPos4f(x, y, z, w); +} + +void save_RasterPos2dv(const GLdouble *v) +{ + save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +void save_RasterPos2fv(const GLfloat *v) +{ + save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +void save_RasterPos2iv(const GLint *v) +{ + save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +void save_RasterPos2sv(const GLshort *v) +{ + save_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +void save_RasterPos3dv(const GLdouble *v) +{ + save_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +void save_RasterPos3fv(const GLfloat *v) +{ + save_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +void save_RasterPos3iv(const GLint *v) +{ + save_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +void save_RasterPos3sv(const GLshort *v) +{ + save_RasterPos4f(v[0], v[1], v[2], 1.0F); +} -static void save_PassThrough( GLcontext *ctx, GLfloat token ) +void save_RasterPos4dv(const GLdouble *v) { + save_RasterPos4f(v[0], v[1], v[2], v[3]); +} + +void save_RasterPos4fv(const GLfloat *v) +{ + save_RasterPos4f(v[0], v[1], v[2], v[3]); +} + +void save_RasterPos4iv(const GLint *v) +{ + save_RasterPos4f(v[0], v[1], v[2], v[3]); +} + +void save_RasterPos4sv(const GLshort *v) +{ + save_RasterPos4f(v[0], v[1], v[2], v[3]); +} + + +static void save_PassThrough( GLfloat token ) +{ + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 ); @@ -1906,13 +2408,14 @@ static void save_PassThrough( GLcontext *ctx, GLfloat token ) n[1].f = token; } if (ctx->ExecuteFlag) { - (*ctx->Exec.PassThrough)( ctx, token ); + (*ctx->Exec.PassThrough)( token ); } } -static void save_ReadBuffer( GLcontext *ctx, GLenum mode ) +static void save_ReadBuffer( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 ); @@ -1920,14 +2423,14 @@ static void save_ReadBuffer( GLcontext *ctx, GLenum mode ) n[1].e = mode; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ReadBuffer)( ctx, mode ); + (*ctx->Exec.ReadBuffer)( mode ); } } -static void save_Rectf( GLcontext *ctx, - GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) +static void save_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_RECTF, 4 ); @@ -1938,22 +2441,63 @@ static void save_Rectf( GLcontext *ctx, n[4].f = y2; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Rectf)( ctx, x1, y1, x2, y2 ); + (*ctx->Exec.Rectf)( x1, y1, x2, y2 ); } } +static void save_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) +{ + save_Rectf(x1, y1, x2, y2); +} + +static void save_Rectdv(const GLdouble *v1, const GLdouble *v2) +{ + save_Rectf(v1[0], v1[1], v2[0], v2[1]); +} + +static void save_Rectfv( const GLfloat *v1, const GLfloat *v2 ) +{ + save_Rectf(v1[0], v1[1], v2[0], v2[1]); +} + +static void save_Recti(GLint x1, GLint y1, GLint x2, GLint y2) +{ + save_Rectf(x1, y1, x2, y2); +} -static void save_Rotatef( GLcontext *ctx, GLfloat angle, - GLfloat x, GLfloat y, GLfloat z ) +static void save_Rectiv(const GLint *v1, const GLint *v2) +{ + save_Rectf(v1[0], v1[1], v2[0], v2[1]); +} + +static void save_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2) +{ + save_Rectf(x1, y1, x2, y2); +} + +static void save_Rectsv(const GLshort *v1, const GLshort *v2) +{ + save_Rectf(v1[0], v1[1], v2[0], v2[1]); +} + + +static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) { GLfloat m[16]; gl_rotation_matrix( angle, x, y, z, m ); - save_MultMatrixf( ctx, m ); /* save and maybe execute */ + save_MultMatrixf( m ); /* save and maybe execute */ } -static void save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +static void save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) { + save_Rotatef(angle, x, y, z); +} + + +static void save_Scalef( GLfloat x, GLfloat y, GLfloat z ) +{ + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_SCALE, 3 ); @@ -1963,14 +2507,20 @@ static void save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) n[3].f = z; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Scalef)( ctx, x, y, z ); + (*ctx->Exec.Scalef)( x, y, z ); } } -static void save_Scissor( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height ) +static void save_Scaled( GLdouble x, GLdouble y, GLdouble z ) +{ + save_Scalef(x, y, z); +} + + +static void save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 ); @@ -1981,13 +2531,14 @@ static void save_Scissor( GLcontext *ctx, n[4].i = height; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Scissor)( ctx, x, y, width, height ); + (*ctx->Exec.Scissor)( x, y, width, height ); } } -static void save_ShadeModel( GLcontext *ctx, GLenum mode ) +static void save_ShadeModel( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 ); @@ -1995,13 +2546,14 @@ static void save_ShadeModel( GLcontext *ctx, GLenum mode ) n[1].e = mode; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ShadeModel)( ctx, mode ); + (*ctx->Exec.ShadeModel)( mode ); } } -static void save_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask ) +static void save_StencilFunc( GLenum func, GLint ref, GLuint mask ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 ); @@ -2011,13 +2563,14 @@ static void save_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mas n[3].ui = mask; } if (ctx->ExecuteFlag) { - (*ctx->Exec.StencilFunc)( ctx, func, ref, mask ); + (*ctx->Exec.StencilFunc)( func, ref, mask ); } } -static void save_StencilMask( GLcontext *ctx, GLuint mask ) +static void save_StencilMask( GLuint mask ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 ); @@ -2025,14 +2578,14 @@ static void save_StencilMask( GLcontext *ctx, GLuint mask ) n[1].ui = mask; } if (ctx->ExecuteFlag) { - (*ctx->Exec.StencilMask)( ctx, mask ); + (*ctx->Exec.StencilMask)( mask ); } } -static void save_StencilOp( GLcontext *ctx, - GLenum fail, GLenum zfail, GLenum zpass ) +static void save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 ); @@ -2042,16 +2595,14 @@ static void save_StencilOp( GLcontext *ctx, n[3].e = zpass; } if (ctx->ExecuteFlag) { - (*ctx->Exec.StencilOp)( ctx, fail, zfail, zpass ); + (*ctx->Exec.StencilOp)( fail, zfail, zpass ); } } - - -static void save_TexEnvfv( GLcontext *ctx, - GLenum target, GLenum pname, const GLfloat *params ) +static void save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_TEXENV, 6 ); @@ -2064,14 +2615,40 @@ static void save_TexEnvfv( GLcontext *ctx, n[6].f = params[3]; } if (ctx->ExecuteFlag) { - (*ctx->Exec.TexEnvfv)( ctx, target, pname, params ); + (*ctx->Exec.TexEnvfv)( target, pname, params ); } } -static void save_TexGenfv( GLcontext *ctx, - GLenum coord, GLenum pname, const GLfloat *params ) +static void save_TexEnvf( GLenum target, GLenum pname, GLfloat param ) +{ + save_TexEnvfv( target, pname, ¶m ); +} + + +static void save_TexEnvi( GLenum target, GLenum pname, GLint param ) +{ + GLfloat p[4]; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0; + save_TexEnvfv( target, pname, p ); +} + + +static void save_TexEnviv( GLenum target, GLenum pname, const GLint *param ) +{ + GLfloat p[4]; + p[0] = INT_TO_FLOAT( param[0] ); + p[1] = INT_TO_FLOAT( param[1] ); + p[2] = INT_TO_FLOAT( param[2] ); + p[3] = INT_TO_FLOAT( param[3] ); + save_TexEnvfv( target, pname, p ); +} + + +static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 ); @@ -2084,14 +2661,56 @@ static void save_TexGenfv( GLcontext *ctx, n[6].f = params[3]; } if (ctx->ExecuteFlag) { - (*ctx->Exec.TexGenfv)( ctx, coord, pname, params ); + (*ctx->Exec.TexGenfv)( coord, pname, params ); } } -static void save_TexParameterfv( GLcontext *ctx, GLenum target, +static void save_TexGeniv(GLenum coord, GLenum pname, const GLint *params ) +{ + GLfloat p[4]; + p[0] = params[0]; + p[1] = params[1]; + p[2] = params[2]; + p[3] = params[3]; + save_TexGenfv(coord, pname, p); +} + + +static void save_TexGend(GLenum coord, GLenum pname, GLdouble param ) +{ + GLfloat p = (GLfloat) param; + save_TexGenfv( coord, pname, &p ); +} + + +static void save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params ) +{ + GLfloat p[4]; + p[0] = params[0]; + p[1] = params[1]; + p[2] = params[2]; + p[3] = params[3]; + save_TexGenfv( coord, pname, p ); +} + + +static void save_TexGenf( GLenum coord, GLenum pname, GLfloat param ) +{ + save_TexGenfv(coord, pname, ¶m); +} + + +static void save_TexGeni( GLenum coord, GLenum pname, GLint param ) +{ + save_TexGeniv( coord, pname, ¶m ); +} + + +static void save_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 ); @@ -2104,26 +2723,52 @@ static void save_TexParameterfv( GLcontext *ctx, GLenum target, n[6].f = params[3]; } if (ctx->ExecuteFlag) { - (*ctx->Exec.TexParameterfv)( ctx, target, pname, params ); + (*ctx->Exec.TexParameterfv)( target, pname, params ); } } -static void save_TexImage1D( GLcontext *ctx, GLenum target, +static void save_TexParameterf( GLenum target, GLenum pname, GLfloat param ) +{ + save_TexParameterfv(target, pname, ¶m); +} + + +static void save_TexParameteri( GLenum target, GLenum pname, const GLint param ) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0; + save_TexParameterfv(target, pname, fparam); +} + + +static void save_TexParameteriv( GLenum target, GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) params[0]; + fparam[1] = fparam[2] = fparam[3] = 0.0; + save_TexParameterfv(target, pname, fparam); +} + + +static void save_TexImage1D( GLenum target, GLint level, GLint components, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels ) { - FLUSH_VB(ctx, "dlist"); + GET_CURRENT_CONTEXT(ctx); if (target == GL_PROXY_TEXTURE_1D) { - (*ctx->Exec.TexImage1D)( ctx, target, level, components, width, + /* don't compile, execute immediately */ + (*ctx->Exec.TexImage1D)( target, level, components, width, border, format, type, pixels ); } else { - Node *n; GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, pixels, &ctx->Unpack); + Node *n; + FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 ); if (n) { n[1].e = target; @@ -2135,32 +2780,34 @@ static void save_TexImage1D( GLcontext *ctx, GLenum target, n[7].e = type; n[8].data = image; } - else { + else if (image) { FREE(image); } if (ctx->ExecuteFlag) { - (*ctx->Exec.TexImage1D)( ctx, target, level, components, width, + (*ctx->Exec.TexImage1D)( target, level, components, width, border, format, type, pixels ); } } } -static void save_TexImage2D( GLcontext *ctx, GLenum target, +static void save_TexImage2D( GLenum target, GLint level, GLint components, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, - const GLvoid *pixels ) + const GLvoid *pixels) { - FLUSH_VB(ctx, "dlist"); + GET_CURRENT_CONTEXT(ctx); if (target == GL_PROXY_TEXTURE_2D) { - (*ctx->Exec.TexImage2D)( ctx, target, level, components, width, + /* don't compile, execute immediately */ + (*ctx->Exec.TexImage2D)( target, level, components, width, height, border, format, type, pixels ); } else { - Node *n; GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, pixels, &ctx->Unpack); + Node *n; + FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 ); if (n) { n[1].e = target; @@ -2173,33 +2820,35 @@ static void save_TexImage2D( GLcontext *ctx, GLenum target, n[8].e = type; n[9].data = image; } - else { + else if (image) { FREE(image); } if (ctx->ExecuteFlag) { - (*ctx->Exec.TexImage2D)( ctx, target, level, components, width, + (*ctx->Exec.TexImage2D)( target, level, components, width, height, border, format, type, pixels ); } } } -static void save_TexImage3D( GLcontext *ctx, GLenum target, +static void save_TexImage3D( GLenum target, GLint level, GLint components, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels ) { - FLUSH_VB(ctx, "dlist"); + GET_CURRENT_CONTEXT(ctx); if (target == GL_PROXY_TEXTURE_3D) { - (*ctx->Exec.TexImage3D)( ctx, target, level, components, width, + /* don't compile, execute immediately */ + (*ctx->Exec.TexImage3D)( target, level, components, width, height, depth, border, format, type, pixels ); } else { + Node *n; GLvoid *image = _mesa_unpack_image(width, height, depth, format, type, pixels, &ctx->Unpack); - Node *n; + FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 ); if (n) { n[1].e = target; @@ -2213,22 +2862,22 @@ static void save_TexImage3D( GLcontext *ctx, GLenum target, n[9].e = type; n[10].data = image; } - else { + else if (image) { FREE(image); } if (ctx->ExecuteFlag) { - (*ctx->Exec.TexImage3D)( ctx, target, level, components, width, - height, depth, border, format, type, pixels ); + (*ctx->Exec.TexImage3D)( target, level, components, width, + height, depth, border, format, type, pixels ); } } } -static void save_TexSubImage1D( GLcontext *ctx, - GLenum target, GLint level, GLint xoffset, +static void save_TexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); Node *n; GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, pixels, &ctx->Unpack); @@ -2243,23 +2892,23 @@ static void save_TexSubImage1D( GLcontext *ctx, n[6].e = type; n[7].data = image; } - else { + else if (image) { FREE(image); } if (ctx->ExecuteFlag) { - (*ctx->Exec.TexSubImage1D)( ctx, target, level, xoffset, width, + (*ctx->Exec.TexSubImage1D)( target, level, xoffset, width, format, type, pixels ); } } -static void save_TexSubImage2D( GLcontext *ctx, - GLenum target, GLint level, +static void save_TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); Node *n; GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, pixels, &ctx->Unpack); @@ -2276,23 +2925,23 @@ static void save_TexSubImage2D( GLcontext *ctx, n[8].e = type; n[9].data = image; } - else { + else if (image) { FREE(image); } if (ctx->ExecuteFlag) { - (*ctx->Exec.TexSubImage2D)( ctx, target, level, xoffset, yoffset, - width, height, format, type, pixels ); + (*ctx->Exec.TexSubImage2D)( target, level, xoffset, yoffset, + width, height, format, type, pixels ); } } -static void save_TexSubImage3D( GLcontext *ctx, - GLenum target, GLint level, +static void save_TexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset,GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); Node *n; GLvoid *image = _mesa_unpack_image(width, height, depth, format, type, pixels, &ctx->Unpack); @@ -2311,18 +2960,20 @@ static void save_TexSubImage3D( GLcontext *ctx, n[10].e = type; n[11].data = image; } - else { + else if (image) { FREE(image); } if (ctx->ExecuteFlag) { - (*ctx->Exec.TexSubImage3D)(ctx, target, level, xoffset, yoffset, zoffset, - width, height, depth, format, type, pixels ); + (*ctx->Exec.TexSubImage3D)( target, level, + xoffset, yoffset, zoffset, + width, height, depth, format, type, pixels ); } } -static void save_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +static void save_Translatef( GLfloat x, GLfloat y, GLfloat z ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_TRANSLATE, 3 ); @@ -2332,15 +2983,21 @@ static void save_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) n[3].f = z; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Translatef)( ctx, x, y, z ); + (*ctx->Exec.Translatef)( x, y, z ); } } +static void save_Translated( GLdouble x, GLdouble y, GLdouble z ) +{ + save_Translatef(x, y, z); +} + + -static void save_Viewport( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height ) +static void save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_VIEWPORT, 4 ); @@ -2351,14 +3008,14 @@ static void save_Viewport( GLcontext *ctx, n[4].i = (GLint) height; } if (ctx->ExecuteFlag) { - (*ctx->Exec.Viewport)( ctx, x, y, width, height ); + (*ctx->Exec.Viewport)( x, y, width, height ); } } -static void save_WindowPos4fMESA( GLcontext *ctx, - GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_WINDOW_POS, 4 ); @@ -2369,18 +3026,17 @@ static void save_WindowPos4fMESA( GLcontext *ctx, n[4].f = w; } if (ctx->ExecuteFlag) { - (*ctx->Exec.WindowPos4fMESA)( ctx, x, y, z, w ); + (*ctx->Exec.WindowPos4fMESA)( x, y, z, w ); } } - - /* GL_ARB_multitexture */ -static void save_ActiveTexture( GLcontext *ctx, GLenum target ) +static void save_ActiveTextureARB( GLenum target ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_ACTIVE_TEXTURE, 1 ); @@ -2388,14 +3044,15 @@ static void save_ActiveTexture( GLcontext *ctx, GLenum target ) n[1].e = target; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ActiveTexture)( ctx, target ); + (*ctx->Exec.ActiveTextureARB)( target ); } } /* GL_ARB_multitexture */ -static void save_ClientActiveTexture( GLcontext *ctx, GLenum target ) +static void save_ClientActiveTextureARB( GLenum target ) { + GET_CURRENT_CONTEXT(ctx); Node *n; FLUSH_VB(ctx, "dlist"); n = alloc_instruction( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 ); @@ -2403,7 +3060,7 @@ static void save_ClientActiveTexture( GLcontext *ctx, GLenum target ) n[1].e = target; } if (ctx->ExecuteFlag) { - (*ctx->Exec.ClientActiveTexture)( ctx, target ); + (*ctx->Exec.ClientActiveTextureARB)( target ); } } @@ -2476,6 +3133,20 @@ void gl_save_error( GLcontext *ctx, GLenum error, const char *s ) /* execute already done */ } + +static GLboolean +islist(GLcontext *ctx, GLuint list) +{ + if (list > 0 && HashLookup(ctx->Shared->DisplayList, list)) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + + /**********************************************************************/ /* Display list execution */ /**********************************************************************/ @@ -2489,21 +3160,11 @@ void gl_save_error( GLcontext *ctx, GLenum error, const char *s ) */ static void execute_list( GLcontext *ctx, GLuint list ) { - static struct gl_pixelstore_attrib defaultPacking = { - 1, /* Alignment */ - 0, /* RowLength */ - 0, /* SkipPixels */ - 0, /* SkipRows */ - 0, /* ImageHeight */ - 0, /* SkipImages */ - GL_FALSE, /* SwapBytes */ - GL_FALSE /* LsbFirst */ - }; Node *n; GLboolean done; OpCode opcode; - if (!gl_IsList(ctx,list)) + if (!islist(ctx,list)) return; /* mesa_print_display_list( list ); */ @@ -2556,34 +3217,34 @@ static void execute_list( GLcontext *ctx, GLuint list ) break; } case OPCODE_ACCUM: - gl_Accum( ctx, n[1].e, n[2].f ); + (*ctx->Exec.Accum)( n[1].e, n[2].f ); break; case OPCODE_ALPHA_FUNC: - gl_AlphaFunc( ctx, n[1].e, n[2].f ); + (*ctx->Exec.AlphaFunc)( n[1].e, n[2].f ); break; case OPCODE_BIND_TEXTURE: - gl_BindTexture( ctx, n[1].e, n[2].ui ); + (*ctx->Exec.BindTexture)( n[1].e, n[2].ui ); break; case OPCODE_BITMAP: { - const struct gl_image *image = (struct gl_image *) n[7].data; - const GLubyte *bitmap = image ? image->Data : NULL; - gl_Bitmap( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i, - n[3].f, n[4].f, n[5].f, n[6].f, - bitmap, &defaultPacking ); + struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec.Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i, + n[3].f, n[4].f, n[5].f, n[6].f, n[7].data ); + ctx->Unpack = save; /* restore */ } break; case OPCODE_BLEND_COLOR: - gl_BlendColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + (*ctx->Exec.BlendColorEXT)( n[1].f, n[2].f, n[3].f, n[4].f ); break; case OPCODE_BLEND_EQUATION: - gl_BlendEquation( ctx, n[1].e ); + (*ctx->Exec.BlendEquationEXT)( n[1].e ); break; case OPCODE_BLEND_FUNC: - gl_BlendFunc( ctx, n[1].e, n[2].e ); + (*ctx->Exec.BlendFunc)( n[1].e, n[2].e ); break; case OPCODE_BLEND_FUNC_SEPARATE: - gl_BlendFuncSeparate( ctx, n[1].e, n[2].e, n[3].e, n[4].e ); + (*ctx->Exec.BlendFuncSeparateINGR)(n[1].e, n[2].e, n[3].e, n[4].e); break; case OPCODE_CALL_LIST: /* Generated by glCallList(), don't add ListBase */ @@ -2598,99 +3259,116 @@ static void execute_list( GLcontext *ctx, GLuint list ) } break; case OPCODE_CLEAR: - gl_Clear( ctx, n[1].bf ); + (*ctx->Exec.Clear)( n[1].bf ); break; case OPCODE_CLEAR_COLOR: - gl_ClearColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + (*ctx->Exec.ClearColor)( n[1].f, n[2].f, n[3].f, n[4].f ); break; case OPCODE_CLEAR_ACCUM: - gl_ClearAccum( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + (*ctx->Exec.ClearAccum)( n[1].f, n[2].f, n[3].f, n[4].f ); break; case OPCODE_CLEAR_DEPTH: - gl_ClearDepth( ctx, (GLclampd) n[1].f ); + (*ctx->Exec.ClearDepth)( (GLclampd) n[1].f ); break; case OPCODE_CLEAR_INDEX: - gl_ClearIndex( ctx, n[1].ui ); + (*ctx->Exec.ClearIndex)( n[1].ui ); break; case OPCODE_CLEAR_STENCIL: - gl_ClearStencil( ctx, n[1].i ); + (*ctx->Exec.ClearStencil)( n[1].i ); break; case OPCODE_CLIP_PLANE: { - GLfloat equ[4]; - equ[0] = n[2].f; - equ[1] = n[3].f; - equ[2] = n[4].f; - equ[3] = n[5].f; - gl_ClipPlane( ctx, n[1].e, equ ); + GLdouble eq[4]; + eq[0] = n[2].f; + eq[1] = n[3].f; + eq[2] = n[4].f; + eq[3] = n[5].f; + (*ctx->Exec.ClipPlane)( n[1].e, eq ); } break; case OPCODE_COLOR_MASK: - gl_ColorMask( ctx, n[1].b, n[2].b, n[3].b, n[4].b ); + (*ctx->Exec.ColorMask)( n[1].b, n[2].b, n[3].b, n[4].b ); break; case OPCODE_COLOR_MATERIAL: - gl_ColorMaterial( ctx, n[1].e, n[2].e ); + (*ctx->Exec.ColorMaterial)( n[1].e, n[2].e ); break; case OPCODE_COLOR_TABLE: - gl_ColorTable( ctx, n[1].e, n[2].e, (struct gl_image *) n[3].data); + { + struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec.ColorTableEXT)( n[1].e, n[2].e, n[3].i, n[4].e, + n[5].e, n[6].data ); + ctx->Unpack = save; /* restore */ + } break; case OPCODE_COLOR_SUB_TABLE: - gl_ColorSubTable( ctx, n[1].e, n[2].i, - (struct gl_image *) n[3].data); + { + struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec.ColorSubTableEXT)( n[1].e, n[2].i, n[3].i, + n[4].e, n[5].e, n[6].data ); + ctx->Unpack = save; /* restore */ + } break; case OPCODE_COPY_PIXELS: - gl_CopyPixels( ctx, n[1].i, n[2].i, + (*ctx->Exec.CopyPixels)( n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e ); break; case OPCODE_COPY_TEX_IMAGE1D: - gl_CopyTexImage1D( ctx, n[1].e, n[2].i, n[3].e, n[4].i, - n[5].i, n[6].i, n[7].i ); + (*ctx->Exec.CopyTexImage1D)( n[1].e, n[2].i, n[3].e, n[4].i, + n[5].i, n[6].i, n[7].i ); break; case OPCODE_COPY_TEX_IMAGE2D: - gl_CopyTexImage2D( ctx, n[1].e, n[2].i, n[3].e, n[4].i, - n[5].i, n[6].i, n[7].i, n[8].i ); + (*ctx->Exec.CopyTexImage2D)( n[1].e, n[2].i, n[3].e, n[4].i, + n[5].i, n[6].i, n[7].i, n[8].i ); break; case OPCODE_COPY_TEX_SUB_IMAGE1D: - gl_CopyTexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, - n[5].i, n[6].i ); + (*ctx->Exec.CopyTexSubImage1D)( n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i ); break; case OPCODE_COPY_TEX_SUB_IMAGE2D: - gl_CopyTexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, - n[5].i, n[6].i, n[7].i, n[8].i ); + (*ctx->Exec.CopyTexSubImage2D)( n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, n[8].i ); break; case OPCODE_COPY_TEX_SUB_IMAGE3D: - gl_CopyTexSubImage3D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, - n[5].i, n[6].i, n[7].i, n[8].i, n[9].i); + (*ctx->Exec.CopyTexSubImage3D)( n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, n[8].i , n[9].i); break; case OPCODE_CULL_FACE: - gl_CullFace( ctx, n[1].e ); + (*ctx->Exec.CullFace)( n[1].e ); break; case OPCODE_DEPTH_FUNC: - gl_DepthFunc( ctx, n[1].e ); + (*ctx->Exec.DepthFunc)( n[1].e ); break; case OPCODE_DEPTH_MASK: - gl_DepthMask( ctx, n[1].b ); + (*ctx->Exec.DepthMask)( n[1].b ); break; case OPCODE_DEPTH_RANGE: - gl_DepthRange( ctx, (GLclampd) n[1].f, (GLclampd) n[2].f ); + (*ctx->Exec.DepthRange)( (GLclampd) n[1].f, (GLclampd) n[2].f ); break; case OPCODE_DISABLE: - gl_Disable( ctx, n[1].e ); + (*ctx->Exec.Disable)( n[1].e ); break; case OPCODE_DRAW_BUFFER: - gl_DrawBuffer( ctx, n[1].e ); + (*ctx->Exec.DrawBuffer)( n[1].e ); break; case OPCODE_DRAW_PIXELS: - gl_DrawPixels( ctx, (struct gl_image *) n[1].data ); + { + struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec.DrawPixels)( n[1].i, n[2].i, n[3].e, n[4].e, + n[5].data ); + ctx->Unpack = save; /* restore */ + } break; case OPCODE_ENABLE: - gl_Enable( ctx, n[1].e ); + (*ctx->Exec.Enable)( n[1].e ); break; case OPCODE_EVALMESH1: - gl_EvalMesh1( ctx, n[1].e, n[2].i, n[3].i ); + (*ctx->Exec.EvalMesh1)( n[1].e, n[2].i, n[3].i ); break; case OPCODE_EVALMESH2: - gl_EvalMesh2( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i ); + (*ctx->Exec.EvalMesh2)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i ); break; case OPCODE_FOG: { @@ -2699,23 +3377,23 @@ static void execute_list( GLcontext *ctx, GLuint list ) p[1] = n[3].f; p[2] = n[4].f; p[3] = n[5].f; - gl_Fogfv( ctx, n[1].e, p ); + (*ctx->Exec.Fogfv)( n[1].e, p ); } break; case OPCODE_FRONT_FACE: - gl_FrontFace( ctx, n[1].e ); + (*ctx->Exec.FrontFace)( n[1].e ); break; case OPCODE_FRUSTUM: - gl_Frustum( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ); + (*ctx->Exec.Frustum)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ); break; case OPCODE_HINT: - gl_Hint( ctx, n[1].e, n[2].e ); + (*ctx->Exec.Hint)( n[1].e, n[2].e ); break; case OPCODE_INDEX_MASK: - gl_IndexMask( ctx, n[1].ui ); + (*ctx->Exec.IndexMask)( n[1].ui ); break; case OPCODE_INIT_NAMES: - gl_InitNames( ctx ); + (*ctx->Exec.InitNames)(); break; case OPCODE_LIGHT: { @@ -2724,7 +3402,7 @@ static void execute_list( GLcontext *ctx, GLuint list ) p[1] = n[4].f; p[2] = n[5].f; p[3] = n[6].f; - gl_Lightfv( ctx, n[1].e, n[2].e, p, 4 ); + (*ctx->Exec.Lightfv)( n[1].e, n[2].e, p ); } break; case OPCODE_LIGHT_MODEL: @@ -2734,24 +3412,24 @@ static void execute_list( GLcontext *ctx, GLuint list ) p[1] = n[3].f; p[2] = n[4].f; p[3] = n[5].f; - gl_LightModelfv( ctx, n[1].e, p ); + (*ctx->Exec.LightModelfv)( n[1].e, p ); } break; case OPCODE_LINE_STIPPLE: - gl_LineStipple( ctx, n[1].i, n[2].us ); + (*ctx->Exec.LineStipple)( n[1].i, n[2].us ); break; case OPCODE_LINE_WIDTH: - gl_LineWidth( ctx, n[1].f ); + (*ctx->Exec.LineWidth)( n[1].f ); break; case OPCODE_LIST_BASE: - gl_ListBase( ctx, n[1].ui ); + (*ctx->Exec.ListBase)( n[1].ui ); break; case OPCODE_LOAD_IDENTITY: - gl_LoadIdentity( ctx ); + (*ctx->Exec.LoadIdentity)(); break; case OPCODE_LOAD_MATRIX: if (sizeof(Node)==sizeof(GLfloat)) { - gl_LoadMatrixf( ctx, &n[1].f ); + (*ctx->Exec.LoadMatrixf)( &n[1].f ); } else { GLfloat m[16]; @@ -2759,40 +3437,54 @@ static void execute_list( GLcontext *ctx, GLuint list ) for (i=0;i<16;i++) { m[i] = n[1+i].f; } - gl_LoadMatrixf( ctx, m ); + (*ctx->Exec.LoadMatrixf)( m ); } break; case OPCODE_LOAD_NAME: - gl_LoadName( ctx, n[1].ui ); + (*ctx->Exec.LoadName)( n[1].ui ); break; case OPCODE_LOGIC_OP: - gl_LogicOp( ctx, n[1].e ); + (*ctx->Exec.LogicOp)( n[1].e ); break; case OPCODE_MAP1: - gl_Map1f( ctx, n[1].e, n[2].f, n[3].f, - n[4].i, n[5].i, (GLfloat *) n[6].data, GL_TRUE ); + { + GLenum target = n[1].e; + GLint ustride = _mesa_evaluator_components(target); + GLint uorder = n[5].i; + GLfloat u1 = n[2].f; + GLfloat u2 = n[3].f; + (*ctx->Exec.Map1f)( target, u1, u2, ustride, uorder, + (GLfloat *) n[6].data ); + } break; case OPCODE_MAP2: - gl_Map2f( ctx, n[1].e, - n[2].f, n[3].f, /* u1, u2 */ - n[6].i, n[8].i, /* ustride, uorder */ - n[4].f, n[5].f, /* v1, v2 */ - n[7].i, n[9].i, /* vstride, vorder */ - (GLfloat *) n[10].data, - GL_TRUE); + { + GLenum target = n[1].e; + GLfloat u1 = n[2].f; + GLfloat u2 = n[3].f; + GLfloat v1 = n[4].f; + GLfloat v2 = n[5].f; + GLint ustride = n[6].i; + GLint vstride = n[7].i; + GLint uorder = n[8].i; + GLint vorder = n[9].i; + (*ctx->Exec.Map2f)( target, u1, u2, ustride, uorder, + v1, v2, vstride, vorder, + (GLfloat *) n[10].data ); + } break; case OPCODE_MAPGRID1: - gl_MapGrid1f( ctx, n[1].i, n[2].f, n[3].f ); + (*ctx->Exec.MapGrid1f)( n[1].i, n[2].f, n[3].f ); break; case OPCODE_MAPGRID2: - gl_MapGrid2f( ctx, n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); + (*ctx->Exec.MapGrid2f)( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); break; case OPCODE_MATRIX_MODE: - gl_MatrixMode( ctx, n[1].e ); + (*ctx->Exec.MatrixMode)( n[1].e ); break; case OPCODE_MULT_MATRIX: if (sizeof(Node)==sizeof(GLfloat)) { - gl_MultMatrixf( ctx, &n[1].f ); + (*ctx->Exec.MultMatrixf)( &n[1].f ); } else { GLfloat m[16]; @@ -2800,26 +3492,26 @@ static void execute_list( GLcontext *ctx, GLuint list ) for (i=0;i<16;i++) { m[i] = n[1+i].f; } - gl_MultMatrixf( ctx, m ); + (*ctx->Exec.MultMatrixf)( m ); } break; case OPCODE_ORTHO: - gl_Ortho( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ); + (*ctx->Exec.Ortho)( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ); break; case OPCODE_PASSTHROUGH: - gl_PassThrough( ctx, n[1].f ); + (*ctx->Exec.PassThrough)( n[1].f ); break; case OPCODE_PIXEL_MAP: - gl_PixelMapfv( ctx, n[1].e, n[2].i, (GLfloat *) n[3].data ); + (*ctx->Exec.PixelMapfv)( n[1].e, n[2].i, (GLfloat *) n[3].data ); break; case OPCODE_PIXEL_TRANSFER: - gl_PixelTransferf( ctx, n[1].e, n[2].f ); + (*ctx->Exec.PixelTransferf)( n[1].e, n[2].f ); break; case OPCODE_PIXEL_ZOOM: - gl_PixelZoom( ctx, n[1].f, n[2].f ); + (*ctx->Exec.PixelZoom)( n[1].f, n[2].f ); break; case OPCODE_POINT_SIZE: - gl_PointSize( ctx, n[1].f ); + (*ctx->Exec.PointSize)( n[1].f ); break; case OPCODE_POINT_PARAMETERS: { @@ -2827,65 +3519,65 @@ static void execute_list( GLcontext *ctx, GLuint list ) params[0] = n[2].f; params[1] = n[3].f; params[2] = n[4].f; - gl_PointParameterfvEXT( ctx, n[1].e, params ); + (*ctx->Exec.PointParameterfvEXT)( n[1].e, params ); } break; case OPCODE_POLYGON_MODE: - gl_PolygonMode( ctx, n[1].e, n[2].e ); + (*ctx->Exec.PolygonMode)( n[1].e, n[2].e ); break; case OPCODE_POLYGON_STIPPLE: - gl_PolygonStipple( ctx, (GLuint *) n[1].data ); + (*ctx->Exec.PolygonStipple)( (GLubyte *) n[1].data ); break; case OPCODE_POLYGON_OFFSET: - gl_PolygonOffset( ctx, n[1].f, n[2].f ); + (*ctx->Exec.PolygonOffset)( n[1].f, n[2].f ); break; case OPCODE_POP_ATTRIB: - gl_PopAttrib( ctx ); + (*ctx->Exec.PopAttrib)(); break; case OPCODE_POP_MATRIX: - gl_PopMatrix( ctx ); + (*ctx->Exec.PopMatrix)(); break; case OPCODE_POP_NAME: - gl_PopName( ctx ); + (*ctx->Exec.PopName)(); break; case OPCODE_PRIORITIZE_TEXTURE: - gl_PrioritizeTextures( ctx, 1, &n[1].ui, &n[2].f ); + (*ctx->Exec.PrioritizeTextures)( 1, &n[1].ui, &n[2].f ); break; case OPCODE_PUSH_ATTRIB: - gl_PushAttrib( ctx, n[1].bf ); + (*ctx->Exec.PushAttrib)( n[1].bf ); break; case OPCODE_PUSH_MATRIX: - gl_PushMatrix( ctx ); + (*ctx->Exec.PushMatrix)(); break; case OPCODE_PUSH_NAME: - gl_PushName( ctx, n[1].ui ); + (*ctx->Exec.PushName)( n[1].ui ); break; case OPCODE_RASTER_POS: - gl_RasterPos4f( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + (*ctx->Exec.RasterPos4f)( n[1].f, n[2].f, n[3].f, n[4].f ); break; case OPCODE_READ_BUFFER: - gl_ReadBuffer( ctx, n[1].e ); + (*ctx->Exec.ReadBuffer)( n[1].e ); break; case OPCODE_RECTF: - gl_Rectf( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + (*ctx->Exec.Rectf)( n[1].f, n[2].f, n[3].f, n[4].f ); break; case OPCODE_SCALE: - gl_Scalef( ctx, n[1].f, n[2].f, n[3].f ); + (*ctx->Exec.Scalef)( n[1].f, n[2].f, n[3].f ); break; case OPCODE_SCISSOR: - gl_Scissor( ctx, n[1].i, n[2].i, n[3].i, n[4].i ); + (*ctx->Exec.Scissor)( n[1].i, n[2].i, n[3].i, n[4].i ); break; case OPCODE_SHADE_MODEL: - gl_ShadeModel( ctx, n[1].e ); + (*ctx->Exec.ShadeModel)( n[1].e ); break; case OPCODE_STENCIL_FUNC: - gl_StencilFunc( ctx, n[1].e, n[2].i, n[3].ui ); + (*ctx->Exec.StencilFunc)( n[1].e, n[2].i, n[3].ui ); break; case OPCODE_STENCIL_MASK: - gl_StencilMask( ctx, n[1].ui ); + (*ctx->Exec.StencilMask)( n[1].ui ); break; case OPCODE_STENCIL_OP: - gl_StencilOp( ctx, n[1].e, n[2].e, n[3].e ); + (*ctx->Exec.StencilOp)( n[1].e, n[2].e, n[3].e ); break; case OPCODE_TEXENV: { @@ -2894,7 +3586,7 @@ static void execute_list( GLcontext *ctx, GLuint list ) params[1] = n[4].f; params[2] = n[5].f; params[3] = n[6].f; - gl_TexEnvfv( ctx, n[1].e, n[2].e, params ); + (*ctx->Exec.TexEnvfv)( n[1].e, n[2].e, params ); } break; case OPCODE_TEXGEN: @@ -2904,7 +3596,7 @@ static void execute_list( GLcontext *ctx, GLuint list ) params[1] = n[4].f; params[2] = n[5].f; params[3] = n[6].f; - gl_TexGenfv( ctx, n[1].e, n[2].e, params ); + (*ctx->Exec.TexGenfv)( n[1].e, n[2].e, params ); } break; case OPCODE_TEXPARAMETER: @@ -2914,74 +3606,75 @@ static void execute_list( GLcontext *ctx, GLuint list ) params[1] = n[4].f; params[2] = n[5].f; params[3] = n[6].f; - gl_TexParameterfv( ctx, n[1].e, n[2].e, params ); + (*ctx->Exec.TexParameterfv)( n[1].e, n[2].e, params ); } break; case OPCODE_TEX_IMAGE1D: { struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = defaultPacking; - gl_TexImage1D( ctx, - n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].e, /* border */ - n[6].e, /* format */ - n[7].e, /* type */ - n[8].data ); + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec.TexImage1D)( + n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].e, /* border */ + n[6].e, /* format */ + n[7].e, /* type */ + n[8].data ); ctx->Unpack = save; /* restore */ } break; case OPCODE_TEX_IMAGE2D: { struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = defaultPacking; - gl_TexImage2D( ctx, - n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].i, /* height */ - n[6].e, /* border */ - n[7].e, /* format */ - n[8].e, /* type */ - n[9].data ); + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec.TexImage2D)( + n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].i, /* height */ + n[6].e, /* border */ + n[7].e, /* format */ + n[8].e, /* type */ + n[9].data ); ctx->Unpack = save; /* restore */ } break; case OPCODE_TEX_IMAGE3D: { struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = defaultPacking; - gl_TexImage3D( ctx, - n[1].e, /* target */ - n[2].i, /* level */ - n[3].i, /* components */ - n[4].i, /* width */ - n[5].i, /* height */ - n[6].i, /* depth */ - n[7].e, /* border */ - n[8].e, /* format */ - n[9].e, /* type */ - n[10].data ); + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec.TexImage3D)( + n[1].e, /* target */ + n[2].i, /* level */ + n[3].i, /* components */ + n[4].i, /* width */ + n[5].i, /* height */ + n[6].i, /* depth */ + n[7].e, /* border */ + n[8].e, /* format */ + n[9].e, /* type */ + n[10].data ); ctx->Unpack = save; /* restore */ } break; case OPCODE_TEX_SUB_IMAGE1D: { struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = defaultPacking; - gl_TexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e, - n[6].e, n[7].data ); + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec.TexSubImage1D)( n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, + n[6].e, n[7].data ); ctx->Unpack = save; /* restore */ } break; case OPCODE_TEX_SUB_IMAGE2D: { struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = defaultPacking; - (*ctx->Exec.TexSubImage2D)( ctx, n[1].e, n[2].i, n[3].i, + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec.TexSubImage2D)( n[1].e, n[2].i, n[3].i, n[4].i, n[5].e, n[6].i, n[7].e, n[8].e, n[9].data ); ctx->Unpack = save; /* restore */ @@ -2990,28 +3683,29 @@ static void execute_list( GLcontext *ctx, GLuint list ) case OPCODE_TEX_SUB_IMAGE3D: { struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = defaultPacking; - gl_TexSubImage3D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i, - n[6].i, n[7].i, n[8].i, n[9].e, n[10].e, - n[11].data ); + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec.TexSubImage3D)( n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, + n[8].i, n[9].e, n[10].e, + n[11].data ); ctx->Unpack = save; /* restore */ } break; case OPCODE_TRANSLATE: - gl_Translatef( ctx, n[1].f, n[2].f, n[3].f ); + (*ctx->Exec.Translatef)( n[1].f, n[2].f, n[3].f ); break; case OPCODE_VIEWPORT: - gl_Viewport( ctx, - n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i ); + (*ctx->Exec.Viewport)(n[1].i, n[2].i, + (GLsizei) n[3].i, (GLsizei) n[4].i); break; case OPCODE_WINDOW_POS: - gl_WindowPos4fMESA( ctx, n[1].f, n[2].f, n[3].f, n[4].f ); + (*ctx->Exec.WindowPos4fMESA)( n[1].f, n[2].f, n[3].f, n[4].f ); break; case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ - gl_ActiveTexture( ctx, n[1].e ); + (*ctx->Exec.ActiveTextureARB)( n[1].e ); break; case OPCODE_CLIENT_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ - gl_ClientActiveTexture( ctx, n[1].e ); + (*ctx->Exec.ClientActiveTextureARB)( n[1].e ); break; case OPCODE_CONTINUE: n = (Node *) n[1].next; @@ -3051,23 +3745,21 @@ static void execute_list( GLcontext *ctx, GLuint list ) /* * Test if a display list number is valid. */ -GLboolean gl_IsList( GLcontext *ctx, GLuint list ) +GLboolean +_mesa_IsList( GLuint list ) { - if (list > 0 && HashLookup(ctx->Shared->DisplayList, list)) { - return GL_TRUE; - } - else { - return GL_FALSE; - } + GET_CURRENT_CONTEXT(ctx); + return islist(ctx, list); } - /* * Delete a sequence of consecutive display lists. */ -void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range ) +void +_mesa_DeleteLists( GLuint list, GLsizei range ) { + GET_CURRENT_CONTEXT(ctx); GLuint i; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteLists"); @@ -3086,8 +3778,10 @@ void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range ) * Return a display list number, n, such that lists n through n+range-1 * are free. */ -GLuint gl_GenLists( GLcontext *ctx, GLsizei range ) +GLuint +_mesa_GenLists(GLsizei range ) { + GET_CURRENT_CONTEXT(ctx); GLuint base; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGenLists", 0); @@ -3115,8 +3809,10 @@ GLuint gl_GenLists( GLcontext *ctx, GLsizei range ) /* * Begin a new display list. */ -void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode ) +void +_mesa_NewList( GLuint list, GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); struct immediate *IM; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glNewList"); @@ -3152,7 +3848,9 @@ void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode ) ctx->CompileFlag = GL_TRUE; ctx->CompileCVAFlag = GL_FALSE; ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE); - ctx->API = ctx->Save; /* Switch the API function pointers */ + + ctx->CurrentDispatch = &ctx->Save; + _glapi_set_dispatch( ctx->CurrentDispatch ); } @@ -3160,8 +3858,10 @@ void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode ) /* * End definition of current display list. */ -void gl_EndList( GLcontext *ctx ) +void +_mesa_EndList( void ) { + GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE&VERBOSE_API) fprintf(stderr, "glEndList\n"); @@ -3202,13 +3902,16 @@ void gl_EndList( GLcontext *ctx ) */ ctx->NewState = ~0; - ctx->API = ctx->Exec; /* Switch the API function pointers */ + ctx->CurrentDispatch = &ctx->Exec; + _glapi_set_dispatch( ctx->CurrentDispatch ); } -void gl_CallList( GLcontext *ctx, GLuint list ) +void +_mesa_CallList( GLuint list ) { + GET_CURRENT_CONTEXT(ctx); /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */ /* execute the display list, and restore the CompileFlag. */ GLboolean save_compile_flag; @@ -3226,8 +3929,10 @@ void gl_CallList( GLcontext *ctx, GLuint list ) ctx->CompileFlag = save_compile_flag; /* also restore API function pointers to point to "save" versions */ - if (save_compile_flag) - ctx->API = ctx->Save; + if (save_compile_flag) { + ctx->CurrentDispatch = &ctx->Save; + _glapi_set_dispatch( ctx->CurrentDispatch ); + } } @@ -3235,9 +3940,10 @@ void gl_CallList( GLcontext *ctx, GLuint list ) /* * Execute glCallLists: call multiple display lists. */ -void gl_CallLists( GLcontext *ctx, - GLsizei n, GLenum type, const GLvoid *lists ) +void +_mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists ) { + GET_CURRENT_CONTEXT(ctx); GLuint list; GLint i; GLboolean save_compile_flag; @@ -3258,9 +3964,10 @@ void gl_CallLists( GLcontext *ctx, ctx->CompileFlag = save_compile_flag; /* also restore API function pointers to point to "save" versions */ - if (save_compile_flag) - ctx->API = ctx->Save; - + if (save_compile_flag) { + ctx->CurrentDispatch = &ctx->Save; + _glapi_set_dispatch( ctx->CurrentDispatch ); + } /* RESET_IMMEDIATE( ctx ); */ } @@ -3270,8 +3977,10 @@ void gl_CallLists( GLcontext *ctx, /* * Set the offset added to list numbers in glCallLists. */ -void gl_ListBase( GLcontext *ctx, GLuint base ) +void +_mesa_ListBase( GLuint base ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glListBase"); ctx->List.ListBase = base; } @@ -3279,23 +3988,18 @@ void gl_ListBase( GLcontext *ctx, GLuint base ) - - /* * Assign all the pointers in 'table' to point to Mesa's display list * building functions. */ -void gl_init_dlist_pointers( struct gl_api_table *table ) +void +_mesa_init_dlist_table( struct _glapi_table *table ) { table->Accum = save_Accum; table->AlphaFunc = save_AlphaFunc; - table->AreTexturesResident = gl_AreTexturesResident; - table->BindTexture = save_BindTexture; + table->Begin = save_Begin; table->Bitmap = save_Bitmap; - table->BlendColor = save_BlendColor; - table->BlendEquation = save_BlendEquation; table->BlendFunc = save_BlendFunc; - table->BlendFuncSeparate = save_BlendFuncSeparate; table->CallList = save_CallList; table->CallLists = save_CallLists; table->Clear = save_Clear; @@ -3305,150 +4009,455 @@ void gl_init_dlist_pointers( struct gl_api_table *table ) table->ClearIndex = save_ClearIndex; table->ClearStencil = save_ClearStencil; table->ClipPlane = save_ClipPlane; + table->Color3b = _mesa_Color3b; + table->Color3bv = _mesa_Color3bv; + table->Color3d = _mesa_Color3d; + table->Color3dv = _mesa_Color3dv; + table->Color3f = _mesa_Color3f; + table->Color3fv = _mesa_Color3fv; + table->Color3i = _mesa_Color3i; + table->Color3iv = _mesa_Color3iv; + table->Color3s = _mesa_Color3s; + table->Color3sv = _mesa_Color3sv; + table->Color3ub = _mesa_Color3ub; + table->Color3ubv = _mesa_Color3ubv; + table->Color3ui = _mesa_Color3ui; + table->Color3uiv = _mesa_Color3uiv; + table->Color3us = _mesa_Color3us; + table->Color3usv = _mesa_Color3usv; + table->Color4b = _mesa_Color4b; + table->Color4bv = _mesa_Color4bv; + table->Color4d = _mesa_Color4d; + table->Color4dv = _mesa_Color4dv; + table->Color4f = _mesa_Color4f; + table->Color4fv = _mesa_Color4fv; + table->Color4i = _mesa_Color4i; + table->Color4iv = _mesa_Color4iv; + table->Color4s = _mesa_Color4s; + table->Color4sv = _mesa_Color4sv; + table->Color4ub = _mesa_Color4ub; + table->Color4ubv = _mesa_Color4ubv; + table->Color4ui = _mesa_Color4ui; + table->Color4uiv = _mesa_Color4uiv; + table->Color4us = _mesa_Color4us; + table->Color4usv = _mesa_Color4usv; table->ColorMask = save_ColorMask; table->ColorMaterial = save_ColorMaterial; - table->ColorTable = save_ColorTable; - table->ColorSubTable = save_ColorSubTable; table->CopyPixels = save_CopyPixels; - table->CopyTexImage1D = save_CopyTexImage1D; - table->CopyTexImage2D = save_CopyTexImage2D; - table->CopyTexSubImage1D = save_CopyTexSubImage1D; - table->CopyTexSubImage2D = save_CopyTexSubImage2D; - table->CopyTexSubImage3D = save_CopyTexSubImage3D; table->CullFace = save_CullFace; - table->DeleteLists = gl_DeleteLists; /* NOT SAVED */ - table->DeleteTextures = gl_DeleteTextures; /* NOT SAVED */ + table->DeleteLists = _mesa_DeleteLists; table->DepthFunc = save_DepthFunc; table->DepthMask = save_DepthMask; table->DepthRange = save_DepthRange; table->Disable = save_Disable; - table->DisableClientState = gl_DisableClientState; /* NOT SAVED */ table->DrawBuffer = save_DrawBuffer; table->DrawPixels = save_DrawPixels; + table->EdgeFlag = _mesa_EdgeFlag; + table->EdgeFlagv = _mesa_EdgeFlagv; table->Enable = save_Enable; - table->Error = gl_save_error; - table->EnableClientState = gl_EnableClientState; /* NOT SAVED */ - table->EndList = gl_EndList; /* NOT SAVED */ + table->End = _mesa_End; + table->EndList = _mesa_EndList; + table->EvalCoord1d = _mesa_EvalCoord1d; + table->EvalCoord1dv = _mesa_EvalCoord1dv; + table->EvalCoord1f = _mesa_EvalCoord1f; + table->EvalCoord1fv = _mesa_EvalCoord1fv; + table->EvalCoord2d = _mesa_EvalCoord2d; + table->EvalCoord2dv = _mesa_EvalCoord2dv; + table->EvalCoord2f = _mesa_EvalCoord2f; + table->EvalCoord2fv = _mesa_EvalCoord2fv; table->EvalMesh1 = save_EvalMesh1; table->EvalMesh2 = save_EvalMesh2; - table->FeedbackBuffer = gl_FeedbackBuffer; /* NOT SAVED */ - table->Finish = gl_Finish; /* NOT SAVED */ - table->Flush = gl_Flush; /* NOT SAVED */ + table->EvalPoint1 = _mesa_EvalPoint1; + table->EvalPoint2 = _mesa_EvalPoint2; + table->FeedbackBuffer = _mesa_FeedbackBuffer; + table->Finish = _mesa_Finish; + table->Flush = _mesa_Flush; + table->Fogf = save_Fogf; table->Fogfv = save_Fogfv; + table->Fogi = save_Fogi; + table->Fogiv = save_Fogiv; table->FrontFace = save_FrontFace; table->Frustum = save_Frustum; - table->GenLists = gl_GenLists; /* NOT SAVED */ - table->GenTextures = gl_GenTextures; /* NOT SAVED */ - - /* NONE OF THESE COMMANDS ARE COMPILED INTO DISPLAY LISTS */ - table->GetBooleanv = gl_GetBooleanv; - table->GetClipPlane = gl_GetClipPlane; - table->GetColorTable = gl_GetColorTable; - table->GetColorTableParameteriv = gl_GetColorTableParameteriv; - table->GetDoublev = gl_GetDoublev; - table->GetError = gl_GetError; - table->GetFloatv = gl_GetFloatv; - table->GetIntegerv = gl_GetIntegerv; - table->GetString = gl_GetString; - table->GetLightfv = gl_GetLightfv; - table->GetLightiv = gl_GetLightiv; - table->GetMapdv = gl_GetMapdv; - table->GetMapfv = gl_GetMapfv; - table->GetMapiv = gl_GetMapiv; - table->GetMaterialfv = gl_GetMaterialfv; - table->GetMaterialiv = gl_GetMaterialiv; - table->GetPixelMapfv = gl_GetPixelMapfv; - table->GetPixelMapuiv = gl_GetPixelMapuiv; - table->GetPixelMapusv = gl_GetPixelMapusv; - table->GetPointerv = gl_GetPointerv; - table->GetPolygonStipple = gl_GetPolygonStipple; - table->GetTexEnvfv = gl_GetTexEnvfv; - table->GetTexEnviv = gl_GetTexEnviv; - table->GetTexGendv = gl_GetTexGendv; - table->GetTexGenfv = gl_GetTexGenfv; - table->GetTexGeniv = gl_GetTexGeniv; - table->GetTexImage = gl_GetTexImage; - table->GetTexLevelParameterfv = gl_GetTexLevelParameterfv; - table->GetTexLevelParameteriv = gl_GetTexLevelParameteriv; - table->GetTexParameterfv = gl_GetTexParameterfv; - table->GetTexParameteriv = gl_GetTexParameteriv; - + table->GenLists = _mesa_GenLists; + table->GetBooleanv = _mesa_GetBooleanv; + table->GetClipPlane = _mesa_GetClipPlane; + table->GetDoublev = _mesa_GetDoublev; + table->GetError = _mesa_GetError; + table->GetFloatv = _mesa_GetFloatv; + table->GetIntegerv = _mesa_GetIntegerv; + table->GetLightfv = _mesa_GetLightfv; + table->GetLightiv = _mesa_GetLightiv; + table->GetMapdv = _mesa_GetMapdv; + table->GetMapfv = _mesa_GetMapfv; + table->GetMapiv = _mesa_GetMapiv; + table->GetMaterialfv = _mesa_GetMaterialfv; + table->GetMaterialiv = _mesa_GetMaterialiv; + table->GetPixelMapfv = _mesa_GetPixelMapfv; + table->GetPixelMapuiv = _mesa_GetPixelMapuiv; + table->GetPixelMapusv = _mesa_GetPixelMapusv; + table->GetPolygonStipple = _mesa_GetPolygonStipple; + table->GetString = _mesa_GetString; + table->GetTexEnvfv = _mesa_GetTexEnvfv; + table->GetTexEnviv = _mesa_GetTexEnviv; + table->GetTexGendv = _mesa_GetTexGendv; + table->GetTexGenfv = _mesa_GetTexGenfv; + table->GetTexGeniv = _mesa_GetTexGeniv; + table->GetTexImage = _mesa_GetTexImage; + table->GetTexLevelParameterfv = _mesa_GetTexLevelParameterfv; + table->GetTexLevelParameteriv = _mesa_GetTexLevelParameteriv; + table->GetTexParameterfv = _mesa_GetTexParameterfv; + table->GetTexParameteriv = _mesa_GetTexParameteriv; table->Hint = save_Hint; table->IndexMask = save_IndexMask; + table->Indexd = _mesa_Indexd; + table->Indexdv = _mesa_Indexdv; + table->Indexf = _mesa_Indexf; + table->Indexfv = _mesa_Indexfv; + table->Indexi = _mesa_Indexi; + table->Indexiv = _mesa_Indexiv; + table->Indexs = _mesa_Indexs; + table->Indexsv = _mesa_Indexsv; table->InitNames = save_InitNames; - table->IsEnabled = gl_IsEnabled; /* NOT SAVED */ - table->IsTexture = gl_IsTexture; /* NOT SAVED */ - table->IsList = gl_IsList; /* NOT SAVED */ + table->IsEnabled = _mesa_IsEnabled; + table->IsList = _mesa_IsList; + table->LightModelf = save_LightModelf; table->LightModelfv = save_LightModelfv; + table->LightModeli = save_LightModeli; + table->LightModeliv = save_LightModeliv; + table->Lightf = save_Lightf; table->Lightfv = save_Lightfv; + table->Lighti = save_Lighti; + table->Lightiv = save_Lightiv; table->LineStipple = save_LineStipple; table->LineWidth = save_LineWidth; table->ListBase = save_ListBase; table->LoadIdentity = save_LoadIdentity; + table->LoadMatrixd = save_LoadMatrixd; table->LoadMatrixf = save_LoadMatrixf; table->LoadName = save_LoadName; table->LogicOp = save_LogicOp; + table->Map1d = save_Map1d; table->Map1f = save_Map1f; + table->Map2d = save_Map2d; table->Map2f = save_Map2f; + table->MapGrid1d = save_MapGrid1d; table->MapGrid1f = save_MapGrid1f; + table->MapGrid2d = save_MapGrid2d; table->MapGrid2f = save_MapGrid2f; + table->Materialf = _mesa_Materialf; + table->Materialfv = _mesa_Materialfv; + table->Materiali = _mesa_Materiali; + table->Materialiv = _mesa_Materialiv; table->MatrixMode = save_MatrixMode; + table->MultMatrixd = save_MultMatrixd; table->MultMatrixf = save_MultMatrixf; table->NewList = save_NewList; + table->Normal3b = _mesa_Normal3b; + table->Normal3bv = _mesa_Normal3bv; + table->Normal3d = _mesa_Normal3d; + table->Normal3dv = _mesa_Normal3dv; + table->Normal3f = _mesa_Normal3f; + table->Normal3fv = _mesa_Normal3fv; + table->Normal3i = _mesa_Normal3i; + table->Normal3iv = _mesa_Normal3iv; + table->Normal3s = _mesa_Normal3s; + table->Normal3sv = _mesa_Normal3sv; table->Ortho = save_Ortho; - table->PointParameterfvEXT = save_PointParameterfvEXT; table->PassThrough = save_PassThrough; table->PixelMapfv = save_PixelMapfv; - table->PixelStorei = gl_PixelStorei; /* NOT SAVED */ + table->PixelMapuiv = save_PixelMapuiv; + table->PixelMapusv = save_PixelMapusv; + table->PixelStoref = _mesa_PixelStoref; + table->PixelStorei = _mesa_PixelStorei; table->PixelTransferf = save_PixelTransferf; + table->PixelTransferi = save_PixelTransferi; table->PixelZoom = save_PixelZoom; table->PointSize = save_PointSize; table->PolygonMode = save_PolygonMode; table->PolygonOffset = save_PolygonOffset; table->PolygonStipple = save_PolygonStipple; table->PopAttrib = save_PopAttrib; - table->PopClientAttrib = gl_PopClientAttrib; /* NOT SAVED */ table->PopMatrix = save_PopMatrix; table->PopName = save_PopName; - table->PrioritizeTextures = save_PrioritizeTextures; table->PushAttrib = save_PushAttrib; - table->PushClientAttrib = gl_PushClientAttrib; /* NOT SAVED */ table->PushMatrix = save_PushMatrix; table->PushName = save_PushName; + table->RasterPos2d = save_RasterPos2d; + table->RasterPos2dv = save_RasterPos2dv; + table->RasterPos2f = save_RasterPos2f; + table->RasterPos2fv = save_RasterPos2fv; + table->RasterPos2i = save_RasterPos2i; + table->RasterPos2iv = save_RasterPos2iv; + table->RasterPos2s = save_RasterPos2s; + table->RasterPos2sv = save_RasterPos2sv; + table->RasterPos3d = save_RasterPos3d; + table->RasterPos3dv = save_RasterPos3dv; + table->RasterPos3f = save_RasterPos3f; + table->RasterPos3fv = save_RasterPos3fv; + table->RasterPos3i = save_RasterPos3i; + table->RasterPos3iv = save_RasterPos3iv; + table->RasterPos3s = save_RasterPos3s; + table->RasterPos3sv = save_RasterPos3sv; + table->RasterPos4d = save_RasterPos4d; + table->RasterPos4dv = save_RasterPos4dv; table->RasterPos4f = save_RasterPos4f; + table->RasterPos4fv = save_RasterPos4fv; + table->RasterPos4i = save_RasterPos4i; + table->RasterPos4iv = save_RasterPos4iv; + table->RasterPos4s = save_RasterPos4s; + table->RasterPos4sv = save_RasterPos4sv; table->ReadBuffer = save_ReadBuffer; - table->ReadPixels = gl_ReadPixels; /* NOT SAVED */ + table->ReadPixels = _mesa_ReadPixels; + table->Rectd = save_Rectd; + table->Rectdv = save_Rectdv; table->Rectf = save_Rectf; - table->RenderMode = gl_RenderMode; /* NOT SAVED */ + table->Rectfv = save_Rectfv; + table->Recti = save_Recti; + table->Rectiv = save_Rectiv; + table->Rects = save_Rects; + table->Rectsv = save_Rectsv; + table->RenderMode = _mesa_RenderMode; + table->Rotated = save_Rotated; table->Rotatef = save_Rotatef; + table->Scaled = save_Scaled; table->Scalef = save_Scalef; table->Scissor = save_Scissor; - table->SelectBuffer = gl_SelectBuffer; /* NOT SAVED */ + table->SelectBuffer = _mesa_SelectBuffer; table->ShadeModel = save_ShadeModel; table->StencilFunc = save_StencilFunc; table->StencilMask = save_StencilMask; table->StencilOp = save_StencilOp; + table->TexCoord1d = _mesa_TexCoord1d; + table->TexCoord1dv = _mesa_TexCoord1dv; + table->TexCoord1f = _mesa_TexCoord1f; + table->TexCoord1fv = _mesa_TexCoord1fv; + table->TexCoord1i = _mesa_TexCoord1i; + table->TexCoord1iv = _mesa_TexCoord1iv; + table->TexCoord1s = _mesa_TexCoord1s; + table->TexCoord1sv = _mesa_TexCoord1sv; + table->TexCoord2d = _mesa_TexCoord2d; + table->TexCoord2dv = _mesa_TexCoord2dv; + table->TexCoord2f = _mesa_TexCoord2f; + table->TexCoord2fv = _mesa_TexCoord2fv; + table->TexCoord2i = _mesa_TexCoord2i; + table->TexCoord2iv = _mesa_TexCoord2iv; + table->TexCoord2s = _mesa_TexCoord2s; + table->TexCoord2sv = _mesa_TexCoord2sv; + table->TexCoord3d = _mesa_TexCoord3d; + table->TexCoord3dv = _mesa_TexCoord3dv; + table->TexCoord3f = _mesa_TexCoord3f; + table->TexCoord3fv = _mesa_TexCoord3fv; + table->TexCoord3i = _mesa_TexCoord3i; + table->TexCoord3iv = _mesa_TexCoord3iv; + table->TexCoord3s = _mesa_TexCoord3s; + table->TexCoord3sv = _mesa_TexCoord3sv; + table->TexCoord4d = _mesa_TexCoord4d; + table->TexCoord4dv = _mesa_TexCoord4dv; + table->TexCoord4f = _mesa_TexCoord4f; + table->TexCoord4fv = _mesa_TexCoord4fv; + table->TexCoord4i = _mesa_TexCoord4i; + table->TexCoord4iv = _mesa_TexCoord4iv; + table->TexCoord4s = _mesa_TexCoord4s; + table->TexCoord4sv = _mesa_TexCoord4sv; + table->TexEnvf = save_TexEnvf; table->TexEnvfv = save_TexEnvfv; + table->TexEnvi = save_TexEnvi; + table->TexEnviv = save_TexEnviv; + table->TexGend = save_TexGend; + table->TexGendv = save_TexGendv; + table->TexGenf = save_TexGenf; table->TexGenfv = save_TexGenfv; + table->TexGeni = save_TexGeni; + table->TexGeniv = save_TexGeniv; table->TexImage1D = save_TexImage1D; table->TexImage2D = save_TexImage2D; - table->TexImage3D = save_TexImage3D; - table->TexSubImage1D = save_TexSubImage1D; - table->TexSubImage2D = save_TexSubImage2D; - table->TexSubImage3D = save_TexSubImage3D; + table->TexParameterf = save_TexParameterf; table->TexParameterfv = save_TexParameterfv; + table->TexParameteri = save_TexParameteri; + table->TexParameteriv = save_TexParameteriv; + table->Translated = save_Translated; table->Translatef = save_Translatef; + table->Vertex2d = _mesa_Vertex2d; + table->Vertex2dv = _mesa_Vertex2dv; + table->Vertex2f = _mesa_Vertex2f; + table->Vertex2fv = _mesa_Vertex2fv; + table->Vertex2i = _mesa_Vertex2i; + table->Vertex2iv = _mesa_Vertex2iv; + table->Vertex2s = _mesa_Vertex2s; + table->Vertex2sv = _mesa_Vertex2sv; + table->Vertex3d = _mesa_Vertex3d; + table->Vertex3dv = _mesa_Vertex3dv; + table->Vertex3f = _mesa_Vertex3f; + table->Vertex3fv = _mesa_Vertex3fv; + table->Vertex3i = _mesa_Vertex3i; + table->Vertex3iv = _mesa_Vertex3iv; + table->Vertex3s = _mesa_Vertex3s; + table->Vertex3sv = _mesa_Vertex3sv; + table->Vertex4d = _mesa_Vertex4d; + table->Vertex4dv = _mesa_Vertex4dv; + table->Vertex4f = _mesa_Vertex4f; + table->Vertex4fv = _mesa_Vertex4fv; + table->Vertex4i = _mesa_Vertex4i; + table->Vertex4iv = _mesa_Vertex4iv; + table->Vertex4s = _mesa_Vertex4s; + table->Vertex4sv = _mesa_Vertex4sv; table->Viewport = save_Viewport; - /* GL_MESA_window_pos extension */ - table->WindowPos4fMESA = save_WindowPos4fMESA; +#ifdef _GLAPI_VERSION_1_1 + table->AreTexturesResident = _mesa_AreTexturesResident; + table->ArrayElement = _mesa_ArrayElement; + table->BindTexture = save_BindTexture; + table->ColorPointer = _mesa_ColorPointer; + table->CopyTexImage1D = save_CopyTexImage1D; + table->CopyTexImage2D = save_CopyTexImage2D; + table->CopyTexSubImage1D = save_CopyTexSubImage1D; + table->CopyTexSubImage2D = save_CopyTexSubImage2D; + table->DeleteTextures = _mesa_DeleteTextures; + table->DisableClientState = _mesa_DisableClientState; + table->DrawArrays = _mesa_DrawArrays; + table->DrawElements = _mesa_DrawElements; + table->EdgeFlagPointer = _mesa_EdgeFlagPointer; + table->EnableClientState = _mesa_EnableClientState; + table->GenTextures = _mesa_GenTextures; + table->GetPointerv = _mesa_GetPointerv; + table->IndexPointer = _mesa_IndexPointer; + table->Indexub = _mesa_Indexub; + table->Indexubv = _mesa_Indexubv; + table->InterleavedArrays = _mesa_InterleavedArrays; + table->IsTexture = _mesa_IsTexture; + table->NormalPointer = _mesa_NormalPointer; + table->PopClientAttrib = _mesa_PopClientAttrib; + table->PrioritizeTextures = save_PrioritizeTextures; + table->PushClientAttrib = _mesa_PushClientAttrib; + table->TexCoordPointer = _mesa_TexCoordPointer; + table->TexSubImage1D = save_TexSubImage1D; + table->TexSubImage2D = save_TexSubImage2D; + table->VertexPointer = _mesa_VertexPointer; +#endif - /* GL_MESA_resize_buffers extension */ - table->ResizeBuffersMESA = gl_ResizeBuffersMESA; +#ifdef _GLAPI_VERSION_1_2 + table->CopyTexSubImage3D = save_CopyTexSubImage3D; + table->DrawRangeElements = _mesa_DrawRangeElements; + table->TexImage3D = save_TexImage3D; + table->TexSubImage3D = save_TexSubImage3D; +#endif - /* GL_ARB_multitexture */ - table->ActiveTexture = save_ActiveTexture; - table->ClientActiveTexture = save_ClientActiveTexture; +#ifdef _GLAPI_ARB_imaging + /* NOT supported, just call stub functions */ + table->BlendColor = _mesa_BlendColor; + table->BlendEquation = _mesa_BlendEquation; + table->ColorSubTable = _mesa_ColorSubTable; + table->ColorTable = _mesa_ColorTable; + table->ColorTableParameterfv = _mesa_ColorTableParameterfv; + table->ColorTableParameteriv = _mesa_ColorTableParameteriv; + table->ConvolutionFilter1D = _mesa_ConvolutionFilter1D; + table->ConvolutionFilter2D = _mesa_ConvolutionFilter2D; + table->ConvolutionParameterf = _mesa_ConvolutionParameterf; + table->ConvolutionParameterfv = _mesa_ConvolutionParameterfv; + table->ConvolutionParameteri = _mesa_ConvolutionParameteri; + table->ConvolutionParameteriv = _mesa_ConvolutionParameteriv; + table->CopyColorSubTable = _mesa_CopyColorSubTable; + table->CopyColorTable = _mesa_CopyColorTable; + table->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D; + table->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D; + table->GetColorTable = _mesa_GetColorTable; + table->GetColorTableParameterfv = _mesa_GetColorTableParameterfv; + table->GetColorTableParameteriv = _mesa_GetColorTableParameteriv; + table->GetConvolutionFilter = _mesa_GetConvolutionFilter; + table->GetConvolutionParameterfv = _mesa_GetConvolutionParameterfv; + table->GetConvolutionParameteriv = _mesa_GetConvolutionParameteriv; + table->GetHistogram = _mesa_GetHistogram; + table->GetHistogramParameterfv = _mesa_GetHistogramParameterfv; + table->GetHistogramParameteriv = _mesa_GetHistogramParameteriv; + table->GetMinmax = _mesa_GetMinmax; + table->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv; + table->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv; + table->GetSeparableFilter = _mesa_GetSeparableFilter; + table->Histogram = _mesa_Histogram; + table->Minmax = _mesa_Minmax; + table->ResetHistogram = _mesa_ResetHistogram; + table->ResetMinmax = _mesa_ResetMinmax; + table->SeparableFilter2D = _mesa_SeparableFilter2D; +#endif + +#ifdef _GLAPI_EXT_color_table + table->ColorTableEXT = save_ColorTable; + table->ColorSubTableEXT = save_ColorSubTable; + table->GetColorTableEXT = _mesa_GetColorTable; + table->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; + table->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; +#endif + +#ifdef _GLAPI_EXT_compiled_vertex_array + table->LockArraysEXT = _mesa_LockArraysEXT; + table->UnlockArraysEXT = _mesa_UnlockArraysEXT; +#endif + +#ifdef _GLAPI_EXT_point_parameters + table->PointParameterfEXT = save_PointParameterfEXT; + table->PointParameterfvEXT = save_PointParameterfvEXT; +#endif + +#ifdef _GLAPI_EXT_polygon_offset + table->PolygonOffsetEXT = save_PolygonOffsetEXT; +#endif + +#ifdef _GLAPI_EXT_blend_minmax + table->BlendEquationEXT = save_BlendEquation; +#endif + +#ifdef _GLAPI_EXT_blend_color + table->BlendColorEXT = save_BlendColor; +#endif + +#ifdef _GLAPI_ARB_multitexture + table->ActiveTextureARB = save_ActiveTextureARB; + table->ClientActiveTextureARB = save_ClientActiveTextureARB; + table->MultiTexCoord1dARB = _mesa_MultiTexCoord1dARB; + table->MultiTexCoord1dvARB = _mesa_MultiTexCoord1dvARB; + table->MultiTexCoord1fARB = _mesa_MultiTexCoord1fARB; + table->MultiTexCoord1fvARB = _mesa_MultiTexCoord1fvARB; + table->MultiTexCoord1iARB = _mesa_MultiTexCoord1iARB; + table->MultiTexCoord1ivARB = _mesa_MultiTexCoord1ivARB; + table->MultiTexCoord1sARB = _mesa_MultiTexCoord1sARB; + table->MultiTexCoord1svARB = _mesa_MultiTexCoord1svARB; + table->MultiTexCoord2dARB = _mesa_MultiTexCoord2dARB; + table->MultiTexCoord2dvARB = _mesa_MultiTexCoord2dvARB; + table->MultiTexCoord2fARB = _mesa_MultiTexCoord2fARB; + table->MultiTexCoord2fvARB = _mesa_MultiTexCoord2fvARB; + table->MultiTexCoord2iARB = _mesa_MultiTexCoord2iARB; + table->MultiTexCoord2ivARB = _mesa_MultiTexCoord2ivARB; + table->MultiTexCoord2sARB = _mesa_MultiTexCoord2sARB; + table->MultiTexCoord2svARB = _mesa_MultiTexCoord2svARB; + table->MultiTexCoord3dARB = _mesa_MultiTexCoord3dARB; + table->MultiTexCoord3dvARB = _mesa_MultiTexCoord3dvARB; + table->MultiTexCoord3fARB = _mesa_MultiTexCoord3fARB; + table->MultiTexCoord3fvARB = _mesa_MultiTexCoord3fvARB; + table->MultiTexCoord3iARB = _mesa_MultiTexCoord3iARB; + table->MultiTexCoord3ivARB = _mesa_MultiTexCoord3ivARB; + table->MultiTexCoord3sARB = _mesa_MultiTexCoord3sARB; + table->MultiTexCoord3svARB = _mesa_MultiTexCoord3svARB; + table->MultiTexCoord4dARB = _mesa_MultiTexCoord4dARB; + table->MultiTexCoord4dvARB = _mesa_MultiTexCoord4dvARB; + table->MultiTexCoord4fARB = _mesa_MultiTexCoord4fARB; + table->MultiTexCoord4fvARB = _mesa_MultiTexCoord4fvARB; + table->MultiTexCoord4iARB = _mesa_MultiTexCoord4iARB; + table->MultiTexCoord4ivARB = _mesa_MultiTexCoord4ivARB; + table->MultiTexCoord4sARB = _mesa_MultiTexCoord4sARB; + table->MultiTexCoord4svARB = _mesa_MultiTexCoord4svARB; +#endif + +#ifdef _GLAPI_INGR_blend_func_separate + table->BlendFuncSeparateINGR = save_BlendFuncSeparateINGR; +#endif + +#ifdef _GLAPI_MESA_window_pos + table->WindowPos4fMESA = save_WindowPos4fMESA; +#endif + +#ifdef _GLAPI_MESA_resize_buffers + table->ResizeBuffersMESA = _mesa_ResizeBuffersMESA; +#endif } @@ -3612,11 +4621,6 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list ) - - - - - /* * Clients may call this function to help debug display list problems. * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed, @@ -3624,6 +4628,6 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list ) */ void mesa_print_display_list( GLuint list ) { - GET_CONTEXT; - print_list( CC, stderr, list ); + GET_CURRENT_CONTEXT(ctx); + print_list( ctx, stderr, list ); } diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h index c5a59181904..f2aaa948c52 100644 --- a/src/mesa/main/dlist.h +++ b/src/mesa/main/dlist.h @@ -1,4 +1,4 @@ -/* $Id: dlist.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: dlist.h,v 1.2 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -51,24 +51,23 @@ extern void gl_init_lists( void ); extern void gl_destroy_list( GLcontext *ctx, GLuint list ); -extern void gl_CallList( GLcontext *ctx, GLuint list ); +extern void _mesa_CallList( GLuint list ); -extern void gl_CallLists( GLcontext *ctx, - GLsizei n, GLenum type, const GLvoid *lists ); +extern void _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists ); -extern void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range ); +extern void _mesa_DeleteLists( GLuint list, GLsizei range ); -extern void gl_EndList( GLcontext *ctx ); +extern void _mesa_EndList( void ); -extern GLuint gl_GenLists( GLcontext *ctx, GLsizei range ); +extern GLuint _mesa_GenLists( GLsizei range ); -extern GLboolean gl_IsList( GLcontext *ctx, GLuint list ); +extern GLboolean _mesa_IsList( GLuint list ); -extern void gl_ListBase( GLcontext *ctx, GLuint base ); +extern void _mesa_ListBase( GLuint base ); -extern void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode ); +extern void _mesa_NewList( GLuint list, GLenum mode ); -extern void gl_init_dlist_pointers( struct gl_api_table *table ); +extern void _mesa_init_dlist_table( struct _glapi_table *table ); extern void gl_compile_cassette( GLcontext *ctx ); diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c index c5bdb6fcba1..103855f7fa8 100644 --- a/src/mesa/main/drawpix.c +++ b/src/mesa/main/drawpix.c @@ -1,8 +1,8 @@ -/* $Id: drawpix.c,v 1.5 1999/11/08 07:36:44 brianp Exp $ */ +/* $Id: drawpix.c,v 1.6 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,19 +25,10 @@ */ - - - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdlib.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "drawpix.h" #include "feedback.h" @@ -53,23 +44,16 @@ -/* TODO: apply texture mapping to fragments */ - - /* - * Try to do a fast glDrawPixels. Conditions include: - * not using a display list - * simple pixel unpacking - * no raster ops - * etc.... + * Try to do a fast and simple RGB(a) glDrawPixels. * Return: GL_TRUE if success, GL_FALSE if slow path must be used instead */ -GLboolean gl_direct_DrawPixels( GLcontext *ctx, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels ) +static GLboolean +simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, + GLsizei width, GLsizei height, GLenum format, GLenum type, + const GLvoid *pixels ) { + const struct gl_pixelstore_attrib *unpack = &ctx->Unpack; GLubyte rgb[MAX_WIDTH][3]; GLubyte rgba[MAX_WIDTH][4]; @@ -87,12 +71,10 @@ GLboolean gl_direct_DrawPixels( GLcontext *ctx, } /* see if device driver can do the drawpix */ - if (ctx->Driver.DrawPixels) { - GLint x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); - GLint y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); - if ((*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type, - unpack, pixels)) - return GL_TRUE; + if (ctx->Driver.DrawPixels + && (*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type, + unpack, pixels)) { + return GL_TRUE; } if ((ctx->RasterMask&(~(SCISSOR_BIT|WINCLIP_BIT)))==0 @@ -106,8 +88,8 @@ GLboolean gl_direct_DrawPixels( GLcontext *ctx, && !unpack->SwapBytes && !unpack->LsbFirst) { - GLint destX = (GLint) (ctx->Current.RasterPos[0] + 0.5F); - GLint destY = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + GLint destX = x; + GLint destY = y; GLint drawWidth = width; /* actual width drawn */ GLint drawHeight = height; /* actual height drawn */ GLint skipPixels = unpack->SkipPixels; @@ -364,10 +346,9 @@ GLboolean gl_direct_DrawPixels( GLcontext *ctx, return GL_FALSE; } } - else { - /* can't do direct render, have to use slow path */ - return GL_FALSE; - } + + /* can't do a simple draw, have to use slow path */ + return GL_FALSE; } @@ -375,99 +356,43 @@ GLboolean gl_direct_DrawPixels( GLcontext *ctx, /* * Do glDrawPixels of index pixels. */ -static void draw_index_pixels( GLcontext *ctx, GLint x, GLint y, - const struct gl_image *image ) +static void +draw_index_pixels( GLcontext *ctx, GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type, const GLvoid *pixels ) { - GLint width, height, widthInBytes; + const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; const GLint desty = y; - GLint i, j; + GLint row, drawWidth; GLdepth zspan[MAX_WIDTH]; - const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; - assert(image); - assert(image->Format == GL_COLOR_INDEX); - - width = image->Width; - height = image->Height; - if (image->Type == GL_BITMAP) - widthInBytes = (width + 7) / 8; - else - widthInBytes = width; + drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width; /* Fragment depth values */ if (ctx->Depth.Test) { GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE); - for (i=0;i<width;i++) { + GLint i; + for (i = 0; i < drawWidth; i++) { zspan[i] = zval; } } - /* process the image row by row */ - for (i=0;i<height;i++,y++) { - GLuint ispan[MAX_WIDTH]; - - /* convert to uints */ - switch (image->Type) { - case GL_UNSIGNED_BYTE: - { - GLubyte *src = (GLubyte *) image->Data + i * width; - for (j=0;j<width;j++) { - ispan[j] = (GLuint) *src++; - } - } - break; - case GL_FLOAT: - { - GLfloat *src = (GLfloat *) image->Data + i * width; - for (j=0;j<width;j++) { - ispan[j] = (GLuint) (GLint) *src++; - } - } - break; - case GL_BITMAP: - { - GLubyte *src = (GLubyte *) image->Data + i * widthInBytes; - for (j=0;j<width;j++) { - ispan[j] = ( src[j >> 3] >> (7 - (j & 0x7)) ) & 1; - } - } - break; - default: - gl_problem( ctx, "draw_index_pixels type" ); - return; - } - - /* apply shift and offset */ - if (ctx->Pixel.IndexOffset || ctx->Pixel.IndexShift) { - gl_shift_and_offset_ci( ctx, width, ispan ); - } - - if (ctx->Visual->RGBAflag) { - /* Convert index to RGBA and write to frame buffer */ - GLubyte rgba[MAX_WIDTH][4]; - gl_map_ci_to_rgba( ctx, width, ispan, rgba ); - if (zoom) { - gl_write_zoomed_rgba_span( ctx, width, x, y, zspan, - (const GLubyte (*)[4])rgba, desty ); - } - else { - gl_write_rgba_span( ctx, width, x, y, zspan, rgba, GL_BITMAP ); - } + /* + * General solution + */ + for (row = 0; row < height; row++, y++) { + GLuint indexes[MAX_WIDTH]; + const GLvoid *source = gl_pixel_addr_in_image(&ctx->Unpack, + pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0); + _mesa_unpack_index_span(ctx, drawWidth, GL_UNSIGNED_INT, indexes, + type, source, &ctx->Unpack, GL_TRUE); + if (zoom) { + gl_write_zoomed_index_span(ctx, drawWidth, x, y, zspan, indexes, desty); } else { - /* optionally apply index map then write to frame buffer */ - if (ctx->Pixel.MapColorFlag) { - gl_map_ci(ctx, width, ispan); - } - if (zoom) { - gl_write_zoomed_index_span( ctx, width, x, y, zspan, ispan, desty ); - } - else { - gl_write_index_span( ctx, width, x, y, zspan, ispan, GL_BITMAP ); - } + gl_write_index_span(ctx, drawWidth, x, y, zspan, indexes, GL_BITMAP); } } - } @@ -476,83 +401,44 @@ static void draw_index_pixels( GLcontext *ctx, GLint x, GLint y, * Do glDrawPixels of stencil image. The image datatype may either * be GLubyte or GLbitmap. */ -static void draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, - const struct gl_image *image ) +static void +draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type, const GLvoid *pixels ) { - GLint widthInBytes, width, height; - const GLint desty = y; - GLint i; const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; - - if (image->Type != GL_BYTE && - image->Type != GL_UNSIGNED_BYTE && - image->Type != GL_SHORT && - image->Type != GL_UNSIGNED_SHORT && - image->Type != GL_INT && - image->Type != GL_UNSIGNED_INT && - image->Type != GL_FLOAT && - image->Type != GL_BITMAP) { - gl_error( ctx, GL_INVALID_OPERATION, "glDrawPixels(stencil type)"); + const GLint desty = y; + GLint row, drawWidth; + + if (type != GL_BYTE && + type != GL_UNSIGNED_BYTE && + type != GL_SHORT && + type != GL_UNSIGNED_SHORT && + type != GL_INT && + type != GL_UNSIGNED_INT && + type != GL_FLOAT && + type != GL_BITMAP) { + gl_error( ctx, GL_INVALID_ENUM, "glDrawPixels(stencil type)"); return; } - assert(image); - assert(image->Format == GL_STENCIL_INDEX); - assert(image->Type == GL_UNSIGNED_BYTE || image->Type == GL_BITMAP); - - if (image->Type == GL_UNSIGNED_BYTE) - widthInBytes = image->Width; - else - widthInBytes = (image->Width + 7) / 8; - width = image->Width; - height = image->Height; - - /* process the image row by row */ - for (i=0;i<height;i++,y++) { - GLstencil *src = (GLstencil*)image->Data + i * widthInBytes; - GLstencil *stencilValues; - GLstencil stencilCopy[MAX_WIDTH]; - - if (image->Type == GL_BITMAP) { - /* convert bitmap data to GLubyte (0 or 1) data */ - GLint j; - for (j = 0; j < width; j++) { - stencilCopy[j] = ( src[j >> 3] >> (7 - (j & 0x7)) ) & 1; - } - src = stencilCopy; - } - - if (ctx->Pixel.IndexOffset || ctx->Pixel.IndexShift - || ctx->Pixel.MapStencilFlag) { + drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width; - /* make copy of stencil values */ - if (src != stencilCopy) - MEMCPY( stencilCopy, src, width * sizeof(GLstencil)); + for (row = 0; row < height; row++, y++) { + GLstencil values[MAX_WIDTH]; + GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte)) + ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; + const GLvoid *source = gl_pixel_addr_in_image(&ctx->Unpack, + pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0); + _mesa_unpack_index_span(ctx, drawWidth, destType, values, + type, source, &ctx->Unpack, GL_TRUE); - /* apply shift and offset */ - if (ctx->Pixel.IndexOffset || ctx->Pixel.IndexShift) { - gl_shift_and_offset_stencil( ctx, width, stencilCopy ); - } - - /* mapping */ - if (ctx->Pixel.MapStencilFlag) { - gl_map_stencil( ctx, width, stencilCopy ); - } - - stencilValues = stencilCopy; - } - else { - /* use stencil values in-place */ - stencilValues = src; - } - - /* write stencil values to stencil buffer */ if (zoom) { - gl_write_zoomed_stencil_span( ctx, (GLuint) width, x, y, - stencilValues, desty ); + gl_write_zoomed_stencil_span( ctx, (GLuint) drawWidth, x, y, + values, desty ); } else { - gl_write_stencil_span( ctx, (GLuint) width, x, y, stencilValues ); + gl_write_stencil_span( ctx, (GLuint) drawWidth, x, y, values ); } } } @@ -562,30 +448,37 @@ static void draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, /* * Do a glDrawPixels of depth values. */ -static void draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, - const struct gl_image *image ) +static void +draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type, const GLvoid *pixels ) { - GLint width, height; + const GLboolean bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0; + const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; const GLint desty = y; GLubyte rgba[MAX_WIDTH][4]; GLuint ispan[MAX_WIDTH]; - const GLboolean bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0; - const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; - - assert(image); - assert(image->Format == GL_DEPTH_COMPONENT); - - width = image->Width; - height = image->Height; + GLint drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width; + + if (type != GL_UNSIGNED_BYTE + && type != GL_UNSIGNED_BYTE + && type != GL_UNSIGNED_SHORT + && type != GL_UNSIGNED_SHORT + && type != GL_UNSIGNED_INT + && type != GL_UNSIGNED_INT + && type != GL_FLOAT) { + gl_error(ctx, GL_INVALID_ENUM, "glDrawPixels(type)"); + return; + } - /* Color or index */ + /* Colors or indexes */ if (ctx->Visual->RGBAflag) { GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0F); GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0F); GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0F); GLint a = (GLint) (ctx->Current.RasterColor[3] * 255.0F); GLint i; - for (i=0; i<width; i++) { + for (i = 0; i < drawWidth; i++) { rgba[i][RCOMP] = r; rgba[i][GCOMP] = g; rgba[i][BCOMP] = b; @@ -594,34 +487,36 @@ static void draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, } else { GLint i; - for (i=0;i<width;i++) { + for (i = 0; i < drawWidth; i++) { ispan[i] = ctx->Current.RasterIndex; } } - if (image->Type==GL_UNSIGNED_SHORT && sizeof(GLdepth)==sizeof(GLushort) + if (type==GL_UNSIGNED_SHORT && sizeof(GLdepth)==sizeof(GLushort) && !bias_or_scale && !zoom && ctx->Visual->RGBAflag) { /* Special case: directly write 16-bit depth values */ - GLint j; - for (j=0;j<height;j++,y++) { - GLdepth *zptr = (GLdepth *) image->Data + j * width; + GLint row; + for (row = 0; row < height; row++, y++) { + const GLdepth *zptr = gl_pixel_addr_in_image(&ctx->Unpack, + pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0); gl_write_rgba_span( ctx, width, x, y, zptr, rgba, GL_BITMAP ); } } - else if (image->Type==GL_UNSIGNED_INT && sizeof(GLdepth)==sizeof(GLuint) + else if (type==GL_UNSIGNED_INT && sizeof(GLdepth)==sizeof(GLuint) && !bias_or_scale && !zoom && ctx->Visual->RGBAflag) { /* Special case: directly write 32-bit depth values */ - GLint i, j; + GLint i, row; /* Compute shift value to scale 32-bit uints down to depth values. */ GLuint shift = 0; GLuint max = MAX_DEPTH; - while ((max&0x80000000)==0) { + while ((max & 0x80000000) == 0) { max = max << 1; shift++; } - for (j=0;j<height;j++,y++) { + for (row = 0; row < height; row++, y++) { GLdepth zspan[MAX_WIDTH]; - GLuint *zptr = (GLuint *) image->Data + j * width; + const GLdepth *zptr = gl_pixel_addr_in_image(&ctx->Unpack, + pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0); for (i=0;i<width;i++) { zspan[i] = zptr[i] >> shift; } @@ -629,72 +524,30 @@ static void draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, } } else { - /* General case (slower) */ - GLint i, j; - - /* process image row by row */ - for (i=0;i<height;i++,y++) { - GLfloat depth[MAX_WIDTH]; + /* General case */ + GLint row; + for (row = 0; row < height; row++, y++) { GLdepth zspan[MAX_WIDTH]; - - switch (image->Type) { - case GL_UNSIGNED_SHORT: - { - GLushort *src = (GLushort *) image->Data + i * width; - for (j=0;j<width;j++) { - depth[j] = USHORT_TO_FLOAT( *src++ ); - } - } - break; - case GL_UNSIGNED_INT: - { - GLuint *src = (GLuint *) image->Data + i * width; - for (j=0;j<width;j++) { - depth[j] = UINT_TO_FLOAT( *src++ ); - } - } - break; - case GL_FLOAT: - { - GLfloat *src = (GLfloat *) image->Data + i * width; - for (j=0;j<width;j++) { - depth[j] = *src++; - } - } - break; - default: - gl_problem(ctx, "Bad type in draw_depth_pixels"); - return; - } - - /* apply depth scale and bias */ - if (ctx->Pixel.DepthScale!=1.0 || ctx->Pixel.DepthBias!=0.0) { - for (j=0;j<width;j++) { - depth[j] = depth[j] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias; - } - } - - /* clamp depth values to [0,1] and convert from floats to integers */ - for (j=0;j<width;j++) { - zspan[j] = (GLdepth) (CLAMP( depth[j], 0.0F, 1.0F ) * DEPTH_SCALE); - } - + const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, + pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0); + _mesa_unpack_depth_span( ctx, drawWidth, zspan, type, src, + &ctx->Unpack, GL_TRUE ); if (ctx->Visual->RGBAflag) { if (zoom) { - gl_write_zoomed_rgba_span( ctx, width, x, y, zspan, - (const GLubyte (*)[4])rgba, desty ); + gl_write_zoomed_rgba_span(ctx, width, x, y, zspan, + (const GLubyte (*)[4])rgba, desty); } else { - gl_write_rgba_span( ctx, width, x, y, zspan, rgba, GL_BITMAP ); + gl_write_rgba_span(ctx, width, x, y, zspan, rgba, GL_BITMAP); } } else { if (zoom) { - gl_write_zoomed_index_span( ctx, width, x, y, zspan, - ispan, GL_BITMAP ); + gl_write_zoomed_index_span(ctx, width, x, y, zspan, + ispan, GL_BITMAP); } else { - gl_write_index_span( ctx, width, x, y, zspan, ispan, GL_BITMAP ); + gl_write_index_span(ctx, width, x, y, zspan, ispan, GL_BITMAP); } } @@ -703,184 +556,71 @@ static void draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, } - -/* Simple unpacking parameters: */ -static struct gl_pixelstore_attrib NoUnpack = { - 1, /* Alignment */ - 0, /* RowLength */ - 0, /* SkipPixels */ - 0, /* SkipRows */ - 0, /* ImageHeight */ - 0, /* SkipImages */ - GL_FALSE, /* SwapBytes */ - GL_FALSE /* LsbFirst */ -}; - - /* * Do glDrawPixels of RGBA pixels. */ -static void draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, - const struct gl_image *image ) +static void +draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels ) { - GLint width, height; - GLint i, j; + const struct gl_pixelstore_attrib *unpack = &ctx->Unpack; + const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; const GLint desty = y; GLdepth zspan[MAX_WIDTH]; GLboolean quickDraw; - const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; - - assert(image); /* Try an optimized glDrawPixels first */ - if (gl_direct_DrawPixels(ctx, &NoUnpack, image->Width, image->Height, - image->Format, image->Type, image->Data )) + if (simple_DrawPixels(ctx, x, y, width, height, format, type, pixels)) return; - width = image->Width; - height = image->Height; - /* Fragment depth values */ if (ctx->Depth.Test) { /* fill in array of z values */ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + GLint i; for (i=0;i<width;i++) { zspan[i] = z; } } - if (ctx->RasterMask==0 && !zoom && x>=0 && y>=0 - && x+width<=ctx->Buffer->Width && y+height<=ctx->Buffer->Height) { + + if (ctx->RasterMask == 0 && !zoom + && x >= 0 && y >= 0 + && x + width <= ctx->Buffer->Width + && y + height <= ctx->Buffer->Height) { quickDraw = GL_TRUE; } else { quickDraw = GL_FALSE; } + /* + * General solution + */ { - /* General solution */ - GLboolean r_flag, g_flag, b_flag, a_flag, l_flag; - GLuint components; GLubyte rgba[MAX_WIDTH][4]; - GLfloat rf[MAX_WIDTH]; - GLfloat gf[MAX_WIDTH]; - GLfloat bf[MAX_WIDTH]; - DEFARRAY(GLfloat,af,MAX_WIDTH); - CHECKARRAY(af,return); - - r_flag = g_flag = b_flag = a_flag = l_flag = GL_FALSE; - switch (image->Format) { - case GL_RED: - r_flag = GL_TRUE; - components = 1; - break; - case GL_GREEN: - g_flag = GL_TRUE; - components = 1; - break; - case GL_BLUE: - b_flag = GL_TRUE; - components = 1; - break; - case GL_ALPHA: - a_flag = GL_TRUE; - components = 1; - break; - case GL_RGB: - r_flag = g_flag = b_flag = GL_TRUE; - components = 3; - break; - case GL_LUMINANCE: - l_flag = GL_TRUE; - components = 1; - break; - case GL_LUMINANCE_ALPHA: - l_flag = a_flag = GL_TRUE; - components = 2; - break; - case GL_RGBA: - r_flag = g_flag = b_flag = a_flag = GL_TRUE; - components = 4; - break; - default: - gl_problem(ctx, "Bad type in draw_rgba_pixels"); - goto cleanup; - } + GLint row; + if (width > MAX_WIDTH) + width = MAX_WIDTH; + for (row = 0; row < height; row++, y++) { + const GLvoid *source = gl_pixel_addr_in_image(unpack, + pixels, width, height, format, type, 0, row, 0); + _mesa_unpack_ubyte_color_span(ctx, width, GL_RGBA, (void*) rgba, + format, type, source, unpack, GL_TRUE); - /* process the image row by row */ - for (i=0;i<height;i++,y++) { - /* convert to floats */ - switch (image->Type) { - case GL_UNSIGNED_BYTE: - { - GLubyte *src = (GLubyte *) image->Data + i * width * components; - for (j=0;j<width;j++) { - if (l_flag) { - rf[j] = gf[j] = bf[j] = UBYTE_TO_FLOAT(*src++); - } - else { - rf[j] = r_flag ? UBYTE_TO_FLOAT(*src++) : 0.0; - gf[j] = g_flag ? UBYTE_TO_FLOAT(*src++) : 0.0; - bf[j] = b_flag ? UBYTE_TO_FLOAT(*src++) : 0.0; - } - af[j] = a_flag ? UBYTE_TO_FLOAT(*src++) : 1.0; - } - } - break; - case GL_FLOAT: - { - GLfloat *src = (GLfloat *) image->Data + i * width * components; - for (j=0;j<width;j++) { - if (l_flag) { - rf[j] = gf[j] = bf[j] = *src++; - } - else { - rf[j] = r_flag ? *src++ : 0.0; - gf[j] = g_flag ? *src++ : 0.0; - bf[j] = b_flag ? *src++ : 0.0; - } - af[j] = a_flag ? *src++ : 1.0; - } - } - break; - default: - gl_problem( ctx, "draw_rgba_pixels type" ); - goto cleanup; - } - - /* apply scale and bias */ - if (ctx->Pixel.ScaleOrBiasRGBA) { - gl_scale_and_bias_color(ctx, width, rf, gf, bf, af); - } - - /* apply pixel mappings */ - if (ctx->Pixel.MapColorFlag) { - gl_map_color(ctx, width, rf, gf, bf, af); - } - - /* convert to integers */ - for (j=0;j<width;j++) { - rgba[j][RCOMP] = (GLint) (rf[j] * 255.0F); - rgba[j][GCOMP] = (GLint) (gf[j] * 255.0F); - rgba[j][BCOMP] = (GLint) (bf[j] * 255.0F); - rgba[j][ACOMP] = (GLint) (af[j] * 255.0F); - } - - /* write to frame buffer */ if (quickDraw) { - (*ctx->Driver.WriteRGBASpan)( ctx, width, x, y, - (const GLubyte (*)[4])rgba, NULL); + (*ctx->Driver.WriteRGBASpan)( ctx, width, x, y, + (CONST GLubyte (*)[]) rgba, NULL); } else if (zoom) { gl_write_zoomed_rgba_span( ctx, width, x, y, zspan, - (const GLubyte (*)[4])rgba, desty ); + (CONST GLubyte (*)[]) rgba, desty ); } else { gl_write_rgba_span( ctx, (GLuint) width, x, y, zspan, rgba, GL_BITMAP); } } -cleanup: - UNDEFARRAY(af); } } @@ -889,45 +629,50 @@ cleanup: /* * Execute glDrawPixels */ -void gl_DrawPixels( GLcontext* ctx, struct gl_image *image ) +void +_mesa_DrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDrawPixels"); - - if (gl_image_error_test( ctx, image, "glDrawPixels" )) - return; - if (ctx->RenderMode==GL_RENDER) { GLint x, y; - if (!ctx->Current.RasterPosValid) { + if (!pixels || !ctx->Current.RasterPosValid) { return; } x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); - switch (image->Format) { - case GL_COLOR_INDEX: - draw_index_pixels( ctx, x, y, image ); - break; + switch (format) { case GL_STENCIL_INDEX: - draw_stencil_pixels( ctx, x, y, image ); + draw_stencil_pixels( ctx, x, y, width, height, type, pixels ); break; case GL_DEPTH_COMPONENT: - draw_depth_pixels( ctx, x, y, image ); + draw_depth_pixels( ctx, x, y, width, height, type, pixels ); + break; + case GL_COLOR_INDEX: + if (ctx->Visual->RGBAflag) + draw_index_pixels(ctx, x, y, width, height, type, pixels); + else + draw_rgba_pixels(ctx, x,y, width, height, format, type, pixels); break; case GL_RED: case GL_GREEN: case GL_BLUE: case GL_ALPHA: - case GL_RGB: case GL_LUMINANCE: case GL_LUMINANCE_ALPHA: + case GL_RGB: + case GL_BGR: case GL_RGBA: - draw_rgba_pixels( ctx, x, y, image ); + case GL_BGRA: + case GL_ABGR_EXT: + draw_rgba_pixels(ctx, x, y, width, height, format, type, pixels); break; default: - gl_error( ctx, GL_INVALID_ENUM, "glDrawPixels" ); + gl_error( ctx, GL_INVALID_ENUM, "glDrawPixels(format)" ); return; } } diff --git a/src/mesa/main/drawpix.h b/src/mesa/main/drawpix.h index cb517ced03b..40da8dfb2c8 100644 --- a/src/mesa/main/drawpix.h +++ b/src/mesa/main/drawpix.h @@ -1,8 +1,8 @@ -/* $Id: drawpix.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: drawpix.h,v 1.2 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef DRAWPIXELS_H #define DRAWPIXELS_H @@ -35,20 +32,9 @@ #include "types.h" -extern GLboolean -gl_direct_DrawPixels( GLcontext *ctx, - const struct gl_pixelstore_attrib *unpack, - GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid *pixels ); - - -#if 000 -extern void gl_DrawPixels( GLcontext *ctx, GLsizei width, GLsizei height, - GLenum format, GLenum type, const GLvoid *pixels ); -#endif - - -extern void gl_DrawPixels( GLcontext *ctx, struct gl_image *image ); +extern void +_mesa_DrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels ); #endif diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index c12013a421a..8a1b79f610f 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1,8 +1,8 @@ -/* $Id: enable.c,v 1.9 1999/11/10 06:29:44 keithw Exp $ */ +/* $Id: enable.c,v 1.10 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,17 +25,10 @@ */ -/* $XFree86: xc/lib/GL/mesa/src/enable.c,v 1.3 1999/04/04 00:20:23 dawes Exp $ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <stdio.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "enable.h" #include "light.h" @@ -54,7 +47,7 @@ /* * Perform glEnable and glDisable calls. */ -void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) +void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) { ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "gl_enable/disable" ); @@ -123,8 +116,8 @@ void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) if (ctx->Light.ColorMaterialEnabled!=state) { ctx->Light.ColorMaterialEnabled = state; ctx->NewState |= NEW_LIGHTING; - if (state) - gl_update_color_material( ctx, ctx->Current.ByteColor ); + if (state) + gl_update_color_material( ctx, ctx->Current.ByteColor ); } break; case GL_CULL_FACE: @@ -478,22 +471,28 @@ void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) -void gl_Enable( GLcontext* ctx, GLenum cap ) +void +_mesa_Enable( GLenum cap ) { - gl_set_enable( ctx, cap, GL_TRUE ); + GET_CURRENT_CONTEXT(ctx); + _mesa_set_enable( ctx, cap, GL_TRUE ); } -void gl_Disable( GLcontext* ctx, GLenum cap ) +void +_mesa_Disable( GLenum cap ) { - gl_set_enable( ctx, cap, GL_FALSE ); + GET_CURRENT_CONTEXT(ctx); + _mesa_set_enable( ctx, cap, GL_FALSE ); } -GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap ) +GLboolean +_mesa_IsEnabled( GLenum cap ) { + GET_CURRENT_CONTEXT(ctx); switch (cap) { case GL_ALPHA_TEST: return ctx->Color.AlphaEnabled; @@ -656,7 +655,8 @@ GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap ) -static void gl_client_state( GLcontext *ctx, GLenum cap, GLboolean state ) +static void +client_state( GLcontext *ctx, GLenum cap, GLboolean state ) { ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, (state @@ -691,15 +691,19 @@ static void gl_client_state( GLcontext *ctx, GLenum cap, GLboolean state ) -void gl_EnableClientState( GLcontext *ctx, GLenum cap ) +void +_mesa_EnableClientState( GLenum cap ) { - gl_client_state( ctx, cap, GL_TRUE ); + GET_CURRENT_CONTEXT(ctx); + client_state( ctx, cap, GL_TRUE ); } -void gl_DisableClientState( GLcontext *ctx, GLenum cap ) +void +_mesa_DisableClientState( GLenum cap ) { - gl_client_state( ctx, cap, GL_FALSE ); + GET_CURRENT_CONTEXT(ctx); + client_state( ctx, cap, GL_FALSE ); } diff --git a/src/mesa/main/enable.h b/src/mesa/main/enable.h index 92a916a9849..f0e9dfd6ae8 100644 --- a/src/mesa/main/enable.h +++ b/src/mesa/main/enable.h @@ -1,8 +1,8 @@ -/* $Id: enable.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: enable.h,v 1.2 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef ENABLE_H #define ENABLE_H @@ -35,17 +32,23 @@ #include "types.h" -extern void gl_set_enable( GLcontext* ctx, GLenum cap, GLboolean state ); +extern void +_mesa_set_enable( GLcontext* ctx, GLenum cap, GLboolean state ); -extern void gl_Disable( GLcontext* ctx, GLenum cap ); +extern void +_mesa_Disable( GLenum cap ); -extern void gl_Enable( GLcontext* ctx, GLenum cap ); +extern void +_mesa_Enable( GLenum cap ); -extern GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap ); +extern GLboolean +_mesa_IsEnabled( GLenum cap ); -extern void gl_EnableClientState( GLcontext *ctx, GLenum cap ); +extern void +_mesa_EnableClientState( GLenum cap ); -extern void gl_DisableClientState( GLcontext *ctx, GLenum cap ); +extern void +_mesa_DisableClientState( GLenum cap ); #endif diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index 695af735fac..3ee2c6fa29b 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -1,8 +1,8 @@ -/* $Id: enums.c,v 1.4 1999/11/08 07:36:44 brianp Exp $ */ +/* $Id: enums.c,v 1.5 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -24,16 +24,14 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef XFree86Server -#include <stdlib.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif -#include "GL/gl.h" +#ifdef PC_HEADER +#include "all.h" +#else +#include "glheader.h" #include "enums.h" -#include "macros.h" +#include "mem.h" +#endif typedef struct { diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c index 36f0616effb..0c0d9507515 100644 --- a/src/mesa/main/eval.c +++ b/src/mesa/main/eval.c @@ -1,8 +1,8 @@ -/* $Id: eval.c,v 1.6 1999/11/08 15:30:05 brianp Exp $ */ +/* $Id: eval.c,v 1.7 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -41,16 +41,11 @@ #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <math.h> -#include <stdlib.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "eval.h" #include "macros.h" +#include "mem.h" #include "mmath.h" #include "types.h" #include "vbcull.h" @@ -528,9 +523,9 @@ de_casteljau_surf(GLfloat *cn, GLfloat *out, GLfloat *du, GLfloat *dv, /* * Return the number of components per control point for any type of * evaluator. Return 0 if bad target. + * See table 5.1 in the OpenGL 1.2 spec. */ - -static GLint components( GLenum target ) +GLuint _mesa_evaluator_components( GLenum target ) { switch (target) { case GL_MAP1_VERTEX_3: return 3; @@ -568,12 +563,11 @@ static GLint components( GLenum target ) * Return: pointer to buffer of contiguous control points or NULL if out * of memory. */ -GLfloat *gl_copy_map_points1f( GLenum target, - GLint ustride, GLint uorder, +GLfloat *gl_copy_map_points1f( GLenum target, GLint ustride, GLint uorder, const GLfloat *points ) { GLfloat *buffer, *p; - GLint i, k, size = components(target); + GLint i, k, size = _mesa_evaluator_components(target); if (!points || size==0) { return NULL; @@ -594,12 +588,11 @@ GLfloat *gl_copy_map_points1f( GLenum target, /* * Same as above but convert doubles to floats. */ -GLfloat *gl_copy_map_points1d( GLenum target, - GLint ustride, GLint uorder, - const GLdouble *points ) +GLfloat *gl_copy_map_points1d( GLenum target, GLint ustride, GLint uorder, + const GLdouble *points ) { GLfloat *buffer, *p; - GLint i, k, size = components(target); + GLint i, k, size = _mesa_evaluator_components(target); if (!points || size==0) { return NULL; @@ -628,15 +621,15 @@ GLfloat *gl_copy_map_points1d( GLenum target, * of memory. */ GLfloat *gl_copy_map_points2f( GLenum target, - GLint ustride, GLint uorder, - GLint vstride, GLint vorder, - const GLfloat *points ) + GLint ustride, GLint uorder, + GLint vstride, GLint vorder, + const GLfloat *points ) { GLfloat *buffer, *p; GLint i, j, k, size, dsize, hsize; GLint uinc; - size = components(target); + size = _mesa_evaluator_components(target); if (!points || size==0) { return NULL; @@ -679,7 +672,7 @@ GLfloat *gl_copy_map_points2d(GLenum target, GLint i, j, k, size, hsize, dsize; GLint uinc; - size = components(target); + size = _mesa_evaluator_components(target); if (!points || size==0) { return NULL; @@ -709,6 +702,7 @@ GLfloat *gl_copy_map_points2d(GLenum target, } +#if 00 /* * This function is called by the display list deallocator function to * specify that a given set of control points are no longer needed. @@ -804,6 +798,7 @@ void gl_free_control_points( GLcontext* ctx, GLenum target, GLfloat *data ) } } +#endif @@ -813,154 +808,130 @@ void gl_free_control_points( GLcontext* ctx, GLenum target, GLfloat *data ) /* - * Note that the array of control points must be 'unpacked' at this time. - * Input: retain - if TRUE, this control point data is also in a display - * list and can't be freed until the list is freed. + * This does the work of glMap1[fd]. */ -void gl_Map1f( GLcontext* ctx, GLenum target, - GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat *points, GLboolean retain ) +static void +map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, + GLint uorder, const GLvoid *points, GLenum type ) { + GET_CURRENT_CONTEXT(ctx); GLint k; - - if (!points) { - gl_error( ctx, GL_OUT_OF_MEMORY, "glMap1f" ); - return; - } - - /* may be a new stride after copying control points */ - stride = components( target ); + GLfloat *pnts; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMap1"); - if (u1==u2) { + assert(type == GL_FLOAT || type == GL_DOUBLE); + + if (u1 == u2) { gl_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" ); return; } - - if (order<1 || order>MAX_EVAL_ORDER) { + if (uorder < 1 || uorder > MAX_EVAL_ORDER) { gl_error( ctx, GL_INVALID_VALUE, "glMap1(order)" ); return; } + if (!points) { + gl_error( ctx, GL_INVALID_VALUE, "glMap1(points)" ); + return; + } - k = components( target ); - if (k==0) { + k = _mesa_evaluator_components( target ); + if (k == 0) { gl_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); } - if (stride < k) { + if (ustride < k) { gl_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" ); return; } + /* make copy of the control points */ + if (type == GL_FLOAT) + pnts = gl_copy_map_points1f(target, ustride, uorder, (GLfloat*) points); + else + pnts = gl_copy_map_points1d(target, ustride, uorder, (GLdouble*) points); + switch (target) { case GL_MAP1_VERTEX_3: - ctx->EvalMap.Map1Vertex3.Order = order; + ctx->EvalMap.Map1Vertex3.Order = uorder; ctx->EvalMap.Map1Vertex3.u1 = u1; ctx->EvalMap.Map1Vertex3.u2 = u2; ctx->EvalMap.Map1Vertex3.du = 1.0 / (u2 - u1); - if (ctx->EvalMap.Map1Vertex3.Points - && !ctx->EvalMap.Map1Vertex3.Retain) { + if (ctx->EvalMap.Map1Vertex3.Points) FREE( ctx->EvalMap.Map1Vertex3.Points ); - } - ctx->EvalMap.Map1Vertex3.Points = (GLfloat *) points; - ctx->EvalMap.Map1Vertex3.Retain = retain; + ctx->EvalMap.Map1Vertex3.Points = pnts; break; case GL_MAP1_VERTEX_4: - ctx->EvalMap.Map1Vertex4.Order = order; + ctx->EvalMap.Map1Vertex4.Order = uorder; ctx->EvalMap.Map1Vertex4.u1 = u1; ctx->EvalMap.Map1Vertex4.u2 = u2; ctx->EvalMap.Map1Vertex4.du = 1.0 / (u2 - u1); - if (ctx->EvalMap.Map1Vertex4.Points - && !ctx->EvalMap.Map1Vertex4.Retain) { + if (ctx->EvalMap.Map1Vertex4.Points) FREE( ctx->EvalMap.Map1Vertex4.Points ); - } - ctx->EvalMap.Map1Vertex4.Points = (GLfloat *) points; - ctx->EvalMap.Map1Vertex4.Retain = retain; + ctx->EvalMap.Map1Vertex4.Points = pnts; break; case GL_MAP1_INDEX: - ctx->EvalMap.Map1Index.Order = order; + ctx->EvalMap.Map1Index.Order = uorder; ctx->EvalMap.Map1Index.u1 = u1; ctx->EvalMap.Map1Index.u2 = u2; ctx->EvalMap.Map1Index.du = 1.0 / (u2 - u1); - if (ctx->EvalMap.Map1Index.Points - && !ctx->EvalMap.Map1Index.Retain) { + if (ctx->EvalMap.Map1Index.Points) FREE( ctx->EvalMap.Map1Index.Points ); - } - ctx->EvalMap.Map1Index.Points = (GLfloat *) points; - ctx->EvalMap.Map1Index.Retain = retain; + ctx->EvalMap.Map1Index.Points = pnts; break; case GL_MAP1_COLOR_4: - ctx->EvalMap.Map1Color4.Order = order; + ctx->EvalMap.Map1Color4.Order = uorder; ctx->EvalMap.Map1Color4.u1 = u1; ctx->EvalMap.Map1Color4.u2 = u2; ctx->EvalMap.Map1Color4.du = 1.0 / (u2 - u1); - if (ctx->EvalMap.Map1Color4.Points - && !ctx->EvalMap.Map1Color4.Retain) { + if (ctx->EvalMap.Map1Color4.Points) FREE( ctx->EvalMap.Map1Color4.Points ); - } - ctx->EvalMap.Map1Color4.Points = (GLfloat *) points; - ctx->EvalMap.Map1Color4.Retain = retain; + ctx->EvalMap.Map1Color4.Points = pnts; break; case GL_MAP1_NORMAL: - ctx->EvalMap.Map1Normal.Order = order; + ctx->EvalMap.Map1Normal.Order = uorder; ctx->EvalMap.Map1Normal.u1 = u1; ctx->EvalMap.Map1Normal.u2 = u2; ctx->EvalMap.Map1Normal.du = 1.0 / (u2 - u1); - if (ctx->EvalMap.Map1Normal.Points - && !ctx->EvalMap.Map1Normal.Retain) { + if (ctx->EvalMap.Map1Normal.Points) FREE( ctx->EvalMap.Map1Normal.Points ); - } - ctx->EvalMap.Map1Normal.Points = (GLfloat *) points; - ctx->EvalMap.Map1Normal.Retain = retain; + ctx->EvalMap.Map1Normal.Points = pnts; break; case GL_MAP1_TEXTURE_COORD_1: - ctx->EvalMap.Map1Texture1.Order = order; + ctx->EvalMap.Map1Texture1.Order = uorder; ctx->EvalMap.Map1Texture1.u1 = u1; ctx->EvalMap.Map1Texture1.u2 = u2; ctx->EvalMap.Map1Texture1.du = 1.0 / (u2 - u1); - if (ctx->EvalMap.Map1Texture1.Points - && !ctx->EvalMap.Map1Texture1.Retain) { + if (ctx->EvalMap.Map1Texture1.Points) FREE( ctx->EvalMap.Map1Texture1.Points ); - } - ctx->EvalMap.Map1Texture1.Points = (GLfloat *) points; - ctx->EvalMap.Map1Texture1.Retain = retain; + ctx->EvalMap.Map1Texture1.Points = pnts; break; case GL_MAP1_TEXTURE_COORD_2: - ctx->EvalMap.Map1Texture2.Order = order; + ctx->EvalMap.Map1Texture2.Order = uorder; ctx->EvalMap.Map1Texture2.u1 = u1; ctx->EvalMap.Map1Texture2.u2 = u2; ctx->EvalMap.Map1Texture2.du = 1.0 / (u2 - u1); - if (ctx->EvalMap.Map1Texture2.Points - && !ctx->EvalMap.Map1Texture2.Retain) { + if (ctx->EvalMap.Map1Texture2.Points) FREE( ctx->EvalMap.Map1Texture2.Points ); - } - ctx->EvalMap.Map1Texture2.Points = (GLfloat *) points; - ctx->EvalMap.Map1Texture2.Retain = retain; + ctx->EvalMap.Map1Texture2.Points = pnts; break; case GL_MAP1_TEXTURE_COORD_3: - ctx->EvalMap.Map1Texture3.Order = order; + ctx->EvalMap.Map1Texture3.Order = uorder; ctx->EvalMap.Map1Texture3.u1 = u1; ctx->EvalMap.Map1Texture3.u2 = u2; ctx->EvalMap.Map1Texture3.du = 1.0 / (u2 - u1); - if (ctx->EvalMap.Map1Texture3.Points - && !ctx->EvalMap.Map1Texture3.Retain) { + if (ctx->EvalMap.Map1Texture3.Points) FREE( ctx->EvalMap.Map1Texture3.Points ); - } - ctx->EvalMap.Map1Texture3.Points = (GLfloat *) points; - ctx->EvalMap.Map1Texture3.Retain = retain; + ctx->EvalMap.Map1Texture3.Points = pnts; break; case GL_MAP1_TEXTURE_COORD_4: - ctx->EvalMap.Map1Texture4.Order = order; + ctx->EvalMap.Map1Texture4.Order = uorder; ctx->EvalMap.Map1Texture4.u1 = u1; ctx->EvalMap.Map1Texture4.u2 = u2; ctx->EvalMap.Map1Texture4.du = 1.0 / (u2 - u1); - if (ctx->EvalMap.Map1Texture4.Points - && !ctx->EvalMap.Map1Texture4.Retain) { + if (ctx->EvalMap.Map1Texture4.Points) FREE( ctx->EvalMap.Map1Texture4.Points ); - } - ctx->EvalMap.Map1Texture4.Points = (GLfloat *) points; - ctx->EvalMap.Map1Texture4.Retain = retain; + ctx->EvalMap.Map1Texture4.Points = pnts; break; default: gl_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); @@ -969,18 +940,30 @@ void gl_Map1f( GLcontext* ctx, GLenum target, +void +_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat *points ) +{ + map1(target, u1, u2, stride, order, points, GL_FLOAT); +} -/* - * Note that the array of control points must be 'unpacked' at this time. - * Input: retain - if TRUE, this control point data is also in a display - * list and can't be freed until the list is freed. - */ -void gl_Map2f( GLcontext* ctx, GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat *points, GLboolean retain ) + +void +_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble *points ) { + map1(target, u1, u2, stride, order, points, GL_DOUBLE); +} + + +static void +map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLvoid *points, GLenum type ) +{ + GET_CURRENT_CONTEXT(ctx); GLint k; + GLfloat *pnts; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMap2"); @@ -1004,7 +987,7 @@ void gl_Map2f( GLcontext* ctx, GLenum target, return; } - k = components( target ); + k = _mesa_evaluator_components( target ); if (k==0) { gl_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); } @@ -1018,6 +1001,14 @@ void gl_Map2f( GLcontext* ctx, GLenum target, return; } + /* make copy of the control points */ + if (type == GL_FLOAT) + pnts = gl_copy_map_points2f(target, ustride, uorder, + vstride, vorder, (GLfloat*) points); + else + pnts = gl_copy_map_points2d(target, ustride, uorder, + vstride, vorder, (GLdouble*) points); + switch (target) { case GL_MAP2_VERTEX_3: ctx->EvalMap.Map2Vertex3.Uorder = uorder; @@ -1028,12 +1019,9 @@ void gl_Map2f( GLcontext* ctx, GLenum target, ctx->EvalMap.Map2Vertex3.v1 = v1; ctx->EvalMap.Map2Vertex3.v2 = v2; ctx->EvalMap.Map2Vertex3.dv = 1.0 / (v2 - v1); - if (ctx->EvalMap.Map2Vertex3.Points - && !ctx->EvalMap.Map2Vertex3.Retain) { + if (ctx->EvalMap.Map2Vertex3.Points) FREE( ctx->EvalMap.Map2Vertex3.Points ); - } - ctx->EvalMap.Map2Vertex3.Retain = retain; - ctx->EvalMap.Map2Vertex3.Points = (GLfloat *) points; + ctx->EvalMap.Map2Vertex3.Points = pnts; break; case GL_MAP2_VERTEX_4: ctx->EvalMap.Map2Vertex4.Uorder = uorder; @@ -1044,12 +1032,9 @@ void gl_Map2f( GLcontext* ctx, GLenum target, ctx->EvalMap.Map2Vertex4.v1 = v1; ctx->EvalMap.Map2Vertex4.v2 = v2; ctx->EvalMap.Map2Vertex4.dv = 1.0 / (v2 - v1); - if (ctx->EvalMap.Map2Vertex4.Points - && !ctx->EvalMap.Map2Vertex4.Retain) { + if (ctx->EvalMap.Map2Vertex4.Points) FREE( ctx->EvalMap.Map2Vertex4.Points ); - } - ctx->EvalMap.Map2Vertex4.Points = (GLfloat *) points; - ctx->EvalMap.Map2Vertex4.Retain = retain; + ctx->EvalMap.Map2Vertex4.Points = pnts; break; case GL_MAP2_INDEX: ctx->EvalMap.Map2Index.Uorder = uorder; @@ -1060,12 +1045,9 @@ void gl_Map2f( GLcontext* ctx, GLenum target, ctx->EvalMap.Map2Index.v1 = v1; ctx->EvalMap.Map2Index.v2 = v2; ctx->EvalMap.Map2Index.dv = 1.0 / (v2 - v1); - if (ctx->EvalMap.Map2Index.Points - && !ctx->EvalMap.Map2Index.Retain) { + if (ctx->EvalMap.Map2Index.Points) FREE( ctx->EvalMap.Map2Index.Points ); - } - ctx->EvalMap.Map2Index.Retain = retain; - ctx->EvalMap.Map2Index.Points = (GLfloat *) points; + ctx->EvalMap.Map2Index.Points = pnts; break; case GL_MAP2_COLOR_4: ctx->EvalMap.Map2Color4.Uorder = uorder; @@ -1076,12 +1058,9 @@ void gl_Map2f( GLcontext* ctx, GLenum target, ctx->EvalMap.Map2Color4.v1 = v1; ctx->EvalMap.Map2Color4.v2 = v2; ctx->EvalMap.Map2Color4.dv = 1.0 / (v2 - v1); - if (ctx->EvalMap.Map2Color4.Points - && !ctx->EvalMap.Map2Color4.Retain) { + if (ctx->EvalMap.Map2Color4.Points) FREE( ctx->EvalMap.Map2Color4.Points ); - } - ctx->EvalMap.Map2Color4.Retain = retain; - ctx->EvalMap.Map2Color4.Points = (GLfloat *) points; + ctx->EvalMap.Map2Color4.Points = pnts; break; case GL_MAP2_NORMAL: ctx->EvalMap.Map2Normal.Uorder = uorder; @@ -1092,12 +1071,9 @@ void gl_Map2f( GLcontext* ctx, GLenum target, ctx->EvalMap.Map2Normal.v1 = v1; ctx->EvalMap.Map2Normal.v2 = v2; ctx->EvalMap.Map2Normal.dv = 1.0 / (v2 - v1); - if (ctx->EvalMap.Map2Normal.Points - && !ctx->EvalMap.Map2Normal.Retain) { + if (ctx->EvalMap.Map2Normal.Points) FREE( ctx->EvalMap.Map2Normal.Points ); - } - ctx->EvalMap.Map2Normal.Retain = retain; - ctx->EvalMap.Map2Normal.Points = (GLfloat *) points; + ctx->EvalMap.Map2Normal.Points = pnts; break; case GL_MAP2_TEXTURE_COORD_1: ctx->EvalMap.Map2Texture1.Uorder = uorder; @@ -1108,12 +1084,9 @@ void gl_Map2f( GLcontext* ctx, GLenum target, ctx->EvalMap.Map2Texture1.v1 = v1; ctx->EvalMap.Map2Texture1.v2 = v2; ctx->EvalMap.Map2Texture1.dv = 1.0 / (v2 - v1); - if (ctx->EvalMap.Map2Texture1.Points - && !ctx->EvalMap.Map2Texture1.Retain) { + if (ctx->EvalMap.Map2Texture1.Points) FREE( ctx->EvalMap.Map2Texture1.Points ); - } - ctx->EvalMap.Map2Texture1.Retain = retain; - ctx->EvalMap.Map2Texture1.Points = (GLfloat *) points; + ctx->EvalMap.Map2Texture1.Points = pnts; break; case GL_MAP2_TEXTURE_COORD_2: ctx->EvalMap.Map2Texture2.Uorder = uorder; @@ -1124,12 +1097,9 @@ void gl_Map2f( GLcontext* ctx, GLenum target, ctx->EvalMap.Map2Texture2.v1 = v1; ctx->EvalMap.Map2Texture2.v2 = v2; ctx->EvalMap.Map2Texture2.dv = 1.0 / (v2 - v1); - if (ctx->EvalMap.Map2Texture2.Points - && !ctx->EvalMap.Map2Texture2.Retain) { + if (ctx->EvalMap.Map2Texture2.Points) FREE( ctx->EvalMap.Map2Texture2.Points ); - } - ctx->EvalMap.Map2Texture2.Retain = retain; - ctx->EvalMap.Map2Texture2.Points = (GLfloat *) points; + ctx->EvalMap.Map2Texture2.Points = pnts; break; case GL_MAP2_TEXTURE_COORD_3: ctx->EvalMap.Map2Texture3.Uorder = uorder; @@ -1140,12 +1110,9 @@ void gl_Map2f( GLcontext* ctx, GLenum target, ctx->EvalMap.Map2Texture3.v1 = v1; ctx->EvalMap.Map2Texture3.v2 = v2; ctx->EvalMap.Map2Texture3.dv = 1.0 / (v2 - v1); - if (ctx->EvalMap.Map2Texture3.Points - && !ctx->EvalMap.Map2Texture3.Retain) { + if (ctx->EvalMap.Map2Texture3.Points) FREE( ctx->EvalMap.Map2Texture3.Points ); - } - ctx->EvalMap.Map2Texture3.Retain = retain; - ctx->EvalMap.Map2Texture3.Points = (GLfloat *) points; + ctx->EvalMap.Map2Texture3.Points = pnts; break; case GL_MAP2_TEXTURE_COORD_4: ctx->EvalMap.Map2Texture4.Uorder = uorder; @@ -1156,12 +1123,9 @@ void gl_Map2f( GLcontext* ctx, GLenum target, ctx->EvalMap.Map2Texture4.v1 = v1; ctx->EvalMap.Map2Texture4.v2 = v2; ctx->EvalMap.Map2Texture4.dv = 1.0 / (v2 - v1); - if (ctx->EvalMap.Map2Texture4.Points - && !ctx->EvalMap.Map2Texture4.Retain) { + if (ctx->EvalMap.Map2Texture4.Points) FREE( ctx->EvalMap.Map2Texture4.Points ); - } - ctx->EvalMap.Map2Texture4.Retain = retain; - ctx->EvalMap.Map2Texture4.Points = (GLfloat *) points; + ctx->EvalMap.Map2Texture4.Points = pnts; break; default: gl_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); @@ -1169,11 +1133,33 @@ void gl_Map2f( GLcontext* ctx, GLenum target, } - +void +_mesa_Map2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points) +{ + map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, + points, GL_FLOAT); +} -void gl_GetMapdv( GLcontext* ctx, GLenum target, GLenum query, GLdouble *v ) +void +_mesa_Map2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ) { + map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, + points, GL_DOUBLE); +} + + + +void +_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v ) +{ + GET_CURRENT_CONTEXT(ctx); GLint i, n; GLfloat *data; @@ -1443,8 +1429,10 @@ void gl_GetMapdv( GLcontext* ctx, GLenum target, GLenum query, GLdouble *v ) } -void gl_GetMapfv( GLcontext* ctx, GLenum target, GLenum query, GLfloat *v ) +void +_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ) { + GET_CURRENT_CONTEXT(ctx); GLint i, n; GLfloat *data; @@ -1714,8 +1702,10 @@ void gl_GetMapfv( GLcontext* ctx, GLenum target, GLenum query, GLfloat *v ) } -void gl_GetMapiv( GLcontext* ctx, GLenum target, GLenum query, GLint *v ) +void +_mesa_GetMapiv( GLenum target, GLenum query, GLint *v ) { + GET_CURRENT_CONTEXT(ctx); GLuint i, n; GLfloat *data; @@ -2613,8 +2603,10 @@ void gl_eval_vb( struct vertex_buffer *VB ) } -void gl_MapGrid1f( GLcontext* ctx, GLint un, GLfloat u1, GLfloat u2 ) +void +_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMapGrid1f"); if (un<1) { @@ -2628,9 +2620,18 @@ void gl_MapGrid1f( GLcontext* ctx, GLint un, GLfloat u1, GLfloat u2 ) } -void gl_MapGrid2f( GLcontext* ctx, GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2 ) +void +_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) +{ + _mesa_MapGrid1f( un, u1, u2 ); +} + + +void +_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMapGrid2f"); if (un<1) { gl_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" ); @@ -2651,9 +2652,185 @@ void gl_MapGrid2f( GLcontext* ctx, GLint un, GLfloat u1, GLfloat u2, } +void +_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ) +{ + _mesa_MapGrid2f( un, u1, u2, vn, v1, v2 ); +} + + + + +/* KW: If are compiling, we don't know whether eval will produce a + * vertex when it is run in the future. If this is pure immediate + * mode, eval is a noop if neither vertex map is enabled. + * + * Thus we need to have a check in the display list code or + * elsewhere for eval(1,2) vertices in the case where + * map(1,2)_vertex is disabled, and to purge those vertices from + * the vb. This is currently done + * via modifications to the cull_vb and render_vb operations, and + * by using the existing cullmask mechanism for all other operations. + */ + + +/* KW: Because the eval values don't become 'current', fixup will flow + * through these vertices, and then evaluation will write on top + * of the fixup results. + * + * This is a little inefficient, but at least it is correct. This + * could be short-circuited in the case where all vertices are + * eval-vertices, or more generally by a cullmask in fixup. + * + * Note: using Obj to hold eval coord data. This data is actually + * transformed if eval is disabled. But disabling eval & sending + * eval coords is stupid, right? + */ + + +#define EVALCOORD1(IM, x) \ +{ \ + GLuint count = IM->Count++; \ + IM->Flag[count] |= VERT_EVAL_C1; \ + ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \ + if (count == VB_MAX-1) \ + IM->maybe_transform_vb( IM ); \ +} + +#define EVALCOORD2(IM, x, y) \ +{ \ + GLuint count = IM->Count++; \ + IM->Flag[count] |= VERT_EVAL_C2; \ + ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \ + if (count == VB_MAX-1) \ + IM->maybe_transform_vb( IM ); \ +} + +#define EVALPOINT1(IM, x) \ +{ \ + GLuint count = IM->Count++; \ + IM->Flag[count] |= VERT_EVAL_P1; \ + ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \ + if (count == VB_MAX-1) \ + IM->maybe_transform_vb( IM ); \ +} + +#define EVALPOINT2(IM, x, y) \ +{ \ + GLuint count = IM->Count++; \ + IM->Flag[count] |= VERT_EVAL_P2; \ + ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \ + if (count == VB_MAX-1) \ + IM->maybe_transform_vb( IM ); \ +} + + +/* Lame internal function: + */ +void gl_EvalCoord1f( GLcontext *CC, GLfloat u ) +{ + struct immediate *i = CC->input; + EVALCOORD1( i, u ); +} + + +void +_mesa_EvalCoord1d( GLdouble u ) +{ + GET_IMMEDIATE; + EVALCOORD1( IM, (GLfloat) u ); +} + + +void +_mesa_EvalCoord1f( GLfloat u ) +{ + GET_IMMEDIATE; + EVALCOORD1( IM, u ); +} + + +void +_mesa_EvalCoord1dv( const GLdouble *u ) +{ + GET_IMMEDIATE; + EVALCOORD1( IM, (GLfloat) *u ); +} + + +void +_mesa_EvalCoord1fv( const GLfloat *u ) +{ + GET_IMMEDIATE; + EVALCOORD1( IM, (GLfloat) *u ); +} + + +void +_mesa_EvalCoord2d( GLdouble u, GLdouble v ) +{ + GET_IMMEDIATE; + EVALCOORD2( IM, (GLfloat) u, (GLfloat) v ); +} + + +void +_mesa_EvalCoord2f( GLfloat u, GLfloat v ) +{ + GET_IMMEDIATE; + EVALCOORD2( IM, u, v ); +} + + +/* Lame internal function: + */ +void gl_EvalCoord2f( GLcontext *CC, GLfloat u, GLfloat v ) +{ + struct immediate *i = CC->input; + EVALCOORD2( i, u, v ); +} + + +void +_mesa_EvalCoord2dv( const GLdouble *u ) +{ + GET_IMMEDIATE; + EVALCOORD2( IM, (GLfloat) u[0], (GLfloat) u[1] ); +} + + +void +_mesa_EvalCoord2fv( const GLfloat *u ) +{ + GET_IMMEDIATE; + EVALCOORD2( IM, u[0], u[1] ); +} + + +void +_mesa_EvalPoint1( GLint i ) +{ + GET_IMMEDIATE; + EVALPOINT1( IM, i ); +} + + +void +_mesa_EvalPoint2( GLint i, GLint j ) +{ + GET_IMMEDIATE; + EVALPOINT2( IM, i, j ); +} + + + -void gl_EvalMesh1( GLcontext* ctx, GLenum mode, GLint i1, GLint i2 ) + +void +_mesa_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) { + GET_CURRENT_CONTEXT(ctx); GLint i; GLfloat u, du; GLenum prim; @@ -2693,11 +2870,10 @@ void gl_EvalMesh1( GLcontext* ctx, GLenum mode, GLint i1, GLint i2 ) -void gl_EvalMesh2( GLcontext* ctx, - GLenum mode, - GLint i1, GLint i2, - GLint j1, GLint j2 ) +void +_mesa_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) { + GET_CURRENT_CONTEXT(ctx); GLint i, j; GLfloat u, du, v, dv, v1, u1; @@ -2758,3 +2934,6 @@ void gl_EvalMesh2( GLcontext* ctx, return; } } + + + diff --git a/src/mesa/main/eval.h b/src/mesa/main/eval.h index cde76b08dde..0b87be3d5fe 100644 --- a/src/mesa/main/eval.h +++ b/src/mesa/main/eval.h @@ -1,8 +1,8 @@ -/* $Id: eval.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: eval.h,v 1.2 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -35,6 +35,9 @@ extern void gl_init_eval( void ); +extern GLuint _mesa_evaluator_components( GLenum target ); + + extern void gl_free_control_points( GLcontext *ctx, GLenum target, GLfloat *data ); @@ -58,38 +61,86 @@ extern GLfloat *gl_copy_map_points2d(GLenum target, const GLdouble *points ); -extern void gl_Map1f( GLcontext* ctx, - GLenum target, GLfloat u1, GLfloat u2, GLint stride, - GLint order, const GLfloat *points, GLboolean retain ); +extern void gl_eval_vb( struct vertex_buffer *VB ); -extern void gl_Map2f( GLcontext* ctx, GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat *points, GLboolean retain ); +extern void +_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, + GLint order, const GLfloat *points ); +extern void +_mesa_Map2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ); -extern void gl_MapGrid1f( GLcontext* ctx, GLint un, GLfloat u1, GLfloat u2 ); +extern void +_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble *points ); -extern void gl_MapGrid2f( GLcontext* ctx, - GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2 ); +extern void +_mesa_Map2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ); -extern void gl_GetMapdv( GLcontext* ctx, - GLenum target, GLenum query, GLdouble *v ); +extern void +_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); -extern void gl_GetMapfv( GLcontext* ctx, - GLenum target, GLenum query, GLfloat *v ); +extern void +_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); -extern void gl_GetMapiv( GLcontext* ctx, - GLenum target, GLenum query, GLint *v ); +extern void +_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ); -extern void gl_EvalMesh1( GLcontext* ctx, GLenum mode, GLint i1, GLint i2 ); +extern void +_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ); -extern void gl_EvalMesh2( GLcontext* ctx, GLenum mode, - GLint i1, GLint i2, GLint j1, GLint j2 ); +extern void +_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v ); -extern void gl_eval_vb( struct vertex_buffer *VB ); +extern void +_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ); + +extern void +_mesa_GetMapiv( GLenum target, GLenum query, GLint *v ); + +extern void +_mesa_EvalMesh1( GLenum mode, GLint i1, GLint i2 ); + +extern void +_mesa_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + +extern void +_mesa_EvalCoord1d( GLdouble u ); + +extern void +_mesa_EvalCoord1f( GLfloat u ); + +extern void +_mesa_EvalCoord1dv( const GLdouble *u ); + +extern void +_mesa_EvalCoord1fv( const GLfloat *u ); + +extern void +_mesa_EvalCoord2d( GLdouble u, GLdouble v ); + +extern void +_mesa_EvalCoord2f( GLfloat u, GLfloat v ); + +extern void +_mesa_EvalCoord2dv( const GLdouble *u ); + +extern void +_mesa_EvalCoord2fv( const GLfloat *u ); + +extern void +_mesa_EvalPoint1( GLint i ); +extern void +_mesa_EvalPoint2( GLint i, GLint j ); #endif diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 80918ca1857..683fba79a0f 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,8 +1,8 @@ -/* $Id: extensions.c,v 1.10 1999/11/08 07:36:44 brianp Exp $ */ +/* $Id: extensions.c,v 1.11 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,15 +25,16 @@ */ -#ifndef XFree86Server -#include <stdlib.h> +#ifdef PC_HEADER +#include "all.h" #else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "extensions.h" +#include "mem.h" #include "simple_list.h" #include "types.h" +#endif #define MAX_EXT_NAMELEN 80 diff --git a/src/mesa/main/feedback.c b/src/mesa/main/feedback.c index d377bd8a7e9..c2a52aaa538 100644 --- a/src/mesa/main/feedback.c +++ b/src/mesa/main/feedback.c @@ -1,8 +1,8 @@ -/* $Id: feedback.c,v 1.5 1999/11/08 07:36:44 brianp Exp $ */ +/* $Id: feedback.c,v 1.6 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,18 +25,10 @@ */ - - - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdio.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "enums.h" #include "feedback.h" @@ -57,8 +49,9 @@ void -gl_FeedbackBuffer( GLcontext *ctx, GLsizei size, GLenum type, GLfloat *buffer ) +_mesa_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glFeedbackBuffer" ); if (ctx->RenderMode==GL_FEEDBACK) { @@ -114,8 +107,10 @@ gl_FeedbackBuffer( GLcontext *ctx, GLsizei size, GLenum type, GLfloat *buffer ) -void gl_PassThrough( GLcontext *ctx, GLfloat token ) +void +_mesa_PassThrough( GLfloat token ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPassThrough"); if (ctx->RenderMode==GL_FEEDBACK) { @@ -256,8 +251,10 @@ void gl_feedback_points( GLcontext *ctx, GLuint first, GLuint last ) /* * NOTE: this function can't be put in a display list. */ -void gl_SelectBuffer( GLcontext *ctx, GLsizei size, GLuint *buffer ) +void +_mesa_SelectBuffer( GLsizei size, GLuint *buffer ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glSelectBuffer"); if (ctx->RenderMode==GL_SELECT) { gl_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" ); @@ -351,8 +348,10 @@ static void write_hit_record( GLcontext *ctx ) -void gl_InitNames( GLcontext *ctx ) +void +_mesa_InitNames( void ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glInitNames"); /* Record the hit before the HitFlag is wiped out again. */ if (ctx->RenderMode==GL_SELECT) { @@ -368,8 +367,10 @@ void gl_InitNames( GLcontext *ctx ) -void gl_LoadName( GLcontext *ctx, GLuint name ) +void +_mesa_LoadName( GLuint name ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLoadName"); if (ctx->RenderMode!=GL_SELECT) { return; @@ -390,8 +391,10 @@ void gl_LoadName( GLcontext *ctx, GLuint name ) } -void gl_PushName( GLcontext *ctx, GLuint name ) +void +_mesa_PushName( GLuint name ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushName"); if (ctx->RenderMode!=GL_SELECT) { return; @@ -409,8 +412,10 @@ void gl_PushName( GLcontext *ctx, GLuint name ) -void gl_PopName( GLcontext *ctx ) +void +_mesa_PopName( void ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopName"); if (ctx->RenderMode!=GL_SELECT) { return; @@ -437,8 +442,10 @@ void gl_PopName( GLcontext *ctx ) /* * NOTE: this function can't be put in a display list. */ -GLint gl_RenderMode( GLcontext *ctx, GLenum mode ) +GLint +_mesa_RenderMode( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); GLint result; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glRenderMode", 0); diff --git a/src/mesa/main/feedback.h b/src/mesa/main/feedback.h index 08aee085199..1909009b565 100644 --- a/src/mesa/main/feedback.h +++ b/src/mesa/main/feedback.h @@ -1,8 +1,8 @@ -/* $Id: feedback.h,v 1.2 1999/09/18 20:41:23 keithw Exp $ */ +/* $Id: feedback.h,v 1.3 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef FEEDBACK_H #define FEEDBACK_H @@ -52,22 +49,30 @@ extern void gl_feedback_vertex( GLcontext *ctx, extern void gl_update_hitflag( GLcontext *ctx, GLfloat z ); -extern void gl_PassThrough( GLcontext *ctx, GLfloat token ); +extern void +_mesa_PassThrough( GLfloat token ); + +extern void +_mesa_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); -extern void gl_FeedbackBuffer( GLcontext *ctx, GLsizei size, - GLenum type, GLfloat *buffer ); +extern void +_mesa_SelectBuffer( GLsizei size, GLuint *buffer ); -extern void gl_SelectBuffer( GLcontext *ctx, GLsizei size, GLuint *buffer ); +extern void +_mesa_InitNames( void ); -extern void gl_InitNames( GLcontext *ctx ); +extern void +_mesa_LoadName( GLuint name ); -extern void gl_LoadName( GLcontext *ctx, GLuint name ); +extern void +_mesa_PushName( GLuint name ); -extern void gl_PushName( GLcontext *ctx, GLuint name ); +extern void +_mesa_PopName( void ); -extern void gl_PopName( GLcontext *ctx ); +extern GLint +_mesa_RenderMode( GLenum mode ); -extern GLint gl_RenderMode( GLcontext *ctx, GLenum mode ); extern void gl_feedback_points( GLcontext *ctx, GLuint first, GLuint last ); extern void gl_feedback_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ); diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c index 211454b1127..e1a69f3b0d9 100644 --- a/src/mesa/main/fog.c +++ b/src/mesa/main/fog.c @@ -1,8 +1,8 @@ -/* $Id: fog.c,v 1.3 1999/11/08 07:36:44 brianp Exp $ */ +/* $Id: fog.c,v 1.4 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,17 +25,10 @@ */ -/* $XFree86: xc/lib/GL/mesa/src/fog.c,v 1.4 1999/04/04 00:20:24 dawes Exp $ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <math.h> -#include <stdlib.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "fog.h" #include "macros.h" @@ -45,8 +38,51 @@ -void gl_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) +void +_mesa_Fogf(GLenum pname, GLfloat param) +{ + _mesa_Fogfv(pname, ¶m); +} + + +void +_mesa_Fogi(GLenum pname, GLint param ) +{ + GLfloat fparam = (GLfloat) param; + _mesa_Fogfv(pname, &fparam); +} + + +void +_mesa_Fogiv(GLenum pname, const GLint *params ) +{ + GLfloat p[4]; + switch (pname) { + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + p[0] = (GLfloat) *params; + break; + case GL_FOG_COLOR: + p[0] = INT_TO_FLOAT( params[0] ); + p[1] = INT_TO_FLOAT( params[1] ); + p[2] = INT_TO_FLOAT( params[2] ); + p[3] = INT_TO_FLOAT( params[3] ); + break; + default: + /* Error will be caught later in gl_Fogfv */ + ; + } + _mesa_Fogfv(pname, p); +} + + +void +_mesa_Fogfv( GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); GLenum m; switch (pname) { diff --git a/src/mesa/main/fog.h b/src/mesa/main/fog.h index cf9dcebaf7d..0bb4d9d72aa 100644 --- a/src/mesa/main/fog.h +++ b/src/mesa/main/fog.h @@ -1,8 +1,8 @@ -/* $Id: fog.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: fog.h,v 1.2 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,7 +25,6 @@ */ - #ifndef FOG_H #define FOG_H @@ -33,7 +32,21 @@ #include "types.h" -extern void gl_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ); +extern void +_mesa_Fogf(GLenum pname, GLfloat param); + + +extern void +_mesa_Fogi(GLenum pname, GLint param ); + + +extern void +_mesa_Fogfv(GLenum pname, const GLfloat *params ); + + +extern void +_mesa_Fogiv(GLenum pname, const GLint *params ); + extern void gl_fog_vertices( struct vertex_buffer *VB ); diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 25544d01263..165b9589ed5 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1,8 +1,8 @@ -/* $Id: get.c,v 1.5 1999/10/17 22:36:35 brianp Exp $ */ +/* $Id: get.c,v 1.6 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,18 +25,10 @@ */ -/* $XFree86: xc/lib/GL/mesa/src/get.c,v 1.3 1999/04/04 00:20:25 dawes Exp $ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdio.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "enable.h" #include "enums.h" @@ -66,8 +58,10 @@ -void gl_GetBooleanv( GLcontext *ctx, GLenum pname, GLboolean *params ) +void +_mesa_GetBooleanv( GLenum pname, GLboolean *params ) { + GET_CURRENT_CONTEXT(ctx); GLuint i; GLuint texUnit = ctx->Texture.CurrentUnit; GLuint texTransformUnit = ctx->Texture.CurrentTransformUnit; @@ -748,13 +742,13 @@ void gl_GetBooleanv( GLcontext *ctx, GLenum pname, GLboolean *params ) *params = INT_TO_BOOL(0); /* TODO */ break; case GL_TEXTURE_1D: - *params = gl_IsEnabled( ctx, GL_TEXTURE_1D ); + *params = _mesa_IsEnabled(GL_TEXTURE_1D ); break; case GL_TEXTURE_2D: - *params = gl_IsEnabled( ctx, GL_TEXTURE_2D ); + *params = _mesa_IsEnabled(GL_TEXTURE_2D ); break; case GL_TEXTURE_3D: - *params = gl_IsEnabled( ctx, GL_TEXTURE_3D ); + *params = _mesa_IsEnabled(GL_TEXTURE_3D ); break; case GL_TEXTURE_BINDING_1D: *params = INT_TO_BOOL(textureUnit->CurrentD[1]->Name); @@ -978,8 +972,10 @@ void gl_GetBooleanv( GLcontext *ctx, GLenum pname, GLboolean *params ) -void gl_GetDoublev( GLcontext *ctx, GLenum pname, GLdouble *params ) +void +_mesa_GetDoublev( GLenum pname, GLdouble *params ) { + GET_CURRENT_CONTEXT(ctx); GLuint i; GLuint texUnit = ctx->Texture.CurrentUnit; GLuint texTransformUnit = ctx->Texture.CurrentTransformUnit; @@ -1660,13 +1656,13 @@ void gl_GetDoublev( GLcontext *ctx, GLenum pname, GLdouble *params ) *params = 0.0; /* TODO */ break; case GL_TEXTURE_1D: - *params = gl_IsEnabled(ctx, GL_TEXTURE_1D) ? 1.0 : 0.0; + *params = _mesa_IsEnabled(GL_TEXTURE_1D) ? 1.0 : 0.0; break; case GL_TEXTURE_2D: - *params = gl_IsEnabled(ctx, GL_TEXTURE_2D) ? 1.0 : 0.0; + *params = _mesa_IsEnabled(GL_TEXTURE_2D) ? 1.0 : 0.0; break; case GL_TEXTURE_3D: - *params = gl_IsEnabled(ctx, GL_TEXTURE_3D) ? 1.0 : 0.0; + *params = _mesa_IsEnabled(GL_TEXTURE_3D) ? 1.0 : 0.0; break; case GL_TEXTURE_BINDING_1D: *params = (GLdouble) textureUnit->CurrentD[1]->Name; @@ -1893,8 +1889,10 @@ void gl_GetDoublev( GLcontext *ctx, GLenum pname, GLdouble *params ) -void gl_GetFloatv( GLcontext *ctx, GLenum pname, GLfloat *params ) +void +_mesa_GetFloatv( GLenum pname, GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); GLuint i; GLuint texUnit = ctx->Texture.CurrentUnit; GLuint texTransformUnit = ctx->Texture.CurrentTransformUnit; @@ -2572,13 +2570,13 @@ void gl_GetFloatv( GLcontext *ctx, GLenum pname, GLfloat *params ) *params = 0.0F; /* TODO */ break; case GL_TEXTURE_1D: - *params = gl_IsEnabled(ctx, GL_TEXTURE_1D) ? 1.0 : 0.0; + *params = _mesa_IsEnabled(GL_TEXTURE_1D) ? 1.0 : 0.0; break; case GL_TEXTURE_2D: - *params = gl_IsEnabled(ctx, GL_TEXTURE_2D) ? 1.0 : 0.0; + *params = _mesa_IsEnabled(GL_TEXTURE_2D) ? 1.0 : 0.0; break; case GL_TEXTURE_3D: - *params = gl_IsEnabled(ctx, GL_TEXTURE_3D) ? 1.0 : 0.0; + *params = _mesa_IsEnabled(GL_TEXTURE_3D) ? 1.0 : 0.0; break; case GL_TEXTURE_BINDING_1D: *params = (GLfloat) textureUnit->CurrentD[1]->Name; @@ -2802,8 +2800,10 @@ void gl_GetFloatv( GLcontext *ctx, GLenum pname, GLfloat *params ) -void gl_GetIntegerv( GLcontext *ctx, GLenum pname, GLint *params ) +void +_mesa_GetIntegerv( GLenum pname, GLint *params ) { + GET_CURRENT_CONTEXT(ctx); GLuint i; GLuint texUnit = ctx->Texture.CurrentUnit; GLuint texTransformUnit = ctx->Texture.CurrentTransformUnit; @@ -3485,13 +3485,13 @@ void gl_GetIntegerv( GLcontext *ctx, GLenum pname, GLint *params ) *params = 0; /* TODO */ break; case GL_TEXTURE_1D: - *params = gl_IsEnabled(ctx, GL_TEXTURE_1D) ? 1 : 0; + *params = _mesa_IsEnabled(GL_TEXTURE_1D) ? 1 : 0; break; case GL_TEXTURE_2D: - *params = gl_IsEnabled(ctx, GL_TEXTURE_2D) ? 1 : 0; + *params = _mesa_IsEnabled(GL_TEXTURE_2D) ? 1 : 0; break; case GL_TEXTURE_3D: - *params = gl_IsEnabled(ctx, GL_TEXTURE_3D) ? 1 : 0; + *params = _mesa_IsEnabled(GL_TEXTURE_3D) ? 1 : 0; break; case GL_TEXTURE_BINDING_1D: *params = textureUnit->CurrentD[1]->Name; @@ -3725,8 +3725,10 @@ void gl_GetIntegerv( GLcontext *ctx, GLenum pname, GLint *params ) -void gl_GetPointerv( GLcontext *ctx, GLenum pname, GLvoid **params ) +void +_mesa_GetPointerv( GLenum pname, GLvoid **params ) { + GET_CURRENT_CONTEXT(ctx); GLuint texUnit = ctx->Texture.CurrentUnit; /*GLuint texTransformUnit = ctx->Texture.CurrentTransformUnit;*/ @@ -3766,11 +3768,13 @@ void gl_GetPointerv( GLcontext *ctx, GLenum pname, GLvoid **params ) -const GLubyte *gl_GetString( GLcontext *ctx, GLenum name ) +const GLubyte * +_mesa_GetString( GLenum name ) { + GET_CURRENT_CONTEXT(ctx); static char result[1000]; static char *vendor = "Brian Paul"; - static char *version = "1.2 Mesa 3.1 beta"; + static char *version = "1.2 Mesa 3.3 beta"; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glGetString", 0); @@ -3811,3 +3815,24 @@ const GLubyte *gl_GetString( GLcontext *ctx, GLenum name ) return NULL; } } + + +/* + * Execute a glGetError command + */ +GLenum +_mesa_GetError( void ) +{ + GET_CURRENT_CONTEXT(ctx); + + GLenum e = ctx->ErrorValue; + + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL( ctx, "glGetError", (GLenum) 0); + + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "glGetError <-- %s\n", gl_lookup_enum_by_nr(e)); + + ctx->ErrorValue = (GLenum) GL_NO_ERROR; + return e; +} + diff --git a/src/mesa/main/get.h b/src/mesa/main/get.h index fefdb219c95..609a86ad3c8 100644 --- a/src/mesa/main/get.h +++ b/src/mesa/main/get.h @@ -1,8 +1,8 @@ -/* $Id: get.h,v 1.2 1999/09/09 23:47:09 brianp Exp $ */ +/* $Id: get.h,v 1.3 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef GET_H #define GET_H @@ -35,17 +32,27 @@ #include "types.h" -extern void gl_GetBooleanv( GLcontext *ctx, GLenum pname, GLboolean *params ); +extern void +_mesa_GetBooleanv( GLenum pname, GLboolean *params ); + +extern void +_mesa_GetDoublev( GLenum pname, GLdouble *params ); + +extern void +_mesa_GetFloatv( GLenum pname, GLfloat *params ); -extern void gl_GetDoublev( GLcontext *ctx, GLenum pname, GLdouble *params ); +extern void +_mesa_GetIntegerv( GLenum pname, GLint *params ); -extern void gl_GetFloatv( GLcontext *ctx, GLenum pname, GLfloat *params ); +extern void +_mesa_GetPointerv( GLenum pname, GLvoid **params ); -extern void gl_GetIntegerv( GLcontext *ctx, GLenum pname, GLint *params ); +extern const GLubyte * +_mesa_GetString( GLenum name ); -extern void gl_GetPointerv( GLcontext *ctx, GLenum pname, GLvoid **params ); +extern GLenum +_mesa_GetError( void ); -extern const GLubyte *gl_GetString( GLcontext *ctx, GLenum name ); #endif diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h new file mode 100644 index 00000000000..f4930cb01fe --- /dev/null +++ b/src/mesa/main/glheader.h @@ -0,0 +1,65 @@ +/* $Id: glheader.h,v 1.1 1999/11/11 01:22:26 brianp Exp $ */ + +/* + * Mesa 3-D graphics library + * Version: 3.3 + * + * Copyright (C) 1999 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. + */ + + +#ifndef GLHEADER_H +#define GLHEADER_H + + +/* + * This is the top-most include file of the Mesa sources. + * It includes gl.h and all system headers which are needed. + * Other Mesa source files should _not_ directly include any system + * headers. This allows Mesa to be integrated into XFree86 and + * allows system-dependent hacks/work-arounds to be collected in one place. + * + * If you touch this file, everything gets recompiled! + * + * This file should be included before any other header in the .c files. + */ + + +#ifdef XFree86LOADER +#include "xf86_ansic.h" +#else +#include <assert.h> +#include <ctype.h> +#include <float.h> +#include <math.h> +#include <limits.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#endif + +#ifdef HAVE_CONFIG_H +#include "conf.h" +#endif + +#include <GL/gl.h> + + +#endif diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 0b0eabfb102..c25190335d3 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -1,8 +1,8 @@ -/* $Id: hash.c,v 1.3 1999/10/13 18:42:50 brianp Exp $ */ +/* $Id: hash.c,v 1.4 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,24 +25,17 @@ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdlib.h> -#include <stdio.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "hash.h" -#include "macros.h" +#include "mem.h" #endif /* - * Generic hash table. Only dependency is the GLuint datatype. + * Generic hash table. * * This is used to implement display list and texture object lookup. * NOTE: key=0 is illegal. diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h index a38159ce090..bd4788ace1a 100644 --- a/src/mesa/main/hash.h +++ b/src/mesa/main/hash.h @@ -1,8 +1,8 @@ -/* $Id: hash.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: hash.h,v 1.2 1999/11/11 01:22:26 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,14 +25,11 @@ */ - - - #ifndef HASH_H #define HASH_H -#include "GL/gl.h" +#include "glheader.h" struct HashTable; diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 582fa5c147e..87a5c4800a6 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,8 +1,8 @@ -/* $Id: image.c,v 1.13 1999/11/08 07:36:44 brianp Exp $ */ +/* $Id: image.c,v 1.14 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,20 +25,14 @@ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdlib.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "image.h" #include "macros.h" +#include "mem.h" #include "mmath.h" #include "pixel.h" #include "types.h" @@ -47,6 +41,26 @@ /* + * These are the image packing parameters for Mesa's internal images. + * That is, _mesa_unpack_image() returns image data in this format. + * When we execute image commands (glDrawPixels, glTexImage, etc) + * from within display lists we have to be sure to set the current + * unpacking params to these values! + */ +struct gl_pixelstore_attrib _mesa_native_packing = { + 1, /* Alignment */ + 0, /* RowLength */ + 0, /* SkipPixels */ + 0, /* SkipRows */ + 0, /* ImageHeight */ + 0, /* SkipImages */ + GL_FALSE, /* SwapBytes */ + GL_FALSE /* LsbFirst */ +}; + + + +/* * Flip the 8 bits in each byte of the given array. */ void gl_flip_bytes( GLubyte *p, GLuint n ) @@ -207,7 +221,6 @@ GLint gl_components_in_format( GLenum format ) case GL_BLUE: case GL_ALPHA: case GL_LUMINANCE: - case GL_INTENSITY: return 1; case GL_LUMINANCE_ALPHA: return 2; @@ -477,441 +490,6 @@ GLvoid *gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing, /* - * Allocate a new gl_image. All fields are initialized to zero. - */ -static struct gl_image *alloc_image( void ) -{ - return CALLOC_STRUCT(gl_image); -} - - - -/* - * Allocate a new gl_image with the error flag set. - */ -static struct gl_image *alloc_error_image( GLint width, GLint height, - GLint depth, GLenum format, - GLenum type ) -{ - struct gl_image *image = alloc_image(); - if (image) { - image->Width = width; - image->Height = height; - image->Depth = depth; - image->Format = format; - image->Type = type; - image->ErrorFlag = GL_TRUE; - } - return image; -} - - - -/* - * Free a gl_image. - */ -void gl_free_image( struct gl_image *image ) -{ - if (image->Data) { - FREE(image->Data); - } - FREE(image); -} - - - -/* - * Do error checking on an image. If there's an error, register it and - * return GL_TRUE, else return GL_FALSE. - */ -GLboolean gl_image_error_test( GLcontext *ctx, const struct gl_image *image, - const char *msg ) -{ - if (!image) { - gl_error( ctx, GL_OUT_OF_MEMORY, msg ); - return GL_TRUE; - } - if (image->Width <= 0 || image->Height <= 0 || image->Depth <= 0) { - gl_error( ctx, GL_INVALID_VALUE, msg ); - return GL_TRUE; - } - else if (!gl_is_legal_format_and_type(image->Format, image->Type)) { - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - - -/* - * Unpack a depth-buffer image storing values as GLshort, GLuint, or GLfloats. - * Input: type - datatype of src depth image - * Return pointer to a new gl_image structure. - * - * Notes: if the source image type is GLushort then the gl_image will - * also store GLushorts. If the src image type is GLuint then the gl_image - * will also store GLuints. For all other src image types the gl_image - * will store GLfloats. The integer cases can later be optimized. - */ -static struct gl_image * -unpack_depth_image( GLcontext *ctx, GLenum type, GLint width, GLint height, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing) - -{ - struct gl_image *image; - GLfloat *fDst; - GLushort *sDst; - GLuint *iDst; - GLint i, j; - GLboolean errorType; - - errorType = type != GL_BYTE && - type != GL_UNSIGNED_BYTE && - type != GL_SHORT && - type != GL_UNSIGNED_SHORT && - type != GL_INT && - type != GL_UNSIGNED_INT && - type != GL_FLOAT; - - image = alloc_image(); - if (image) { - image->Width = width; - image->Height = height; - image->Depth = 1; - image->Components = 1; - image->Format = GL_DEPTH_COMPONENT; - if (errorType) { - image->Type = type; - image->Data = NULL; - } - if (type==GL_UNSIGNED_SHORT) { - image->Type = GL_UNSIGNED_SHORT; - image->Data = MALLOC( width * height * sizeof(GLushort)); - } - else if (type==GL_UNSIGNED_INT) { - image->Type = GL_UNSIGNED_INT; - image->Data = MALLOC( width * height * sizeof(GLuint)); - } - else { - image->Type = GL_FLOAT; - image->Data = MALLOC( width * height * sizeof(GLfloat)); - } - image->RefCount = 0; - if (!image->Data) - return image; - } - else { - return NULL; - } - - if (errorType) - return image; - - fDst = (GLfloat *) image->Data; - sDst = (GLushort *) image->Data; - iDst = (GLuint *) image->Data; - - for (i=0;i<height;i++) { - GLvoid *src = gl_pixel_addr_in_image( packing, pixels, - width, height, - GL_DEPTH_COMPONENT, type, - 0, i, 0 ); - if (!src) { - return image; - } - - switch (type) { - case GL_BYTE: - assert(image->Type == GL_FLOAT); - for (j=0; j<width; j++) { - *fDst++ = BYTE_TO_FLOAT(((GLbyte*)src)[j]); - } - break; - case GL_UNSIGNED_BYTE: - assert(image->Type == GL_FLOAT); - for (j=0; j<width; j++) { - *fDst++ = UBYTE_TO_FLOAT(((GLubyte*)src)[j]); - } - break; - case GL_UNSIGNED_SHORT: - assert(image->Type == GL_UNSIGNED_SHORT); - MEMCPY( sDst, src, width * sizeof(GLushort) ); - if (packing->SwapBytes) { - gl_swap2( sDst, width ); - } - sDst += width; - break; - case GL_SHORT: - assert(image->Type == GL_FLOAT); - if (packing->SwapBytes) { - for (j=0;j<width;j++) { - GLshort value = ((GLshort*)src)[j]; - value = ((value >> 8) & 0xff) | ((value&0xff) << 8); - *fDst++ = SHORT_TO_FLOAT(value); - } - } - else { - for (j=0;j<width;j++) { - *fDst++ = SHORT_TO_FLOAT(((GLshort*)src)[j]); - } - } - break; - case GL_INT: - assert(image->Type == GL_FLOAT); - if (packing->SwapBytes) { - for (j=0;j<width;j++) { - GLint value = ((GLint*)src)[j]; - value = ((value >> 24) & 0x000000ff) | - ((value >> 8) & 0x0000ff00) | - ((value << 8) & 0x00ff0000) | - ((value << 24) & 0xff000000); - *fDst++ = INT_TO_FLOAT(value); - } - } - else { - for (j=0;j<width;j++) { - *fDst++ = INT_TO_FLOAT(((GLint*)src)[j]); - } - } - iDst += width; - break; - case GL_UNSIGNED_INT: - assert(image->Type == GL_UNSIGNED_INT); - MEMCPY( iDst, src, width * sizeof(GLuint) ); - if (packing->SwapBytes) { - gl_swap4( iDst, width ); - } - iDst += width; - break; - case GL_FLOAT: - assert(image->Type == GL_FLOAT); - MEMCPY( fDst, src, width * sizeof(GLfloat) ); - if (packing->SwapBytes) { - gl_swap4( (GLuint*) fDst, width ); - } - fDst += width; - break; - default: - gl_problem(ctx, "unpack_depth_image type" ); - return image; - } - } - - return image; -} - - - -/* - * Unpack a stencil image. Store as GLubytes in a gl_image structure. - * Return: pointer to new gl_image structure. - */ -static struct gl_image * -unpack_stencil_image( GLcontext *ctx, GLenum type, GLint width, GLint height, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - struct gl_image *image; - GLubyte *dst; - GLint i, j; - GLboolean errorType; - - assert(sizeof(GLstencil) == sizeof(GLubyte)); - - errorType = type != GL_BYTE && - type != GL_UNSIGNED_BYTE && - type != GL_SHORT && - type != GL_UNSIGNED_SHORT && - type != GL_INT && - type != GL_UNSIGNED_INT && - type != GL_FLOAT && - type != GL_BITMAP; - - image = alloc_image(); - if (image) { - image->Width = width; - image->Height = height; - image->Depth = 1; - image->Components = 1; - image->Format = GL_STENCIL_INDEX; - if (errorType) { - image->Type = type; - image->Data = NULL; - } - else { - image->Type = GL_UNSIGNED_BYTE; - image->Data = MALLOC( width * height * sizeof(GLubyte)); - } - image->RefCount = 0; - if (!image->Data) - return image; - } - else { - return NULL; - } - - if (errorType) - return image; /* error will be generated later */ - - dst = (GLubyte *) image->Data; - - for (i=0;i<height;i++) { - GLvoid *src = gl_pixel_addr_in_image( packing, pixels, - width, height, - GL_STENCIL_INDEX, type, - 0, i, 0 ); - if (!src) { - return image; - } - - switch (type) { - case GL_UNSIGNED_BYTE: - case GL_BYTE: - MEMCPY( dst, src, width * sizeof(GLubyte) ); - dst += width * sizeof(GLubyte); - break; - case GL_UNSIGNED_SHORT: - case GL_SHORT: - if (packing->SwapBytes) { - /* grab upper byte */ - for (j=0; j < width; j++) { - *dst++ = (((GLushort*)src)[j] & 0xff00) >> 8; - } - } - else { - for (j=0; j < width; j++) { - *dst++ = (((GLushort*)src)[j]) & 0xff; - } - } - break; - case GL_INT: - if (packing->SwapBytes) { - /* grab upper byte */ - for (j=0; j < width; j++) { - *dst++ = (((GLuint*)src)[j] & 0xff000000) >> 8; - } - } - else { - for (j=0; j < width; j++) { - *dst++ = (((GLuint*)src)[j]) & 0xff; - } - } - break; - case GL_UNSIGNED_INT: - if (packing->SwapBytes) { - /* grab upper byte */ - for (j=0; j < width; j++) { - *dst++ = (((GLuint*)src)[j] & 0xff000000) >> 8; - } - } - else { - for (j=0; j < width; j++) { - *dst++ = (((GLuint*)src)[j]) & 0xff; - } - } - break; - case GL_FLOAT: - if (packing->SwapBytes) { - for (j=0; j < width; j++) { - GLfloat fvalue; - GLint value = ((GLuint*)src)[j]; - value = ((value & 0xff000000) >> 24) - | ((value & 0x00ff0000) >> 8) - | ((value & 0x0000ff00) << 8) - | ((value & 0x000000ff) << 24); - fvalue = *((GLfloat*) &value); - *dst++ = ((GLint) fvalue) & 0xff; - } - } - else { - for (j=0; j < width; j++) { - GLfloat fvalue = ((GLfloat *)src)[j]; - *dst++ = ((GLint) fvalue) & 0xff; - } - } - break; - default: - gl_problem(ctx, "unpack_stencil_image type" ); - return image; - } - } - - return image; -} - - - -/* - * Unpack a bitmap, return a new gl_image struct. - */ -static struct gl_image * -unpack_bitmap( GLenum format, GLint width, GLint height, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - struct gl_image *image; - GLint bytes, i, width_in_bytes; - GLubyte *buffer, *dst; - - assert(format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX); - - /* Alloc dest storage */ - bytes = ((width+7)/8 * height); - if (bytes>0 && pixels!=NULL) { - buffer = (GLubyte *) MALLOC( bytes ); - if (!buffer) { - return NULL; - } - /* Copy/unpack pixel data to buffer */ - width_in_bytes = CEILING( width, 8 ); - dst = buffer; - for (i=0; i<height; i++) { - GLvoid *src = gl_pixel_addr_in_image( packing, pixels, - width, height, - GL_COLOR_INDEX, GL_BITMAP, - 0, i, 0 ); - if (!src) { - FREE(buffer); - return NULL; - } - MEMCPY( dst, src, width_in_bytes ); - dst += width_in_bytes; - } - /* Bit flipping */ - if (packing->LsbFirst) { - gl_flip_bytes( buffer, bytes ); - } - } - else { - /* a 'null' bitmap */ - buffer = NULL; - } - - image = alloc_image(); - if (image) { - image->Width = width; - image->Height = height; - image->Depth = 1; - image->Components = 0; - image->Format = format; - image->Type = GL_BITMAP; - image->Data = buffer; - image->RefCount = 0; - } - else { - FREE( buffer ); - return NULL; - } - - return image; -} - - - -/* * Unpack a 32x32 pixel polygon stipple from user memory using the * current pixel unpack settings. */ @@ -963,701 +541,6 @@ void gl_pack_polygon_stipple( const GLcontext *ctx, /* - * Unpack an RGBA or CI image and store it as unsigned bytes - */ -static struct gl_image * -unpack_ubyte_image( GLint width, GLint height, - GLint depth, GLenum format, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - struct gl_image *image; - GLint width_in_bytes; - GLint components; - GLubyte *buffer, *dst; - GLint i, d; - - components = gl_components_in_format( format ); - - width_in_bytes = width * components * sizeof(GLubyte); - buffer = (GLubyte *) MALLOC( height * width_in_bytes * depth ); - if (!buffer) { - return NULL; - } - - /* Copy/unpack pixel data to buffer */ - dst = buffer; - for (d=0; d<depth; d++ ) { - for (i=0;i<height;i++) { - GLubyte *src = (GLubyte *) gl_pixel_addr_in_image( packing, - pixels, width, height, format, GL_UNSIGNED_BYTE, - d, i, 0 ); - if (!src) { - FREE(buffer); - return NULL; - } - MEMCPY( dst, src, width_in_bytes ); - dst += width_in_bytes; - } - } - - if (format == GL_BGR) { - /* swap order of every ubyte triplet from BGR to RGB */ - for (i=0; i<width*height; i++) { - GLubyte b = buffer[i*3+0]; - GLubyte r = buffer[i*3+2]; - buffer[i*3+0] = r; - buffer[i*3+2] = b; - } - } - else if (format == GL_BGRA) { - /* swap order of every ubyte quadruplet from BGRA to RGBA */ - for (i=0; i<width*height; i++) { - GLubyte b = buffer[i*4+0]; - GLubyte r = buffer[i*4+2]; - buffer[i*4+0] = r; - buffer[i*4+2] = b; - } - } - else if (format == GL_ABGR_EXT) { - /* swap order of every ubyte quadruplet from ABGR to RGBA */ - for (i=0; i<width*height; i++) { - GLubyte a = buffer[i*4+0]; - GLubyte b = buffer[i*4+1]; - GLubyte g = buffer[i*4+2]; - GLubyte r = buffer[i*4+3]; - buffer[i*4+0] = r; - buffer[i*4+1] = g; - buffer[i*4+2] = b; - buffer[i*4+3] = a; - } - } - - - image = alloc_image(); - if (image) { - image->Width = width; - image->Height = height; - image->Depth = depth; - image->Components = components; - if (format == GL_BGR) - image->Format = GL_RGB; - else if (format == GL_BGRA) - image->Format = GL_RGBA; - else if (format == GL_ABGR_EXT) - image->Format = GL_RGBA; - else - image->Format = format; - image->Type = GL_UNSIGNED_BYTE; - image->Data = buffer; - image->RefCount = 0; - } - else { - FREE( buffer ); - } - - return image; -} - - - -/* - * Unpack a color image storing image as GLfloats - */ -static struct gl_image * -unpack_float_image( GLcontext *ctx, GLint width, GLint height, GLint depth, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - struct gl_image *image; - GLfloat *dst; - GLint elems_per_row; - GLint components; - GLint i, j, d; - GLboolean normalize; - - assert(type != GL_BITMAP); - - components = gl_components_in_format( format ); - assert(components > 0); /* should have been caught earlier */ - - if (!gl_is_legal_format_and_type( format, type )) { - /* bad pixel type for format, make dummy image */ - image = alloc_image(); - if (image) { - image->Width = width; - image->Height = height; - image->Depth = depth; - image->Components = components; - image->Format = format; - image->Type = type; - image->Data = NULL; - image->RefCount = 0; - } - return image; - } - - elems_per_row = width * components; - - image = alloc_image(); - if (image) { - image->Width = width; - image->Height = height; - image->Depth = depth; - image->Components = components; - if (format == GL_BGR) - image->Format = GL_RGB; - else if (format == GL_BGRA) - image->Format = GL_RGBA; - else if (format == GL_ABGR_EXT) - image->Format = GL_RGBA; - else - image->Format = format; - image->Type = GL_FLOAT; - image->Data = MALLOC( elems_per_row * height * depth * sizeof(GLfloat)); - image->RefCount = 0; - if (!image->Data) - return image; - } - else { - return NULL; - } - - normalize = (format != GL_COLOR_INDEX) && (format != GL_STENCIL_INDEX); - - dst = (GLfloat *) image->Data; - - for (d=0; d<depth; d++) { - for (i=0;i<height;i++) { - GLvoid *src = gl_pixel_addr_in_image( packing, pixels, - width, height, - format, type, - d, i, 0 ); - if (!src) { - return image; - } - - switch (type) { - case GL_UNSIGNED_BYTE: - { - GLubyte *ubsrc = (GLubyte *) src; - if (normalize) { - for (j=0;j<elems_per_row;j++) { - *dst++ = UBYTE_TO_FLOAT(ubsrc[j]); - } - } - else { - for (j=0;j<elems_per_row;j++) { - *dst++ = (GLfloat) ubsrc[j]; - } - } - } - break; - case GL_BYTE: - if (normalize) { - for (j=0;j<elems_per_row;j++) { - *dst++ = BYTE_TO_FLOAT(((GLbyte*)src)[j]); - } - } - else { - for (j=0;j<elems_per_row;j++) { - *dst++ = (GLfloat) ((GLbyte*)src)[j]; - } - } - break; - case GL_UNSIGNED_SHORT: - if (packing->SwapBytes) { - for (j=0;j<elems_per_row;j++) { - GLushort value = ((GLushort*)src)[j]; - value = ((value >> 8) & 0xff) | ((value&0xff) << 8); - if (normalize) { - *dst++ = USHORT_TO_FLOAT(value); - } - else { - *dst++ = (GLfloat) value; - } - } - } - else { - if (normalize) { - for (j=0;j<elems_per_row;j++) { - *dst++ = USHORT_TO_FLOAT(((GLushort*)src)[j]); - } - } - else { - for (j=0;j<elems_per_row;j++) { - *dst++ = (GLfloat) ((GLushort*)src)[j]; - } - } - } - break; - case GL_SHORT: - if (packing->SwapBytes) { - for (j=0;j<elems_per_row;j++) { - GLshort value = ((GLshort*)src)[j]; - value = ((value >> 8) & 0xff) | ((value&0xff) << 8); - if (normalize) { - *dst++ = SHORT_TO_FLOAT(value); - } - else { - *dst++ = (GLfloat) value; - } - } - } - else { - if (normalize) { - for (j=0;j<elems_per_row;j++) { - *dst++ = SHORT_TO_FLOAT(((GLshort*)src)[j]); - } - } - else { - for (j=0;j<elems_per_row;j++) { - *dst++ = (GLfloat) ((GLshort*)src)[j]; - } - } - } - break; - case GL_UNSIGNED_INT: - if (packing->SwapBytes) { - GLuint value; - for (j=0;j<elems_per_row;j++) { - value = ((GLuint*)src)[j]; - value = ((value & 0xff000000) >> 24) - | ((value & 0x00ff0000) >> 8) - | ((value & 0x0000ff00) << 8) - | ((value & 0x000000ff) << 24); - if (normalize) { - *dst++ = UINT_TO_FLOAT(value); - } - else { - *dst++ = (GLfloat) value; - } - } - } - else { - if (normalize) { - for (j=0;j<elems_per_row;j++) { - *dst++ = UINT_TO_FLOAT(((GLuint*)src)[j]); - } - } - else { - for (j=0;j<elems_per_row;j++) { - *dst++ = (GLfloat) ((GLuint*)src)[j]; - } - } - } - break; - case GL_INT: - if (packing->SwapBytes) { - GLint value; - for (j=0;j<elems_per_row;j++) { - value = ((GLint*)src)[j]; - value = ((value & 0xff000000) >> 24) - | ((value & 0x00ff0000) >> 8) - | ((value & 0x0000ff00) << 8) - | ((value & 0x000000ff) << 24); - if (normalize) { - *dst++ = INT_TO_FLOAT(value); - } - else { - *dst++ = (GLfloat) value; - } - } - } - else { - if (normalize) { - for (j=0;j<elems_per_row;j++) { - *dst++ = INT_TO_FLOAT(((GLint*)src)[j]); - } - } - else { - for (j=0;j<elems_per_row;j++) { - *dst++ = (GLfloat) ((GLint*)src)[j]; - } - } - } - break; - case GL_FLOAT: - if (packing->SwapBytes) { - GLint value; - for (j=0;j<elems_per_row;j++) { - value = ((GLuint*)src)[j]; - value = ((value & 0xff000000) >> 24) - | ((value & 0x00ff0000) >> 8) - | ((value & 0x0000ff00) << 8) - | ((value & 0x000000ff) << 24); - *dst++ = *((GLfloat*) &value); - } - } - else { - MEMCPY( dst, src, elems_per_row*sizeof(GLfloat) ); - dst += elems_per_row; - } - break; - case GL_UNSIGNED_BYTE_3_3_2: - { - GLubyte *ubsrc = (GLubyte *) src; - for (j=0;j<width;j++) { - GLubyte p = ubsrc[j]; - *dst++ = ((p >> 5) ) * (1.0F / 7.0F); /* red */ - *dst++ = ((p >> 2) & 0x7) * (1.0F / 7.0F); /* green */ - *dst++ = ((p ) & 0x3) * (1.0F / 3.0F); /* blue */ - } - } - break; - case GL_UNSIGNED_BYTE_2_3_3_REV: - { - GLubyte *ubsrc = (GLubyte *) src; - for (j=0;j<width;j++) { - GLubyte p = ubsrc[j]; - *dst++ = ((p ) & 0x7) * (1.0F / 7.0F); /* red */ - *dst++ = ((p >> 3) & 0x7) * (1.0F / 7.0F); /* green */ - *dst++ = ((p >> 6) ) * (1.0F / 3.0F); /* blue */ - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5: - { - GLushort *ussrc = (GLushort *) src; - for (j=0;j<width;j++) { - GLushort p = ussrc[j]; - *dst++ = ((p >> 11) ) * (1.0F / 31.0F); /* red */ - *dst++ = ((p >> 5) & 0x3f) * (1.0F / 63.0F); /* green */ - *dst++ = ((p ) & 0x1f) * (1.0F / 31.0F); /* blue */ - } - } - break; - case GL_UNSIGNED_SHORT_5_6_5_REV: - { - GLushort *ussrc = (GLushort *) src; - for (j=0;j<width;j++) { - GLushort p = ussrc[j]; - *dst++ = ((p ) & 0x1f) * (1.0F / 31.0F); /* red */ - *dst++ = ((p >> 5) & 0x3f) * (1.0F / 63.0F); /* green */ - *dst++ = ((p >> 11) ) * (1.0F / 31.0F); /* blue */ - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4: - { - GLushort *ussrc = (GLushort *) src; - for (j=0;j<width;j++) { - GLushort p = ussrc[j]; - *dst++ = ((p >> 12) ) * (1.0F / 15.0F); /* red */ - *dst++ = ((p >> 8) & 0xf) * (1.0F / 15.0F); /* green */ - *dst++ = ((p >> 4) & 0xf) * (1.0F / 15.0F); /* blue */ - *dst++ = ((p ) & 0xf) * (1.0F / 15.0F); /* alpha */ - } - } - break; - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - { - GLushort *ussrc = (GLushort *) src; - for (j=0;j<width;j++) { - GLushort p = ussrc[j]; - *dst++ = ((p ) & 0xf) * (1.0F / 15.0F); /* red */ - *dst++ = ((p >> 4) & 0xf) * (1.0F / 15.0F); /* green */ - *dst++ = ((p >> 8) & 0xf) * (1.0F / 15.0F); /* blue */ - *dst++ = ((p >> 12) ) * (1.0F / 15.0F); /* alpha */ - } - } - break; - case GL_UNSIGNED_SHORT_5_5_5_1: - { - GLushort *ussrc = (GLushort *) src; - for (j=0;j<width;j++) { - GLushort p = ussrc[j]; - *dst++ = ((p >> 11) ) * (1.0F / 31.0F); /* red */ - *dst++ = ((p >> 6) & 0x1f) * (1.0F / 31.0F); /* green */ - *dst++ = ((p >> 1) & 0x1f) * (1.0F / 31.0F); /* blue */ - *dst++ = ((p ) & 0x1) * (1.0F / 1.0F); /* alpha */ - } - } - break; - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - { - GLushort *ussrc = (GLushort *) src; - for (j=0;j<width;j++) { - GLushort p = ussrc[j]; - *dst++ = ((p ) & 0x1f) * (1.0F / 31.0F); /* red */ - *dst++ = ((p >> 5) & 0x1f) * (1.0F / 31.0F); /* green */ - *dst++ = ((p >> 10) & 0x1f) * (1.0F / 31.0F); /* blue */ - *dst++ = ((p >> 15) ) * (1.0F / 1.0F); /* alpha */ - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8: - { - GLuint *uisrc = (GLuint *) src; - for (j=0;j<width;j++) { - GLuint p = uisrc[j]; - *dst++ = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 24) ); - *dst++ = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 16) & 0xff); - *dst++ = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 8) & 0xff); - *dst++ = UBYTE_COLOR_TO_FLOAT_COLOR((p ) & 0xff); - } - } - break; - case GL_UNSIGNED_INT_8_8_8_8_REV: - { - GLuint *uisrc = (GLuint *) src; - for (j=0;j<width;j++) { - GLuint p = uisrc[j]; - *dst++ = UBYTE_COLOR_TO_FLOAT_COLOR((p ) & 0xff); - *dst++ = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 8) & 0xff); - *dst++ = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 16) & 0xff); - *dst++ = UBYTE_COLOR_TO_FLOAT_COLOR((p >> 24) ); - } - } - break; - case GL_UNSIGNED_INT_10_10_10_2: - { - GLuint *uisrc = (GLuint *) src; - for (j=0;j<width;j++) { - GLuint p = uisrc[j]; - *dst++ = ((p >> 22) ) * (1.0F / 1023.0F); /* r */ - *dst++ = ((p >> 12) & 0x3ff) * (1.0F / 1023.0F); /* g */ - *dst++ = ((p >> 2) & 0x3ff) * (1.0F / 1023.0F); /* b */ - *dst++ = ((p ) & 0x3 ) * (1.0F / 3.0F); /* a */ - } - } - break; - case GL_UNSIGNED_INT_2_10_10_10_REV: - { - GLuint *uisrc = (GLuint *) src; - for (j=0;j<width;j++) { - GLuint p = uisrc[j]; - *dst++ = ((p ) & 0x3ff) * (1.0F / 1023.0F); /* r*/ - *dst++ = ((p >> 10) & 0x3ff) * (1.0F / 1023.0F); /* g */ - *dst++ = ((p >> 20) & 0x3ff) * (1.0F / 1023.0F); /* b */ - *dst++ = ((p >> 30) ) * (1.0F / 3.0F); /* a */ - } - } - break; - default: - gl_problem(ctx, "unpack_float_image type" ); - return image; - } - } - } - - if (format == GL_BGR) { - /* swap order of every float triplet from BGR to RGBA */ - GLfloat *buffer = (GLfloat *) image->Data; - for (i=0; i<width*height*depth; i++) { - GLfloat b = buffer[i*3+0]; - GLfloat r = buffer[i*3+2]; - buffer[i*3+0] = r; - buffer[i*3+2] = b; - } - } - else if (format == GL_BGRA) { - /* swap order of every float quadruplet from BGRA to RGBA */ - GLfloat *buffer = (GLfloat *) image->Data; - for (i=0; i<width*height*depth; i++) { - GLfloat b = buffer[i*4+0]; - GLfloat r = buffer[i*4+2]; - buffer[i*4+0] = r; - buffer[i*4+2] = b; - } - } - else if (format == GL_ABGR_EXT) { - /* swap order of every float quadruplet from ABGR to RGBA */ - GLfloat *buffer = (GLfloat *) image->Data; - for (i=0; i<width*height*depth; i++) { - GLfloat a = buffer[i*4+0]; - GLfloat b = buffer[i*4+1]; - GLfloat g = buffer[i*4+2]; - GLfloat r = buffer[i*4+3]; - buffer[i*4+0] = r; - buffer[i*4+1] = g; - buffer[i*4+2] = b; - buffer[i*4+3] = a; - } - } - - return image; -} - - - -/* - * Unpack a bitmap image, using current glPixelStore parameters, - * making a new gl_image. - */ -struct gl_image *gl_unpack_bitmap( GLcontext *ctx, - GLsizei width, GLsizei height, - const GLubyte *bitmap, - const struct gl_pixelstore_attrib *packing ) -{ - return gl_unpack_image( ctx, width, height, - GL_COLOR_INDEX, GL_BITMAP, bitmap, packing ); -} - - - -/* - * Unpack a 2-D image from user's buffer. Return pointer to new - * gl_image struct. - * - * Input: width, height - size in pixels - * format - format of incoming pixel data - * type - datatype of incoming pixel data - * pixels - pointer to unpacked image in user buffer - */ -struct gl_image *gl_unpack_image( GLcontext *ctx, - GLint width, GLint height, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ) -{ - return gl_unpack_image3D( ctx, width, height, 1, - format, type, pixels, packing ); -} - - - -/* - * Unpack a 1, 2 or 3-D image from user-supplied address, returning a - * pointer to a new gl_image struct. - * This function is always called by a higher-level unpack function such - * as gl_unpack_texsubimage() or gl_unpack_bitmap(). - * - * Input: width, height, depth - size in pixels - * format - format of incoming pixel data - * type - datatype of incoming pixel data - * pixels - pointer to unpacked image. - */ -struct gl_image *gl_unpack_image3D( GLcontext *ctx, - GLint width, GLint height, GLint depth, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing) -{ - if (width <= 0 || height <= 0 || depth <= 0) { - return alloc_error_image(width, height, depth, format, type); - } - - if (type==GL_BITMAP) { - if (format != GL_COLOR_INDEX && format != GL_STENCIL_INDEX) { - return alloc_error_image(width, height, depth, format, type); - } - else { - return unpack_bitmap( format, width, height, pixels, packing ); - } - } - else if (format==GL_DEPTH_COMPONENT) { - /* TODO: pack as GLdepth values (GLushort or GLuint) */ - return unpack_depth_image( ctx, type, width, height, pixels, packing ); - } - else if (format==GL_STENCIL_INDEX) { - /* TODO: pack as GLstencil (GLubyte or GLushort) */ - return unpack_stencil_image( ctx, type, width, height, pixels, packing ); - } - else if (type==GL_UNSIGNED_BYTE) { - /* upack, convert to GLubytes */ - return unpack_ubyte_image( width, height, depth, format, pixels, packing ); - } - else { - /* upack, convert to floats */ - return unpack_float_image( ctx, width, height, depth, - format, type, pixels, packing ); - } - - /* never get here */ - /*return NULL;*/ -} - - -/* - * Apply pixel-transfer operations (scale, bias, mapping) to a single row - * of a gl_image. Put resulting color components into result array. - */ -void gl_scale_bias_map_image_data( const GLcontext *ctx, - const struct gl_image *image, - GLint row, GLubyte result[] ) -{ - GLint start, i; - - assert(ctx); - assert(image); - assert(result); - assert(row >= 0); - - start = row * image->Width * image->Components; - - for (i=0; i < image->Width; i++) { - GLint pos = start+i; - GLfloat red, green, blue, alpha; - if (image->Type == GL_UNSIGNED_BYTE) { - const GLubyte *data = (GLubyte *) image->Data; - switch (image->Format) { - case GL_RED: - red = data[pos] * (1.0F/255.0F); - green = 0; - blue = 0; - alpha = 0; - break; - case GL_RGB: - red = data[pos*3+0] * (1.0F/255.0F); - green = data[pos*3+1] * (1.0F/255.0F); - blue = data[pos*3+2] * (1.0F/255.0F); - alpha = 0; - break; - default: - gl_problem(ctx, "bad image format in gl_scale...image_data"); - return; - } - } - else if (image->Type == GL_FLOAT) { - const GLubyte *data = (GLubyte *) image->Data; - switch (image->Format) { - case GL_RED: - red = data[pos]; - green = 0; - blue = 0; - alpha = 0; - break; - case GL_RGB: - red = data[pos*3+0]; - green = data[pos*3+1]; - blue = data[pos*3+2]; - alpha = 0; - break; - default: - gl_problem(ctx, "bad image format in gl_scale...image_data"); - return; - } - } - else { - gl_problem(ctx, "Bad image type in gl_scale_...image_data"); - return; - } - - assert(red >= 0.0 && red <= 1.0); - assert(green >= 0.0 && green <= 1.0); - assert(blue >= 0.0 && blue <= 1.0); - assert(alpha >= 0.0 && alpha <= 1.0); - - /* - if (scale or bias) { - - - } - if (mapping) { - - } - */ - - result[i*4+0] = (GLubyte) (red * 255.0); - result[i*4+1] = (GLubyte) (green * 255.0); - result[i*4+2] = (GLubyte) (blue * 255.0); - result[i*4+3] = (GLubyte) (alpha * 255.0); - } -} - - - -/* * Pack the given RGBA span into client memory at 'dest' address * in the given pixel format and type. * Optionally apply the enabled pixel transfer ops. @@ -1678,14 +561,14 @@ void gl_pack_rgba_span( const GLcontext *ctx, const struct gl_pixelstore_attrib *packing, GLboolean applyTransferOps ) { + applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag); + /* Test for optimized case first */ - if (!ctx->Pixel.ScaleOrBiasRGBA && !ctx->Pixel.MapColorFlag && - format == GL_RGBA && type == GL_UNSIGNED_BYTE) { + if (!applyTransferOps && format == GL_RGBA && type == GL_UNSIGNED_BYTE) { /* common simple case */ MEMCPY( destination, rgba, n * 4 * sizeof(GLubyte) ); } - else if (!ctx->Pixel.ScaleOrBiasRGBA && !ctx->Pixel.MapColorFlag && - format == GL_RGB && type == GL_UNSIGNED_BYTE) { + else if (!applyTransferOps && format == GL_RGB && type == GL_UNSIGNED_BYTE) { /* common simple case */ GLint i; GLubyte *dest = (GLubyte *) destination; @@ -1697,6 +580,7 @@ void gl_pack_rgba_span( const GLcontext *ctx, } } else { + /* general solution */ GLfloat red[MAX_WIDTH], green[MAX_WIDTH], blue[MAX_WIDTH]; GLfloat alpha[MAX_WIDTH], luminance[MAX_WIDTH]; const GLfloat rscale = 1.0F / 255.0F; @@ -2470,11 +1354,6 @@ void gl_pack_rgba_span( const GLcontext *ctx, } - -/* - * New (3.3) functions - */ - #define SWAP2BYTE(VALUE) \ { \ GLubyte *bytes = (GLubyte *) &(VALUE); \ @@ -2679,16 +1558,6 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], GLint stride; GLint rComp, bComp, gComp, aComp; - if (0) - { - int i; - for (i = 0; i<n;i++) { - rgba[i][0] = rgba[i][1] = rgba[i][2] = rgba[i][3] = 0; - } - return; - } - - ASSERT(srcFormat == GL_RED || srcFormat == GL_GREEN || srcFormat == GL_BLUE || @@ -2710,17 +1579,10 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], srcType == GL_INT || srcType == GL_FLOAT || srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_10_10_10_2 || - srcType == GL_UNSIGNED_INT_2_10_10_10_REV); + srcType == GL_UNSIGNED_INT_10_10_10_2); switch (srcFormat) { case GL_RED: @@ -2810,10 +1672,6 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], return; } - assert(redIndex >= -1 && redIndex <= 4); - assert(greenIndex >= -1 && greenIndex <= 4); - assert(blueIndex >= -1 && blueIndex <= 4); - assert(alphaIndex >= -1 && alphaIndex <= 4); #define PROCESS(INDEX, CHANNEL, DEFAULT, TYPE, CONVERSION) \ if ((INDEX) < 0) { \ @@ -3228,22 +2086,16 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, srcType == GL_INT || srcType == GL_FLOAT || srcType == GL_UNSIGNED_BYTE_3_3_2 || - srcType == GL_UNSIGNED_BYTE_2_3_3_REV || - srcType == GL_UNSIGNED_SHORT_5_6_5 || - srcType == GL_UNSIGNED_SHORT_5_6_5_REV || srcType == GL_UNSIGNED_SHORT_4_4_4_4 || - srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || srcType == GL_UNSIGNED_SHORT_5_5_5_1 || - srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || srcType == GL_UNSIGNED_INT_8_8_8_8 || - srcType == GL_UNSIGNED_INT_8_8_8_8_REV || - srcType == GL_UNSIGNED_INT_10_10_10_2 || - srcType == GL_UNSIGNED_INT_2_10_10_10_REV); + srcType == GL_UNSIGNED_INT_10_10_10_2); /* this is intended for RGBA mode */ - ASSERT(ctx->Visual->RGBAflag); + assert(ctx->Visual->RGBAflag); applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || + ctx->Pixel.MapColorFlag || ctx->Pixel.MapColorFlag); /* Try simple cases first */ @@ -3426,6 +2278,7 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, /* Now return the GLubyte data in the requested dstFormat */ + if (dstRedIndex >= 0) { GLubyte *dst = dest; GLuint i; @@ -3589,6 +2442,206 @@ _mesa_unpack_index_span( const GLcontext *ctx, GLuint n, /* + * Unpack a row of stencil data from a client buffer according to + * the pixel unpacking parameters. Apply pixel transfer ops if enabled + * and applyTransferOps is true. + * This is (or will be) used by glDrawPixels + * + * Args: ctx - the context + * n - number of pixels + * dstType - destination datatype + * dest - destination array + * srcType - source pixel type + * source - source data pointer + * unpacking - pixel unpacking parameters + * applyTransferOps - apply offset/bias/lookup ops? + */ +void +_mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, + GLenum dstType, GLvoid *dest, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *unpacking, + GLboolean applyTransferOps ) +{ + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_FLOAT); + + ASSERT(dstType == GL_UNSIGNED_BYTE || + dstType == GL_UNSIGNED_SHORT || + dstType == GL_UNSIGNED_INT); + + applyTransferOps &= (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset || ctx->Pixel.MapColorFlag); + + /* + * Try simple cases first + */ + if (!applyTransferOps && srcType == GL_UNSIGNED_BYTE + && dstType == GL_UNSIGNED_BYTE) { + MEMCPY(dest, source, n * sizeof(GLubyte)); + } + else if (!applyTransferOps && srcType == GL_UNSIGNED_INT + && dstType == GL_UNSIGNED_INT && !unpacking->SwapBytes) { + MEMCPY(dest, source, n * sizeof(GLuint)); + } + else { + /* + * general solution + */ + GLuint indexes[MAX_WIDTH]; + assert(n <= MAX_WIDTH); + + extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source, + unpacking); + + if (applyTransferOps) { + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { + /* shift and offset indexes */ + gl_shift_and_offset_ci(ctx, n, indexes); + } + + if (ctx->Pixel.MapStencilFlag) { + /* Apply stencil lookup table */ + GLuint mask = ctx->Pixel.MapStoSsize - 1; + GLuint i; + for (i=0;i<n;i++) { + indexes[i] = ctx->Pixel.MapStoS[ indexes[i] & mask ]; + } + } + } + + /* convert to dest type */ + switch (dstType) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLubyte) (indexes[i] & 0xff); + } + } + break; + case GL_UNSIGNED_SHORT: + { + GLuint *dst = (GLuint *) dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[i] = (GLushort) (indexes[i] & 0xffff); + } + } + break; + case GL_UNSIGNED_INT: + MEMCPY(dest, indexes, n * sizeof(GLuint)); + break; + default: + gl_problem(ctx, "bad dstType in _mesa_unpack_stencil_span"); + } + } +} + + + +void +_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *unpacking, + GLboolean applyTransferOps ) +{ + GLfloat *depth = MALLOC(n * sizeof(GLfloat)); + if (!depth) + return; + + switch (srcType) { + case GL_BYTE: + { + GLuint i; + const GLubyte *src = (const GLubyte *) source; + for (i = 0; i < n; i++) { + depth[i] = BYTE_TO_FLOAT(src[i]); + } + } + break; + case GL_UNSIGNED_BYTE: + { + GLuint i; + const GLubyte *src = (const GLubyte *) source; + for (i = 0; i < n; i++) { + depth[i] = UBYTE_TO_FLOAT(src[i]); + } + } + break; + case GL_SHORT: + { + GLuint i; + const GLshort *src = (const GLshort *) source; + for (i = 0; i < n; i++) { + depth[i] = SHORT_TO_FLOAT(src[i]); + } + } + break; + case GL_UNSIGNED_SHORT: + { + GLuint i; + const GLushort *src = (const GLushort *) source; + for (i = 0; i < n; i++) { + depth[i] = USHORT_TO_FLOAT(src[i]); + } + } + break; + case GL_INT: + { + GLuint i; + const GLint *src = (const GLint *) source; + for (i = 0; i < n; i++) { + depth[i] = INT_TO_FLOAT(src[i]); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint i; + const GLuint *src = (const GLuint *) source; + for (i = 0; i < n; i++) { + depth[i] = UINT_TO_FLOAT(src[i]); + } + } + break; + case GL_FLOAT: + MEMCPY(depth, source, n * sizeof(GLfloat)); + break; + default: + gl_problem(NULL, "bad type in _mesa_unpack_depth_span()"); + return; + } + + + /* apply depth scale and bias */ + if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { + GLuint i; + for (i = 0; i < n; i++) { + depth[i] = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias; + } + } + + /* clamp depth values to [0,1] and convert from floats to integers */ + { + GLuint i; + for (i = 0; i < n; i++) { + dest[i] = (GLdepth) (CLAMP(depth[i], 0.0F, 1.0F) * DEPTH_SCALE); + } + } + + FREE(depth); +} + + + +/* * Unpack image data. Apply byteswapping, byte flipping (bitmap). * Return all image data in a contiguous block. */ @@ -3656,3 +2709,106 @@ _mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth, return destBuffer; } } + + +/* + * Unpack bitmap data. Resulting data will be in most-significant-bit-first + * order with row alignment = 1 byte. + */ +GLvoid * +_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, + const struct gl_pixelstore_attrib *packing ) +{ + GLint bytes, row, width_in_bytes; + GLubyte *buffer, *dst; + + if (!pixels) + return NULL; + + /* Alloc dest storage */ + bytes = ((width + 7) / 8 * height); + buffer = (GLubyte *) MALLOC( bytes ); + if (!buffer) + return NULL; + + + width_in_bytes = CEILING( width, 8 ); + dst = buffer; + for (row = 0; row < height; row++) { + GLubyte *src = gl_pixel_addr_in_image( packing, pixels, width, height, + GL_COLOR_INDEX, GL_BITMAP, + 0, row, 0 ); + if (!src) { + FREE(buffer); + return NULL; + } + + if (packing->SkipPixels == 0) { + MEMCPY( dst, src, width_in_bytes ); + if (packing->LsbFirst) { + gl_flip_bytes( dst, width_in_bytes ); + } + } + else { + /* handling SkipPixels is a bit tricky (no pun intended!) */ + GLint i; + if (packing->LsbFirst) { + GLubyte srcMask = 1 << (packing->SkipPixels & 0x7); + GLubyte dstMask = 128; + GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 128) { + srcMask = 1; + s++; + } + else { + srcMask = srcMask << 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + else { + GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7); + GLubyte dstMask = 128; + GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + } + dst += width_in_bytes; + } + + return buffer; +} diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 80e5ea7c3fc..03651cc14a1 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -1,4 +1,4 @@ -/* $Id: image.h,v 1.2 1999/11/03 17:27:05 brianp Exp $ */ +/* $Id: image.h,v 1.3 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -25,9 +25,6 @@ */ - - - #ifndef IMAGE_H #define IMAGE_H @@ -35,6 +32,9 @@ #include "types.h" +extern struct gl_pixelstore_attrib _mesa_native_packing; + + extern void gl_flip_bytes( GLubyte *p, GLuint n ); @@ -61,33 +61,16 @@ gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing, GLint img, GLint row, GLint column ); -extern struct gl_image * -gl_unpack_bitmap( GLcontext *ctx, GLsizei width, GLsizei height, - const GLubyte *bitmap, - const struct gl_pixelstore_attrib *packing ); - - -extern void gl_unpack_polygon_stipple( const GLcontext *ctx, - const GLubyte *pattern, - GLuint dest[32] ); - - -extern void gl_pack_polygon_stipple( const GLcontext *ctx, - const GLuint pattern[32], - GLubyte *dest ); - - -extern struct gl_image * -gl_unpack_image( GLcontext *ctx, GLint width, GLint height, - GLenum srcFormat, GLenum srcType, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ); - +extern void +gl_unpack_polygon_stipple( const GLcontext *ctx, + const GLubyte *pattern, + GLuint dest[32] ); -struct gl_image * -gl_unpack_image3D( GLcontext *ctx, GLint width, GLint height,GLint depth, - GLenum srcFormat, GLenum srcType, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing ); +extern void +gl_pack_polygon_stipple( const GLcontext *ctx, + const GLuint pattern[32], + GLubyte *dest ); extern void @@ -98,19 +81,6 @@ gl_pack_rgba_span( const GLcontext *ctx, GLboolean applyTransferOps ); -extern void gl_free_image( struct gl_image *image ); - - -extern GLboolean gl_image_error_test( GLcontext *ctx, - const struct gl_image *image, - const char *msg ); - - -/* - * New (3.3) functions - */ - - extern void _mesa_unpack_ubyte_color_span( const GLcontext *ctx, GLuint n, GLenum dstFormat, GLubyte dest[], @@ -127,10 +97,31 @@ _mesa_unpack_index_span( const GLcontext *ctx, GLuint n, const struct gl_pixelstore_attrib *unpacking, GLboolean applyTransferOps ); + +extern void +_mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, + GLenum dstType, GLvoid *dest, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *unpacking, + GLboolean applyTransferOps ); + + +extern void +_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, + GLenum srcType, const GLvoid *source, + const struct gl_pixelstore_attrib *unpacking, + GLboolean applyTransferOps ); + + extern void * _mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *unpack ); +extern GLvoid * +_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, + const struct gl_pixelstore_attrib *packing ); + + #endif diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index e38e25ba822..f5a611dd140 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -1,8 +1,8 @@ -/* $Id: light.c,v 1.8 1999/11/10 06:29:44 keithw Exp $ */ +/* $Id: light.c,v 1.9 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,27 +25,16 @@ */ - - - #ifdef PC_HEADER #include "all.h" #else -#include <float.h> -#ifndef XFree86Server -#include <assert.h> -#include <float.h> -#include <math.h> -#include <stdlib.h> -#include <stdio.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "enums.h" #include "light.h" #include "macros.h" #include "matrix.h" +#include "mem.h" #include "mmath.h" #include "simple_list.h" #include "types.h" @@ -55,46 +44,50 @@ -void gl_ShadeModel( GLcontext *ctx, GLenum mode ) +void +_mesa_ShadeModel( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glShadeModel"); if (MESA_VERBOSE & VERBOSE_API) fprintf(stderr, "glShadeModel %s\n", gl_lookup_enum_by_nr(mode)); - - switch (mode) { - case GL_FLAT: - case GL_SMOOTH: + if (mode == GL_FLAT || mode == GL_SMOOTH) { if (ctx->Light.ShadeModel!=mode) { - ctx->Light.ShadeModel = mode; - ctx->TriangleCaps ^= DD_FLATSHADE; - ctx->NewState |= NEW_RASTER_OPS; + ctx->Light.ShadeModel = mode; + ctx->TriangleCaps ^= DD_FLATSHADE; + ctx->NewState |= NEW_RASTER_OPS; + if (ctx->Driver.ShadeModel) + (*ctx->Driver.ShadeModel)( ctx, mode ); } - break; - default: + } + else { gl_error( ctx, GL_INVALID_ENUM, "glShadeModel" ); } - - if (ctx->Driver.ShadeModel) - (*ctx->Driver.ShadeModel)( ctx, mode ); } -void gl_Lightfv( GLcontext *ctx, - GLenum light, GLenum pname, const GLfloat *params, - GLint nparams ) +void +_mesa_Lightf( GLenum light, GLenum pname, GLfloat param ) { - GLint l; + _mesa_Lightfv( light, pname, ¶m ); +} - (void) nparams; + +void +_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); + GLint l; + GLint nParams; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLight"); l = (GLint) (light - GL_LIGHT0); - if (l<0 || l>=MAX_LIGHTS) { + if (l < 0 || l >= MAX_LIGHTS) { gl_error( ctx, GL_INVALID_ENUM, "glLight" ); return; } @@ -102,18 +95,22 @@ void gl_Lightfv( GLcontext *ctx, switch (pname) { case GL_AMBIENT: COPY_4V( ctx->Light.Light[l].Ambient, params ); + nParams = 4; break; case GL_DIFFUSE: COPY_4V( ctx->Light.Light[l].Diffuse, params ); + nParams = 4; break; case GL_SPECULAR: COPY_4V( ctx->Light.Light[l].Specular, params ); + nParams = 4; break; case GL_POSITION: /* transform position by ModelView matrix */ TRANSFORM_POINT( ctx->Light.Light[l].EyePosition, ctx->ModelView.m, params ); + nParams = 4; break; case GL_SPOT_DIRECTION: /* transform direction by inverse modelview */ @@ -123,6 +120,7 @@ void gl_Lightfv( GLcontext *ctx, TRANSFORM_NORMAL( ctx->Light.Light[l].EyeDirection, params, ctx->ModelView.inv ); + nParams = 3; break; case GL_SPOT_EXPONENT: if (params[0]<0.0 || params[0]>128.0) { @@ -133,6 +131,7 @@ void gl_Lightfv( GLcontext *ctx, ctx->Light.Light[l].SpotExponent = params[0]; gl_compute_spot_exp_table( &ctx->Light.Light[l] ); } + nParams = 1; break; case GL_SPOT_CUTOFF: if ((params[0]<0.0 || params[0]>90.0) && params[0]!=180.0) { @@ -143,6 +142,7 @@ void gl_Lightfv( GLcontext *ctx, ctx->Light.Light[l].CosCutoff = cos(params[0]*DEG2RAD); if (ctx->Light.Light[l].CosCutoff < 0) ctx->Light.Light[l].CosCutoff = 0; + nParams = 1; break; case GL_CONSTANT_ATTENUATION: if (params[0]<0.0) { @@ -150,6 +150,7 @@ void gl_Lightfv( GLcontext *ctx, return; } ctx->Light.Light[l].ConstantAttenuation = params[0]; + nParams = 1; break; case GL_LINEAR_ATTENUATION: if (params[0]<0.0) { @@ -157,6 +158,7 @@ void gl_Lightfv( GLcontext *ctx, return; } ctx->Light.Light[l].LinearAttenuation = params[0]; + nParams = 1; break; case GL_QUADRATIC_ATTENUATION: if (params[0]<0.0) { @@ -164,23 +166,73 @@ void gl_Lightfv( GLcontext *ctx, return; } ctx->Light.Light[l].QuadraticAttenuation = params[0]; + nParams = 1; break; default: gl_error( ctx, GL_INVALID_ENUM, "glLight" ); - break; + return; } if (ctx->Driver.Lightfv) - ctx->Driver.Lightfv( ctx, light, pname, params, nparams ); + ctx->Driver.Lightfv( ctx, light, pname, params, nParams ); ctx->NewState |= NEW_LIGHTING; } +void +_mesa_Lighti( GLenum light, GLenum pname, GLint param ) +{ + _mesa_Lightiv( light, pname, ¶m ); +} + -void gl_GetLightfv( GLcontext *ctx, - GLenum light, GLenum pname, GLfloat *params ) +void +_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params ) { + GLfloat fparam[4]; + + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_POSITION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + fparam[3] = (GLfloat) params[3]; + break; + case GL_SPOT_DIRECTION: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* error will be caught later in gl_Lightfv */ + ; + } + + _mesa_Lightfv( light, pname, fparam ); +} + + + +void +_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); GLint l = (GLint) (light - GL_LIGHT0); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetLight"); @@ -229,8 +281,10 @@ void gl_GetLightfv( GLcontext *ctx, -void gl_GetLightiv( GLcontext *ctx, GLenum light, GLenum pname, GLint *params ) +void +_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params ) { + GET_CURRENT_CONTEXT(ctx); GLint l = (GLint) (light - GL_LIGHT0); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetLight"); @@ -298,9 +352,11 @@ void gl_GetLightiv( GLcontext *ctx, GLenum light, GLenum pname, GLint *params ) /**********************************************************************/ -void gl_LightModelfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) +void +_mesa_LightModelfv( GLenum pname, const GLfloat *params ) { - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLightModel"); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLightModelfv"); switch (pname) { case GL_LIGHT_MODEL_AMBIENT: @@ -344,6 +400,46 @@ void gl_LightModelfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) } +void +_mesa_LightModeliv( GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLightModeliv"); + + switch (pname) { + case GL_LIGHT_MODEL_AMBIENT: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + case GL_LIGHT_MODEL_TWO_SIDE: + case GL_LIGHT_MODEL_COLOR_CONTROL: + fparam[0] = (GLfloat) params[0]; + break; + default: + /* Error will be caught later in gl_LightModelfv */ + ; + } + _mesa_LightModelfv( pname, fparam ); +} + + +void +_mesa_LightModeli( GLenum pname, GLint param ) +{ + _mesa_LightModeliv( pname, ¶m ); +} + + +void +_mesa_LightModelf( GLenum pname, GLfloat param ) +{ + _mesa_LightModelfv( pname, ¶m ); +} + /********** MATERIAL **********/ @@ -569,11 +665,11 @@ void gl_update_color_material( GLcontext *ctx, GLfloat tmp[4], color[4]; UBYTE_RGBA_TO_FLOAT_RGBA( color, rgba ); - + if (MESA_VERBOSE&VERBOSE_IMMEDIATE) fprintf(stderr, "gl_update_color_material, mask %x\n", bitmask); - + if (bitmask & FRONT_AMBIENT_BIT) { struct gl_material *mat = &ctx->Light.Material[0]; SUB_3V( tmp, color, mat->Ambient ); @@ -676,8 +772,10 @@ void gl_update_color_material( GLcontext *ctx, -void gl_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ) +void +_mesa_ColorMaterial( GLenum face, GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); GLuint bitmask; GLuint legal = (FRONT_EMISSION_BIT | BACK_EMISSION_BIT | FRONT_SPECULAR_BIT | BACK_SPECULAR_BIT | @@ -705,12 +803,21 @@ void gl_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ) + +void +_mesa_Materialf( GLenum face, GLenum pname, GLfloat param ) +{ + _mesa_Materialfv( face, pname, ¶m ); +} + + /* KW: This is now called directly (ie by name) from the glMaterial* * API functions. */ -void gl_Materialfv( GLcontext *ctx, - GLenum face, GLenum pname, const GLfloat *params ) +void +_mesa_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); struct immediate *IM; struct gl_material *mat; GLuint bitmask; @@ -736,6 +843,7 @@ void gl_Materialfv( GLcontext *ctx, IM->MaterialMask[count] = 0; } + IM->MaterialMask[count] |= bitmask; mat = IM->Material[count]; @@ -784,11 +892,48 @@ void gl_Materialfv( GLcontext *ctx, } +void +_mesa_Materiali(GLenum face, GLenum pname, GLint param ) +{ + _mesa_Materialiv(face, pname, ¶m); +} + + +void +_mesa_Materialiv(GLenum face, GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + switch (pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_EMISSION: + case GL_AMBIENT_AND_DIFFUSE: + fparam[0] = INT_TO_FLOAT( params[0] ); + fparam[1] = INT_TO_FLOAT( params[1] ); + fparam[2] = INT_TO_FLOAT( params[2] ); + fparam[3] = INT_TO_FLOAT( params[3] ); + break; + case GL_SHININESS: + fparam[0] = (GLfloat) params[0]; + break; + case GL_COLOR_INDEXES: + fparam[0] = (GLfloat) params[0]; + fparam[1] = (GLfloat) params[1]; + fparam[2] = (GLfloat) params[2]; + break; + default: + /* Error will be caught later in gl_Materialfv */ + ; + } + _mesa_Materialfv(face, pname, fparam); +} -void gl_GetMaterialfv( GLcontext *ctx, - GLenum face, GLenum pname, GLfloat *params ) +void +_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); GLuint f; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetMaterialfv"); @@ -831,9 +976,10 @@ void gl_GetMaterialfv( GLcontext *ctx, -void gl_GetMaterialiv( GLcontext *ctx, - GLenum face, GLenum pname, GLint *params ) +void +_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) { + GET_CURRENT_CONTEXT(ctx); GLuint f; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetMaterialiv"); diff --git a/src/mesa/main/light.h b/src/mesa/main/light.h index 18d25e9828f..fc1ed0be673 100644 --- a/src/mesa/main/light.h +++ b/src/mesa/main/light.h @@ -1,8 +1,8 @@ -/* $Id: light.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: light.h,v 1.2 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef LIGHT_H #define LIGHT_H @@ -42,44 +39,69 @@ struct gl_shine_tab { }; -extern void gl_ShadeModel( GLcontext *ctx, GLenum mode ); +extern void +_mesa_ShadeModel( GLenum mode ); -extern void gl_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ); +extern void +_mesa_ColorMaterial( GLenum face, GLenum mode ); -extern void gl_Lightfv( GLcontext *ctx, - GLenum light, GLenum pname, const GLfloat *params, - GLint nparams ); +extern void +_mesa_Lightf( GLenum light, GLenum pname, GLfloat param ); -extern void gl_LightModelfv( GLcontext *ctx, - GLenum pname, const GLfloat *params ); +extern void +_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ); +extern void +_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params ); -extern GLuint gl_material_bitmask( GLcontext *ctx, - GLenum face, GLenum pname, - GLuint legal, - const char * ); +extern void +_mesa_Lighti( GLenum light, GLenum pname, GLint param ); -extern void gl_set_material( GLcontext *ctx, GLuint bitmask, - const GLfloat *params); +extern void +_mesa_LightModelf( GLenum pname, GLfloat param ); + +extern void +_mesa_LightModelfv( GLenum pname, const GLfloat *params ); + +extern void +_mesa_LightModeli( GLenum pname, GLint param ); -extern void gl_Materialfv( GLcontext *ctx, - GLenum face, GLenum pname, const GLfloat *params ); +extern void +_mesa_LightModeliv( GLenum pname, const GLint *params ); +extern void +_mesa_Materialf( GLenum face, GLenum pname, GLfloat param ); +extern void +_mesa_Materialfv( GLenum face, GLenum pname, const GLfloat *params ); -extern void gl_GetLightfv( GLcontext *ctx, - GLenum light, GLenum pname, GLfloat *params ); +extern void +_mesa_Materiali( GLenum face, GLenum pname, GLint param ); -extern void gl_GetLightiv( GLcontext *ctx, - GLenum light, GLenum pname, GLint *params ); +extern void +_mesa_Materialiv( GLenum face, GLenum pname, const GLint *params ); +extern void +_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params ); -extern void gl_GetMaterialfv( GLcontext *ctx, - GLenum face, GLenum pname, GLfloat *params ); +extern void +_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params ); -extern void gl_GetMaterialiv( GLcontext *ctx, - GLenum face, GLenum pname, GLint *params ); +extern void +_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); +extern void +_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ); + + + +extern GLuint gl_material_bitmask( GLcontext *ctx, + GLenum face, GLenum pname, + GLuint legal, + const char * ); + +extern void gl_set_material( GLcontext *ctx, GLuint bitmask, + const GLfloat *params); extern void gl_compute_spot_exp_table( struct gl_light *l ); diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c index ee3ab24ca98..199686f60f3 100644 --- a/src/mesa/main/lines.c +++ b/src/mesa/main/lines.c @@ -1,8 +1,8 @@ -/* $Id: lines.c,v 1.5 1999/11/08 14:36:32 brianp Exp $ */ +/* $Id: lines.c,v 1.6 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,17 +25,10 @@ */ - - - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "depth.h" #include "feedback.h" @@ -50,8 +43,10 @@ -void gl_LineWidth( GLcontext *ctx, GLfloat width ) +void +_mesa_LineWidth( GLfloat width ) { + GET_CURRENT_CONTEXT(ctx); if (width<=0.0) { gl_error( ctx, GL_INVALID_VALUE, "glLineWidth" ); return; @@ -68,8 +63,10 @@ void gl_LineWidth( GLcontext *ctx, GLfloat width ) -void gl_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern ) +void +_mesa_LineStipple( GLint factor, GLushort pattern ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLineStipple"); ctx->Line.StippleFactor = CLAMP( factor, 1, 256 ); ctx->Line.StipplePattern = pattern; diff --git a/src/mesa/main/lines.h b/src/mesa/main/lines.h index f85a7a49103..36a6bed1f75 100644 --- a/src/mesa/main/lines.h +++ b/src/mesa/main/lines.h @@ -1,8 +1,8 @@ -/* $Id: lines.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: lines.h,v 1.2 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef LINES_H #define LINES_H @@ -35,11 +32,14 @@ #include "types.h" -extern void gl_LineWidth( GLcontext *ctx, GLfloat width ); +extern void +_mesa_LineWidth( GLfloat width ); -extern void gl_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern ); +extern void +_mesa_LineStipple( GLint factor, GLushort pattern ); -extern void gl_set_line_function( GLcontext *ctx ); +extern void +gl_set_line_function( GLcontext *ctx ); #endif diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index bba09837215..9e7b8194396 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -1,8 +1,8 @@ -/* $Id: macros.h,v 1.6 1999/11/08 15:29:43 brianp Exp $ */ +/* $Id: macros.h,v 1.7 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - /* * A collection of useful macros. */ @@ -36,13 +33,8 @@ #ifndef MACROS_H #define MACROS_H -#ifndef XFree86Server -#include <assert.h> -#include <math.h> -#include <string.h> -#else -#include <GL/glx_ansic.h> -#endif + +#include "glheader.h" #ifdef DEBUG @@ -165,26 +157,26 @@ do { \ #define ACC_4V( DST, SRC ) \ do { \ - (DST)[0] += (SRC)[0]; \ - (DST)[1] += (SRC)[1]; \ - (DST)[2] += (SRC)[2]; \ - (DST)[3] += (SRC)[3]; \ + (DST)[0] += (SRC)[0]; \ + (DST)[1] += (SRC)[1]; \ + (DST)[2] += (SRC)[2]; \ + (DST)[3] += (SRC)[3]; \ } while (0) #define ACC_SCALE_4V( DST, SRCA, SRCB ) \ do { \ - (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ - (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ - (DST)[2] += (SRCA)[2] * (SRCB)[2]; \ - (DST)[3] += (SRCA)[3] * (SRCB)[3]; \ + (DST)[0] += (SRCA)[0] * (SRCB)[0]; \ + (DST)[1] += (SRCA)[1] * (SRCB)[1]; \ + (DST)[2] += (SRCA)[2] * (SRCB)[2]; \ + (DST)[3] += (SRCA)[3] * (SRCB)[3]; \ } while (0) #define ACC_SCALE_SCALAR_4V( DST, S, SRCB ) \ do { \ - (DST)[0] += S * (SRCB)[0]; \ - (DST)[1] += S * (SRCB)[1]; \ - (DST)[2] += S * (SRCB)[2]; \ - (DST)[3] += S * (SRCB)[3]; \ + (DST)[0] += S * (SRCB)[0]; \ + (DST)[1] += S * (SRCB)[1]; \ + (DST)[2] += S * (SRCB)[2]; \ + (DST)[3] += S * (SRCB)[3]; \ } while (0) #define SCALE_SCALAR_4V( DST, S, SRCB ) \ @@ -480,69 +472,6 @@ do { \ -/* - * Memory allocation - * XXX these should probably go into a new glmemory.h file. - */ -#ifdef DEBUG -extern void *gl_malloc(size_t bytes); -extern void *gl_calloc(size_t bytes); -extern void gl_free(void *ptr); -#define MALLOC(BYTES) gl_malloc(BYTES) -#define CALLOC(BYTES) gl_calloc(BYTES) -#define MALLOC_STRUCT(T) (struct T *) gl_malloc(sizeof(struct T)) -#define CALLOC_STRUCT(T) (struct T *) gl_calloc(sizeof(struct T)) -#define FREE(PTR) gl_free(PTR) -#else -#define MALLOC(BYTES) (void *) malloc(BYTES) -#define CALLOC(BYTES) (void *) calloc(1, BYTES) -#define MALLOC_STRUCT(T) (struct T *) malloc(sizeof(struct T)) -#define CALLOC_STRUCT(T) (struct T *) calloc(1,sizeof(struct T)) -#define FREE(PTR) free(PTR) -#endif - - -/* Memory copy: */ -#ifdef SUNOS4 -#define MEMCPY( DST, SRC, BYTES) \ - memcpy( (char *) (DST), (char *) (SRC), (int) (BYTES) ) -#else -#define MEMCPY( DST, SRC, BYTES) \ - memcpy( (void *) (DST), (void *) (SRC), (size_t) (BYTES) ) -#endif - - -/* Memory set: */ -#ifdef SUNOS4 -#define MEMSET( DST, VAL, N ) \ - memset( (char *) (DST), (int) (VAL), (int) (N) ) -#else -#define MEMSET( DST, VAL, N ) \ - memset( (void *) (DST), (int) (VAL), (size_t) (N) ) -#endif - - -/* MACs and BeOS don't support static larger than 32kb, so... */ -#if defined(macintosh) && !defined(__MRC__) - extern char *AGLAlloc(int size); - extern void AGLFree(char* ptr); -# define DEFARRAY(TYPE,NAME,SIZE) TYPE *NAME = (TYPE*)AGLAlloc(sizeof(TYPE)*(SIZE)) -# define DEFMARRAY(TYPE,NAME,SIZE1,SIZE2) TYPE (*NAME)[SIZE2] = (TYPE(*)[SIZE2])AGLAlloc(sizeof(TYPE)*(SIZE1)*(SIZE2)) -# define CHECKARRAY(NAME,CMD) do {if (!(NAME)) {CMD;}} while (0) -# define UNDEFARRAY(NAME) do {if ((NAME)) {AGLFree((char*)NAME);} }while (0) -#elif defined(__BEOS__) -# define DEFARRAY(TYPE,NAME,SIZE) TYPE *NAME = (TYPE*)malloc(sizeof(TYPE)*(SIZE)) -# define DEFMARRAY(TYPE,NAME,SIZE1,SIZE2) TYPE (*NAME)[SIZE2] = (TYPE(*)[SIZE2])malloc(sizeof(TYPE)*(SIZE1)*(SIZE2)) -# define CHECKARRAY(NAME,CMD) do {if (!(NAME)) {CMD;}} while (0) -# define UNDEFARRAY(NAME) do {if ((NAME)) {free((char*)NAME);} }while (0) -#else -# define DEFARRAY(TYPE,NAME,SIZE) TYPE NAME[SIZE] -# define DEFMARRAY(TYPE,NAME,SIZE1,SIZE2) TYPE NAME[SIZE1][SIZE2] -# define CHECKARRAY(NAME,CMD) do {} while(0) -# define UNDEFARRAY(NAME) -#endif - - /* Some compilers don't like some of Mesa's const usage */ #ifdef NO_CONST # define CONST diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index fea77709a9f..16f30be1f04 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -1,8 +1,8 @@ -/* $Id: matrix.c,v 1.8 1999/11/08 07:36:44 brianp Exp $ */ +/* $Id: matrix.c,v 1.9 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - /* * Matrix operations * @@ -43,18 +40,11 @@ #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "enums.h" -#include "macros.h" #include "matrix.h" +#include "mem.h" #include "mmath.h" #include "types.h" #endif @@ -902,11 +892,12 @@ do { \ } while (0) -void gl_Frustum( GLcontext *ctx, - GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ) +void +_mesa_Frustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ) { + GET_CURRENT_CONTEXT(ctx); GLfloat x, y, a, b, c, d; GLfloat m[16]; GLmatrix *mat = 0; @@ -952,11 +943,12 @@ void gl_Frustum( GLcontext *ctx, } -void gl_Ortho( GLcontext *ctx, - GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ) +void +_mesa_Ortho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ) { + GET_CURRENT_CONTEXT(ctx); GLfloat x, y, z; GLfloat tx, ty, tz; GLfloat m[16]; @@ -991,8 +983,10 @@ void gl_Ortho( GLcontext *ctx, } -void gl_MatrixMode( GLcontext *ctx, GLenum mode ) +void +_mesa_MatrixMode( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMatrixMode"); switch (mode) { case GL_MODELVIEW: @@ -1007,8 +1001,10 @@ void gl_MatrixMode( GLcontext *ctx, GLenum mode ) -void gl_PushMatrix( GLcontext *ctx ) +void +_mesa_PushMatrix( void ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushMatrix"); if (MESA_VERBOSE&VERBOSE_API) @@ -1056,8 +1052,10 @@ void gl_PushMatrix( GLcontext *ctx ) -void gl_PopMatrix( GLcontext *ctx ) +void +_mesa_PopMatrix( void ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopMatrix"); if (MESA_VERBOSE&VERBOSE_API) @@ -1111,8 +1109,10 @@ void gl_PopMatrix( GLcontext *ctx ) -void gl_LoadIdentity( GLcontext *ctx ) +void +_mesa_LoadIdentity( void ) { + GET_CURRENT_CONTEXT(ctx); GLmatrix *mat = 0; GET_ACTIVE_MATRIX(ctx, mat, ctx->NewState, "glLoadIdentity"); @@ -1131,8 +1131,10 @@ void gl_LoadIdentity( GLcontext *ctx ) } -void gl_LoadMatrixf( GLcontext *ctx, const GLfloat *m ) +void +_mesa_LoadMatrixf( const GLfloat *m ) { + GET_CURRENT_CONTEXT(ctx); GLmatrix *mat = 0; GET_ACTIVE_MATRIX(ctx, mat, ctx->NewState, "glLoadMatrix"); @@ -1162,12 +1164,25 @@ void gl_LoadMatrixf( GLcontext *ctx, const GLfloat *m ) } +void +_mesa_LoadMatrixd( const GLdouble *m ) +{ + GLfloat f[16]; + GLint i; + for (i = 0; i < 16; i++) + f[i] = m[i]; + _mesa_LoadMatrixf(f); +} + + /* * Multiply the active matrix by an arbitary matrix. */ -void gl_MultMatrixf( GLcontext *ctx, const GLfloat *m ) +void +_mesa_MultMatrixf( const GLfloat *m ) { + GET_CURRENT_CONTEXT(ctx); GLmatrix *mat = 0; GET_ACTIVE_MATRIX( ctx, mat, ctx->NewState, "glMultMatrix" ); matmul4( mat->m, mat->m, m ); @@ -1178,8 +1193,10 @@ void gl_MultMatrixf( GLcontext *ctx, const GLfloat *m ) /* * Multiply the active matrix by an arbitary matrix. */ -void gl_MultMatrixd( GLcontext *ctx, const GLdouble *m ) +void +_mesa_MultMatrixd( const GLdouble *m ) { + GET_CURRENT_CONTEXT(ctx); GLmatrix *mat = 0; GET_ACTIVE_MATRIX( ctx, mat, ctx->NewState, "glMultMatrix" ); matmul4fd( mat->m, mat->m, m ); @@ -1227,9 +1244,10 @@ void gl_mat_mul_mat( GLmatrix *mat, const GLmatrix *m ) /* * Execute a glRotate call */ -void gl_Rotatef( GLcontext *ctx, - GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) +void +_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) { + GET_CURRENT_CONTEXT(ctx); GLfloat m[16]; if (angle != 0.0F) { GLmatrix *mat = 0; @@ -1240,11 +1258,20 @@ void gl_Rotatef( GLcontext *ctx, } } +void +_mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) +{ + _mesa_Rotatef(angle, x, y, z); +} + + /* * Execute a glScale call */ -void gl_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +void +_mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ) { + GET_CURRENT_CONTEXT(ctx); GLmatrix *mat = 0; GLfloat *m; GET_ACTIVE_MATRIX(ctx, mat, ctx->NewState, "glScale"); @@ -1265,11 +1292,21 @@ void gl_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) MAT_DIRTY_DEPENDENTS); } + +void +_mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ) +{ + _mesa_Scalef(x, y, z); +} + + /* * Execute a glTranslate call */ -void gl_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) +void +_mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ) { + GET_CURRENT_CONTEXT(ctx); GLmatrix *mat = 0; GLfloat *m; GET_ACTIVE_MATRIX(ctx, mat, ctx->NewState, "glTranslate"); @@ -1286,13 +1323,22 @@ void gl_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) } +void +_mesa_Translated( GLdouble x, GLdouble y, GLdouble z ) +{ + _mesa_Translatef(x, y, z); +} + + + /* * Define a new viewport and reallocate auxillary buffers if the size of * the window (color buffer) has changed. */ -void gl_Viewport( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height ) +void +_mesa_Viewport( GLint x, GLint y, GLsizei width, GLsizei height ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glViewport"); if (width<0 || height<0) { @@ -1330,7 +1376,7 @@ void gl_Viewport( GLcontext *ctx, /* Check if window/buffer has been resized and if so, reallocate the * ancillary buffers. */ - gl_ResizeBuffersMESA(ctx); + _mesa_ResizeBuffersMESA(); ctx->RasterMask &= ~WINCLIP_BIT; @@ -1350,7 +1396,8 @@ void gl_Viewport( GLcontext *ctx, -void gl_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval ) +void +_mesa_DepthRange( GLclampd nearval, GLclampd farval ) { /* * nearval - specifies mapping of the near clipping plane to window @@ -1364,7 +1411,7 @@ void gl_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval ) * this range to window z coords. */ GLfloat n, f; - + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDepthRange"); if (MESA_VERBOSE&VERBOSE_API) diff --git a/src/mesa/main/matrix.h b/src/mesa/main/matrix.h index fcc630f62a6..24796687990 100644 --- a/src/mesa/main/matrix.h +++ b/src/mesa/main/matrix.h @@ -1,8 +1,8 @@ -/* $Id: matrix.h,v 1.2 1999/10/08 09:27:11 keithw Exp $ */ +/* $Id: matrix.h,v 1.3 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,16 +25,14 @@ */ - - - #ifndef MATRIX_H #define MATRIX_H -#include "GL/gl.h" +#include "types.h" #include "config.h" + typedef struct { GLfloat m[16]; GLfloat *inv; /* optional */ @@ -42,6 +40,7 @@ typedef struct { GLuint type; } GLmatrix; + #ifdef VMS #define gl_calculate_model_project_matrix gl_calculate_model_project_matr #endif @@ -51,69 +50,90 @@ extern void gl_rotation_matrix( GLfloat angle, GLfloat x, GLfloat y, GLfloat z, GLfloat m[] ); +extern void gl_mat_mul_floats( GLmatrix *mat, const GLfloat *m, GLuint flags ); -extern void gl_Frustum( GLcontext *ctx, - GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ); +extern void gl_mat_mul_mat( GLmatrix *mat, const GLmatrix *mat2 ); -extern void gl_Ortho( GLcontext *ctx, - GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble nearval, GLdouble farval ); +extern void gl_calculate_model_project_matrix( GLcontext *ctx ); -extern void gl_PushMatrix( GLcontext *ctx ); +extern void gl_matrix_ctr( GLmatrix *m ); -extern void gl_PopMatrix( GLcontext *ctx ); +extern void gl_matrix_dtr( GLmatrix *m ); -extern void gl_LoadIdentity( GLcontext *ctx ); +extern void gl_matrix_alloc_inv( GLmatrix *m ); -extern void gl_LoadMatrixf( GLcontext *ctx, const GLfloat *m ); +extern void gl_matrix_copy( GLmatrix *to, const GLmatrix *from ); -extern void gl_MatrixMode( GLcontext *ctx, GLenum mode ); +extern void gl_matrix_mul( GLmatrix *dest, + const GLmatrix *a, + const GLmatrix *b ); -extern void gl_MultMatrixf( GLcontext *ctx, const GLfloat *m ); +extern void gl_matrix_analyze( GLmatrix *mat ); -extern void gl_mat_mul_floats( GLmatrix *mat, const GLfloat *m, GLuint flags ); -extern void gl_mat_mul_mat( GLmatrix *mat, const GLmatrix *mat2 ); +extern GLboolean gl_matrix_invert( GLmatrix *mat ); -extern void gl_Rotatef( GLcontext *ctx, - GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); +extern void gl_print_matrix( const GLmatrix *m ); -extern void gl_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ); -extern void gl_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ); -extern void gl_Viewport( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height ); +extern void +_mesa_Frustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ); -extern void gl_DepthRange( GLcontext* ctx, GLclampd nearval, GLclampd farval ); +extern void +_mesa_Ortho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble nearval, GLdouble farval ); +extern void +_mesa_PushMatrix( void ); +extern void +_mesa_PopMatrix( void ); +extern void +_mesa_LoadIdentity( void ); +extern void +_mesa_LoadMatrixf( const GLfloat *m ); -extern void gl_calculate_model_project_matrix( GLcontext *ctx ); +extern void +_mesa_LoadMatrixd( const GLdouble *m ); +extern void +_mesa_MatrixMode( GLenum mode ); -extern void gl_matrix_ctr( GLmatrix *m ); +extern void +_mesa_MultMatrixf( const GLfloat *m ); -extern void gl_matrix_dtr( GLmatrix *m ); +extern void +_mesa_MultMatrixd( const GLdouble *m ); -extern void gl_matrix_alloc_inv( GLmatrix *m ); +extern void +_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); -extern void gl_matrix_copy( GLmatrix *to, const GLmatrix *from ); +extern void +_mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ); -extern void gl_matrix_mul( GLmatrix *dest, - const GLmatrix *a, - const GLmatrix *b ); +extern void +_mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ); -extern void gl_matrix_analyze( GLmatrix *mat ); +extern void +_mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ); +extern void +_mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ); + +extern void +_mesa_Translated( GLdouble x, GLdouble y, GLdouble z ); + +extern void +_mesa_Viewport( GLint x, GLint y, GLsizei width, GLsizei height ); + +extern void +_mesa_DepthRange( GLclampd nearval, GLclampd farval ); -extern void gl_MultMatrixd( GLcontext *ctx, const GLdouble *m ); -extern GLboolean gl_matrix_invert( GLmatrix *mat ); -extern void gl_print_matrix( const GLmatrix *m ); #endif diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 2bc95208038..1651fe1190c 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -1,8 +1,8 @@ -/* $Id: pixel.c,v 1.4 1999/11/08 07:36:44 brianp Exp $ */ +/* $Id: pixel.c,v 1.5 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - /* * glPixelStore, glPixelTransfer, glPixelMap, glPixelZoom, etc. */ @@ -36,15 +33,10 @@ #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "macros.h" +#include "mem.h" #include "pixel.h" #include "types.h" #endif @@ -57,8 +49,10 @@ -void gl_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor ) +void +_mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPixelZoom"); ctx->Pixel.ZoomX = xfactor; @@ -72,13 +66,13 @@ void gl_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor ) /**********************************************************************/ -void gl_PixelStorei( GLcontext *ctx, GLenum pname, GLint param ) +void +_mesa_PixelStorei( GLenum pname, GLint param ) { /* NOTE: this call can't be compiled into the display list */ - + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPixelStore"); - switch (pname) { case GL_PACK_SWAP_BYTES: ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE; @@ -174,6 +168,11 @@ void gl_PixelStorei( GLcontext *ctx, GLenum pname, GLint param ) } +void +_mesa_PixelStoref( GLenum pname, GLfloat param ) +{ + _mesa_PixelStorei( pname, (GLint) param ); +} @@ -183,11 +182,11 @@ void gl_PixelStorei( GLcontext *ctx, GLenum pname, GLint param ) -void gl_PixelMapfv( GLcontext *ctx, - GLenum map, GLint mapsize, const GLfloat *values ) +void +_mesa_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values ) { GLint i; - + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPixelMapfv"); @@ -288,10 +287,50 @@ void gl_PixelMapfv( GLcontext *ctx, +void +_mesa_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values ) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLint i; + if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { + for (i=0;i<mapsize;i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + for (i=0;i<mapsize;i++) { + fvalues[i] = UINT_TO_FLOAT( values[i] ); + } + } + _mesa_PixelMapfv(map, mapsize, fvalues); +} + + + +void +_mesa_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values ) +{ + GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; + GLint i; + if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { + for (i=0;i<mapsize;i++) { + fvalues[i] = (GLfloat) values[i]; + } + } + else { + for (i=0;i<mapsize;i++) { + fvalues[i] = USHORT_TO_FLOAT( values[i] ); + } + } + _mesa_PixelMapfv(map, mapsize, fvalues); +} + -void gl_GetPixelMapfv( GLcontext *ctx, GLenum map, GLfloat *values ) +void +_mesa_GetPixelMapfv( GLenum map, GLfloat *values ) { + GET_CURRENT_CONTEXT(ctx); GLint i; ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetPixelMapfv"); @@ -337,8 +376,10 @@ void gl_GetPixelMapfv( GLcontext *ctx, GLenum map, GLfloat *values ) } -void gl_GetPixelMapuiv( GLcontext *ctx, GLenum map, GLuint *values ) +void +_mesa_GetPixelMapuiv( GLenum map, GLuint *values ) { + GET_CURRENT_CONTEXT(ctx); GLint i; ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetPixelMapfv"); @@ -396,8 +437,10 @@ void gl_GetPixelMapuiv( GLcontext *ctx, GLenum map, GLuint *values ) } -void gl_GetPixelMapusv( GLcontext *ctx, GLenum map, GLushort *values ) +void +_mesa_GetPixelMapusv( GLenum map, GLushort *values ) { + GET_CURRENT_CONTEXT(ctx); GLint i; ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetPixelMapfv"); @@ -469,8 +512,10 @@ void gl_GetPixelMapusv( GLcontext *ctx, GLenum map, GLushort *values ) * Implements glPixelTransfer[fi] whether called immediately or from a * display list. */ -void gl_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param ) +void +_mesa_PixelTransferf( GLenum pname, GLfloat param ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPixelTransfer"); @@ -534,6 +579,13 @@ void gl_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param ) } +void +_mesa_PixelTransferi( GLenum pname, GLint param ) +{ + _mesa_PixelTransferf( pname, (GLfloat) param ); +} + + /* diff --git a/src/mesa/main/pixel.h b/src/mesa/main/pixel.h index d14b011dc7e..841c98258f0 100644 --- a/src/mesa/main/pixel.h +++ b/src/mesa/main/pixel.h @@ -1,8 +1,8 @@ -/* $Id: pixel.h,v 1.2 1999/10/30 08:20:57 brianp Exp $ */ +/* $Id: pixel.h,v 1.3 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef PIXEL_H #define PIXEL_H @@ -40,21 +37,39 @@ */ -extern void gl_GetPixelMapfv( GLcontext *ctx, GLenum map, GLfloat *values ); +extern void +_mesa_GetPixelMapfv( GLenum map, GLfloat *values ); + +extern void +_mesa_GetPixelMapuiv( GLenum map, GLuint *values ); + +extern void +_mesa_GetPixelMapusv( GLenum map, GLushort *values ); + +extern void +_mesa_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values ); + +extern void +_mesa_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values ); -extern void gl_GetPixelMapuiv( GLcontext *ctx, GLenum map, GLuint *values ); +extern void +_mesa_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values ); -extern void gl_GetPixelMapusv( GLcontext *ctx, GLenum map, GLushort *values ); +extern void +_mesa_PixelStoref( GLenum pname, GLfloat param ); +extern void +_mesa_PixelStorei( GLenum pname, GLint param ); -extern void gl_PixelMapfv( GLcontext *ctx, - GLenum map, GLint mapsize, const GLfloat *values ); +extern void +_mesa_PixelTransferf( GLenum pname, GLfloat param ); -extern void gl_PixelStorei( GLcontext *ctx, GLenum pname, GLint param ); +extern void +_mesa_PixelTransferi( GLenum pname, GLint param ); -extern void gl_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param ); +extern void +_mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor ); -extern void gl_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor ); /* diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c index 3ecbd105065..a7b0eed4cca 100644 --- a/src/mesa/main/points.c +++ b/src/mesa/main/points.c @@ -1,8 +1,8 @@ -/* $Id: points.c,v 1.4 1999/10/21 12:45:53 brianp Exp $ */ +/* $Id: points.c,v 1.5 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -23,18 +23,12 @@ * 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. */ -/* $XFree86: xc/lib/GL/mesa/src/points.c,v 1.4 1999/04/04 00:20:29 dawes Exp $ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <math.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "feedback.h" #include "macros.h" @@ -45,18 +39,20 @@ #include "texstate.h" #include "types.h" #include "vb.h" -#include "mmath.h" #endif -void gl_PointSize( GLcontext *ctx, GLfloat size ) +void +_mesa_PointSize( GLfloat size ) { - if (size<=0.0) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointSize"); + + if (size <= 0.0) { gl_error( ctx, GL_INVALID_VALUE, "glPointSize" ); return; } - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointSize"); if (ctx->Point.Size != size) { ctx->Point.Size = size; @@ -68,11 +64,20 @@ void gl_PointSize( GLcontext *ctx, GLfloat size ) -void gl_PointParameterfvEXT( GLcontext *ctx, GLenum pname, - const GLfloat *params) +void +_mesa_PointParameterfEXT( GLenum pname, GLfloat param) { + _mesa_PointParameterfvEXT(pname, ¶m); +} + + +void +_mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointParameterfvEXT"); - if(pname==GL_DISTANCE_ATTENUATION_EXT) { + + if (pname == GL_DISTANCE_ATTENUATION_EXT) { GLboolean tmp = ctx->Point.Attenuated; COPY_3V(ctx->Point.Params,params); ctx->Point.Attenuated = (params[0] != 1.0 || @@ -84,25 +89,26 @@ void gl_PointParameterfvEXT( GLcontext *ctx, GLenum pname, ctx->TriangleCaps ^= DD_POINT_ATTEN; ctx->NewState |= NEW_RASTER_OPS; } - } else { - if (*params<0.0 ) { - gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" ); + } + else { + if (*params<0.0 ) { + gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" ); + return; + } + switch (pname) { + case GL_POINT_SIZE_MIN_EXT: + ctx->Point.MinSize=*params; + break; + case GL_POINT_SIZE_MAX_EXT: + ctx->Point.MaxSize=*params; + break; + case GL_POINT_FADE_THRESHOLD_SIZE_EXT: + ctx->Point.Threshold=*params; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glPointParameterfvEXT" ); return; - } - switch (pname) { - case GL_POINT_SIZE_MIN_EXT: - ctx->Point.MinSize=*params; - break; - case GL_POINT_SIZE_MAX_EXT: - ctx->Point.MaxSize=*params; - break; - case GL_POINT_FADE_THRESHOLD_SIZE_EXT: - ctx->Point.Threshold=*params; - break; - default: - gl_error( ctx, GL_INVALID_ENUM, "glPointParameterfvEXT" ); - return; - } + } } ctx->NewState |= NEW_RASTER_OPS; } diff --git a/src/mesa/main/points.h b/src/mesa/main/points.h index a53ce9b2d22..b024ffbdf85 100644 --- a/src/mesa/main/points.h +++ b/src/mesa/main/points.h @@ -1,8 +1,8 @@ -/* $Id: points.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: points.h,v 1.2 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -35,11 +35,19 @@ #include "types.h" -extern void gl_PointSize( GLcontext *ctx, GLfloat size ); +extern void +_mesa_PointSize( GLfloat size ); + + +extern void +_mesa_PointParameterfEXT( GLenum pname, GLfloat param); + + +extern void +_mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params ); + extern void gl_set_point_function( GLcontext *ctx ); -extern void gl_PointParameterfvEXT( GLcontext *ctx, GLenum pname, - const GLfloat *params ); #endif diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index eebbaa886fa..f93ab195665 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -1,8 +1,8 @@ -/* $Id: polygon.c,v 1.6 1999/11/08 15:28:08 brianp Exp $ */ +/* $Id: polygon.c,v 1.7 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,31 +25,25 @@ */ -/* $XFree86: xc/lib/GL/mesa/src/polygon.c,v 1.3 1999/04/04 00:20:29 dawes Exp $ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "image.h" #include "enums.h" #include "macros.h" +#include "mem.h" #include "polygon.h" #include "types.h" #endif -void gl_CullFace( GLcontext *ctx, GLenum mode ) +void +_mesa_CullFace( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCullFace"); if (MESA_VERBOSE&VERBOSE_API) @@ -69,8 +63,10 @@ void gl_CullFace( GLcontext *ctx, GLenum mode ) -void gl_FrontFace( GLcontext *ctx, GLenum mode ) +void +_mesa_FrontFace( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glFrontFace"); if (MESA_VERBOSE&VERBOSE_API) @@ -91,8 +87,10 @@ void gl_FrontFace( GLcontext *ctx, GLenum mode ) -void gl_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ) +void +_mesa_PolygonMode( GLenum face, GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonMode"); if (MESA_VERBOSE&VERBOSE_API) @@ -137,8 +135,11 @@ void gl_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ) /* * NOTE: stipple pattern has already been unpacked. */ -void gl_PolygonStipple( GLcontext *ctx, const GLuint pattern[32] ) +void +_mesa_PolygonStipple( const GLubyte *mask ) { + GET_CURRENT_CONTEXT(ctx); + GLuint *pattern = (GLuint *) mask; /* XXX verify */ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonStipple"); if (MESA_VERBOSE&VERBOSE_API) @@ -153,8 +154,10 @@ void gl_PolygonStipple( GLcontext *ctx, const GLuint pattern[32] ) -void gl_GetPolygonStipple( GLcontext *ctx, GLubyte *dest ) +void +_mesa_GetPolygonStipple( GLubyte *dest ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonOffset"); if (MESA_VERBOSE&VERBOSE_API) @@ -165,9 +168,10 @@ void gl_GetPolygonStipple( GLcontext *ctx, GLubyte *dest ) -void gl_PolygonOffset( GLcontext *ctx, - GLfloat factor, GLfloat units ) +void +_mesa_PolygonOffset( GLfloat factor, GLfloat units ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonOffset"); if (MESA_VERBOSE&VERBOSE_API) @@ -177,3 +181,10 @@ void gl_PolygonOffset( GLcontext *ctx, ctx->Polygon.OffsetUnits = units; } + +void +_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) +{ + _mesa_PolygonOffset(factor, bias * DEPTH_SCALE ); +} + diff --git a/src/mesa/main/polygon.h b/src/mesa/main/polygon.h index ac591bbda4b..71e17cf56a7 100644 --- a/src/mesa/main/polygon.h +++ b/src/mesa/main/polygon.h @@ -1,8 +1,8 @@ -/* $Id: polygon.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: polygon.h,v 1.2 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef POLYGON_H #define POLYGON_H @@ -35,18 +32,26 @@ #include "types.h" -extern void gl_CullFace( GLcontext *ctx, GLenum mode ); +extern void +_mesa_CullFace( GLenum mode ); + +extern void +_mesa_FrontFace( GLenum mode ); -extern void gl_FrontFace( GLcontext *ctx, GLenum mode ); +extern void +_mesa_PolygonMode( GLenum face, GLenum mode ); -extern void gl_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ); +extern void +_mesa_PolygonOffset( GLfloat factor, GLfloat units ); -extern void gl_PolygonOffset( GLcontext *ctx, - GLfloat factor, GLfloat units ); +extern void +_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias ); -extern void gl_PolygonStipple( GLcontext *ctx, const GLuint pattern[32] ); +extern void +_mesa_PolygonStipple( const GLubyte *mask ); -extern void gl_GetPolygonStipple( GLcontext *ctx, GLubyte *mask ); +extern void +_mesa_GetPolygonStipple( GLubyte *mask ); #endif diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c index eeca646f2f0..160c9e3ed13 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -1,8 +1,8 @@ -/* $Id: rastpos.c,v 1.3 1999/11/08 15:28:08 brianp Exp $ */ +/* $Id: rastpos.c,v 1.4 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,18 +25,10 @@ */ - - - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <math.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "clip.h" #include "context.h" #include "feedback.h" @@ -54,8 +46,8 @@ /* * Caller: context->API.RasterPos4f */ -void gl_RasterPos4f( GLcontext *ctx, - GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +static void raster_pos4f( GLcontext *ctx, + GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { GLfloat v[4], eye[4], clip[4], ndc[3], d; @@ -161,69 +153,147 @@ void gl_RasterPos4f( GLcontext *ctx, -/* - * This is a MESA extension function. Pretty much just like glRasterPos - * except we don't apply the modelview or projection matrices; specify a - * window coordinate directly. - * Caller: context->API.WindowPos4fMESA pointer. - */ -void gl_windowpos( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) +void +_mesa_RasterPos2d(GLdouble x, GLdouble y) { - /* KW: Assume that like rasterpos, this must be outside begin/end. - */ - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glWindowPosMESA" ); + _mesa_RasterPos4f(x, y, 0.0F, 1.0F); +} - /* set raster position */ - ctx->Current.RasterPos[0] = x; - ctx->Current.RasterPos[1] = y; - ctx->Current.RasterPos[2] = CLAMP( z, 0.0F, 1.0F ); - ctx->Current.RasterPos[3] = w; +void +_mesa_RasterPos2f(GLfloat x, GLfloat y) +{ + _mesa_RasterPos4f(x, y, 0.0F, 1.0F); +} - ctx->Current.RasterPosValid = GL_TRUE; +void +_mesa_RasterPos2i(GLint x, GLint y) +{ + _mesa_RasterPos4f(x, y, 0.0F, 1.0F); +} - /* raster color */ - if (0 && ctx->Light.Enabled) { - - /* KW: I don't see how this can work - would have to take the - * inverse of the projection matrix or the combined - * modelProjection matrix, transform point and normal, and - * do the lighting. Those inverses are not used for - * anything else. This is not an object-space lighting - * issue - what this is trying to do is something like - * clip-space or window-space lighting... - * - * Anyway, since the implementation was never correct, I'm - * not fixing it now - just use the unlit color. - */ - - /* KW: As a reprise, we now *do* keep the inverse of the projection - * matrix, so it is not infeasible to try to swim up stream - * in this manner. I still don't want to implement it, - * however. - */ - } - else { - /* use current color or index */ - if (ctx->Visual->RGBAflag) { - UBYTE_RGBA_TO_FLOAT_RGBA(ctx->Current.RasterColor, - ctx->Current.ByteColor); - } - else { - ctx->Current.RasterIndex = ctx->Current.Index; - } - } +void +_mesa_RasterPos2s(GLshort x, GLshort y) +{ + _mesa_RasterPos4f(x, y, 0.0F, 1.0F); +} - ctx->Current.RasterDistance = 0.0; +void +_mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z) +{ + _mesa_RasterPos4f(x, y, z, 1.0F); +} - { - GLuint texSet; - for (texSet=0; texSet<MAX_TEXTURE_UNITS; texSet++) { - COPY_4FV( ctx->Current.RasterMultiTexCoord[texSet], - ctx->Current.Texcoord[texSet] ); - } - } +void +_mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z) +{ + _mesa_RasterPos4f(x, y, z, 1.0F); +} - if (ctx->RenderMode==GL_SELECT) { - gl_update_hitflag( ctx, ctx->Current.RasterPos[2] ); - } +void +_mesa_RasterPos3i(GLint x, GLint y, GLint z) +{ + _mesa_RasterPos4f(x, y, z, 1.0F); +} + +void +_mesa_RasterPos3s(GLshort x, GLshort y, GLshort z) +{ + _mesa_RasterPos4f(x, y, z, 1.0F); +} + +void +_mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + _mesa_RasterPos4f(x, y, z, w); +} + +void +_mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + raster_pos4f(ctx, x, y, z, w); +} + +void +_mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w) +{ + _mesa_RasterPos4f(x, y, z, w); +} + +void +_mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + _mesa_RasterPos4f(x, y, z, w); +} + +void +_mesa_RasterPos2dv(const GLdouble *v) +{ + _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +void +_mesa_RasterPos2fv(const GLfloat *v) +{ + _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +void +_mesa_RasterPos2iv(const GLint *v) +{ + _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +void +_mesa_RasterPos2sv(const GLshort *v) +{ + _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F); +} + +void +_mesa_RasterPos3dv(const GLdouble *v) +{ + _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +void +_mesa_RasterPos3fv(const GLfloat *v) +{ + _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +void +_mesa_RasterPos3iv(const GLint *v) +{ + _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +void +_mesa_RasterPos3sv(const GLshort *v) +{ + _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F); +} + +void +_mesa_RasterPos4dv(const GLdouble *v) +{ + _mesa_RasterPos4f(v[0], v[1], v[2], v[3]); +} + +void +_mesa_RasterPos4fv(const GLfloat *v) +{ + _mesa_RasterPos4f(v[0], v[1], v[2], v[3]); +} + +void +_mesa_RasterPos4iv(const GLint *v) +{ + _mesa_RasterPos4f(v[0], v[1], v[2], v[3]); +} + +void +_mesa_RasterPos4sv(const GLshort *v) +{ + _mesa_RasterPos4f(v[0], v[1], v[2], v[3]); } diff --git a/src/mesa/main/rastpos.h b/src/mesa/main/rastpos.h index 44dfbab0d62..49223ce236c 100644 --- a/src/mesa/main/rastpos.h +++ b/src/mesa/main/rastpos.h @@ -1,8 +1,8 @@ -/* $Id: rastpos.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: rastpos.h,v 1.2 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,23 +25,84 @@ */ +#ifndef RASTPOS_H +#define RASTPOS_H +#include "glheader.h" -#ifndef RASTPOS_H -#define RASTPOS_H +extern void +_mesa_RasterPos2d(GLdouble x, GLdouble y); + +extern void +_mesa_RasterPos2f(GLfloat x, GLfloat y); + +extern void +_mesa_RasterPos2i(GLint x, GLint y); + +extern void +_mesa_RasterPos2s(GLshort x, GLshort y); + +extern void +_mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z); + +extern void +_mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z); + +extern void +_mesa_RasterPos3i(GLint x, GLint y, GLint z); + +extern void +_mesa_RasterPos3s(GLshort x, GLshort y, GLshort z); + +extern void +_mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w); + +extern void +_mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w); + +extern void +_mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w); + +extern void +_mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w); + +extern void +_mesa_RasterPos2dv(const GLdouble *v); + +extern void +_mesa_RasterPos2fv(const GLfloat *v); + +extern void +_mesa_RasterPos2iv(const GLint *v); + +extern void +_mesa_RasterPos2sv(const GLshort *v); + +extern void +_mesa_RasterPos3dv(const GLdouble *v); + +extern void +_mesa_RasterPos3fv(const GLfloat *v); -#include "types.h" +extern void +_mesa_RasterPos3iv(const GLint *v); +extern void +_mesa_RasterPos3sv(const GLshort *v); -extern void gl_RasterPos4f( GLcontext *ctx, - GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +extern void +_mesa_RasterPos4dv(const GLdouble *v); +extern void +_mesa_RasterPos4fv(const GLfloat *v); -extern void gl_windowpos( GLcontext *ctx, - GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +extern void +_mesa_RasterPos4iv(const GLint *v); +extern void +_mesa_RasterPos4sv(const GLshort *v); #endif diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c index 4510d7f4fcf..0530700d827 100644 --- a/src/mesa/main/stencil.c +++ b/src/mesa/main/stencil.c @@ -1,8 +1,8 @@ -/* $Id: stencil.c,v 1.8 1999/11/08 15:28:08 brianp Exp $ */ +/* $Id: stencil.c,v 1.9 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,19 +25,12 @@ */ -/* $XFree86: xc/lib/GL/mesa/src/stencil.c,v 1.3 1999/04/04 00:20:32 dawes Exp $ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <stdlib.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" -#include "macros.h" +#include "mem.h" #include "pb.h" #include "stencil.h" #include "types.h" @@ -61,8 +54,10 @@ #define STENCIL_ADDRESS(X,Y) (ctx->Buffer->Stencil + ctx->Buffer->Width * (Y) + (X)) -void gl_ClearStencil( GLcontext *ctx, GLint s ) +void +_mesa_ClearStencil( GLint s ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glClearStencil"); ctx->Stencil.Clear = (GLstencil) s; @@ -73,8 +68,10 @@ void gl_ClearStencil( GLcontext *ctx, GLint s ) -void gl_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask ) +void +_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ) { + GET_CURRENT_CONTEXT(ctx); GLint maxref; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glStencilFunc"); @@ -106,8 +103,10 @@ void gl_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask ) -void gl_StencilMask( GLcontext *ctx, GLuint mask ) +void +_mesa_StencilMask( GLuint mask ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glStencilMask"); ctx->Stencil.WriteMask = (GLstencil) mask; @@ -118,8 +117,10 @@ void gl_StencilMask( GLcontext *ctx, GLuint mask ) -void gl_StencilOp( GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass ) +void +_mesa_StencilOp( GLenum fail, GLenum zfail, GLenum zpass ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glStencilOp"); switch (fail) { case GL_KEEP: @@ -1061,7 +1062,7 @@ void gl_alloc_stencil_buffer( GLcontext *ctx ) ctx->Buffer->Stencil = (GLstencil *) MALLOC(buffersize * sizeof(GLstencil)); if (!ctx->Buffer->Stencil) { /* out of memory */ - gl_set_enable( ctx, GL_STENCIL_TEST, GL_FALSE ); + _mesa_set_enable( ctx, GL_STENCIL_TEST, GL_FALSE ); gl_error( ctx, GL_OUT_OF_MEMORY, "gl_alloc_stencil_buffer" ); } } diff --git a/src/mesa/main/stencil.h b/src/mesa/main/stencil.h index 989cd988fe8..8d8cbda4bc2 100644 --- a/src/mesa/main/stencil.h +++ b/src/mesa/main/stencil.h @@ -1,8 +1,8 @@ -/* $Id: stencil.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: stencil.h,v 1.2 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef STENCIL_H #define STENCIL_H @@ -35,18 +32,20 @@ #include "types.h" -extern void gl_ClearStencil( GLcontext *ctx, GLint s ); +extern void +_mesa_ClearStencil( GLint s ); -extern void gl_StencilFunc( GLcontext *ctx, GLenum func, - GLint ref, GLuint mask ); +extern void +_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask ); -extern void gl_StencilMask( GLcontext *ctx, GLuint mask ); +extern void +_mesa_StencilMask( GLuint mask ); -extern void gl_StencilOp( GLcontext *ctx, GLenum fail, - GLenum zfail, GLenum zpass ); +extern void +_mesa_StencilOp( GLenum fail, GLenum zfail, GLenum zpass ); diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index e2644b733a1..42d1c90efbf 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1,8 +1,8 @@ -/* $Id: teximage.c,v 1.11 1999/11/08 07:36:44 brianp Exp $ */ +/* $Id: teximage.c,v 1.12 1999/11/11 01:22:27 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -28,17 +28,10 @@ #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "image.h" -#include "macros.h" +#include "mem.h" #include "mmath.h" #include "span.h" #include "teximage.h" @@ -58,25 +51,13 @@ -static struct gl_pixelstore_attrib defaultPacking = { - 1, /* Alignment */ - 0, /* RowLength */ - 0, /* SkipPixels */ - 0, /* SkipRows */ - 0, /* ImageHeight */ - 0, /* SkipImages */ - GL_FALSE, /* SwapBytes */ - GL_FALSE /* LsbFirst */ -}; - - - /* * Compute log base 2 of n. * If n isn't an exact power of two return -1. * If n<0 return -1. */ -static int logbase2( int n ) +static int +logbase2( int n ) { GLint i = 1; GLint log2 = 0; @@ -105,7 +86,8 @@ static int logbase2( int n ) * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA. * Return -1 if invalid enum. */ -static GLint decode_internal_format( GLint format ) +static GLint +decode_internal_format( GLint format ) { switch (format) { case GL_ALPHA: @@ -177,7 +159,8 @@ static GLint decode_internal_format( GLint format ) * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA. Return the * number of components for the format. Return -1 if invalid enum. */ -static GLint components_in_intformat( GLint format ) +static GLint +components_in_intformat( GLint format ) { switch (format) { case GL_ALPHA: @@ -243,14 +226,16 @@ static GLint components_in_intformat( GLint format ) -struct gl_texture_image *gl_alloc_texture_image( void ) +struct gl_texture_image * +gl_alloc_texture_image( void ) { return CALLOC_STRUCT(gl_texture_image); } -void gl_free_texture_image( struct gl_texture_image *teximage ) +void +gl_free_texture_image( struct gl_texture_image *teximage ) { if (teximage->Data) { FREE( teximage->Data ); @@ -267,7 +252,8 @@ void gl_free_texture_image( struct gl_texture_image *teximage ) * These fields are set only here by core Mesa but device drivers may * overwritting these fields to indicate true texel resolution. */ -static void set_teximage_component_sizes( struct gl_texture_image *texImage ) +static void +set_teximage_component_sizes( struct gl_texture_image *texImage ) { switch (texImage->Format) { case GL_ALPHA: @@ -762,7 +748,7 @@ texture_error_check( GLcontext *ctx, GLenum target, * Return: GL_TRUE = an error was detected, GL_FALSE = no errors */ static GLboolean -subtexture_error_check( GLcontext *ctx, GLint dimensions, +subtexture_error_check( GLcontext *ctx, GLuint dimensions, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint width, GLint height, GLint depth, @@ -870,7 +856,7 @@ subtexture_error_check( GLcontext *ctx, GLint dimensions, * Return: GL_TRUE = an error was detected, GL_FALSE = no errors */ static GLboolean -copytexture_error_check( GLcontext *ctx, GLint dimensions, +copytexture_error_check( GLcontext *ctx, GLuint dimensions, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border ) { @@ -940,7 +926,7 @@ copytexture_error_check( GLcontext *ctx, GLint dimensions, static GLboolean -copytexsubimage_error_check( GLcontext *ctx, GLint dimensions, +copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height ) @@ -981,7 +967,7 @@ copytexsubimage_error_check( GLcontext *ctx, GLint dimensions, return GL_TRUE; } - teximage = texUnit->CurrentD[dimensions]->Image[level]; + teximage = texUnit->CurrentD[3]->Image[level]; if (!teximage) { char message[100]; sprintf(message, "glCopyTexSubImage%dD(undefined texture)", dimensions); @@ -1042,11 +1028,12 @@ copytexsubimage_error_check( GLcontext *ctx, GLint dimensions, /* * Called from the API. Note that width includes the border. */ -void gl_TexImage1D( GLcontext *ctx, GLenum target, GLint level, - GLint internalformat, - GLsizei width, GLint border, GLenum format, - GLenum type, const GLvoid *pixels ) +void +_mesa_TexImage1D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint border, GLenum format, + GLenum type, const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage1D"); @@ -1111,12 +1098,13 @@ void gl_TexImage1D( GLcontext *ctx, GLenum target, GLint level, } -void gl_TexImage2D( GLcontext *ctx, GLenum target, GLint level, - GLint internalformat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels ) +void +_mesa_TexImage2D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage2D"); @@ -1186,16 +1174,17 @@ void gl_TexImage2D( GLcontext *ctx, GLenum target, GLint level, * Called by the API or display list executor. * Note that width and height include the border. */ -void gl_TexImage3D( GLcontext *ctx, GLenum target, GLint level, - GLint internalformat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum format, GLenum type, - const GLvoid *pixels ) +void +_mesa_TexImage3D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage3D"); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage3DEXT"); - if (target==GL_TEXTURE_3D) { + if (target==GL_TEXTURE_3D_EXT) { struct gl_texture_image *teximage; if (texture_error_check( ctx, target, level, internalformat, format, type, 3, width, height, depth, @@ -1259,9 +1248,11 @@ void gl_TexImage3D( GLcontext *ctx, GLenum target, GLint level, -void gl_GetTexImage( GLcontext *ctx, GLenum target, GLint level, GLenum format, - GLenum type, GLvoid *pixels ) +void +_mesa_GetTexImage( GLenum target, GLint level, GLenum format, + GLenum type, GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); const struct gl_texture_object *texObj; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexImage"); @@ -1387,11 +1378,13 @@ void gl_GetTexImage( GLcontext *ctx, GLenum target, GLint level, GLenum format, -void gl_TexSubImage1D( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels ) +void +_mesa_TexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_image *destTex; @@ -1454,12 +1447,14 @@ void gl_TexSubImage1D( GLcontext *ctx, GLenum target, GLint level, } -void gl_TexSubImage2D( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels ) +void +_mesa_TexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_image *destTex; @@ -1535,12 +1530,14 @@ void gl_TexSubImage2D( GLcontext *ctx, GLenum target, GLint level, -void gl_TexSubImage3D( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, - const GLvoid *pixels ) +void +_mesa_TexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + const GLvoid *pixels ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_image *destTex; @@ -1647,11 +1644,13 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, -void gl_CopyTexImage1D( GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, - GLsizei width, GLint border ) +void +_mesa_CopyTexImage1D( GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, + GLsizei width, GLint border ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexImage1D"); if (!copytexture_error_check(ctx, 1, target, level, internalFormat, @@ -1661,19 +1660,20 @@ void gl_CopyTexImage1D( GLcontext *ctx, GLenum target, GLint level, gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D" ); return; } - (*ctx->Exec.TexImage1D)( ctx, target, level, internalFormat, width, - border, GL_RGBA, GL_UNSIGNED_BYTE, image ); + (*ctx->Exec.TexImage1D)( target, level, internalFormat, width, + border, GL_RGBA, GL_UNSIGNED_BYTE, image ); FREE(image); } } -void gl_CopyTexImage2D( GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border ) +void +_mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexImage2D"); if (!copytexture_error_check(ctx, 2, target, level, internalFormat, @@ -1683,13 +1683,8 @@ void gl_CopyTexImage2D( GLcontext *ctx, GLenum target, GLint level, gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D" ); return; } - { - struct gl_pixelstore_attrib save = ctx->Unpack; - ctx->Unpack = defaultPacking; - (ctx->Exec.TexImage2D)( ctx, target, level, internalFormat, width, + (ctx->Exec.TexImage2D)( target, level, internalFormat, width, height, border, GL_RGBA, GL_UNSIGNED_BYTE, image ); - ctx->Unpack = save; /* restore */ - } FREE(image); } } @@ -1751,9 +1746,11 @@ copy_tex_sub_image( GLcontext *ctx, struct gl_texture_image *dest, -void gl_CopyTexSubImage1D( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, GLsizei width ) +void +_mesa_CopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, GLsizei width ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexSubImage1D"); if (!copytexsubimage_error_check(ctx, 1, target, level, @@ -1777,10 +1774,12 @@ void gl_CopyTexSubImage1D( GLcontext *ctx, GLenum target, GLint level, -void gl_CopyTexSubImage2D( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height ) +void +_mesa_CopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexSubImage2D"); if (!copytexsubimage_error_check(ctx, 2, target, level, @@ -1805,10 +1804,12 @@ void gl_CopyTexSubImage2D( GLcontext *ctx, GLenum target, GLint level, -void gl_CopyTexSubImage3D( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLsizei height ) +void +_mesa_CopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexSubImage3D"); if (!copytexsubimage_error_check(ctx, 3, target, level, diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index 032f44ce7fd..98ab512262a 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -1,8 +1,8 @@ -/* $Id: teximage.h,v 1.2 1999/11/03 17:27:05 brianp Exp $ */ +/* $Id: teximage.h,v 1.3 1999/11/11 01:22:28 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -35,97 +35,90 @@ /*** Internal functions ***/ -extern struct gl_texture_image *gl_alloc_texture_image( void ); +extern struct gl_texture_image * +gl_alloc_texture_image( void ); -extern void gl_free_texture_image( struct gl_texture_image *teximage ); +extern void +gl_free_texture_image( struct gl_texture_image *teximage ); +/*** API entry point functions ***/ -/*** API entry points ***/ +extern void +_mesa_TexImage1D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLint border, + GLenum format, GLenum type, const GLvoid *pixels ); -extern void gl_TexImage1D( GLcontext *ctx, - GLenum target, GLint level, GLint internalformat, - GLsizei width, GLint border, GLenum format, - GLenum type, const GLvoid *pixels ); +extern void +_mesa_TexImage2D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels ); -extern void gl_TexImage2D( GLcontext *ctx, - GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels ); +extern void +_mesa_TexImage3D( GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels ); -extern void gl_TexImage3D( GLcontext *ctx, - GLenum target, GLint level, GLint internalformat, - GLsizei width, GLsizei height, GLsizei depth, - GLint border, GLenum format, GLenum type, - const GLvoid *pixels ); +extern void +_mesa_GetTexImage( GLenum target, GLint level, + GLenum format, GLenum type, GLvoid *pixels ); -extern void gl_GetTexImage( GLcontext *ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid *pixels ); +extern void +_mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset, + GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels ); -extern void gl_TexSubImage1D( GLcontext *ctx, - GLenum target, GLint level, GLint xoffset, - GLsizei width, GLenum format, GLenum type, - const GLvoid *pixels ); +extern void +_mesa_TexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); -extern void gl_TexSubImage2D( GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels ); +extern void +_mesa_TexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, + const GLvoid *pixels ); -extern void gl_TexSubImage3D( GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLenum type, - const GLvoid *pixels ); +extern void +_mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLint border ); -extern void gl_CopyTexImage1D( GLcontext *ctx, - GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, - GLsizei width, GLint border ); +extern void +_mesa_CopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border ); -extern void gl_CopyTexImage2D( GLcontext *ctx, - GLenum target, GLint level, - GLenum internalformat, GLint x, GLint y, - GLsizei width, GLsizei height, - GLint border ); +extern void +_mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, + GLint x, GLint y, GLsizei width ); -extern void gl_CopyTexSubImage1D( GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, - GLsizei width ); +extern void +_mesa_CopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height ); -extern void gl_CopyTexSubImage2D( GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLsizei height ); - - -extern void gl_CopyTexSubImage3D( GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint zoffset, - GLint x, GLint y, - GLsizei width, GLsizei height ); +extern void +_mesa_CopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height ); #endif diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 2d7db2d5193..fae67d4fc7c 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1,8 +1,8 @@ -/* $Id: texobj.c,v 1.7 1999/11/05 06:43:11 brianp Exp $ */ +/* $Id: texobj.c,v 1.8 1999/11/11 01:22:28 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -23,25 +23,16 @@ * 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. */ -/* $XFree86: xc/lib/GL/mesa/src/texobj.c,v 1.3 1999/04/04 00:20:32 dawes Exp $ */ - - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "enums.h" #include "hash.h" -#include "macros.h" +#include "mem.h" #include "teximage.h" #include "texstate.h" #include "texobj.h" @@ -83,13 +74,13 @@ gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name, obj->BaseLevel = 0; obj->MaxLevel = 1000; obj->MinMagThresh = 0.0F; - obj->Palette[0] = 255; - obj->Palette[1] = 255; - obj->Palette[2] = 255; - obj->Palette[3] = 255; - obj->PaletteSize = 1; - obj->PaletteIntFormat = GL_RGBA; - obj->PaletteFormat = GL_RGBA; + obj->Palette.Table[0] = 255; + obj->Palette.Table[1] = 255; + obj->Palette.Table[2] = 255; + obj->Palette.Table[3] = 255; + obj->Palette.Size = 1; + obj->Palette.IntFormat = GL_RGBA; + obj->Palette.Format = GL_RGBA; /* insert into linked list */ if (shared) { @@ -334,8 +325,10 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur /* * Execute glGenTextures */ -void gl_GenTextures( GLcontext *ctx, GLsizei n, GLuint *texName ) +void +_mesa_GenTextures( GLsizei n, GLuint *texName ) { + GET_CURRENT_CONTEXT(ctx); GLuint first; GLint i; @@ -365,8 +358,10 @@ void gl_GenTextures( GLcontext *ctx, GLsizei n, GLuint *texName ) /* * Execute glDeleteTextures */ -void gl_DeleteTextures( GLcontext *ctx, GLsizei n, const GLuint *texName) +void +_mesa_DeleteTextures( GLsizei n, const GLuint *texName) { + GET_CURRENT_CONTEXT(ctx); GLint i; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteTextures"); @@ -409,8 +404,10 @@ void gl_DeleteTextures( GLcontext *ctx, GLsizei n, const GLuint *texName) /* * Execute glBindTexture */ -void gl_BindTexture( GLcontext *ctx, GLenum target, GLuint texName ) +void +_mesa_BindTexture( GLenum target, GLuint texName ) { + GET_CURRENT_CONTEXT(ctx); GLuint unit = ctx->Texture.CurrentUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; struct gl_texture_object *oldTexObj; @@ -501,10 +498,11 @@ void gl_BindTexture( GLcontext *ctx, GLenum target, GLuint texName ) /* * Execute glPrioritizeTextures */ -void gl_PrioritizeTextures( GLcontext *ctx, - GLsizei n, const GLuint *texName, - const GLclampf *priorities ) +void +_mesa_PrioritizeTextures( GLsizei n, const GLuint *texName, + const GLclampf *priorities ) { + GET_CURRENT_CONTEXT(ctx); GLint i; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPrioritizeTextures"); @@ -533,10 +531,11 @@ void gl_PrioritizeTextures( GLcontext *ctx, /* * Execute glAreTexturesResident */ -GLboolean gl_AreTexturesResident( GLcontext *ctx, GLsizei n, - const GLuint *texName, - GLboolean *residences ) +GLboolean +_mesa_AreTexturesResident( GLsizei n, const GLuint *texName, + GLboolean *residences ) { + GET_CURRENT_CONTEXT(ctx); GLboolean resident = GL_TRUE; GLint i; @@ -575,8 +574,10 @@ GLboolean gl_AreTexturesResident( GLcontext *ctx, GLsizei n, /* * Execute glIsTexture */ -GLboolean gl_IsTexture( GLcontext *ctx, GLuint texture ) +GLboolean +_mesa_IsTexture( GLuint texture ) { + GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glIsTextures", GL_FALSE); if (texture>0 && HashLookup(ctx->Shared->TexObjects, texture)) { diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h index 655c823753c..a4bf3961518 100644 --- a/src/mesa/main/texobj.h +++ b/src/mesa/main/texobj.h @@ -1,8 +1,8 @@ -/* $Id: texobj.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: texobj.h,v 1.2 1999/11/11 01:22:28 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,9 +25,6 @@ */ - - - #ifndef TEXTOBJ_H #define TEXTOBJ_H @@ -59,27 +56,30 @@ extern void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl * API functions */ -extern void gl_GenTextures( GLcontext *ctx, GLsizei n, GLuint *textures ); +extern void +_mesa_GenTextures( GLsizei n, GLuint *textures ); -extern void gl_DeleteTextures( GLcontext *ctx, - GLsizei n, const GLuint *textures); +extern void +_mesa_DeleteTextures( GLsizei n, const GLuint *textures ); -extern void gl_BindTexture( GLcontext *ctx, GLenum target, GLuint texture ); +extern void +_mesa_BindTexture( GLenum target, GLuint texture ); -extern void gl_PrioritizeTextures( GLcontext *ctx, - GLsizei n, const GLuint *textures, - const GLclampf *priorities ); +extern void +_mesa_PrioritizeTextures( GLsizei n, const GLuint *textures, + const GLclampf *priorities ); -extern GLboolean gl_AreTexturesResident( GLcontext *ctx, GLsizei n, - const GLuint *textures, - GLboolean *residences ); +extern GLboolean +_mesa_AreTexturesResident( GLsizei n, const GLuint *textures, + GLboolean *residences ); -extern GLboolean gl_IsTexture( GLcontext *ctx, GLuint texture ); +extern GLboolean +_mesa_IsTexture( GLuint texture ); #endif diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 5a3664e79aa..7e5ce3085a0 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -1,8 +1,8 @@ -/* $Id: texstate.c,v 1.4 1999/11/05 06:43:11 brianp Exp $ */ +/* $Id: texstate.c,v 1.5 1999/11/11 01:22:28 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * @@ -25,16 +25,10 @@ */ - #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <assert.h> -#include <stdio.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" #include "enums.h" #include "macros.h" @@ -66,9 +60,10 @@ /**********************************************************************/ -void gl_TexEnvfv( GLcontext *ctx, - GLenum target, GLenum pname, const GLfloat *param ) +void +_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexEnv"); @@ -128,12 +123,40 @@ void gl_TexEnvfv( GLcontext *ctx, } +void +_mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ) +{ + _mesa_TexEnvfv( target, pname, ¶m ); +} + + + +void +_mesa_TexEnvi( GLenum target, GLenum pname, GLint param ) +{ + GLfloat p[4]; + p[0] = (GLfloat) param; + p[1] = p[2] = p[3] = 0.0; + _mesa_TexEnvfv( target, pname, p ); +} + +void +_mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ) +{ + GLfloat p[4]; + p[0] = INT_TO_FLOAT( param[0] ); + p[1] = INT_TO_FLOAT( param[1] ); + p[2] = INT_TO_FLOAT( param[2] ); + p[3] = INT_TO_FLOAT( param[3] ); + _mesa_TexEnvfv( target, pname, p ); +} -void gl_GetTexEnvfv( GLcontext *ctx, - GLenum target, GLenum pname, GLfloat *params ) +void +_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; if (target!=GL_TEXTURE_ENV) { gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" ); @@ -152,9 +175,10 @@ void gl_GetTexEnvfv( GLcontext *ctx, } -void gl_GetTexEnviv( GLcontext *ctx, - GLenum target, GLenum pname, GLint *params ) +void +_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; if (target!=GL_TEXTURE_ENV) { gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" ); @@ -183,9 +207,17 @@ void gl_GetTexEnviv( GLcontext *ctx, /**********************************************************************/ -void gl_TexParameterfv( GLcontext *ctx, - GLenum target, GLenum pname, const GLfloat *params ) +void +_mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param ) +{ + _mesa_TexParameterfv(target, pname, ¶m); +} + + +void +_mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; GLenum eparam = (GLenum) (GLint) params[0]; struct gl_texture_object *texObj; @@ -330,20 +362,41 @@ void gl_TexParameterfv( GLcontext *ctx, } +void +_mesa_TexParameteri( GLenum target, GLenum pname, const GLint param ) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0; + _mesa_TexParameterfv(target, pname, fparam); +} + +void +_mesa_TexParameteriv( GLenum target, GLenum pname, const GLint *params ) +{ + GLfloat fparam[4]; + fparam[0] = (GLfloat) params[0]; + fparam[1] = fparam[2] = fparam[3] = 0.0; + _mesa_TexParameterfv(target, pname, fparam); +} + -void gl_GetTexLevelParameterfv( GLcontext *ctx, GLenum target, GLint level, - GLenum pname, GLfloat *params ) +void +_mesa_GetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ) { GLint iparam; - gl_GetTexLevelParameteriv( ctx, target, level, pname, &iparam ); + _mesa_GetTexLevelParameteriv( target, level, pname, &iparam ); *params = (GLfloat) iparam; } -void gl_GetTexLevelParameteriv( GLcontext *ctx, GLenum target, GLint level, - GLenum pname, GLint *params ) +void +_mesa_GetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ) { + GET_CURRENT_CONTEXT(ctx); const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; const struct gl_texture_image *img = NULL; GLuint dimensions; @@ -448,10 +501,10 @@ void gl_GetTexLevelParameteriv( GLcontext *ctx, GLenum target, GLint level, - -void gl_GetTexParameterfv( GLcontext *ctx, - GLenum target, GLenum pname, GLfloat *params ) +void +_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *obj; @@ -516,9 +569,10 @@ void gl_GetTexParameterfv( GLcontext *ctx, } -void gl_GetTexParameteriv( GLcontext *ctx, - GLenum target, GLenum pname, GLint *params ) +void +_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) { + GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_object *obj; @@ -597,9 +651,10 @@ void gl_GetTexParameteriv( GLcontext *ctx, /**********************************************************************/ -void gl_TexGenfv( GLcontext *ctx, - GLenum coord, GLenum pname, const GLfloat *params ) +void +_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); GLuint tUnit = ctx->Texture.CurrentTransformUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit]; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexGenfv"); @@ -610,7 +665,7 @@ void gl_TexGenfv( GLcontext *ctx, gl_lookup_enum_by_nr(pname), *(int *)params); - switch( coord ) { + switch (coord) { case GL_S: if (pname==GL_TEXTURE_GEN_MODE) { GLenum mode = (GLenum) (GLint) *params; @@ -796,10 +851,57 @@ void gl_TexGenfv( GLcontext *ctx, } +void +_mesa_TexGeniv(GLenum coord, GLenum pname, const GLint *params ) +{ + GLfloat p[4]; + p[0] = params[0]; + p[1] = params[1]; + p[2] = params[2]; + p[3] = params[3]; + _mesa_TexGenfv(coord, pname, p); +} + + +void +_mesa_TexGend(GLenum coord, GLenum pname, GLdouble param ) +{ + GLfloat p = (GLfloat) param; + _mesa_TexGenfv( coord, pname, &p ); +} + + +void +_mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params ) +{ + GLfloat p[4]; + p[0] = params[0]; + p[1] = params[1]; + p[2] = params[2]; + p[3] = params[3]; + _mesa_TexGenfv( coord, pname, p ); +} + -void gl_GetTexGendv( GLcontext *ctx, - GLenum coord, GLenum pname, GLdouble *params ) +void +_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ) { + _mesa_TexGenfv(coord, pname, ¶m); +} + + +void +_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) +{ + _mesa_TexGeniv( coord, pname, ¶m ); +} + + + +void +_mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) +{ + GET_CURRENT_CONTEXT(ctx); GLuint tUnit = ctx->Texture.CurrentTransformUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit]; @@ -874,9 +976,10 @@ void gl_GetTexGendv( GLcontext *ctx, -void gl_GetTexGenfv( GLcontext *ctx, - GLenum coord, GLenum pname, GLfloat *params ) +void +_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) { + GET_CURRENT_CONTEXT(ctx); GLuint tUnit = ctx->Texture.CurrentTransformUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit]; @@ -951,9 +1054,10 @@ void gl_GetTexGenfv( GLcontext *ctx, -void gl_GetTexGeniv( GLcontext *ctx, - GLenum coord, GLenum pname, GLint *params ) +void +_mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) { + GET_CURRENT_CONTEXT(ctx); GLuint tUnit = ctx->Texture.CurrentTransformUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit]; @@ -983,7 +1087,7 @@ void gl_GetTexGeniv( GLcontext *ctx, break; case GL_T: if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = (GLint) texUnit->GenModeT; + params[0] = texUnit->GenModeT; } else if (pname==GL_OBJECT_PLANE) { params[0] = (GLint) texUnit->ObjectPlaneT[0]; @@ -1004,7 +1108,7 @@ void gl_GetTexGeniv( GLcontext *ctx, break; case GL_R: if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = (GLint) texUnit->GenModeR; + params[0] = texUnit->GenModeR; } else if (pname==GL_OBJECT_PLANE) { params[0] = (GLint) texUnit->ObjectPlaneR[0]; @@ -1025,7 +1129,7 @@ void gl_GetTexGeniv( GLcontext *ctx, break; case GL_Q: if (pname==GL_TEXTURE_GEN_MODE) { - params[0] = (GLint) texUnit->GenModeQ; + params[0] = texUnit->GenModeQ; } else if (pname==GL_OBJECT_PLANE) { params[0] = (GLint) texUnit->ObjectPlaneQ[0]; @@ -1038,7 +1142,7 @@ void gl_GetTexGeniv( GLcontext *ctx, params[1] = (GLint) texUnit->EyePlaneQ[1]; params[2] = (GLint) texUnit->EyePlaneQ[2]; params[3] = (GLint) texUnit->EyePlaneQ[3]; - } + } else { gl_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); return; @@ -1052,8 +1156,10 @@ void gl_GetTexGeniv( GLcontext *ctx, /* GL_ARB_multitexture */ -void gl_ActiveTexture( GLcontext *ctx, GLenum target ) +void +_mesa_ActiveTextureARB( GLenum target ) { + GET_CURRENT_CONTEXT(ctx); GLint maxUnits = ctx->Const.MaxTextureUnits; ASSERT_OUTSIDE_BEGIN_END( ctx, "glActiveTextureARB" ); @@ -1077,8 +1183,10 @@ void gl_ActiveTexture( GLcontext *ctx, GLenum target ) /* GL_ARB_multitexture */ -void gl_ClientActiveTexture( GLcontext *ctx, GLenum target ) +void +_mesa_ClientActiveTextureARB( GLenum target ) { + GET_CURRENT_CONTEXT(ctx); GLint maxUnits = ctx->Const.MaxTextureUnits; ASSERT_OUTSIDE_BEGIN_END( ctx, "glClientActiveTextureARB" ); diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h index 870693bfa70..d3111f02e3f 100644 --- a/src/mesa/main/texstate.h +++ b/src/mesa/main/texstate.h @@ -1,4 +1,4 @@ -/* $Id: texstate.h,v 1.1 1999/08/19 00:55:41 jtg Exp $ */ +/* $Id: texstate.h,v 1.2 1999/11/11 01:22:28 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -37,46 +37,80 @@ /*** Called from API ***/ -extern void gl_GetTexEnvfv( GLcontext *ctx, - GLenum target, GLenum pname, GLfloat *params ); +extern void +_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); -extern void gl_GetTexEnviv( GLcontext *ctx, - GLenum target, GLenum pname, GLint *params ); +extern void +_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ); -extern void gl_GetTexGendv( GLcontext *ctx, - GLenum coord, GLenum pname, GLdouble *params ); +extern void +_mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); -extern void gl_GetTexGenfv( GLcontext *ctx, - GLenum coord, GLenum pname, GLfloat *params ); +extern void +_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); -extern void gl_GetTexGeniv( GLcontext *ctx, - GLenum coord, GLenum pname, GLint *params ); +extern void +_mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ); -extern void gl_GetTexLevelParameterfv( GLcontext *ctx, - GLenum target, GLint level, - GLenum pname, GLfloat *params ); +extern void +_mesa_GetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ); -extern void gl_GetTexLevelParameteriv( GLcontext *ctx, - GLenum target, GLint level, - GLenum pname, GLint *params ); +extern void +_mesa_GetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ); -extern void gl_GetTexParameterfv( GLcontext *ctx, GLenum target, - GLenum pname, GLfloat *params ); +extern void +_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ); -extern void gl_GetTexParameteriv( GLcontext *ctx, - GLenum target, GLenum pname, GLint *params ); +extern void +_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ); -extern void gl_TexEnvfv( GLcontext *ctx, - GLenum target, GLenum pname, const GLfloat *param ); +extern void +_mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param ); +extern void +_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ); -extern void gl_TexParameterfv( GLcontext *ctx, GLenum target, GLenum pname, - const GLfloat *params ); +extern void +_mesa_TexEnvi( GLenum target, GLenum pname, GLint param ); +extern void +_mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param ); -extern void gl_TexGenfv( GLcontext *ctx, - GLenum coord, GLenum pname, const GLfloat *params ); + +extern void +_mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ); + +extern void +_mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param ); + + +extern void +_mesa_TexParameteri( GLenum target, GLenum pname, GLint param ); + +extern void +_mesa_TexParameteriv( GLenum target, GLenum pname, const GLint *params ); + + +extern void +_mesa_TexGend( GLenum coord, GLenum pname, GLdouble param ); + +extern void +_mesa_TexGendv( GLenum coord, GLenum pname, const GLdouble *params ); + +extern void +_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ); + +extern void +_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); + +extern void +_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ); + +extern void +_mesa_TexGeniv( GLenum coord, GLenum pname, const GLint *params ); @@ -86,9 +120,11 @@ extern void gl_SelectTextureTransform( GLcontext *ctx, GLenum target ); /* * GL_ARB_multitexture */ -extern void gl_ActiveTexture( GLcontext *ctx, GLenum target ); +extern void +_mesa_ActiveTextureARB( GLenum target ); -extern void gl_ClientActiveTexture( GLcontext *ctx, GLenum target ); +extern void +_mesa_ClientActiveTextureARB( GLenum target ); diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index bf7053cd1ac..8fcc63b9e72 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1,4 +1,4 @@ -/* $Id: varray.c,v 1.13 1999/11/09 17:26:15 keithw Exp $ */ +/* $Id: varray.c,v 1.14 1999/11/11 01:22:28 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -27,15 +27,8 @@ #ifdef PC_HEADER #include "all.h" #else -#ifndef XFree86Server -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#else -#include "GL/xf86glx.h" -#endif +#include "glheader.h" #include "context.h" -#include "api.h" #include "cva.h" #include "enable.h" #include "enums.h" @@ -54,24 +47,14 @@ #include "vbindirect.h" #include "vbxform.h" #include "xform.h" -#ifdef XFree86Server -#include "GL/xf86glx.h" -#endif #endif -#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server) && !defined(GLX_USE_DLOPEN) -#define NEED_MESA_FUNCS_WRAPPED -#include "mesa_api.h" -#endif -void GLAPIENTRY glVertexPointer(CTX_ARG GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr ) +void +_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) { - GLcontext *ctx; - GET_CONTEXT; - CHECK_CONTEXT; - ctx = CC; + GET_CURRENT_CONTEXT(ctx); if (size<2 || size>4) { gl_error( ctx, GL_INVALID_VALUE, "glVertexPointer(size)" ); @@ -120,13 +103,10 @@ void GLAPIENTRY glVertexPointer(CTX_ARG GLint size, GLenum type, GLsizei stride, -void GLAPIENTRY glNormalPointer(CTX_ARG GLenum type, GLsizei stride, - const GLvoid *ptr ) +void +_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) { - GLcontext *ctx; - GET_CONTEXT; - CHECK_CONTEXT; - ctx = CC; + GET_CURRENT_CONTEXT(ctx); if (stride<0) { gl_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" ); @@ -172,13 +152,11 @@ void GLAPIENTRY glNormalPointer(CTX_ARG GLenum type, GLsizei stride, -void GLAPIENTRY glColorPointer(CTX_ARG GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr ) +void +_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) { - GLcontext *ctx; - GET_CONTEXT; - CHECK_CONTEXT; - ctx = CC; + GET_CURRENT_CONTEXT(ctx); + if (size<3 || size>4) { gl_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" ); return; @@ -237,13 +215,10 @@ void GLAPIENTRY glColorPointer(CTX_ARG GLint size, GLenum type, GLsizei stride, -void GLAPIENTRY glIndexPointer(CTX_ARG GLenum type, GLsizei stride, - const GLvoid *ptr ) +void +_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) { - GLcontext *ctx; - GET_CONTEXT; - CHECK_CONTEXT; - ctx = CC; + GET_CURRENT_CONTEXT(ctx); if (stride<0) { gl_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" ); @@ -284,16 +259,12 @@ void GLAPIENTRY glIndexPointer(CTX_ARG GLenum type, GLsizei stride, -void GLAPIENTRY glTexCoordPointer(CTX_ARG GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr ) +void +_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) { + GET_CURRENT_CONTEXT(ctx); GLuint texUnit; - GLcontext *ctx; - GET_CONTEXT; - CHECK_CONTEXT; - ctx = CC; - texUnit = ctx->Array.ActiveTexture; if (size<1 || size>4) { @@ -346,14 +317,11 @@ void GLAPIENTRY glTexCoordPointer(CTX_ARG GLint size, GLenum type, -void GLAPIENTRY glEdgeFlagPointer(CTX_ARG GLsizei stride, const void *vptr ) +void +_mesa_EdgeFlagPointer(GLsizei stride, const void *vptr) { + GET_CURRENT_CONTEXT(ctx); const GLboolean *ptr = (GLboolean *)vptr; - - GLcontext *ctx; - GET_CONTEXT; - CHECK_CONTEXT; - ctx = CC; if (stride<0) { gl_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" ); @@ -470,8 +438,42 @@ void gl_exec_array_elements( GLcontext *ctx, struct immediate *IM, -void gl_DrawArrays( GLcontext *ctx, GLenum mode, GLint start, GLsizei count ) +/* Enough funny business going on in here it might be quicker to use a + * function pointer. + */ +#define ARRAY_ELT( IM, i ) \ +{ \ + GLuint count = IM->Count; \ + IM->Elt[count] = i; \ + IM->Flag[count] = ((IM->Flag[count] & IM->ArrayAndFlags) | \ + VERT_ELT); \ + IM->FlushElt |= IM->ArrayEltFlush; \ + IM->Count = count += IM->ArrayIncr; \ + if (count == VB_MAX) \ + IM->maybe_transform_vb( IM ); \ +} + + +void +_mesa_ArrayElement( GLint i ) +{ + GET_IMMEDIATE; + ARRAY_ELT( IM, i ); +} + + +void gl_ArrayElement( GLcontext *CC, GLint i ) +{ + struct immediate *im = CC->input; + ARRAY_ELT( im, i ); +} + + + +void +_mesa_DrawArrays(GLenum mode, GLint start, GLsizei count) { + GET_CURRENT_CONTEXT(ctx); struct vertex_buffer *VB = ctx->VB; GLint i; @@ -781,16 +783,13 @@ static GLuint natural_stride[0x10] = 0 /* f */ }; -void GLAPIENTRY glDrawElements(CTX_ARG GLenum mode, GLsizei count, - GLenum type, const GLvoid *indices ) + +void +_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { - GLcontext *ctx; + GET_CURRENT_CONTEXT(ctx); struct gl_cva *cva; - GET_CONTEXT; - CHECK_CONTEXT; - ctx = CC; - cva = &ctx->CVA; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDrawElements"); @@ -900,10 +899,10 @@ void GLAPIENTRY glDrawElements(CTX_ARG GLenum mode, GLsizei count, -void GLAPIENTRY glInterleavedArrays(CTX_ARG GLenum format, GLsizei stride, - const GLvoid *pointer ) +void +_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) { - GLcontext *ctx; + GET_CURRENT_CONTEXT(ctx); GLboolean tflag, cflag, nflag; /* enable/disable flags */ GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ @@ -913,11 +912,6 @@ void GLAPIENTRY glInterleavedArrays(CTX_ARG GLenum format, GLsizei stride, GLint c, f; GLint coordUnitSave; - GET_CONTEXT; - CHECK_CONTEXT; - ctx = CC; - - f = sizeof(GLfloat); c = f * ((4*sizeof(GLubyte) + (f-1)) / f); @@ -1041,8 +1035,8 @@ void GLAPIENTRY glInterleavedArrays(CTX_ARG GLenum format, GLsizei stride, stride = defstride; } - gl_DisableClientState( ctx, GL_EDGE_FLAG_ARRAY ); - gl_DisableClientState( ctx, GL_INDEX_ARRAY ); + _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY ); + _mesa_DisableClientState( GL_INDEX_ARRAY ); /* Texcoords */ coordUnitSave = ctx->Array.ActiveTexture; @@ -1050,63 +1044,61 @@ void GLAPIENTRY glInterleavedArrays(CTX_ARG GLenum format, GLsizei stride, GLint i; GLint factor = ctx->Array.TexCoordInterleaveFactor; for (i = 0; i < factor; i++) { - gl_ClientActiveTexture( ctx, (GLenum) (GL_TEXTURE0_ARB + i) ); - gl_EnableClientState( ctx, GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer(CTX_PRM tcomps, GL_FLOAT, stride, + _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) ); + _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY ); + glTexCoordPointer( tcomps, GL_FLOAT, stride, (GLubyte *) pointer + i * coffset ); } for (i = factor; i < ctx->Const.MaxTextureUnits; i++) { - gl_ClientActiveTexture( ctx, (GLenum) (GL_TEXTURE0_ARB + i) ); - gl_DisableClientState( ctx, GL_TEXTURE_COORD_ARRAY ); + _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) ); + _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); } } else { GLint i; for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - gl_ClientActiveTexture( ctx, (GLenum) (GL_TEXTURE0_ARB + i) ); - gl_DisableClientState( ctx, GL_TEXTURE_COORD_ARRAY ); + _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) ); + _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); } } /* Restore texture coordinate unit index */ - gl_ClientActiveTexture( ctx, (GLenum) (GL_TEXTURE0_ARB + coordUnitSave) ); + _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + coordUnitSave) ); /* Color */ if (cflag) { - gl_EnableClientState( ctx, GL_COLOR_ARRAY ); - glColorPointer(CTX_PRM ccomps, ctype, stride, + _mesa_EnableClientState( GL_COLOR_ARRAY ); + glColorPointer( ccomps, ctype, stride, (GLubyte*) pointer + coffset ); } else { - gl_DisableClientState( ctx, GL_COLOR_ARRAY ); + _mesa_DisableClientState( GL_COLOR_ARRAY ); } /* Normals */ if (nflag) { - gl_EnableClientState( ctx, GL_NORMAL_ARRAY ); - glNormalPointer(CTX_PRM GL_FLOAT, stride, + _mesa_EnableClientState( GL_NORMAL_ARRAY ); + glNormalPointer( GL_FLOAT, stride, (GLubyte*) pointer + noffset ); } else { - gl_DisableClientState( ctx, GL_NORMAL_ARRAY ); + _mesa_DisableClientState( GL_NORMAL_ARRAY ); } - gl_EnableClientState( ctx, GL_VERTEX_ARRAY ); - glVertexPointer(CTX_PRM vcomps, GL_FLOAT, stride, + _mesa_EnableClientState( GL_VERTEX_ARRAY ); + glVertexPointer( vcomps, GL_FLOAT, stride, (GLubyte *) pointer + voffset ); } -void GLAPIENTRY glDrawRangeElements(CTX_ARG GLenum mode, GLuint start, - GLuint end, GLsizei count, - GLenum type, const GLvoid *indices ) +void +_mesa_DrawRangeElements(GLenum mode, GLuint start, + GLuint end, GLsizei count, + GLenum type, const GLvoid *indices) { - GLcontext *ctx; - GET_CONTEXT; - CHECK_CONTEXT; - ctx = CC; + GET_CURRENT_CONTEXT(ctx); if (end < start) { gl_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements( end < start )"); @@ -1114,11 +1106,11 @@ void GLAPIENTRY glDrawRangeElements(CTX_ARG GLenum mode, GLuint start, } if (!ctx->Array.LockCount && 2*count > (GLint) 3*(end-start)) { - glLockArraysEXT(CTX_PRM start, end ); - glDrawElements(CTX_PRM mode, count, type, indices ); - glUnlockArraysEXT(CTX_VPRM ); + glLockArraysEXT( start, end ); + glDrawElements( mode, count, type, indices ); + glUnlockArraysEXT(); } else { - glDrawElements(CTX_PRM mode, count, type, indices ); + glDrawElements( mode, count, type, indices ); } } diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index 88cedb4a1ce..f4d0981b103 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -1,4 +1,4 @@ -/* $Id: varray.h,v 1.4 1999/10/19 18:37:05 keithw Exp $ */ +/* $Id: varray.h,v 1.5 1999/11/11 01:22:28 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -32,70 +32,67 @@ #include "types.h" -extern void gl_VertexPointer( GLcontext *ctx, - GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr ); +extern void +_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr); -extern void gl_NormalPointer( GLcontext *ctx, - GLenum type, GLsizei stride, const GLvoid *ptr ); +extern void +_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr); -extern void gl_ColorPointer( GLcontext *ctx, - GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr ); +extern void +_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr); -extern void gl_IndexPointer( GLcontext *ctx, - GLenum type, GLsizei stride, - const GLvoid *ptr ); +extern void +_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr); -extern void gl_TexCoordPointer( GLcontext *ctx, - GLint size, GLenum type, GLsizei stride, - const GLvoid *ptr ); +extern void +_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, + const GLvoid *ptr); -extern void gl_EdgeFlagPointer( GLcontext *ctx, - GLsizei stride, const GLboolean *ptr ); +extern void +_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr); -extern void gl_GetPointerv( GLcontext *ctx, GLenum pname, GLvoid **params ); +extern void +_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count); +extern void +_mesa_save_DrawArrays(GLenum mode, GLint first, GLsizei count); -extern void gl_DrawArrays( GLcontext *ctx, - GLenum mode, GLint first, GLsizei count ); -extern void gl_save_DrawArrays( GLcontext *ctx, - GLenum mode, GLint first, GLsizei count ); +extern void +_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices); -extern void gl_DrawElements( GLcontext *ctx, - GLenum mode, GLsizei count, - GLenum type, const GLvoid *indices ); - -extern void gl_save_DrawElements( GLcontext *ctx, - GLenum mode, GLsizei count, - GLenum type, const GLvoid *indices ); +extern void +_mesa_save_DrawElements(GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices); -extern void gl_InterleavedArrays( GLcontext *ctx, - GLenum format, GLsizei stride, - const GLvoid *pointer ); +extern void +_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); -extern void gl_save_InterleavedArrays( GLcontext *ctx, - GLenum format, GLsizei stride, - const GLvoid *pointer ); +extern void +_mesa_save_InterleavedArrays(GLenum format, GLsizei stride, + const GLvoid *pointer); -extern void gl_DrawRangeElements( GLcontext *ctx, GLenum mode, GLuint start, - GLuint end, GLsizei count, GLenum type, - const GLvoid *indices ); +extern void +_mesa_DrawRangeElements(GLenum mode, GLuint start, + GLuint end, GLsizei count, GLenum type, + const GLvoid *indices); -extern void gl_save_DrawRangeElements( GLcontext *ctx, GLenum mode, - GLuint start, GLuint end, GLsizei count, - GLenum type, const GLvoid *indices ); +extern void +_mesa_save_DrawRangeElements(GLenum mode, + GLuint start, GLuint end, GLsizei count, + GLenum type, const GLvoid *indices ); extern void gl_exec_array_elements( GLcontext *ctx, @@ -105,4 +102,5 @@ extern void gl_exec_array_elements( GLcontext *ctx, extern void gl_update_client_state( GLcontext *ctx ); + #endif |