summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-06-15 03:03:06 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-06-15 03:03:06 +0000
commit8afe7de8deaf3c9613fd68b344de8c52b02b1879 (patch)
treef600a192c9d0136faea8864a53eabc819eeb791f /src/mesa
parent8bdd0dc8d0e9c9cb2c71fbdd4c77e982cfc0b350 (diff)
Implemented GL_NV_texture_rectangle extension.
Replace struct gl_texure_object's Dimension w/ Target field. Added _EnabledUnits to struct gl_texture_attrib - the _ReallyEnabled field is obsolete, but still present for now. This effectively removes the 8-texture units limit, 32 units now possible, but unlikely! New TEXTURE_1D/2D/3D/CUBE/RECT_BIT tokens for unit->_ReallyEnabled field. Updated device drivers to use ctx->Texture._EnabledUnits.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/d3d/D3Dvbrender.c6
-rw-r--r--src/mesa/drivers/dos/dmesa.c2
-rw-r--r--src/mesa/drivers/glide/fxdd.c32
-rw-r--r--src/mesa/drivers/glide/fxsetup.c38
-rw-r--r--src/mesa/drivers/glide/fxvb.c8
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c6
-rw-r--r--src/mesa/drivers/windows/wmesa.c4
-rw-r--r--src/mesa/drivers/windows/wmesa_stereo.c8
-rw-r--r--src/mesa/drivers/x11/xm_line.c6
-rw-r--r--src/mesa/drivers/x11/xm_tri.c4
-rw-r--r--src/mesa/main/attrib.c47
-rw-r--r--src/mesa/main/config.h9
-rw-r--r--src/mesa/main/context.c53
-rw-r--r--src/mesa/main/enable.c51
-rw-r--r--src/mesa/main/extensions.c4
-rw-r--r--src/mesa/main/get.c58
-rw-r--r--src/mesa/main/mtypes.h96
-rw-r--r--src/mesa/main/state.c57
-rw-r--r--src/mesa/main/teximage.c234
-rw-r--r--src/mesa/main/teximage.h4
-rw-r--r--src/mesa/main/texobj.c113
-rw-r--r--src/mesa/main/texobj.h8
-rw-r--r--src/mesa/main/texstate.c103
-rw-r--r--src/mesa/main/texstore.c32
-rw-r--r--src/mesa/swrast/s_aaline.c6
-rw-r--r--src/mesa/swrast/s_aatriangle.c8
-rw-r--r--src/mesa/swrast/s_context.c10
-rw-r--r--src/mesa/swrast/s_copypix.c6
-rw-r--r--src/mesa/swrast/s_drawpix.c6
-rw-r--r--src/mesa/swrast/s_lines.c6
-rw-r--r--src/mesa/swrast/s_points.c8
-rw-r--r--src/mesa/swrast/s_pointtemp.h4
-rw-r--r--src/mesa/swrast/s_span.c14
-rw-r--r--src/mesa/swrast/s_texture.c216
-rw-r--r--src/mesa/swrast/s_triangle.c15
-rw-r--r--src/mesa/swrast_setup/ss_vb.c10
-rw-r--r--src/mesa/tnl/t_vb_render.c4
37 files changed, 923 insertions, 373 deletions
diff --git a/src/mesa/drivers/d3d/D3Dvbrender.c b/src/mesa/drivers/d3d/D3Dvbrender.c
index a3a18323fe..7f60ca82a6 100644
--- a/src/mesa/drivers/d3d/D3Dvbrender.c
+++ b/src/mesa/drivers/d3d/D3Dvbrender.c
@@ -1511,7 +1511,7 @@ static void SetRenderStates( GLcontext *ctx )
/*================================================*/
/* Check too see if there are new TEXTURE states. */
/*================================================*/
- if ( ctx->Texture._ReallyEnabled )
+ if ( ctx->Texture._EnabledUnits )
{
switch( ctx->Texture.Set[ctx->Texture.CurrentSet].EnvMode )
{
@@ -1871,9 +1871,9 @@ static void DebugRenderStates( GLcontext *ctx, BOOL bForce )
/*================================================*/
/* Check too see if there are new TEXTURE states. */
/*================================================*/
- if ( texture != ctx->Texture._ReallyEnabled )
+ if ( texture != ctx->Texture._EnabledUnits )
{
- texture = ctx->Texture._ReallyEnabled;
+ texture = ctx->Texture._EnabledUnits;
DPF(( 0, "\tTexture\t\t%s", (texture) ? "ENABLED" : "--------" ));
}
diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c
index d05d436c1e..c9bc898dcb 100644
--- a/src/mesa/drivers/dos/dmesa.c
+++ b/src/mesa/drivers/dos/dmesa.c
@@ -413,7 +413,7 @@ static swrast_tri_func dmesa_choose_tri_function (GLcontext *ctx)
if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
- if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;
+ if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL;
if (ctx->Light.ShadeModel==GL_SMOOTH
&& swrast->_RasterMask==DEPTH_BIT
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index caff948851..2fb1a2ada4 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -1,4 +1,4 @@
-/* $Id: fxdd.c,v 1.87 2002/06/15 02:38:16 brianp Exp $ */
+/* $Id: fxdd.c,v 1.88 2002/06/15 03:03:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -841,14 +841,15 @@ fx_check_IsInHardware(GLcontext * ctx)
/* Unsupported texture/multitexture cases */
if (fxMesa->haveTwoTMUs) {
- if (ctx->Texture._ReallyEnabled & (TEXTURE0_3D | TEXTURE1_3D))
- return GL_FALSE; /* can't do 3D textures */
- if (ctx->Texture._ReallyEnabled & (TEXTURE0_1D | TEXTURE1_1D))
- return GL_FALSE; /* can't do 1D textures */
+ /* we can only do 2D textures */
+ if (ctx->Texture.Unit[0]._ReallyEnabled & ~TEXTURE_2D_BIT)
+ return GL_FALSE;
+ if (ctx->Texture.Unit[1]._ReallyEnabled & ~TEXTURE_2D_BIT)
+ return GL_FALSE;
- if (ctx->Texture._ReallyEnabled & TEXTURE0_2D) {
+ if (ctx->Texture.Unit[0]._ReallyEnabled & TEXTURE_2D_BIT) {
if (ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
- (ctx->Texture._ReallyEnabled & TEXTURE1_2D ||
+ (ctx->Texture.Unit[1]._ReallyEnabled & TEXTURE_2D_BIT ||
ctx->Texture.Unit[0].EnvColor[0] != 0 ||
ctx->Texture.Unit[0].EnvColor[1] != 0 ||
ctx->Texture.Unit[0].EnvColor[2] != 0 ||
@@ -859,7 +860,7 @@ fx_check_IsInHardware(GLcontext * ctx)
return GL_FALSE;
}
- if (ctx->Texture._ReallyEnabled & TEXTURE1_2D) {
+ if (ctx->Texture.Unit[1]._ReallyEnabled & TEXTURE_2D_BIT) {
if (ctx->Texture.Unit[1].EnvMode == GL_BLEND)
return GL_FALSE;
if (ctx->Texture.Unit[1]._Current->Image[0]->Border > 0)
@@ -873,9 +874,10 @@ fx_check_IsInHardware(GLcontext * ctx)
/* KW: This was wrong (I think) and I changed it... which doesn't mean
* it is now correct...
+ * BP: The old condition just seemed to test if both texture units
+ * were enabled. That's easy!
*/
- if ((ctx->Texture._ReallyEnabled & (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D)) &&
- (ctx->Texture._ReallyEnabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D))) {
+ if (ctx->Texture._EnabledUnits == 0x3) {
/* Can't use multipass to blend a multitextured triangle - fall
* back to software.
*/
@@ -893,16 +895,12 @@ fx_check_IsInHardware(GLcontext * ctx)
}
}
else {
- if ((ctx->Texture._ReallyEnabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D)) ||
- /* Not very well written ... */
- ((ctx->Texture._ReallyEnabled & TEXTURE0_1D) &&
- (!(ctx->Texture._ReallyEnabled & TEXTURE0_2D)))
- ) {
+ /* we have just one texture unit */
+ if (ctx->Texture._EnabledUnits > 0x1) {
return GL_FALSE;
}
-
- if ((ctx->Texture._ReallyEnabled & TEXTURE0_2D) &&
+ if ((ctx->Texture.Unit[0]._ReallyEnabled & TEXTURE_2D_BIT) &&
(ctx->Texture.Unit[0].EnvMode == GL_BLEND)) {
return GL_FALSE;
}
diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c
index 431b02a9ba..bf51635b31 100644
--- a/src/mesa/drivers/glide/fxsetup.c
+++ b/src/mesa/drivers/glide/fxsetup.c
@@ -1,4 +1,4 @@
-/* $Id: fxsetup.c,v 1.36 2001/09/23 16:50:01 brianp Exp $ */
+/* $Id: fxsetup.c,v 1.37 2002/06/15 03:03:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1002,39 +1002,25 @@ static void
fxSetupTexture_NoLock(GLcontext * ctx)
{
fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
- GLuint tex2Denabled;
if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr, "fxmesa: fxSetupTexture(...)\n");
}
- /* Texture Combine, Color Combine and Alpha Combine.
- */
- tex2Denabled = (ctx->Texture._ReallyEnabled & TEXTURE0_2D);
-
- if (fxMesa->haveTwoTMUs)
- tex2Denabled |= (ctx->Texture._ReallyEnabled & TEXTURE1_2D);
-
- switch (tex2Denabled) {
- case TEXTURE0_2D:
+ /* Texture Combine, Color Combine and Alpha Combine. */
+ if (ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT &&
+ ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT &&
+ fxMesa->haveTwoTMUs) {
+ fxSetupTextureDoubleTMU_NoLock(ctx);
+ }
+ else if (ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT) {
fxSetupTextureSingleTMU_NoLock(ctx, 0);
- break;
- case TEXTURE1_2D:
+ }
+ else if (ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT) {
fxSetupTextureSingleTMU_NoLock(ctx, 1);
- break;
- case (TEXTURE0_2D | TEXTURE1_2D):
- if (fxMesa->haveTwoTMUs)
- fxSetupTextureDoubleTMU_NoLock(ctx);
- else {
- if (MESA_VERBOSE & VERBOSE_DRIVER)
- fprintf(stderr, "fxmesa: enabling fake multitexture\n");
-
- fxSetupTextureSingleTMU_NoLock(ctx, 0);
- }
- break;
- default:
+ }
+ else {
fxSetupTextureNone_NoLock(ctx);
- break;
}
}
diff --git a/src/mesa/drivers/glide/fxvb.c b/src/mesa/drivers/glide/fxvb.c
index f0534b65ec..24e01af096 100644
--- a/src/mesa/drivers/glide/fxvb.c
+++ b/src/mesa/drivers/glide/fxvb.c
@@ -1,4 +1,4 @@
-/* $Id: fxvb.c,v 1.13 2002/06/15 02:38:16 brianp Exp $ */
+/* $Id: fxvb.c,v 1.14 2002/06/15 03:03:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -342,8 +342,8 @@ void fxChooseVertexState( GLcontext *ctx )
fxMesa->tmu_source[0] = 0;
fxMesa->tmu_source[1] = 1;
- if (ctx->Texture._ReallyEnabled & TEXTURE1_ANY) {
- if (ctx->Texture._ReallyEnabled & TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits & 0x2) {
+ if (ctx->Texture._EnabledUnits & 0x1) {
ind |= SETUP_TMU1|SETUP_TMU0;
}
else {
@@ -352,7 +352,7 @@ void fxChooseVertexState( GLcontext *ctx )
ind |= SETUP_TMU0;
}
}
- else if (ctx->Texture._ReallyEnabled & TEXTURE0_ANY) {
+ else if (ctx->Texture._EnabledUnits & 0x1) {
ind |= SETUP_TMU0;
}
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 4b69df600f..5675171b96 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -1,4 +1,4 @@
-/* $Id: osmesa.c,v 1.81 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: osmesa.c,v 1.82 2002/06/15 03:03:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1802,7 +1802,7 @@ osmesa_choose_line_function( GLcontext *ctx )
if (CHAN_BITS != 8) return NULL;
if (ctx->RenderMode != GL_RENDER) return NULL;
if (ctx->Line.SmoothFlag) return NULL;
- if (ctx->Texture._ReallyEnabled) return NULL;
+ if (ctx->Texture._EnabledUnits) return NULL;
if (ctx->Light.ShadeModel != GL_FLAT) return NULL;
if (ctx->Line.Width != 1.0F) return NULL;
if (ctx->Line.StippleFlag) return NULL;
@@ -1956,7 +1956,7 @@ osmesa_choose_triangle_function( GLcontext *ctx )
if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
if (ctx->Polygon.StippleFlag) return (swrast_tri_func) NULL;
- if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;
+ if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL;
if (osmesa->format != OSMESA_RGBA &&
osmesa->format != OSMESA_BGRA &&
osmesa->format != OSMESA_ARGB) return (swrast_tri_func) NULL;
diff --git a/src/mesa/drivers/windows/wmesa.c b/src/mesa/drivers/windows/wmesa.c
index 94a23d2d75..09fa23737f 100644
--- a/src/mesa/drivers/windows/wmesa.c
+++ b/src/mesa/drivers/windows/wmesa.c
@@ -1,4 +1,4 @@
-/* $Id: wmesa.c,v 1.30 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: wmesa.c,v 1.31 2002/06/15 03:03:10 brianp Exp $ */
/*
* Windows (Win32) device driver for Mesa 3.4
@@ -3201,7 +3201,7 @@ static triangle_func choose_triangle_function( GLcontext *ctx )
int depth = wmesa->cColorBits;
if (ctx->Polygon.SmoothFlag) return NULL;
- if (ctx->Texture._ReallyEnabled) return NULL;
+ if (ctx->Texture._EnabledUnits) return NULL;
if (!wmesa->db_flag) return NULL;
if (ctx->swrast->_RasterMask & MULTI_DRAW_BIT) return NULL;
diff --git a/src/mesa/drivers/windows/wmesa_stereo.c b/src/mesa/drivers/windows/wmesa_stereo.c
index a4397c41bf..fea0dc4229 100644
--- a/src/mesa/drivers/windows/wmesa_stereo.c
+++ b/src/mesa/drivers/windows/wmesa_stereo.c
@@ -421,7 +421,7 @@ extern points_func choose_points_function( GLcontext* ctx )
{
STARTPROFILE
if (ctx->Point.Size==1.0 && !ctx->Point.SmoothFlag && ctx->_RasterMask==0
- && !ctx->Texture._ReallyEnabled && ctx->Visual->RGBAflag) {
+ && ctx->Texture._EnabledUnits == 0 && ctx->Visual->RGBAflag) {
ENDPROFILE(choose_points_function)
return fast_rgb_points;
}
@@ -479,7 +479,7 @@ static line_func choose_line_function( GLcontext* ctx )
STARTPROFILE
if (ctx->Line.Width==1.0 && !ctx->Line.SmoothFlag && !ctx->Line.StippleFlag
&& ctx->Light.ShadeModel==GL_FLAT && ctx->_RasterMask==0
- && !ctx->Texture._ReallyEnabled && Current->rgb_flag) {
+ && ctx->Texture._EnabledUnits == 0 && Current->rgb_flag) {
ENDPROFILE(choose_line_function)
return fast_flat_rgb_line;
}
@@ -590,7 +590,7 @@ static triangle_func choose_triangle_function( GLcontext *ctx )
{
if (ctx->Polygon.SmoothFlag) return NULL;
if (ctx->Polygon.StippleFlag) return NULL;
- if (ctx->Texture._ReallyEnabled) return NULL;
+ if (ctx->Texture._EnabledUnits) return NULL;
if (ctx->_RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
@@ -661,7 +661,7 @@ static polygon_func choose_polygon_function( GLcontext* ctx )
STARTPROFILE
if (!ctx->Polygon.SmoothFlag && !ctx->Polygon.StippleFlag
&& ctx->Light.ShadeModel==GL_FLAT && ctx->_RasterMask==0
- && !ctx->Texture._ReallyEnabled && Current->rgb_flag==GL_TRUE) {
+ && ctx->Texture._EnabledUnits == 0 && Current->rgb_flag==GL_TRUE) {
ENDPROFILE(choose_polygon_function)
return fast_flat_rgb_polygon;
}
diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c
index ce70680901..989969d024 100644
--- a/src/mesa/drivers/x11/xm_line.c
+++ b/src/mesa/drivers/x11/xm_line.c
@@ -1,4 +1,4 @@
-/* $Id: xm_line.c,v 1.19 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: xm_line.c,v 1.20 2002/06/15 03:03:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -101,7 +101,7 @@ void xmesa_choose_point( GLcontext *ctx )
if (ctx->RenderMode == GL_RENDER
&& ctx->Point.Size == 1.0F && !ctx->Point.SmoothFlag
&& swrast->_RasterMask == 0
- && !ctx->Texture._ReallyEnabled
+ && !ctx->Texture._EnabledUnits
&& xmesa->xm_buffer->buffer != XIMAGE) {
swrast->Point = draw_points_ANY_pixmap;
}
@@ -557,7 +557,7 @@ static swrast_line_func get_line_func( GLcontext *ctx )
if (ctx->RenderMode != GL_RENDER) return (swrast_line_func) NULL;
if (ctx->Line.SmoothFlag) return (swrast_line_func) NULL;
- if (ctx->Texture._ReallyEnabled) return (swrast_line_func) NULL;
+ if (ctx->Texture._EnabledUnits) return (swrast_line_func) NULL;
if (ctx->Light.ShadeModel != GL_FLAT) return (swrast_line_func) NULL;
if (ctx->Line.StippleFlag) return (swrast_line_func) NULL;
if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c
index f0aef4c0ec..4b3f02677e 100644
--- a/src/mesa/drivers/x11/xm_tri.c
+++ b/src/mesa/drivers/x11/xm_tri.c
@@ -1,4 +1,4 @@
-/* $Id: xm_tri.c,v 1.23 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: xm_tri.c,v 1.24 2002/06/15 03:03:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1529,7 +1529,7 @@ static swrast_tri_func get_triangle_func( GLcontext *ctx )
if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
- if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;
+ if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL;
if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_tri_func) NULL;
if (xmesa->xm_buffer->buffer==XIMAGE) {
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index a7f90155bb..fb5fbc8b70 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.67 2002/06/15 02:38:15 brianp Exp $ */
+/* $Id: attrib.c,v 1.68 2002/06/15 03:03:06 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -81,9 +81,7 @@ copy_texobj_state( struct gl_texture_object *dest,
const struct gl_texture_object *src )
{
dest->Name = src->Name;
- /*
- dest->Dimensions = src->Dimensions;
- */
+ /*dest->Target = src->Target*/
dest->Priority = src->Priority;
dest->BorderColor[0] = src->BorderColor[0];
dest->BorderColor[1] = src->BorderColor[1];
@@ -383,6 +381,7 @@ _mesa_PushAttrib(GLbitfield mask)
ctx->Texture.Unit[u].Current2D->RefCount++;
ctx->Texture.Unit[u].Current3D->RefCount++;
ctx->Texture.Unit[u].CurrentCubeMap->RefCount++;
+ ctx->Texture.Unit[u].CurrentRect->RefCount++;
}
attr = MALLOC_STRUCT( gl_texture_attrib );
MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) );
@@ -392,6 +391,7 @@ _mesa_PushAttrib(GLbitfield mask)
copy_texobj_state(&attr->Unit[u].Saved2D, attr->Unit[u].Current2D);
copy_texobj_state(&attr->Unit[u].Saved3D, attr->Unit[u].Current3D);
copy_texobj_state(&attr->Unit[u].SavedCubeMap, attr->Unit[u].CurrentCubeMap);
+ copy_texobj_state(&attr->Unit[u].SavedRect, attr->Unit[u].CurrentRect);
}
newnode = new_attrib_node( GL_TEXTURE_BIT );
newnode->data = attr;
@@ -580,11 +580,17 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
(*ctx->Driver.ActiveTexture)(ctx, i);
}
(*ctx->Driver.Enable)( ctx, GL_TEXTURE_1D,
- (GLboolean) (enable->Texture[i] & TEXTURE0_1D) );
+ (GLboolean) (enable->Texture[i] & TEXTURE_1D_BIT) );
(*ctx->Driver.Enable)( ctx, GL_TEXTURE_2D,
- (GLboolean) (enable->Texture[i] & TEXTURE0_2D) );
+ (GLboolean) (enable->Texture[i] & TEXTURE_2D_BIT) );
(*ctx->Driver.Enable)( ctx, GL_TEXTURE_3D,
- (GLboolean) (enable->Texture[i] & TEXTURE0_3D) );
+ (GLboolean) (enable->Texture[i] & TEXTURE_3D_BIT) );
+ if (ctx->Extensions.ARB_texture_cube_map)
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_CUBE_MAP_ARB,
+ (GLboolean) (enable->Texture[i] & TEXTURE_CUBE_BIT) );
+ if (ctx->Extensions.NV_texture_rectangle)
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_RECTANGLE_NV,
+ (GLboolean) (enable->Texture[i] & TEXTURE_RECT_BIT) );
}
}
@@ -627,18 +633,22 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
const struct gl_texture_unit *unit = &texAttrib->Unit[u];
- GLuint numObjs, i;
+ GLuint i;
_mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u);
_mesa_set_enable(ctx, GL_TEXTURE_1D,
- (GLboolean) (unit->Enabled & TEXTURE0_1D ? GL_TRUE : GL_FALSE));
+ (GLboolean) (unit->Enabled & TEXTURE_1D_BIT ? GL_TRUE : GL_FALSE));
_mesa_set_enable(ctx, GL_TEXTURE_2D,
- (GLboolean) (unit->Enabled & TEXTURE0_2D ? GL_TRUE : GL_FALSE));
+ (GLboolean) (unit->Enabled & TEXTURE_2D_BIT ? GL_TRUE : GL_FALSE));
_mesa_set_enable(ctx, GL_TEXTURE_3D,
- (GLboolean) (unit->Enabled & TEXTURE0_3D ? GL_TRUE : GL_FALSE));
+ (GLboolean) (unit->Enabled & TEXTURE_3D_BIT ? GL_TRUE : GL_FALSE));
if (ctx->Extensions.ARB_texture_cube_map) {
_mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP_ARB,
- (GLboolean) (unit->Enabled & TEXTURE0_CUBE ? GL_TRUE : GL_FALSE));
+ (GLboolean) (unit->Enabled & TEXTURE_CUBE_BIT ? GL_TRUE : GL_FALSE));
+ }
+ if (ctx->Extensions.NV_texture_rectangle) {
+ _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV,
+ (GLboolean) (unit->Enabled & TEXTURE_RECT_BIT ? GL_TRUE : GL_FALSE));
}
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode);
_mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor);
@@ -695,9 +705,7 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
}
/* Restore texture object state */
- numObjs = ctx->Extensions.ARB_texture_cube_map ? 4 : 3;
-
- for (i = 0; i < numObjs; i++) {
+ for (i = 0; i < 5; i++) {
GLenum target = 0;
const struct gl_texture_object *obj = NULL;
GLfloat bordColor[4];
@@ -716,9 +724,17 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
obj = &unit->Saved3D;
break;
case 3:
+ if (!ctx->Extensions.ARB_texture_cube_map)
+ continue;
target = GL_TEXTURE_CUBE_MAP_ARB;
obj = &unit->SavedCubeMap;
break;
+ case 4:
+ if (!ctx->Extensions.NV_texture_rectangle)
+ continue;
+ target = GL_TEXTURE_RECTANGLE_NV;
+ obj = &unit->SavedRect;
+ break;
default:
; /* silence warnings */
}
@@ -770,6 +786,7 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
ctx->Texture.Unit[u].Current2D->RefCount--;
ctx->Texture.Unit[u].Current3D->RefCount--;
ctx->Texture.Unit[u].CurrentCubeMap->RefCount--;
+ ctx->Texture.Unit[u].CurrentRect->RefCount--;
}
}
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index d02baedcc9..f0bd88462d 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -1,10 +1,10 @@
-/* $Id: config.h,v 1.39 2002/06/15 02:38:15 brianp Exp $ */
+/* $Id: config.h,v 1.40 2002/06/15 03:03:07 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 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"),
@@ -109,9 +109,12 @@
/* Number of 3D texture mipmap levels */
#define MAX_3D_TEXTURE_LEVELS 8
-/* Number of cube texture mipmap levels */
+/* Number of cube texture mipmap levels - GL_ARB_texture_cube_map */
#define MAX_CUBE_TEXTURE_LEVELS 12
+/* Maximum rectangular texture size - GL_NV_texture_rectangle */
+#define MAX_TEXTURE_RECT_SIZE 2048
+
/* Number of texture units - GL_ARB_multitexture */
#define MAX_TEXTURE_UNITS 8
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 2baff7c299..daf4eb69b3 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.167 2002/06/15 02:38:15 brianp Exp $ */
+/* $Id: context.c,v 1.168 2002/06/15 03:03:07 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -644,26 +644,33 @@ alloc_shared_state( void )
/* Default Texture objects */
outOfMemory = GL_FALSE;
- ss->Default1D = _mesa_alloc_texture_object(ss, 0, 1);
+ ss->Default1D = _mesa_alloc_texture_object(ss, 0, GL_TEXTURE_1D);
if (!ss->Default1D) {
outOfMemory = GL_TRUE;
}
- ss->Default2D = _mesa_alloc_texture_object(ss, 0, 2);
+ ss->Default2D = _mesa_alloc_texture_object(ss, 0, GL_TEXTURE_2D);
if (!ss->Default2D) {
outOfMemory = GL_TRUE;
}
- ss->Default3D = _mesa_alloc_texture_object(ss, 0, 3);
+ ss->Default3D = _mesa_alloc_texture_object(ss, 0, GL_TEXTURE_3D);
if (!ss->Default3D) {
outOfMemory = GL_TRUE;
}
- ss->DefaultCubeMap = _mesa_alloc_texture_object(ss, 0, 6);
+ ss->DefaultCubeMap = _mesa_alloc_texture_object(ss, 0,
+ GL_TEXTURE_CUBE_MAP_ARB);
if (!ss->DefaultCubeMap) {
outOfMemory = GL_TRUE;
}
+ ss->DefaultRect = _mesa_alloc_texture_object(ss, 0,
+ GL_TEXTURE_RECTANGLE_NV);
+ if (!ss->DefaultRect) {
+ outOfMemory = GL_TRUE;
+ }
+
if (!ss->DisplayList || !ss->TexObjects || !ss->VertexPrograms
|| outOfMemory) {
/* Ran out of memory at some point. Free everything and return NULL */
@@ -681,6 +688,8 @@ alloc_shared_state( void )
_mesa_free_texture_object(ss, ss->Default3D);
if (ss->DefaultCubeMap)
_mesa_free_texture_object(ss, ss->DefaultCubeMap);
+ if (ss->DefaultRect)
+ _mesa_free_texture_object(ss, ss->DefaultRect);
FREE(ss);
return NULL;
}
@@ -839,6 +848,7 @@ init_texture_unit( GLcontext *ctx, GLuint unit )
texUnit->Current2D = ctx->Shared->Default2D;
texUnit->Current3D = ctx->Shared->Default3D;
texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
+ texUnit->CurrentRect = ctx->Shared->DefaultRect;
}
@@ -896,6 +906,7 @@ init_attrib_groups( GLcontext *ctx )
ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS;
ctx->Const.MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS;
+ ctx->Const.MaxTextureRectSize = MAX_TEXTURE_RECT_SIZE;
ctx->Const.MaxTextureUnits = MAX_TEXTURE_UNITS;
ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY;
ctx->Const.MaxTextureLodBias = MAX_TEXTURE_LOD_BIAS;
@@ -1285,7 +1296,8 @@ init_attrib_groups( GLcontext *ctx )
/* Texture group */
ctx->Texture.CurrentUnit = 0; /* multitexture */
- ctx->Texture._ReallyEnabled = 0;
+ ctx->Texture._ReallyEnabled = 0; /* XXX obsolete */
+ ctx->Texture._EnabledUnits = 0;
for (i=0; i<MAX_TEXTURE_UNITS; i++)
init_texture_unit( ctx, i );
ctx->Texture.SharedPalette = GL_FALSE;
@@ -1484,25 +1496,26 @@ alloc_proxy_textures( GLcontext *ctx )
GLboolean out_of_memory;
GLint i;
- ctx->Texture.Proxy1D = _mesa_alloc_texture_object(NULL, 0, 1);
+ ctx->Texture.Proxy1D = _mesa_alloc_texture_object(NULL, 0, GL_TEXTURE_1D);
if (!ctx->Texture.Proxy1D) {
return GL_FALSE;
}
- ctx->Texture.Proxy2D = _mesa_alloc_texture_object(NULL, 0, 2);
+ ctx->Texture.Proxy2D = _mesa_alloc_texture_object(NULL, 0, GL_TEXTURE_2D);
if (!ctx->Texture.Proxy2D) {
_mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
return GL_FALSE;
}
- ctx->Texture.Proxy3D = _mesa_alloc_texture_object(NULL, 0, 3);
+ ctx->Texture.Proxy3D = _mesa_alloc_texture_object(NULL, 0, GL_TEXTURE_3D);
if (!ctx->Texture.Proxy3D) {
_mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
_mesa_free_texture_object(NULL, ctx->Texture.Proxy2D);
return GL_FALSE;
}
- ctx->Texture.ProxyCubeMap = _mesa_alloc_texture_object(NULL, 0, 6);
+ ctx->Texture.ProxyCubeMap = _mesa_alloc_texture_object(NULL, 0,
+ GL_TEXTURE_CUBE_MAP_ARB);
if (!ctx->Texture.ProxyCubeMap) {
_mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
_mesa_free_texture_object(NULL, ctx->Texture.Proxy2D);
@@ -1510,6 +1523,16 @@ alloc_proxy_textures( GLcontext *ctx )
return GL_FALSE;
}
+ ctx->Texture.ProxyRect = _mesa_alloc_texture_object(NULL, 0,
+ GL_TEXTURE_RECTANGLE_NV);
+ if (!ctx->Texture.ProxyRect) {
+ _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
+ _mesa_free_texture_object(NULL, ctx->Texture.Proxy2D);
+ _mesa_free_texture_object(NULL, ctx->Texture.Proxy3D);
+ _mesa_free_texture_object(NULL, ctx->Texture.ProxyCubeMap);
+ return GL_FALSE;
+ }
+
out_of_memory = GL_FALSE;
for (i=0;i<MAX_TEXTURE_LEVELS;i++) {
ctx->Texture.Proxy1D->Image[i] = _mesa_alloc_texture_image();
@@ -1523,6 +1546,10 @@ alloc_proxy_textures( GLcontext *ctx )
out_of_memory = GL_TRUE;
}
}
+ ctx->Texture.ProxyRect->Image[0] = _mesa_alloc_texture_image();
+ if (!ctx->Texture.ProxyRect->Image[0])
+ out_of_memory = GL_TRUE;
+
if (out_of_memory) {
for (i=0;i<MAX_TEXTURE_LEVELS;i++) {
if (ctx->Texture.Proxy1D->Image[i]) {
@@ -1538,10 +1565,14 @@ alloc_proxy_textures( GLcontext *ctx )
_mesa_free_texture_image(ctx->Texture.ProxyCubeMap->Image[i]);
}
}
+ if (ctx->Texture.ProxyRect->Image[0]) {
+ _mesa_free_texture_image(ctx->Texture.ProxyRect->Image[0]);
+ }
_mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
_mesa_free_texture_object(NULL, ctx->Texture.Proxy2D);
_mesa_free_texture_object(NULL, ctx->Texture.Proxy3D);
_mesa_free_texture_object(NULL, ctx->Texture.ProxyCubeMap);
+ _mesa_free_texture_object(NULL, ctx->Texture.ProxyRect);
return GL_FALSE;
}
else {
@@ -1647,6 +1678,7 @@ _mesa_initialize_context( GLcontext *ctx,
ctx->Shared->Default2D->RefCount += MAX_TEXTURE_UNITS;
ctx->Shared->Default3D->RefCount += MAX_TEXTURE_UNITS;
ctx->Shared->DefaultCubeMap->RefCount += MAX_TEXTURE_UNITS;
+ ctx->Shared->DefaultRect->RefCount += MAX_TEXTURE_UNITS;
init_attrib_groups( ctx );
@@ -1862,6 +1894,7 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_free_texture_object( NULL, ctx->Texture.Proxy2D );
_mesa_free_texture_object( NULL, ctx->Texture.Proxy3D );
_mesa_free_texture_object( NULL, ctx->Texture.ProxyCubeMap );
+ _mesa_free_texture_object( NULL, ctx->Texture.ProxyRect );
/* Free evaluator data */
if (ctx->EvalMap.Map1Vertex3.Points)
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index bb0c4b705b..eb031e8d66 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.65 2002/06/15 02:38:15 brianp Exp $ */
+/* $Id: enable.c,v 1.66 2002/06/15 03:03:07 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -539,9 +539,9 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
case GL_TEXTURE_1D: {
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
- GLuint newenabled = texUnit->Enabled & ~TEXTURE0_1D;
+ GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT;
if (state)
- newenabled |= TEXTURE0_1D;
+ newenabled |= TEXTURE_1D_BIT;
if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
@@ -551,9 +551,9 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
case GL_TEXTURE_2D: {
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
- GLuint newenabled = texUnit->Enabled & ~TEXTURE0_2D;
+ GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT;
if (state)
- newenabled |= TEXTURE0_2D;
+ newenabled |= TEXTURE_2D_BIT;
if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
@@ -563,9 +563,9 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
case GL_TEXTURE_3D: {
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
- GLuint newenabled = texUnit->Enabled & ~TEXTURE0_3D;
+ GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT;
if (state)
- newenabled |= TEXTURE0_3D;
+ newenabled |= TEXTURE_3D_BIT;
if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
@@ -720,10 +720,10 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
{
const GLuint curr = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
- GLuint newenabled = texUnit->Enabled & ~TEXTURE0_CUBE;
+ GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT;
CHECK_EXTENSION(ARB_texture_cube_map);
if (state)
- newenabled |= TEXTURE0_CUBE;
+ newenabled |= TEXTURE_CUBE_BIT;
if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
@@ -872,6 +872,22 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
}
break;
+ /* GL_NV_texture_rectangle */
+ case GL_TEXTURE_RECTANGLE_NV:
+ {
+ const GLuint curr = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
+ GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT;
+ CHECK_EXTENSION(NV_texture_rectangle);
+ if (state)
+ newenabled |= TEXTURE_RECT_BIT;
+ if (!ctx->Visual.rgbMode || texUnit->Enabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Enabled = newenabled;
+ }
+ break;
+
default:
_mesa_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
return;
@@ -1021,19 +1037,19 @@ _mesa_IsEnabled( GLenum cap )
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE;
+ return (texUnit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE;
}
case GL_TEXTURE_2D:
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE;
+ return (texUnit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE;
}
case GL_TEXTURE_3D:
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE;
+ return (texUnit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE;
}
case GL_TEXTURE_GEN_Q:
{
@@ -1133,7 +1149,7 @@ _mesa_IsEnabled( GLenum cap )
{
const struct gl_texture_unit *texUnit;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE;
+ return (texUnit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE;
}
/* GL_ARB_multisample */
@@ -1236,6 +1252,15 @@ _mesa_IsEnabled( GLenum cap )
return ctx->Eval.Map2Attrib[map];
}
+ /* GL_NV_texture_rectangle */
+ case GL_TEXTURE_RECTANGLE_NV:
+ CHECK_EXTENSION(NV_texture_rectangle);
+ {
+ const struct gl_texture_unit *texUnit;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE;
+ }
+
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
return GL_FALSE;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index c86bf7ce2d..bfecb3af7b 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -1,4 +1,4 @@
-/* $Id: extensions.c,v 1.74 2002/05/27 17:04:53 brianp Exp $ */
+/* $Id: extensions.c,v 1.75 2002/06/15 03:03:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -114,6 +114,7 @@ static struct {
{ ON, "GL_MESA_window_pos", F(MESA_window_pos) },
{ OFF, "GL_NV_blend_square", F(NV_blend_square) },
{ OFF, "GL_NV_point_sprite", F(NV_point_sprite) },
+ { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) },
{ ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) },
{ OFF, "GL_NV_vertex_program", F(NV_vertex_program) },
{ OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) },
@@ -178,6 +179,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
"GL_MESA_resize_buffers",
"GL_NV_blend_square",
"GL_NV_point_sprite",
+ "GL_NV_texture_rectangle",
"GL_NV_texgen_reflection",
"GL_NV_vertex_program",
"GL_NV_vertex_program1_1",
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 7f718a7b21..e723d18d5e 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.81 2002/06/15 02:38:15 brianp Exp $ */
+/* $Id: get.c,v 1.82 2002/06/15 03:03:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1441,6 +1441,20 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
*params = 0;
break;
+ /* GL_NV_texture_rectangle */
+ case GL_TEXTURE_RECTANGLE_NV:
+ CHECK_EXTENSION_B(NV_texture_rectangle);
+ *params = _mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV);
+ break;
+ case GL_TEXTURE_BINDING_RECTANGLE_NV:
+ CHECK_EXTENSION_B(NV_texture_rectangle);
+ *params = INT_TO_BOOL(textureUnit->CurrentRect->Name);
+ break;
+ case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV:
+ CHECK_EXTENSION_B(NV_texture_rectangle);
+ *params = INT_TO_BOOL(ctx->Const.MaxTextureRectSize);
+ break;
+
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" );
}
@@ -2677,6 +2691,20 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
/* GL_NV_vertex_program */
/* XXX to do */
+ /* GL_NV_texture_rectangle */
+ case GL_TEXTURE_RECTANGLE_NV:
+ CHECK_EXTENSION_D(NV_texture_rectangle);
+ *params = (GLdouble) _mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV);
+ break;
+ case GL_TEXTURE_BINDING_RECTANGLE_NV:
+ CHECK_EXTENSION_D(NV_texture_rectangle);
+ *params = (GLdouble) textureUnit->CurrentRect->Name;
+ break;
+ case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV:
+ CHECK_EXTENSION_D(NV_texture_rectangle);
+ *params = (GLdouble) ctx->Const.MaxTextureRectSize;
+ break;
+
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glGetDoublev" );
}
@@ -3896,6 +3924,20 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
/* GL_NV_vertex_program */
/* XXX to do */
+ /* GL_NV_texture_rectangle */
+ case GL_TEXTURE_RECTANGLE_NV:
+ CHECK_EXTENSION_F(NV_texture_rectangle);
+ *params = (GLfloat) _mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV);
+ break;
+ case GL_TEXTURE_BINDING_RECTANGLE_NV:
+ CHECK_EXTENSION_F(NV_texture_rectangle);
+ *params = (GLfloat) textureUnit->CurrentRect->Name;
+ break;
+ case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV:
+ CHECK_EXTENSION_F(NV_texture_rectangle);
+ *params = (GLfloat) ctx->Const.MaxTextureRectSize;
+ break;
+
default:
GET_FLOAT_ERROR;
}
@@ -5153,6 +5195,20 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
/* GL_NV_vertex_program */
/* XXX to do */
+ /* GL_NV_texture_rectangle */
+ case GL_TEXTURE_RECTANGLE_NV:
+ CHECK_EXTENSION_I(NV_texture_rectangle);
+ *params = (GLint) _mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV);
+ break;
+ case GL_TEXTURE_BINDING_RECTANGLE_NV:
+ CHECK_EXTENSION_I(NV_texture_rectangle);
+ *params = (GLint) textureUnit->CurrentRect->Name;
+ break;
+ case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV:
+ CHECK_EXTENSION_I(NV_texture_rectangle);
+ *params = (GLint) ctx->Const.MaxTextureRectSize;
+ break;
+
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" );
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 846ed85de4..608d63244f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.79 2002/06/15 02:38:16 brianp Exp $ */
+/* $Id: mtypes.h,v 1.80 2002/06/15 03:03:08 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -726,52 +726,25 @@ struct gl_stencil_attrib {
#define R_BIT 4
#define Q_BIT 8
-#define NUM_TEXTURE_TARGETS 4 /* 1D, 2D, 3D and CUBE */
-
-/* Texture Enabled flags */
-#define TEXTURE0_1D 0x1 /* Texture unit 0 (default) */
-#define TEXTURE0_2D 0x2
-#define TEXTURE0_3D 0x4
-#define TEXTURE0_CUBE 0x8
-#define TEXTURE0_ANY (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D | TEXTURE0_CUBE)
-#define TEXTURE1_1D (TEXTURE0_1D << 4) /* Texture unit 1 */
-#define TEXTURE1_2D (TEXTURE0_2D << 4)
-#define TEXTURE1_3D (TEXTURE0_3D << 4)
-#define TEXTURE1_CUBE (TEXTURE0_CUBE << 4)
-#define TEXTURE1_ANY (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D | TEXTURE1_CUBE)
-#define TEXTURE2_1D (TEXTURE0_1D << 8) /* Texture unit 2 */
-#define TEXTURE2_2D (TEXTURE0_2D << 8)
-#define TEXTURE2_3D (TEXTURE0_3D << 8)
-#define TEXTURE2_CUBE (TEXTURE0_CUBE << 8)
-#define TEXTURE2_ANY (TEXTURE2_1D | TEXTURE2_2D | TEXTURE2_3D | TEXTURE2_CUBE)
-#define TEXTURE3_1D (TEXTURE0_1D << 12) /* Texture unit 3 */
-#define TEXTURE3_2D (TEXTURE0_2D << 12)
-#define TEXTURE3_3D (TEXTURE0_3D << 12)
-#define TEXTURE3_CUBE (TEXTURE0_CUBE << 12)
-#define TEXTURE3_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
-#define TEXTURE4_1D (TEXTURE0_1D << 16) /* Texture unit 4 */
-#define TEXTURE4_2D (TEXTURE0_2D << 16)
-#define TEXTURE4_3D (TEXTURE0_3D << 16)
-#define TEXTURE4_CUBE (TEXTURE0_CUBE << 16)
-#define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
-#define TEXTURE5_1D (TEXTURE0_1D << 20) /* Texture unit 5 */
-#define TEXTURE5_2D (TEXTURE0_2D << 20)
-#define TEXTURE5_3D (TEXTURE0_3D << 20)
-#define TEXTURE5_CUBE (TEXTURE0_CUBE << 20)
-#define TEXTURE5_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
-#define TEXTURE6_1D (TEXTURE0_1D << 24) /* Texture unit 6 */
-#define TEXTURE6_2D (TEXTURE0_2D << 24)
-#define TEXTURE6_3D (TEXTURE0_3D << 24)
-#define TEXTURE6_CUBE (TEXTURE0_CUBE << 24)
-#define TEXTURE6_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
-#define TEXTURE7_1D (TEXTURE0_1D << 28) /* Texture unit 7 */
-#define TEXTURE7_2D (TEXTURE0_2D << 28)
-#define TEXTURE7_3D (TEXTURE0_3D << 28)
-#define TEXTURE7_CUBE (TEXTURE0_CUBE << 28)
-#define TEXTURE7_ANY (TEXTURE3_1D | TEXTURE3_2D | TEXTURE3_3D | TEXTURE3_CUBE)
-
-/* Bitmap versions of the GL_ constants.
- */
+/* Texture.Unit[]._ReallyEnabled flags: */
+#define TEXTURE_1D_BIT 0x01
+#define TEXTURE_2D_BIT 0x02
+#define TEXTURE_3D_BIT 0x04
+#define TEXTURE_CUBE_BIT 0x08
+#define TEXTURE_RECT_BIT 0x10
+
+#define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
+
+/* Texture Enabled flags - XXX these are obsolete!!! */
+#define TEXTURE0_1D TEXTURE_1D_BIT
+#define TEXTURE0_2D TEXTURE_2D_BIT
+#define TEXTURE0_3D TEXTURE_3D_BIT
+#define TEXTURE0_CUBE TEXTURE_CUBE_BIT
+#define TEXTURE0_RECT TEXTURE_RECT_BIT
+#define TEXTURE0_ANY 0x1F
+
+
+/* Bitmap versions of the GL_ constants. */
#define TEXGEN_SPHERE_MAP 0x1
#define TEXGEN_OBJ_LINEAR 0x2
#define TEXGEN_EYE_LINEAR 0x4
@@ -788,8 +761,7 @@ struct gl_stencil_attrib {
-/* A selection of state flags to make driver and module's lives easier.
- */
+/* A selection of state flags to make driver and module's lives easier. */
#define ENABLE_TEXGEN0 0x1
#define ENABLE_TEXGEN1 0x2
#define ENABLE_TEXGEN2 0x4
@@ -846,6 +818,7 @@ struct gl_texture_format {
FetchTexelFunc FetchTexel3D;
};
+
/* Texture image record */
struct gl_texture_image {
GLenum Format; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
@@ -864,6 +837,9 @@ struct gl_texture_image {
GLuint HeightLog2; /* = log2(Height2) */
GLuint DepthLog2; /* = log2(Depth2) */
GLuint MaxLog2; /* = MAX(WidthLog2, HeightLog2) */
+ GLfloat WidthScale; /* used for mipmap lod computation */
+ GLfloat HeightScale; /* used for mipmap lod computation */
+ GLfloat DepthScale; /* used for mipmap lod computation */
GLvoid *Data; /* Image data, accessed via FetchTexel() */
const struct gl_texture_format *TexFormat;
@@ -883,7 +859,7 @@ struct gl_texture_object {
_glthread_Mutex Mutex; /* for thread safety */
GLint RefCount; /* reference count */
GLuint Name; /* an unsigned integer */
- GLuint Dimensions; /* 1 or 2 or 3 or 6 (cube map) */
+ GLenum Target; /* GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
GLfloat Priority; /* in [0,1] */
GLfloat BorderValues[4]; /* unclamped */
GLchan BorderColor[4]; /* clamped, as GLchan */
@@ -928,13 +904,10 @@ struct gl_texture_object {
};
-
-/*
- * Texture units are new with the multitexture extension.
- */
+/* Texture unit record */
struct gl_texture_unit {
- GLuint Enabled; /* bitmask of TEXTURE0_1D, _2D, _3D, _CUBE */
- GLuint _ReallyEnabled; /* 0 or one of TEXTURE0_1D, _2D, _3D, _CUBE */
+ GLuint Enabled; /* bitmask of TEXTURE_*_BIT flags */
+ GLuint _ReallyEnabled; /* 0 or exactly one of TEXTURE_*_BIT flags */
GLenum EnvMode; /* GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
GLfloat EnvColor[4];
@@ -972,6 +945,7 @@ struct gl_texture_unit {
struct gl_texture_object *Current2D;
struct gl_texture_object *Current3D;
struct gl_texture_object *CurrentCubeMap; /* GL_ARB_texture_cube_map */
+ struct gl_texture_object *CurrentRect; /* GL_NV_texture_rectangle */
struct gl_texture_object *_Current; /* Points to really enabled tex obj */
@@ -979,13 +953,17 @@ struct gl_texture_unit {
struct gl_texture_object Saved2D;
struct gl_texture_object Saved3D;
struct gl_texture_object SavedCubeMap;
+ struct gl_texture_object SavedRect;
};
+/* The texture attribute group */
struct gl_texture_attrib {
/* multitexture */
GLuint CurrentUnit; /* Active texture unit */
+ GLuint _EnabledUnits; /* one bit set for each really-enabled unit */
+ /* XXX this field will go away, use _EnabledUnits instead! */
GLuint _ReallyEnabled; /* enables for all texture units: */
/* = (Unit[0]._ReallyEnabled << 0) | */
/* (Unit[1]._ReallyEnabled << 4) | */
@@ -1001,6 +979,7 @@ struct gl_texture_attrib {
struct gl_texture_object *Proxy2D;
struct gl_texture_object *Proxy3D;
struct gl_texture_object *ProxyCubeMap;
+ struct gl_texture_object *ProxyRect;
/* GL_EXT_shared_texture_palette */
GLboolean SharedPalette;
@@ -1297,6 +1276,7 @@ struct gl_shared_state {
struct gl_texture_object *Default2D;
struct gl_texture_object *Default3D;
struct gl_texture_object *DefaultCubeMap;
+ struct gl_texture_object *DefaultRect;
/* GL_NV_vertex_program */
struct _mesa_HashTable *VertexPrograms;
@@ -1350,7 +1330,8 @@ struct gl_frame_buffer {
struct gl_constants {
GLint MaxTextureLevels;
GLint Max3DTextureLevels;
- GLint MaxCubeTextureLevels;
+ GLint MaxCubeTextureLevels; /* GL_ARB_texture_cube_map */
+ GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */
GLuint MaxTextureUnits;
GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
GLfloat MaxTextureLodBias; /* GL_EXT_texture_lod_bias */
@@ -1432,6 +1413,7 @@ struct gl_extensions {
GLboolean MESA_sprite_point;
GLboolean NV_blend_square;
GLboolean NV_point_sprite;
+ GLboolean NV_texture_rectangle;
GLboolean NV_texgen_reflection;
GLboolean NV_vertex_program;
GLboolean NV_vertex_program1_1;
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index d94c9c7337..f1d83610b4 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -1,4 +1,4 @@
-/* $Id: state.c,v 1.84 2002/06/06 16:31:24 brianp Exp $ */
+/* $Id: state.c,v 1.85 2002/06/15 03:03:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -763,9 +763,10 @@ update_texture_matrices( GLcontext *ctx )
static void
update_texture_state( GLcontext *ctx )
{
- GLuint i;
+ GLuint unit;
- ctx->Texture._ReallyEnabled = 0;
+ ctx->Texture._ReallyEnabled = 0; /* XXX obsolete */
+ ctx->Texture._EnabledUnits = 0;
ctx->Texture._GenFlags = 0;
ctx->_NeedNormals &= ~NEED_NORMALS_TEXGEN;
ctx->_NeedEyeCoords &= ~NEED_EYE_TEXGEN;
@@ -774,8 +775,8 @@ update_texture_state( GLcontext *ctx )
/* Update texture unit state.
*/
- for (i=0; i < ctx->Const.MaxTextureUnits; i++) {
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
texUnit->_ReallyEnabled = 0;
texUnit->_GenFlags = 0;
@@ -783,49 +784,60 @@ update_texture_state( GLcontext *ctx )
if (!texUnit->Enabled)
continue;
- /* Find the texture of highest dimensionality that is enabled
- * and complete. We'll use it for texturing.
+ /* Look for the highest-priority texture target that's enabled and
+ * complete. That's the one we'll use for texturing.
*/
- if (texUnit->Enabled & TEXTURE0_CUBE) {
+ if (texUnit->Enabled & TEXTURE_CUBE_BIT) {
struct gl_texture_object *texObj = texUnit->CurrentCubeMap;
if (!texObj->Complete) {
_mesa_test_texobj_completeness(ctx, texObj);
}
if (texObj->Complete) {
- texUnit->_ReallyEnabled = TEXTURE0_CUBE;
+ texUnit->_ReallyEnabled = TEXTURE_CUBE_BIT;
texUnit->_Current = texObj;
}
}
- if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE0_3D)) {
+ if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE_3D_BIT)) {
struct gl_texture_object *texObj = texUnit->Current3D;
if (!texObj->Complete) {
_mesa_test_texobj_completeness(ctx, texObj);
}
if (texObj->Complete) {
- texUnit->_ReallyEnabled = TEXTURE0_3D;
+ texUnit->_ReallyEnabled = TEXTURE_3D_BIT;
texUnit->_Current = texObj;
}
}
- if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE0_2D)) {
+ if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE_RECT_BIT)) {
+ struct gl_texture_object *texObj = texUnit->CurrentRect;
+ if (!texObj->Complete) {
+ _mesa_test_texobj_completeness(ctx, texObj);
+ }
+ if (texObj->Complete) {
+ texUnit->_ReallyEnabled = TEXTURE_RECT_BIT;
+ texUnit->_Current = texObj;
+ }
+ }
+
+ if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE_2D_BIT)) {
struct gl_texture_object *texObj = texUnit->Current2D;
if (!texObj->Complete) {
_mesa_test_texobj_completeness(ctx, texObj);
}
if (texObj->Complete) {
- texUnit->_ReallyEnabled = TEXTURE0_2D;
+ texUnit->_ReallyEnabled = TEXTURE_2D_BIT;
texUnit->_Current = texObj;
}
}
- if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE0_1D)) {
+ if (!texUnit->_ReallyEnabled && (texUnit->Enabled & TEXTURE_1D_BIT)) {
struct gl_texture_object *texObj = texUnit->Current1D;
if (!texObj->Complete) {
_mesa_test_texobj_completeness(ctx, texObj);
}
if (texObj->Complete) {
- texUnit->_ReallyEnabled = TEXTURE0_1D;
+ texUnit->_ReallyEnabled = TEXTURE_1D_BIT;
texUnit->_Current = texObj;
}
}
@@ -835,9 +847,14 @@ update_texture_state( GLcontext *ctx )
continue;
}
+ /* Texture._ReallyEnabled records the enable state for all units in
+ * one word.
+ */
{
- GLuint flag = texUnit->_ReallyEnabled << (i * NUM_TEXTURE_TARGETS);
- ctx->Texture._ReallyEnabled |= flag;
+ GLuint flag = texUnit->_ReallyEnabled << (unit * NUM_TEXTURE_TARGETS);
+ ctx->Texture._ReallyEnabled |= flag; /* XXX obsolete field! */
+ if (texUnit->_ReallyEnabled)
+ ctx->Texture._EnabledUnits |= (1 << unit);
}
if (texUnit->TexGenEnabled) {
@@ -854,12 +871,12 @@ update_texture_state( GLcontext *ctx )
texUnit->_GenFlags |= texUnit->_GenBitR;
}
- ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(i);
+ ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit);
ctx->Texture._GenFlags |= texUnit->_GenFlags;
}
- if (ctx->TextureMatrixStack[i].Top->type != MATRIX_IDENTITY)
- ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(i);
+ if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY)
+ ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit);
}
if (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS) {
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 342bab3aac..2ad0df9d6b 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1,4 +1,4 @@
-/* $Id: teximage.c,v 1.108 2002/04/23 16:44:46 brianp Exp $ */
+/* $Id: teximage.c,v 1.109 2002/06/15 03:03:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -359,6 +359,10 @@ _mesa_set_tex_image(struct gl_texture_object *tObj,
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
tObj->NegZ[level] = texImage;
return;
+ case GL_TEXTURE_RECTANGLE_NV:
+ ASSERT(level == 0);
+ tObj->Image[level] = texImage;
+ return;
default:
_mesa_problem(NULL, "bad target in _mesa_set_tex_image()");
return;
@@ -435,6 +439,12 @@ _mesa_select_tex_object(GLcontext *ctx, const struct gl_texture_unit *texUnit,
case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
return ctx->Extensions.ARB_texture_cube_map
? ctx->Texture.ProxyCubeMap : NULL;
+ case GL_TEXTURE_RECTANGLE_NV:
+ return ctx->Extensions.NV_texture_rectangle
+ ? texUnit->CurrentRect : NULL;
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ return ctx->Extensions.NV_texture_rectangle
+ ? ctx->Texture.ProxyRect : NULL;
default:
_mesa_problem(NULL, "bad target in _mesa_select_tex_object()");
return NULL;
@@ -500,6 +510,22 @@ _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
return ctx->Texture.ProxyCubeMap->Image[level];
else
return NULL;
+ case GL_TEXTURE_RECTANGLE_NV:
+ if (ctx->Extensions.NV_texture_rectangle) {
+ ASSERT(level == 0);
+ return texUnit->CurrentRect->Image[level];
+ }
+ else {
+ return NULL;
+ }
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ if (ctx->Extensions.NV_texture_rectangle) {
+ ASSERT(level == 0);
+ return ctx->Texture.ProxyRect->Image[level];
+ }
+ else {
+ return NULL;
+ }
default:
_mesa_problem(ctx, "bad target in _mesa_select_tex_image()");
return NULL;
@@ -598,7 +624,7 @@ clear_teximage_fields(struct gl_texture_image *img)
* Initialize basic fields of the gl_texture_image struct.
*/
void
-_mesa_init_teximage_fields(GLcontext *ctx,
+_mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
struct gl_texture_image *img,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum internalFormat)
@@ -625,6 +651,18 @@ _mesa_init_teximage_fields(GLcontext *ctx,
img->Depth2 = 1 << img->DepthLog2;
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
img->IsCompressed = is_compressed_format(ctx, internalFormat);
+ /* Compute Width/Height/DepthScale for mipmap lod computation */
+ if (target == GL_TEXTURE_RECTANGLE_NV) {
+ /* scale = 1.0 since texture coords directly map to texels */
+ img->WidthScale = 1.0;
+ img->HeightScale = 1.0;
+ img->DepthScale = 1.0;
+ }
+ else {
+ img->WidthScale = (GLfloat) img->Width;
+ img->HeightScale = (GLfloat) img->Height;
+ img->DepthScale = (GLfloat) img->Depth;
+ }
}
@@ -648,31 +686,73 @@ texture_error_check( GLcontext *ctx, GLenum target,
GLint maxLevels = 0, maxTextureSize;
if (dimensions == 1) {
- isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_1D);
- if (target != GL_TEXTURE_1D && !isProxy) {
+ if (target == GL_PROXY_TEXTURE_1D) {
+ isProxy = GL_TRUE;
+ }
+ else if (target == GL_TEXTURE_1D) {
+ isProxy = GL_FALSE;
+ }
+ else {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" );
return GL_TRUE;
}
maxLevels = ctx->Const.MaxTextureLevels;
}
else if (dimensions == 2) {
- isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_2D ||
- target == GL_PROXY_TEXTURE_CUBE_MAP_ARB);
- if (target != GL_TEXTURE_2D && !isProxy &&
- !(ctx->Extensions.ARB_texture_cube_map &&
- target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
- _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" );
- return GL_TRUE;
- }
- if (target == GL_PROXY_TEXTURE_2D || target == GL_TEXTURE_2D)
+ if (target == GL_PROXY_TEXTURE_2D) {
+ isProxy = GL_TRUE;
maxLevels = ctx->Const.MaxTextureLevels;
- else
+ }
+ else if (target == GL_TEXTURE_2D) {
+ isProxy = GL_FALSE;
+ maxLevels = ctx->Const.MaxTextureLevels;
+ }
+ else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
+ return GL_TRUE;
+ }
+ isProxy = GL_TRUE;
maxLevels = ctx->Const.MaxCubeTextureLevels;
+ }
+ else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
+ return GL_TRUE;
+ }
+ isProxy = GL_FALSE;
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ }
+ else if (target == GL_PROXY_TEXTURE_RECTANGLE_NV) {
+ if (!ctx->Extensions.NV_texture_rectangle) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
+ return GL_TRUE;
+ }
+ isProxy = GL_TRUE;
+ maxLevels = 1;
+ }
+ else if (target == GL_TEXTURE_RECTANGLE_NV) {
+ if (!ctx->Extensions.NV_texture_rectangle) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
+ return GL_TRUE;
+ }
+ isProxy = GL_FALSE;
+ maxLevels = 1;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
+ return GL_TRUE;
+ }
}
else if (dimensions == 3) {
- isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_3D);
- if (target != GL_TEXTURE_3D && !isProxy) {
+ if (target == GL_PROXY_TEXTURE_3D) {
+ isProxy = GL_TRUE;
+ }
+ else if (target == GL_TEXTURE_3D) {
+ isProxy = GL_FALSE;
+ }
+ else {
_mesa_error( ctx, GL_INVALID_ENUM, "glTexImage3D(target)" );
return GL_TRUE;
}
@@ -695,9 +775,24 @@ texture_error_check( GLcontext *ctx, GLenum target,
}
return GL_TRUE;
}
+ if ((target == GL_TEXTURE_RECTANGLE_NV ||
+ target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0) {
+ return GL_TRUE;
+ }
/* Width */
- if (width < 2 * border || width > 2 + maxTextureSize
+ if (target == GL_TEXTURE_RECTANGLE_NV ||
+ target == GL_PROXY_TEXTURE_RECTANGLE_NV) {
+ if (width < 1 || width > ctx->Const.MaxTextureRectSize) {
+ if (!isProxy) {
+ char message[100];
+ sprintf(message, "glTexImage%dD(width=%d)", dimensions, width);
+ _mesa_error(ctx, GL_INVALID_VALUE, message);
+ }
+ return GL_TRUE;
+ }
+ }
+ else if (width < 2 * border || width > 2 + maxTextureSize
|| logbase2( width - 2 * border ) < 0) {
if (!isProxy) {
char message[100];
@@ -708,7 +803,18 @@ texture_error_check( GLcontext *ctx, GLenum target,
}
/* Height */
- if (dimensions >= 2) {
+ if (target == GL_TEXTURE_RECTANGLE_NV ||
+ target == GL_PROXY_TEXTURE_RECTANGLE_NV) {
+ if (height < 1 || height > ctx->Const.MaxTextureRectSize) {
+ if (!isProxy) {
+ char message[100];
+ sprintf(message, "glTexImage%dD(height=%d)", dimensions, height);
+ _mesa_error(ctx, GL_INVALID_VALUE, message);
+ }
+ return GL_TRUE;
+ }
+ }
+ else if (dimensions >= 2) {
if (height < 2 * border || height > 2 + maxTextureSize
|| logbase2( height - 2 * border ) < 0) {
if (!isProxy) {
@@ -745,7 +851,18 @@ texture_error_check( GLcontext *ctx, GLenum target,
}
/* Level */
- if (level < 0 || level >= maxLevels) {
+ if (target == GL_TEXTURE_RECTANGLE_NV ||
+ target == GL_PROXY_TEXTURE_RECTANGLE_NV) {
+ if (level != 0) {
+ if (!isProxy) {
+ char message[100];
+ sprintf(message, "glTexImage2D(level=%d)", level);
+ _mesa_error(ctx, GL_INVALID_VALUE, message);
+ }
+ return GL_TRUE;
+ }
+ }
+ else if (level < 0 || level >= maxLevels) {
if (!isProxy) {
char message[100];
sprintf(message, "glTexImage%dD(level=%d)", dimensions, level);
@@ -966,10 +1083,15 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
maxLevels = ctx->Const.MaxTextureLevels;
}
else if (dimensions == 2) {
- if (ctx->Extensions.ARB_texture_cube_map) {
- if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB ||
- target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) &&
- target != GL_TEXTURE_2D) {
+ if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (target == GL_TEXTURE_RECTANGLE_NV) {
+ if (!ctx->Extensions.NV_texture_rectangle) {
_mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
return GL_TRUE;
}
@@ -978,8 +1100,10 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
_mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
return GL_TRUE;
}
- if (target == GL_PROXY_TEXTURE_2D && target == GL_TEXTURE_2D)
+ if (target == GL_TEXTURE_2D)
maxLevels = ctx->Const.MaxTextureLevels;
+ else if (target == GL_TEXTURE_RECTANGLE_NV)
+ maxLevels = 1;
else
maxLevels = ctx->Const.MaxCubeTextureLevels;
}
@@ -1211,6 +1335,9 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
else if (target == GL_TEXTURE_3D) {
maxLevels = ctx->Const.Max3DTextureLevels;
}
+ else if (target == GL_TEXTURE_RECTANGLE_NV) {
+ maxLevels = 1;
+ }
else {
maxLevels = ctx->Const.MaxCubeTextureLevels;
}
@@ -1354,7 +1481,8 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
texImage->Data = NULL;
}
clear_teximage_fields(texImage); /* not really needed, but helpful */
- _mesa_init_teximage_fields(ctx, texImage, postConvWidth, 1, 1,
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, 1, 1,
border, internalFormat);
if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
@@ -1410,7 +1538,8 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
struct gl_texture_image *texImage;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, texImage, postConvWidth, 1, 1,
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, 1, 1,
border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
@@ -1449,7 +1578,9 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
if (target == GL_TEXTURE_2D ||
(ctx->Extensions.ARB_texture_cube_map &&
target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) ||
+ (ctx->Extensions.NV_texture_rectangle &&
+ target == GL_TEXTURE_RECTANGLE_NV)) {
/* non-proxy target */
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
@@ -1479,8 +1610,9 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
texImage->Data = NULL;
}
clear_teximage_fields(texImage); /* not really needed, but helpful */
- _mesa_init_teximage_fields(ctx, texImage, postConvWidth, postConvHeight,
- 1, border, internalFormat);
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, postConvHeight, 1,
+ border, internalFormat);
if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
@@ -1527,7 +1659,9 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
}
else if (target == GL_PROXY_TEXTURE_2D ||
(target == GL_PROXY_TEXTURE_CUBE_MAP_ARB &&
- ctx->Extensions.ARB_texture_cube_map)) {
+ ctx->Extensions.ARB_texture_cube_map) ||
+ (target == GL_PROXY_TEXTURE_RECTANGLE_NV &&
+ ctx->Extensions.NV_texture_rectangle)) {
/* Proxy texture: check for errors and update proxy state */
GLenum error = texture_error_check(ctx, target, level, internalFormat,
format, type, 2,
@@ -1537,8 +1671,9 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
struct gl_texture_image *texImage;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, texImage, postConvWidth,
- postConvHeight, 1, border, internalFormat);
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, postConvHeight, 1,
+ border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
internalFormat, format, type,
@@ -1600,8 +1735,9 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
texImage->Data = NULL;
}
clear_teximage_fields(texImage); /* not really needed, but helpful */
- _mesa_init_teximage_fields(ctx, texImage, width, height, depth, border,
- internalFormat);
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ width, height, depth,
+ border, internalFormat);
if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
@@ -1657,7 +1793,7 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
struct gl_texture_image *texImage;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, texImage, width, height, 1,
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
@@ -1871,7 +2007,7 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
}
clear_teximage_fields(texImage); /* not really needed, but helpful */
- _mesa_init_teximage_fields(ctx, texImage, postConvWidth, 1, 1,
+ _mesa_init_teximage_fields(ctx, target, texImage, postConvWidth, 1, 1,
border, internalFormat);
@@ -1935,7 +2071,8 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
}
clear_teximage_fields(texImage); /* not really needed, but helpful */
- _mesa_init_teximage_fields(ctx, texImage, postConvWidth, postConvHeight, 1,
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, postConvHeight, 1,
border, internalFormat);
ASSERT(ctx->Driver.CopyTexImage2D);
@@ -2119,7 +2256,7 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
texImage->Data = NULL;
}
- _mesa_init_teximage_fields(ctx, texImage, width, 1, 1,
+ _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
border, internalFormat);
if (ctx->Extensions.ARB_texture_compression) {
@@ -2144,7 +2281,7 @@ _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
struct gl_texture_image *texImage;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, texImage, width, 1, 1,
+ _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
@@ -2191,7 +2328,9 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
if (target == GL_TEXTURE_2D ||
(ctx->Extensions.ARB_texture_cube_map &&
target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
- target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) ||
+ (ctx->Extensions.NV_texture_rectangle &&
+ target == GL_TEXTURE_RECTANGLE_NV)) {
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
@@ -2218,8 +2357,8 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
texImage->Data = NULL;
}
- _mesa_init_teximage_fields(ctx, texImage, width, height, 1, border,
- internalFormat);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ border, internalFormat);
if (ctx->Extensions.ARB_texture_compression) {
ASSERT(ctx->Driver.CompressedTexImage2D);
@@ -2243,7 +2382,7 @@ _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
struct gl_texture_image *texImage;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, texImage, width, height, 1,
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
@@ -2316,8 +2455,8 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
texImage->Data = NULL;
}
- _mesa_init_teximage_fields(ctx, texImage, width, height, depth, border,
- internalFormat);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, depth,
+ border, internalFormat);
if (ctx->Extensions.ARB_texture_compression) {
ASSERT(ctx->Driver.CompressedTexImage3D);
@@ -2342,7 +2481,8 @@ _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
struct gl_texture_image *texImage;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
- _mesa_init_teximage_fields(ctx, texImage, width, height, depth,
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ width, height, depth,
border, internalFormat);
ASSERT(ctx->Driver.TestProxyTexImage);
error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index b86a280512..03b052c414 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -1,4 +1,4 @@
-/* $Id: teximage.h,v 1.20 2001/11/18 22:48:13 brianp Exp $ */
+/* $Id: teximage.h,v 1.21 2002/06/15 03:03:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -48,7 +48,7 @@ _mesa_free_texture_image( struct gl_texture_image *teximage );
extern void
-_mesa_init_teximage_fields(GLcontext *ctx,
+_mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
struct gl_texture_image *img,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum internalFormat);
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 97140723e7..f41bc13a17 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1,4 +1,4 @@
-/* $Id: texobj.c,v 1.54 2002/06/15 02:38:16 brianp Exp $ */
+/* $Id: texobj.c,v 1.55 2002/06/15 03:03:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -49,17 +49,23 @@
* table.
* Input: shared - the shared GL state structure to contain the texture object
* name - integer name for the texture object
- * dimensions - either 1, 2, 3 or 6 (cube map)
+ * target - either GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D,
+ * GL_TEXTURE_CUBE_MAP_ARB or GL_TEXTURE_RECTANGLE_NV
* zero is ok for the sake of GenTextures()
* Return: pointer to new texture object
*/
struct gl_texture_object *
_mesa_alloc_texture_object( struct gl_shared_state *shared,
- GLuint name, GLuint dimensions )
+ GLuint name, GLenum target )
{
struct gl_texture_object *obj;
- ASSERT(dimensions <= 3 || dimensions == 6);
+ ASSERT(target == 0 ||
+ target == GL_TEXTURE_1D ||
+ target == GL_TEXTURE_2D ||
+ target == GL_TEXTURE_3D ||
+ target == GL_TEXTURE_CUBE_MAP_ARB ||
+ target == GL_TEXTURE_RECTANGLE_NV);
obj = CALLOC_STRUCT(gl_texture_object);
@@ -68,12 +74,20 @@ _mesa_alloc_texture_object( struct gl_shared_state *shared,
_glthread_INIT_MUTEX(obj->Mutex);
obj->RefCount = 1;
obj->Name = name;
- obj->Dimensions = dimensions;
+ obj->Target = target;
obj->Priority = 1.0F;
- obj->WrapS = GL_REPEAT;
- obj->WrapT = GL_REPEAT;
- obj->WrapR = GL_REPEAT;
- obj->MinFilter = GL_NEAREST_MIPMAP_LINEAR;
+ if (target == GL_TEXTURE_RECTANGLE_NV) {
+ obj->WrapS = GL_CLAMP_TO_EDGE;
+ obj->WrapT = GL_CLAMP_TO_EDGE;
+ obj->WrapR = GL_CLAMP_TO_EDGE;
+ obj->MinFilter = GL_LINEAR;
+ }
+ else {
+ obj->WrapS = GL_REPEAT;
+ obj->WrapT = GL_REPEAT;
+ obj->WrapR = GL_REPEAT;
+ obj->MinFilter = GL_NEAREST_MIPMAP_LINEAR;
+ }
obj->MagFilter = GL_LINEAR;
obj->MinLod = -1000.0;
obj->MaxLod = 1000.0;
@@ -196,24 +210,32 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
/* Compute _MaxLevel */
- if (t->Dimensions == 1) {
+ if (t->Target == GL_TEXTURE_1D) {
maxLog2 = t->Image[baseLevel]->WidthLog2;
maxLevels = ctx->Const.MaxTextureLevels;
}
- else if (t->Dimensions == 2 || t->Dimensions == 6) {
+ else if (t->Target == GL_TEXTURE_2D) {
maxLog2 = MAX2(t->Image[baseLevel]->WidthLog2,
t->Image[baseLevel]->HeightLog2);
- maxLevels = (t->Dimensions == 2) ?
- ctx->Const.MaxTextureLevels : ctx->Const.MaxCubeTextureLevels;
+ maxLevels = ctx->Const.MaxTextureLevels;
}
- else if (t->Dimensions == 3) {
+ else if (t->Target == GL_TEXTURE_3D) {
GLint max = MAX2(t->Image[baseLevel]->WidthLog2,
t->Image[baseLevel]->HeightLog2);
maxLog2 = MAX2(max, (GLint)(t->Image[baseLevel]->DepthLog2));
maxLevels = ctx->Const.Max3DTextureLevels;
}
+ else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) {
+ maxLog2 = MAX2(t->Image[baseLevel]->WidthLog2,
+ t->Image[baseLevel]->HeightLog2);
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ }
+ else if (t->Target == GL_TEXTURE_RECTANGLE_NV) {
+ maxLog2 = 0; /* not applicable */
+ maxLevels = 1; /* no mipmapping */
+ }
else {
- _mesa_problem(ctx, "Bad t->Dimension in _mesa_test_texobj_completeness");
+ _mesa_problem(ctx, "Bad t->Target in _mesa_test_texobj_completeness");
return;
}
@@ -226,7 +248,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
/* Compute _MaxLambda = q - b (see the 1.2 spec) used during mipmapping */
t->_MaxLambda = (GLfloat) (t->_MaxLevel - t->BaseLevel);
- if (t->Dimensions == 6) {
+ if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) {
/* make sure that all six cube map level 0 images are the same size */
const GLuint w = t->Image[baseLevel]->Width2;
const GLuint h = t->Image[baseLevel]->Height2;
@@ -282,7 +304,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
/* Test things which depend on number of texture image dimensions */
- if (t->Dimensions == 1) {
+ if (t->Target == GL_TEXTURE_1D) {
/* Test 1-D mipmaps */
GLuint width = t->Image[baseLevel]->Width2;
for (i = baseLevel + 1; i < maxLevels; i++) {
@@ -306,7 +328,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
}
}
- else if (t->Dimensions == 2) {
+ else if (t->Target == GL_TEXTURE_2D) {
/* Test 2-D mipmaps */
GLuint width = t->Image[baseLevel]->Width2;
GLuint height = t->Image[baseLevel]->Height2;
@@ -339,7 +361,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
}
}
- else if (t->Dimensions == 3) {
+ else if (t->Target == GL_TEXTURE_3D) {
/* Test 3-D mipmaps */
GLuint width = t->Image[baseLevel]->Width2;
GLuint height = t->Image[baseLevel]->Height2;
@@ -386,7 +408,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
}
}
- else if (t->Dimensions == 6) {
+ else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) {
/* make sure 6 cube faces are consistant */
GLuint width = t->Image[baseLevel]->Width2;
GLuint height = t->Image[baseLevel]->Height2;
@@ -428,8 +450,12 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
}
}
+ else if (t->Target == GL_TEXTURE_RECTANGLE_NV) {
+ /* XXX special checking? */
+
+ }
else {
- /* Dimensions = ??? */
+ /* Target = ??? */
_mesa_problem(ctx, "Bug in gl_test_texture_object_completeness\n");
}
}
@@ -473,8 +499,8 @@ _mesa_GenTextures( GLsizei n, GLuint *texName )
/* Allocate new, empty texture objects */
for (i=0;i<n;i++) {
GLuint name = first + i;
- GLuint dims = 0;
- (void) _mesa_alloc_texture_object( ctx->Shared, name, dims);
+ GLenum target = 0;
+ (void) _mesa_alloc_texture_object( ctx->Shared, name, target);
}
_glthread_UNLOCK_MUTEX(GenTexturesLock);
@@ -561,7 +587,6 @@ _mesa_BindTexture( GLenum target, GLuint texName )
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
struct gl_texture_object *oldTexObj;
struct gl_texture_object *newTexObj = 0;
- GLuint targetDim;
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
@@ -570,24 +595,28 @@ _mesa_BindTexture( GLenum target, GLuint texName )
switch (target) {
case GL_TEXTURE_1D:
- targetDim = 1;
oldTexObj = texUnit->Current1D;
break;
case GL_TEXTURE_2D:
- targetDim = 2;
oldTexObj = texUnit->Current2D;
break;
case GL_TEXTURE_3D:
- targetDim = 3;
oldTexObj = texUnit->Current3D;
break;
case GL_TEXTURE_CUBE_MAP_ARB:
- if (ctx->Extensions.ARB_texture_cube_map) {
- targetDim = 6;
- oldTexObj = texUnit->CurrentCubeMap;
- break;
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
+ return;
+ }
+ oldTexObj = texUnit->CurrentCubeMap;
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ if (!ctx->Extensions.NV_texture_rectangle) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
+ return;
}
- /* fallthrough */
+ oldTexObj = texUnit->CurrentRect;
+ break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
return;
@@ -614,6 +643,9 @@ _mesa_BindTexture( GLenum target, GLuint texName )
case GL_TEXTURE_CUBE_MAP_ARB:
newTexObj = ctx->Shared->DefaultCubeMap;
break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ newTexObj = ctx->Shared->DefaultRect;
+ break;
default:
; /* Bad targets are caught above */
}
@@ -624,23 +656,30 @@ _mesa_BindTexture( GLenum target, GLuint texName )
newTexObj = (struct gl_texture_object *) _mesa_HashLookup(hash, texName);
if (newTexObj) {
/* error checking */
- if (newTexObj->Dimensions > 0 && newTexObj->Dimensions != targetDim) {
+ if (newTexObj->Target != 0 && newTexObj->Target != target) {
/* the named texture object's dimensions don't match the target */
_mesa_error( ctx, GL_INVALID_OPERATION,
"glBindTexture(wrong dimensionality)" );
return;
}
+ if (newTexObj->Target == 0 && target == GL_TEXTURE_RECTANGLE_NV) {
+ /* have to init wrap and filter state here - kind of klunky */
+ newTexObj->WrapS = GL_CLAMP_TO_EDGE;
+ newTexObj->WrapT = GL_CLAMP_TO_EDGE;
+ newTexObj->WrapR = GL_CLAMP_TO_EDGE;
+ newTexObj->MinFilter = GL_LINEAR;
+ }
}
else {
/* if this is a new texture id, allocate a texture object now */
newTexObj = _mesa_alloc_texture_object( ctx->Shared, texName,
- targetDim);
+ target);
if (!newTexObj) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture");
return;
}
}
- newTexObj->Dimensions = targetDim;
+ newTexObj->Target = target;
}
newTexObj->RefCount++;
@@ -662,8 +701,12 @@ _mesa_BindTexture( GLenum target, GLuint texName )
case GL_TEXTURE_CUBE_MAP_ARB:
texUnit->CurrentCubeMap = newTexObj;
break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ texUnit->CurrentRect = newTexObj;
+ break;
default:
_mesa_problem(ctx, "bad target in BindTexture");
+ return;
}
/* Pass BindTexture call to device driver */
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index d359aa9ba2..3257dc761f 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -1,10 +1,10 @@
-/* $Id: texobj.h,v 1.6 2001/03/12 00:48:39 gareth Exp $ */
+/* $Id: texobj.h,v 1.7 2002/06/15 03:03:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 4.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2002 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"),
@@ -39,7 +39,7 @@
extern struct gl_texture_object *
_mesa_alloc_texture_object( struct gl_shared_state *shared, GLuint name,
- GLuint dimensions );
+ GLenum target );
extern void
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 8319613804..2284499bf3 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.74 2002/06/15 02:38:16 brianp Exp $ */
+/* $Id: texstate.c,v 1.75 2002/06/15 03:03:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -967,11 +967,19 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
texObj = texUnit->Current3D;
break;
case GL_TEXTURE_CUBE_MAP_ARB:
- if (ctx->Extensions.ARB_texture_cube_map) {
- texObj = texUnit->CurrentCubeMap;
- break;
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" );
+ return;
}
- /* fallthrough */
+ texObj = texUnit->CurrentCubeMap;
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ if (!ctx->Extensions.NV_texture_rectangle) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" );
+ return;
+ }
+ texObj = texUnit->CurrentRect;
+ break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" );
return;
@@ -983,11 +991,15 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
if (texObj->MinFilter == eparam)
return;
- if (eparam==GL_NEAREST || eparam==GL_LINEAR
- || eparam==GL_NEAREST_MIPMAP_NEAREST
- || eparam==GL_LINEAR_MIPMAP_NEAREST
- || eparam==GL_NEAREST_MIPMAP_LINEAR
- || eparam==GL_LINEAR_MIPMAP_LINEAR) {
+ if (eparam==GL_NEAREST || eparam==GL_LINEAR) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->MinFilter = eparam;
+ }
+ else if ((eparam==GL_NEAREST_MIPMAP_NEAREST ||
+ eparam==GL_LINEAR_MIPMAP_NEAREST ||
+ eparam==GL_NEAREST_MIPMAP_LINEAR ||
+ eparam==GL_LINEAR_MIPMAP_LINEAR) &&
+ texObj->Target != GL_TEXTURE_RECTANGLE_NV) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->MinFilter = eparam;
}
@@ -1013,13 +1025,18 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
case GL_TEXTURE_WRAP_S:
if (texObj->WrapS == eparam)
return;
- if (eparam==GL_CLAMP ||
- eparam==GL_REPEAT ||
- eparam==GL_CLAMP_TO_EDGE ||
+ if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE ||
(eparam == GL_CLAMP_TO_BORDER_ARB &&
- ctx->Extensions.ARB_texture_border_clamp) ||
- (eparam == GL_MIRRORED_REPEAT_ARB &&
- ctx->Extensions.ARB_texture_mirrored_repeat)) {
+ ctx->Extensions.ARB_texture_border_clamp)) {
+ /* any texture target */
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->WrapS = eparam;
+ }
+ else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV &&
+ (eparam == GL_REPEAT ||
+ (eparam == GL_MIRRORED_REPEAT_ARB &&
+ ctx->Extensions.ARB_texture_mirrored_repeat))) {
+ /* non-rectangle texture */
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->WrapS = eparam;
}
@@ -1031,13 +1048,18 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
case GL_TEXTURE_WRAP_T:
if (texObj->WrapT == eparam)
return;
- if (eparam==GL_CLAMP ||
- eparam==GL_REPEAT ||
- eparam==GL_CLAMP_TO_EDGE ||
+ if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE ||
(eparam == GL_CLAMP_TO_BORDER_ARB &&
- ctx->Extensions.ARB_texture_border_clamp) ||
- (eparam == GL_MIRRORED_REPEAT_ARB &&
- ctx->Extensions.ARB_texture_mirrored_repeat)) {
+ ctx->Extensions.ARB_texture_border_clamp)) {
+ /* any texture target */
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->WrapT = eparam;
+ }
+ else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV &&
+ (eparam == GL_REPEAT ||
+ (eparam == GL_MIRRORED_REPEAT_ARB &&
+ ctx->Extensions.ARB_texture_mirrored_repeat))) {
+ /* non-rectangle texture */
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->WrapT = eparam;
}
@@ -1049,13 +1071,18 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
case GL_TEXTURE_WRAP_R_EXT:
if (texObj->WrapR == eparam)
return;
- if (eparam==GL_CLAMP ||
- eparam==GL_REPEAT ||
- eparam==GL_CLAMP_TO_EDGE ||
+ if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE ||
(eparam == GL_CLAMP_TO_BORDER_ARB &&
- ctx->Extensions.ARB_texture_border_clamp) ||
- (eparam == GL_MIRRORED_REPEAT_ARB &&
- ctx->Extensions.ARB_texture_mirrored_repeat)) {
+ ctx->Extensions.ARB_texture_border_clamp)) {
+ /* any texture target */
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->WrapR = eparam;
+ }
+ else if (texObj->Target != GL_TEXTURE_RECTANGLE_NV &&
+ (eparam == GL_REPEAT ||
+ (eparam == GL_MIRRORED_REPEAT_ARB &&
+ ctx->Extensions.ARB_texture_mirrored_repeat))) {
+ /* non-rectangle texture */
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->WrapR = eparam;
}
@@ -1103,6 +1130,10 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
_mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
return;
}
+ if (target == GL_TEXTURE_RECTANGLE_NV && params[0] != 0.0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
+ return;
+ }
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texObj->BaseLevel = (GLint) params[0];
break;
@@ -1321,6 +1352,9 @@ tex_image_dimensions(GLcontext *ctx, GLenum target)
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
return ctx->Extensions.ARB_texture_cube_map ? 2 : 0;
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ return ctx->Extensions.NV_texture_rectangle ? 2 : 0;
default:
_mesa_problem(ctx, "bad target in _mesa_tex_target_dimensions()");
return 0;
@@ -1358,9 +1392,17 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
case GL_PROXY_TEXTURE_3D:
maxLevels = ctx->Const.Max3DTextureLevels;
break;
- default:
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
maxLevels = ctx->Const.MaxCubeTextureLevels;
break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ maxLevels = 1;
+ break;
+ default:
+ _mesa_problem(ctx, "bad target in _mesa_GetTexLevelParameter");
+ return;
}
if (level < 0 || level >= maxLevels) {
@@ -1381,7 +1423,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
isProxy = (target == GL_PROXY_TEXTURE_1D) ||
(target == GL_PROXY_TEXTURE_2D) ||
(target == GL_PROXY_TEXTURE_3D) ||
- (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB);
+ (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) ||
+ (target == GL_PROXY_TEXTURE_RECTANGLE_NV);
switch (pname) {
case GL_TEXTURE_WIDTH:
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index abf2d1472f..7d37bcb00f 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1,4 +1,4 @@
-/* $Id: texstore.c,v 1.36 2002/04/04 16:59:05 brianp Exp $ */
+/* $Id: texstore.c,v 1.37 2002/06/15 03:03:09 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1617,6 +1617,7 @@ _mesa_generate_mipmap(GLcontext *ctx,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
0 };
+ const GLenum targetsRect[] = { GL_TEXTURE_RECTANGLE_NV, 0 };
const GLenum *targets;
GLint level;
GLint maxLevels = 0;
@@ -1624,23 +1625,27 @@ _mesa_generate_mipmap(GLcontext *ctx,
ASSERT(texObj);
ASSERT(texObj->Image[texObj->BaseLevel]);
- switch (texObj->Dimensions) {
- case 1:
+ switch (texObj->Target) {
+ case GL_TEXTURE_1D:
targets = targets1D;
maxLevels = ctx->Const.MaxTextureLevels;
break;
- case 2:
+ case GL_TEXTURE_2D:
targets = targets2D;
maxLevels = ctx->Const.MaxTextureLevels;
break;
- case 3:
+ case GL_TEXTURE_3D:
targets = targets3D;
maxLevels = ctx->Const.Max3DTextureLevels;
break;
- case 6:
+ case GL_TEXTURE_CUBE_MAP_ARB:
targets = targetsCube;
maxLevels = ctx->Const.MaxCubeTextureLevels;
break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ targets = targetsRect;
+ maxLevels = 1;
+ break;
default:
_mesa_problem(ctx,
"Bad texture object dimension in _mesa_generate_mipmaps");
@@ -1711,7 +1716,7 @@ _mesa_generate_mipmap(GLcontext *ctx,
MESA_PBUFFER_FREE(dstImage->Data);
/* initialize new image */
- _mesa_init_teximage_fields(ctx, dstImage, dstWidth, dstHeight,
+ _mesa_init_teximage_fields(ctx, t, dstImage, dstWidth, dstHeight,
dstDepth, border, srcImage->Format);
dstImage->DriverData = NULL;
dstImage->TexFormat = srcImage->TexFormat;
@@ -1732,23 +1737,26 @@ _mesa_generate_mipmap(GLcontext *ctx,
/*
* We use simple 2x2 averaging to compute the next mipmap level.
*/
- switch (texObj->Dimensions) {
- case 1:
+ switch (texObj->Target) {
+ case GL_TEXTURE_1D:
make_1d_mipmap(srcImage->TexFormat, border,
srcWidth, (const GLubyte *) srcImage->Data,
dstWidth, (GLubyte *) dstImage->Data);
break;
- case 2:
- case 6:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_CUBE_MAP_ARB:
make_2d_mipmap(srcImage->TexFormat, border,
srcWidth, srcHeight, (const GLubyte *) srcImage->Data,
dstWidth, dstHeight, (GLubyte *) dstImage->Data);
break;
- case 3:
+ case GL_TEXTURE_3D:
make_3d_mipmap(srcImage->TexFormat, border,
srcWidth, srcHeight, srcDepth, (const GLubyte *) srcImage->Data,
dstWidth, dstHeight, dstDepth, (GLubyte *) dstImage->Data);
break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ /* no mipmaps, do nothing */
+ break;
default:
_mesa_problem(ctx, "bad dimensions in _mesa_generate_mipmaps");
return;
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
index a3a041d0e4..5805fb3d06 100644
--- a/src/mesa/swrast/s_aaline.c
+++ b/src/mesa/swrast/s_aaline.c
@@ -1,4 +1,4 @@
-/* $Id: s_aaline.c,v 1.14 2002/04/19 14:05:50 brianp Exp $ */
+/* $Id: s_aaline.c,v 1.15 2002/06/15 03:03:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -513,8 +513,8 @@ _swrast_choose_aa_line_function(GLcontext *ctx)
if (ctx->Visual.rgbMode) {
/* RGBA */
- if (ctx->Texture._ReallyEnabled) {
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits != 0) {
+ if (ctx->Texture._EnabledUnits > 1) {
/* Multitextured! */
if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR ||
ctx->Fog.ColorSumEnabled)
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index ea939a5369..66796dff35 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_aatriangle.c,v 1.23 2002/03/16 18:02:07 brianp Exp $ */
+/* $Id: s_aatriangle.c,v 1.24 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -450,9 +450,9 @@ _mesa_set_aa_triangle_function(GLcontext *ctx)
{
ASSERT(ctx->Polygon.SmoothFlag);
- if (ctx->Texture._ReallyEnabled) {
+ if (ctx->Texture._EnabledUnits != 0) {
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits > 1) {
SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
}
else {
@@ -460,7 +460,7 @@ _mesa_set_aa_triangle_function(GLcontext *ctx)
}
}
else {
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits > 1) {
SWRAST_CONTEXT(ctx)->Triangle = multitex_aa_tri;
}
else {
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index e0180d1ca7..a4f59df8ae 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -1,4 +1,4 @@
-/* $Id: s_context.c,v 1.34 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: s_context.c,v 1.35 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -60,7 +60,7 @@ _swrast_update_rasterflags( GLcontext *ctx )
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
if (colorMask != 0xffffffff) RasterMask |= MASKING_BIT;
if (ctx->Color.ColorLogicOpEnabled) RasterMask |= LOGIC_OP_BIT;
- if (ctx->Texture._ReallyEnabled) RasterMask |= TEXTURE_BIT;
+ if (ctx->Texture._EnabledUnits) RasterMask |= TEXTURE_BIT;
}
else {
if (ctx->Color.IndexMask != 0xffffffff) RasterMask |= MASKING_BIT;
@@ -220,7 +220,7 @@ _swrast_validate_triangle( GLcontext *ctx,
swrast->choose_triangle( ctx );
if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
- !ctx->Texture._ReallyEnabled) {
+ ctx->Texture._EnabledUnits == 0) {
swrast->SpecTriangle = swrast->Triangle;
swrast->Triangle = _swrast_add_spec_terms_triangle;
}
@@ -237,7 +237,7 @@ _swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
swrast->choose_line( ctx );
if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
- !ctx->Texture._ReallyEnabled) {
+ ctx->Texture._EnabledUnits == 0) {
swrast->SpecLine = swrast->Line;
swrast->Line = _swrast_add_spec_terms_line;
}
@@ -255,7 +255,7 @@ _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 )
swrast->choose_point( ctx );
if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
- !ctx->Texture._ReallyEnabled) {
+ ctx->Texture._EnabledUnits == 0) {
swrast->SpecPoint = swrast->Point;
swrast->Point = _swrast_add_spec_terms_point;
}
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index bea0af4883..2c6bd26312 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -1,4 +1,4 @@
-/* $Id: s_copypix.c,v 1.37 2002/04/19 14:05:50 brianp Exp $ */
+/* $Id: s_copypix.c,v 1.38 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -257,7 +257,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
span->color.rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
}
- if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) {
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._EnabledUnits) {
span->end = width;
_swrast_pixel_texture(ctx, span);
}
@@ -500,7 +500,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
UNDEFARRAY(rgbaFloat); /* mac 32k limitation */
}
- if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) {
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._EnabledUnits) {
span->end = width;
_swrast_pixel_texture(ctx, span);
}
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index ab2dec8e19..0bee50400f 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: s_drawpix.c,v 1.34 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: s_drawpix.c,v 1.35 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -116,7 +116,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
_mesa_span_default_fog(ctx, span);
if ((SWRAST_CONTEXT(ctx)->_RasterMask & ~CLIP_BIT) == 0
- && ctx->Texture._ReallyEnabled == 0
+ && ctx->Texture._EnabledUnits == 0
&& unpack->Alignment == 1
&& !unpack->SwapBytes
&& !unpack->LsbFirst) {
@@ -817,7 +817,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
(ctx->Pixel.HistogramEnabled && ctx->Histogram.Sink))
continue;
- if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) {
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._EnabledUnits) {
span->end = width;
_swrast_pixel_texture(ctx, span);
}
diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c
index 19cc6f0cc3..e9e9c670d7 100644
--- a/src/mesa/swrast/s_lines.c
+++ b/src/mesa/swrast/s_lines.c
@@ -1,4 +1,4 @@
-/* $Id: s_lines.c,v 1.29 2002/04/19 14:05:50 brianp Exp $ */
+/* $Id: s_lines.c,v 1.30 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -771,8 +771,8 @@ _swrast_choose_line( GLcontext *ctx )
_swrast_choose_aa_line_function(ctx);
ASSERT(swrast->Triangle);
}
- else if (ctx->Texture._ReallyEnabled) {
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY ||
+ else if (ctx->Texture._EnabledUnits) {
+ if (ctx->Texture._EnabledUnits > 1 ||
(ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) {
/* multi-texture and/or separate specular color */
if (ctx->Light.ShadeModel == GL_SMOOTH)
diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c
index d84fc7bd94..0c060f16ef 100644
--- a/src/mesa/swrast/s_points.c
+++ b/src/mesa/swrast/s_points.c
@@ -1,4 +1,4 @@
-/* $Id: s_points.c,v 1.18 2002/05/27 17:04:53 brianp Exp $ */
+/* $Id: s_points.c,v 1.19 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -215,7 +215,7 @@ _swrast_choose_point( GLcontext *ctx )
if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
USE(atten_antialiased_rgba_point);
}
- else if (ctx->Texture._ReallyEnabled) {
+ else if (ctx->Texture._EnabledUnits) {
USE(antialiased_tex_rgba_point);
}
else {
@@ -228,7 +228,7 @@ _swrast_choose_point( GLcontext *ctx )
}
else if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
if (rgbMode) {
- if (ctx->Texture._ReallyEnabled) {
+ if (ctx->Texture._EnabledUnits) {
if (ctx->Point.SmoothFlag) {
USE(atten_antialiased_rgba_point);
}
@@ -245,7 +245,7 @@ _swrast_choose_point( GLcontext *ctx )
USE(atten_general_ci_point);
}
}
- else if (ctx->Texture._ReallyEnabled && rgbMode) {
+ else if (ctx->Texture._EnabledUnits && rgbMode) {
/* textured */
USE(textured_rgba_point);
}
diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h
index 1865e1a7d3..1fc8ba39f4 100644
--- a/src/mesa/swrast/s_pointtemp.h
+++ b/src/mesa/swrast/s_pointtemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_pointtemp.h,v 1.16 2002/05/27 17:04:53 brianp Exp $ */
+/* $Id: s_pointtemp.h,v 1.17 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -284,7 +284,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
ASSERT(span->end > 0);
#if FLAGS & (TEXTURE | SPRITE)
- if (ctx->Texture._ReallyEnabled)
+ if (ctx->Texture._EnabledUnits)
_mesa_write_texture_span(ctx, span);
else
_mesa_write_rgba_span(ctx, span);
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 0a1e317608..a3271d7806 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1,4 +1,4 @@
-/* $Id: s_span.c,v 1.43 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: s_span.c,v 1.44 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -345,7 +345,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
ASSERT(span->interpMask & SPAN_TEXTURE);
ASSERT(!(span->arrayMask & SPAN_TEXTURE));
- if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits > 1) {
/* multitexture */
GLuint u;
span->arrayMask |= SPAN_TEXTURE;
@@ -355,8 +355,8 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
const struct gl_texture_image *img = obj->Image[obj->BaseLevel];
GLboolean needLambda = (obj->MinFilter != obj->MagFilter);
if (needLambda) {
- const GLfloat texW = (GLfloat) img->Width;
- const GLfloat texH = (GLfloat) img->Height;
+ const GLfloat texW = (GLfloat) img->WidthScale;
+ const GLfloat texH = (GLfloat) img->HeightScale;
const GLfloat dsdx = span->texStepX[u][0];
const GLfloat dsdy = span->texStepY[u][0];
const GLfloat dtdx = span->texStepX[u][1];
@@ -432,8 +432,8 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
span->arrayMask |= SPAN_TEXTURE;
if (needLambda) {
/* just texture unit 0, with lambda */
- const GLfloat texW = (GLfloat) img->Width;
- const GLfloat texH = (GLfloat) img->Height;
+ const GLfloat texW = (GLfloat) img->WidthScale;
+ const GLfloat texH = (GLfloat) img->HeightScale;
const GLfloat dsdx = span->texStepX[0][0];
const GLfloat dsdy = span->texStepY[0][0];
const GLfloat dtdx = span->texStepX[0][1];
@@ -1137,7 +1137,7 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span)
span->primitive == GL_POLYGON || span->primitive == GL_BITMAP);
ASSERT(span->end <= MAX_WIDTH);
ASSERT((span->interpMask & span->arrayMask) == 0);
- ASSERT(ctx->Texture._ReallyEnabled);
+ ASSERT(ctx->Texture._EnabledUnits);
/*
printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__, span->interpMask, span->arrayMask);
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 97a8447c30..ab8b00abee 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -1,4 +1,4 @@
-/* $Id: s_texture.c,v 1.62 2002/05/02 00:59:20 brianp Exp $ */
+/* $Id: s_texture.c,v 1.63 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -2016,6 +2016,187 @@ sample_lambda_cube( GLcontext *ctx, GLuint texUnit,
}
+/**********************************************************************/
+/* Texture Rectangle Sampling Functions */
+/**********************************************************************/
+
+static void
+sample_nearest_rect(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4])
+{
+ const struct gl_texture_image *img = tObj->Image[0];
+ const GLfloat width = (GLfloat) img->Width;
+ const GLfloat height = (GLfloat) img->Height;
+ const GLint width_minus_1 = img->Width - 1;
+ const GLint height_minus_1 = img->Height - 1;
+ GLuint i;
+
+ (void) texUnit;
+ (void) lambda;
+
+ ASSERT(tObj->WrapS == GL_CLAMP ||
+ tObj->WrapS == GL_CLAMP_TO_EDGE ||
+ tObj->WrapS == GL_CLAMP_TO_BORDER_ARB);
+ ASSERT(tObj->WrapT == GL_CLAMP ||
+ tObj->WrapT == GL_CLAMP_TO_EDGE ||
+ tObj->WrapT == GL_CLAMP_TO_BORDER_ARB);
+ ASSERT(img->Format != GL_COLOR_INDEX);
+
+ /* XXX move Wrap mode tests outside of loops for common cases */
+ for (i = 0; i < n; i++) {
+ GLint row, col;
+ /* NOTE: we DO NOT use [0, 1] texture coordinates! */
+ if (tObj->WrapS == GL_CLAMP) {
+ col = IFLOOR( CLAMP(texcoords[i][0], 0.0F, width) );
+ }
+ else if (tObj->WrapS == GL_CLAMP_TO_EDGE) {
+ col = IFLOOR( CLAMP(texcoords[i][0], 0.5F, width - 0.5F) );
+ }
+ else {
+ col = IFLOOR( CLAMP(texcoords[i][0], -0.5F, width + 0.5F) );
+ }
+ if (tObj->WrapT == GL_CLAMP) {
+ row = IFLOOR( CLAMP(texcoords[i][1], 0.0F, height) );
+ }
+ else if (tObj->WrapT == GL_CLAMP_TO_EDGE) {
+ row = IFLOOR( CLAMP(texcoords[i][1], 0.5F, height - 0.5F) );
+ }
+ else {
+ row = IFLOOR( CLAMP(texcoords[i][1], -0.5F, height + 0.5F) );
+ }
+
+ col = CLAMP(col, 0, width_minus_1);
+ row = CLAMP(row, 0, height_minus_1);
+
+ (*img->FetchTexel)(img, col, row, 0, (GLvoid *) rgba[i]);
+ }
+}
+
+
+static void
+sample_linear_rect(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ const struct gl_texture_image *img = tObj->Image[0];
+ const GLfloat width = (GLfloat) img->Width;
+ const GLfloat height = (GLfloat) img->Height;
+ const GLint width_minus_1 = img->Width - 1;
+ const GLint height_minus_1 = img->Height - 1;
+ GLuint i;
+
+ (void) texUnit;
+ (void) lambda;
+
+ ASSERT(tObj->WrapS == GL_CLAMP ||
+ tObj->WrapS == GL_CLAMP_TO_EDGE ||
+ tObj->WrapS == GL_CLAMP_TO_BORDER_ARB);
+ ASSERT(tObj->WrapT == GL_CLAMP ||
+ tObj->WrapT == GL_CLAMP_TO_EDGE ||
+ tObj->WrapT == GL_CLAMP_TO_BORDER_ARB);
+ ASSERT(img->Format != GL_COLOR_INDEX);
+
+ /* XXX lots of opportunity for optimization in this loop */
+ for (i = 0; i < n; i++) {
+ GLfloat frow, fcol;
+ GLint row0, col0, row1, col1;
+ GLchan t00[4], t01[4], t10[4], t11[4];
+ GLfloat a, b, w00, w01, w10, w11;
+
+ /* NOTE: we DO NOT use [0, 1] texture coordinates! */
+ if (tObj->WrapS == GL_CLAMP) {
+ fcol = CLAMP(texcoords[i][0], 0.0F, width);
+ }
+ else if (tObj->WrapS == GL_CLAMP_TO_EDGE) {
+ fcol = CLAMP(texcoords[i][0], 0.5F, width - 0.5F);
+ }
+ else {
+ fcol = CLAMP(texcoords[i][0], -0.5F, width + 0.5F);
+ }
+ if (tObj->WrapT == GL_CLAMP) {
+ frow = CLAMP(texcoords[i][1], 0.0F, height);
+ }
+ else if (tObj->WrapT == GL_CLAMP_TO_EDGE) {
+ frow = CLAMP(texcoords[i][1], 0.5F, height - 0.5F);
+ }
+ else {
+ frow = CLAMP(texcoords[i][1], -0.5F, height + 0.5F);
+ }
+
+ /* compute integer rows/columns */
+ col0 = IFLOOR(fcol);
+ col1 = col0 + 1;
+ col0 = CLAMP(col0, 0, width_minus_1);
+ col1 = CLAMP(col1, 0, width_minus_1);
+ row0 = IFLOOR(frow);
+ row1 = row0 + 1;
+ row0 = CLAMP(row0, 0, height_minus_1);
+ row1 = CLAMP(row1, 0, height_minus_1);
+
+ /* get four texel samples */
+ (*img->FetchTexel)(img, col0, row0, 0, (GLvoid *) t00);
+ (*img->FetchTexel)(img, col1, row0, 0, (GLvoid *) t10);
+ (*img->FetchTexel)(img, col0, row1, 0, (GLvoid *) t01);
+ (*img->FetchTexel)(img, col1, row1, 0, (GLvoid *) t11);
+
+ /* compute sample weights */
+ a = FRAC(fcol);
+ b = FRAC(frow);
+ w00 = (1.0F-a) * (1.0F-b);
+ w10 = a * (1.0F-b);
+ w01 = (1.0F-a) * b ;
+ w11 = a * b ;
+
+ /* compute weighted average of samples */
+ rgba[i][0] = w00 * t00[0] + w10 * t10[0] + w01 * t01[0] + w11 * t11[0];
+ rgba[i][1] = w00 * t00[1] + w10 * t10[1] + w01 * t01[1] + w11 * t11[1];
+ rgba[i][2] = w00 * t00[2] + w10 * t10[2] + w01 * t01[2] + w11 * t11[2];
+ rgba[i][3] = w00 * t00[3] + w10 * t10[3] + w01 * t01[3] + w11 * t11[3];
+ }
+}
+
+
+static void
+sample_lambda_rect( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4])
+{
+ GLuint minStart, minEnd, magStart, magEnd;
+
+ /* We only need lambda to decide between minification and magnification.
+ * There is no mipmapping with rectangular textures.
+ */
+ compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
+ n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+
+ if (minStart < minEnd) {
+ if (tObj->MinFilter == GL_NEAREST) {
+ sample_nearest_rect( ctx, texUnit, tObj, minEnd - minStart,
+ texcoords + minStart, NULL, rgba + minStart);
+ }
+ else {
+ sample_linear_rect( ctx, texUnit, tObj, minEnd - minStart,
+ texcoords + minStart, NULL, rgba + minStart);
+ }
+ }
+ if (magStart < magEnd) {
+ if (tObj->MagFilter == GL_NEAREST) {
+ sample_nearest_rect( ctx, texUnit, tObj, magEnd - magStart,
+ texcoords + magStart, NULL, rgba + magStart);
+ }
+ else {
+ sample_linear_rect( ctx, texUnit, tObj, magEnd - magStart,
+ texcoords + magStart, NULL, rgba + magStart);
+ }
+ }
+}
+
+
+
/*
* Sample a shadow/depth texture.
*/
@@ -2036,7 +2217,9 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
(void) unit;
ASSERT(tObj->Image[tObj->BaseLevel]->Format == GL_DEPTH_COMPONENT);
- ASSERT(tObj->Dimensions == 1 || tObj->Dimensions == 2);
+ ASSERT(tObj->Target == GL_TEXTURE_1D ||
+ tObj->Target == GL_TEXTURE_2D ||
+ tObj->Target == GL_TEXTURE_RECTANGLE_NV);
/* XXXX if tObj->MinFilter != tObj->MagFilter, we're ignoring lambda */
@@ -2064,6 +2247,7 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
for (i = 0; i < n; i++) {
GLfloat depthSample;
GLint col, row;
+ /* XXX fix for texture rectangle! */
COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapS, texcoords[i][0], width, col);
COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapT, texcoords[i][1], height, row);
depthSample = *((const GLfloat *) texImage->Data + row * width + col);
@@ -2134,6 +2318,7 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
GLfloat u, v;
GLuint useBorderTexel;
+ /* XXX fix for texture rectangle! */
COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapS, texcoords[i][0], u, width, i0, i1);
COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapT, texcoords[i][1], v, height,j0, j1);
@@ -2317,7 +2502,7 @@ sample_depth_texture2(const GLcontext *ctx,
const GLchan ambient = texObj->ShadowAmbient;
GLboolean lequal, gequal;
- if (texObj->Dimensions != 2) {
+ if (texObj->Target != GL_TEXTURE_2D) {
_mesa_problem(ctx, "only 2-D depth textures supported at this time");
return;
}
@@ -2435,8 +2620,8 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
}
}
- switch (t->Dimensions) {
- case 1:
+ switch (t->Target) {
+ case GL_TEXTURE_1D:
if (format == GL_DEPTH_COMPONENT) {
swrast->TextureSample[texUnit] = sample_depth_texture;
}
@@ -2451,7 +2636,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
swrast->TextureSample[texUnit] = sample_nearest_1d;
}
break;
- case 2:
+ case GL_TEXTURE_2D:
if (format == GL_DEPTH_COMPONENT) {
swrast->TextureSample[texUnit] = sample_depth_texture;
}
@@ -2480,7 +2665,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
swrast->TextureSample[texUnit] = sample_nearest_2d;
}
break;
- case 3:
+ case GL_TEXTURE_3D:
if (needLambda) {
swrast->TextureSample[texUnit] = sample_lambda_3d;
}
@@ -2492,7 +2677,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
swrast->TextureSample[texUnit] = sample_nearest_3d;
}
break;
- case 6: /* cube map */
+ case GL_TEXTURE_CUBE_MAP_ARB:
if (needLambda) {
swrast->TextureSample[texUnit] = sample_lambda_cube;
}
@@ -2504,8 +2689,20 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
swrast->TextureSample[texUnit] = sample_nearest_cube;
}
break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ if (needLambda) {
+ swrast->TextureSample[texUnit] = sample_lambda_rect;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ swrast->TextureSample[texUnit] = sample_linear_rect;
+ }
+ else {
+ ASSERT(t->MinFilter == GL_NEAREST);
+ swrast->TextureSample[texUnit] = sample_nearest_rect;
+ }
+ break;
default:
- _mesa_problem(ctx, "invalid dimensions in _swrast_choose_texture_sample_func");
+ _mesa_problem(ctx, "invalid target in _swrast_choose_texture_sample_func");
}
}
}
@@ -2640,7 +2837,6 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n,
return;
argRGB[j] = (const GLchan (*)[4])
(texelBuffer + srcUnit * (n * 4 * sizeof(GLchan)));
- printf("unit %d from unit %d\n", unit, srcUnit);
}
}
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 1816624d67..bdbdde76b8 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.c,v 1.58 2002/04/19 14:05:50 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.59 2002/06/15 03:03:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -124,7 +124,7 @@ static void flat_rgba_triangle( GLcontext *ctx,
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
- ASSERT(!ctx->Texture._ReallyEnabled); \
+ ASSERT(ctx->Texture._EnabledUnits == 0); \
ASSERT(ctx->Light.ShadeModel==GL_FLAT); \
span->interpMask |= SPAN_RGBA; \
span->red = ChanToFixed(v2->color[0]); \
@@ -161,7 +161,7 @@ static void smooth_rgba_triangle( GLcontext *ctx,
#define SETUP_CODE \
{ \
/* texturing must be off */ \
- ASSERT(!ctx->Texture._ReallyEnabled); \
+ ASSERT(ctx->Texture._EnabledUnits == 0); \
ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \
}
@@ -1116,7 +1116,7 @@ _swrast_choose_triangle( GLcontext *ctx )
}
}
- if (ctx->Texture._ReallyEnabled) {
+ if (ctx->Texture._EnabledUnits) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */
const struct gl_texture_object *texObj2D;
const struct gl_texture_image *texImg;
@@ -1130,7 +1130,8 @@ _swrast_choose_triangle( GLcontext *ctx )
envMode = ctx->Texture.Unit[0].EnvMode;
/* First see if we can used an optimized 2-D texture function */
- if (ctx->Texture._ReallyEnabled==TEXTURE0_2D
+ if (ctx->Texture._EnabledUnits == 1
+ && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
&& texObj2D->WrapS==GL_REPEAT
&& texObj2D->WrapT==GL_REPEAT
&& texImg->Border==0
@@ -1172,7 +1173,7 @@ _swrast_choose_triangle( GLcontext *ctx )
}
else {
/* general case textured triangles */
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits > 1) {
USE(multitextured_triangle);
}
else {
@@ -1181,7 +1182,7 @@ _swrast_choose_triangle( GLcontext *ctx )
}
}
else {
- ASSERT(!ctx->Texture._ReallyEnabled);
+ ASSERT(!ctx->Texture._EnabledUnits);
if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* smooth shaded, no texturing, stippled or some raster ops */
if (rgbmode) {
diff --git a/src/mesa/swrast_setup/ss_vb.c b/src/mesa/swrast_setup/ss_vb.c
index b47508b6f6..fce1d489a0 100644
--- a/src/mesa/swrast_setup/ss_vb.c
+++ b/src/mesa/swrast_setup/ss_vb.c
@@ -1,4 +1,4 @@
-/* $Id: ss_vb.c,v 1.18 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: ss_vb.c,v 1.19 2002/06/15 03:03:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -388,10 +388,10 @@ _swsetup_choose_rastersetup_func(GLcontext *ctx)
if (ctx->Visual.rgbMode) {
funcindex = COLOR;
- if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY)
- funcindex |= MULTITEX;
- else if (ctx->Texture._ReallyEnabled & TEXTURE0_ANY)
- funcindex |= TEX0;
+ if (ctx->Texture._EnabledUnits > 1)
+ funcindex |= MULTITEX; /* a unit above unit[0] is enabled */
+ else if (ctx->Texture._EnabledUnits == 1)
+ funcindex |= TEX0; /* only unit 0 is enabled */
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
funcindex |= SPEC;
diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c
index 496c22cc42..361a2fa442 100644
--- a/src/mesa/tnl/t_vb_render.c
+++ b/src/mesa/tnl/t_vb_render.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_render.c,v 1.29 2002/04/09 16:56:52 keithw Exp $ */
+/* $Id: t_vb_render.c,v 1.30 2002/06/15 03:03:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -365,7 +365,7 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage )
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
inputs |= VERT_BIT_COLOR1;
- if (ctx->Texture._ReallyEnabled) {
+ if (ctx->Texture._EnabledUnits) {
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
if (ctx->Texture.Unit[i]._ReallyEnabled)
inputs |= VERT_BIT_TEX(i);