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.
/*================================================*/
/* 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 )
{
/*================================================*/
/* 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" : "--------" ));
}
\r
if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;\r
if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;\r
- if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;\r
+ if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL;\r
\r
if (ctx->Light.ShadeModel==GL_SMOOTH\r
&& swrast->_RasterMask==DEPTH_BIT\r
-/* $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
/* 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 ||
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)
/* 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.
*/
}
}
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;
}
-/* $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
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;
}
}
-/* $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
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 {
ind |= SETUP_TMU0;
}
}
- else if (ctx->Texture._ReallyEnabled & TEXTURE0_ANY) {
+ else if (ctx->Texture._EnabledUnits & 0x1) {
ind |= SETUP_TMU0;
}
-/* $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
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;
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;
-/* $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
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;
{\r
STARTPROFILE\r
if (ctx->Point.Size==1.0 && !ctx->Point.SmoothFlag && ctx->_RasterMask==0\r
- && !ctx->Texture._ReallyEnabled && ctx->Visual->RGBAflag) {\r
+ && ctx->Texture._EnabledUnits == 0 && ctx->Visual->RGBAflag) {\r
ENDPROFILE(choose_points_function)\r
return fast_rgb_points;\r
}\r
STARTPROFILE\r
if (ctx->Line.Width==1.0 && !ctx->Line.SmoothFlag && !ctx->Line.StippleFlag\r
&& ctx->Light.ShadeModel==GL_FLAT && ctx->_RasterMask==0\r
- && !ctx->Texture._ReallyEnabled && Current->rgb_flag) {\r
+ && ctx->Texture._EnabledUnits == 0 && Current->rgb_flag) {\r
ENDPROFILE(choose_line_function)\r
return fast_flat_rgb_line;\r
}\r
{\r
if (ctx->Polygon.SmoothFlag) return NULL;\r
if (ctx->Polygon.StippleFlag) return NULL;\r
- if (ctx->Texture._ReallyEnabled) return NULL;\r
+ if (ctx->Texture._EnabledUnits) return NULL;\r
\r
if (ctx->_RasterMask==DEPTH_BIT\r
&& ctx->Depth.Func==GL_LESS\r
STARTPROFILE\r
if (!ctx->Polygon.SmoothFlag && !ctx->Polygon.StippleFlag\r
&& ctx->Light.ShadeModel==GL_FLAT && ctx->_RasterMask==0\r
- && !ctx->Texture._ReallyEnabled && Current->rgb_flag==GL_TRUE) {\r
+ && ctx->Texture._EnabledUnits == 0 && Current->rgb_flag==GL_TRUE) {\r
ENDPROFILE(choose_polygon_function)\r
return fast_flat_rgb_polygon;\r
}\r
-/* $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
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;
}
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;
-/* $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
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) {
-/* $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
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];
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) );
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;
(*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) );
}
}
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);
}
/* 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];
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 */
}
ctx->Texture.Unit[u].Current2D->RefCount--;
ctx->Texture.Unit[u].Current3D->RefCount--;
ctx->Texture.Unit[u].CurrentCubeMap->RefCount--;
+ ctx->Texture.Unit[u].CurrentRect->RefCount--;
}
}
-/* $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"),
/* 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
-/* $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
/* 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 */
_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;
}
texUnit->Current2D = ctx->Shared->Default2D;
texUnit->Current3D = ctx->Shared->Default3D;
texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
+ texUnit->CurrentRect = ctx->Shared->DefaultRect;
}
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;
/* 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;
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);
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();
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]) {
_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 {
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 );
_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)
-/* $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
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);
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);
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);
{
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);
}
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;
{
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:
{
{
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 */
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;
-/* $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
{ 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) },
"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",
-/* $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
*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" );
}
/* 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" );
}
/* 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;
}
/* 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" );
}
-/* $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
#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
-/* 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
FetchTexelFunc FetchTexel3D;
};
+
/* Texture image record */
struct gl_texture_image {
GLenum Format; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
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;
_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 */
};
-
-/*
- * 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];
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 */
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) | */
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;
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;
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 */
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;
-/* $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
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;
/* 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;
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;
}
}
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) {
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) {
-/* $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
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;
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;
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;
* 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)
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;
+ }
}
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;
}
}
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];
}
/* 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) {
}
/* 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);
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;
}
_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;
}
else if (target == GL_TEXTURE_3D) {
maxLevels = ctx->Const.Max3DTextureLevels;
}
+ else if (target == GL_TEXTURE_RECTANGLE_NV) {
+ maxLevels = 1;
+ }
else {
maxLevels = ctx->Const.MaxCubeTextureLevels;
}
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)
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,
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;
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);
}
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,
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,
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);
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,
}
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);
}
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);
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) {
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,
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;
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);
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,
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);
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,
-/* $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
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);
-/* $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
* 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);
_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;
}
/* 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;
}
/* 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;
}
/* 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++) {
}
}
}
- 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;
}
}
}
- 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;
}
}
}
- 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;
}
}
}
+ 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");
}
}
/* 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);
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))
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;
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 */
}
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++;
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 */
-/* $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"),
extern struct gl_texture_object *
_mesa_alloc_texture_object( struct gl_shared_state *shared, GLuint name,
- GLuint dimensions );
+ GLenum target );
extern void
-/* $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
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;
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;
}
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;
}
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;
}
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;
}
_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;
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;
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) {
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:
-/* $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
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;
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");
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;
/*
* 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;
-/* $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
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)
-/* $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
{
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 {
}
}
else {
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits > 1) {
SWRAST_CONTEXT(ctx)->Triangle = multitex_aa_tri;
}
else {
-/* $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
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;
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;
}
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;
}
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;
}
-/* $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
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);
}
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);
}
-/* $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
_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) {
(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);
}
-/* $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
_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)
-/* $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
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 {
}
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);
}
USE(atten_general_ci_point);
}
}
- else if (ctx->Texture._ReallyEnabled && rgbMode) {
+ else if (ctx->Texture._EnabledUnits && rgbMode) {
/* textured */
USE(textured_rgba_point);
}
-/* $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
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);
-/* $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
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;
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];
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];
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);
-/* $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
}
+/**********************************************************************/
+/* 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.
*/
(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 */
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);
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);
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;
}
}
}
- switch (t->Dimensions) {
- case 1:
+ switch (t->Target) {
+ case GL_TEXTURE_1D:
if (format == GL_DEPTH_COMPONENT) {
swrast->TextureSample[texUnit] = sample_depth_texture;
}
swrast->TextureSample[texUnit] = sample_nearest_1d;
}
break;
- case 2:
+ case GL_TEXTURE_2D:
if (format == GL_DEPTH_COMPONENT) {
swrast->TextureSample[texUnit] = sample_depth_texture;
}
swrast->TextureSample[texUnit] = sample_nearest_2d;
}
break;
- case 3:
+ case GL_TEXTURE_3D:
if (needLambda) {
swrast->TextureSample[texUnit] = sample_lambda_3d;
}
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;
}
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");
}
}
}
return;
argRGB[j] = (const GLchan (*)[4])
(texelBuffer + srcUnit * (n * 4 * sizeof(GLchan)));
- printf("unit %d from unit %d\n", unit, srcUnit);
}
}
-/* $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
#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]); \
#define SETUP_CODE \
{ \
/* texturing must be off */ \
- ASSERT(!ctx->Texture._ReallyEnabled); \
+ ASSERT(ctx->Texture._EnabledUnits == 0); \
ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \
}
}
}
- 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;
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
}
else {
/* general case textured triangles */
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits > 1) {
USE(multitextured_triangle);
}
else {
}
}
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) {
-/* $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
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;
-/* $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
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);