-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c,v 1.4 2002/11/05 17:46:07 tsi Exp $ */
#include <stdlib.h>
#include <stdio.h>
-#include "glheader.h"
-#include "mtypes.h"
-#include "imports.h"
-#include "simple_list.h"
-#include "enums.h"
-#include "texstore.h"
+#include "main/glheader.h"
+#include "main/mtypes.h"
+#include "main/imports.h"
+#include "main/simple_list.h"
+#include "main/enums.h"
+#include "main/texstore.h"
#include "teximage.h"
-#include "texformat.h"
+#include "main/texformat.h"
+#include "texobj.h"
#include "swrast/swrast.h"
-#include "mm.h"
-#include "gamma_context.h"
+#include "main/mm.h"
+#include "gammacontext.h"
#include "colormac.h"
static void gammaSetTexWrapping(gammaTextureObjectPtr t,
GLenum wraps, GLenum wrapt)
{
- CARD32 t1 = t->TextureAddressMode;
- CARD32 t2 = t->TextureReadMode;
+ uint32_t t1 = t->TextureAddressMode;
+ uint32_t t2 = t->TextureReadMode;
t1 &= ~(TAM_SWrap_Mask | TAM_TWrap_Mask);
t2 &= ~(TRM_UWrap_Mask | TRM_VWrap_Mask);
GLenum minf, GLenum magf,
GLfloat bias)
{
- CARD32 t1 = t->TextureAddressMode;
- CARD32 t2 = t->TextureReadMode;
+ uint32_t t1 = t->TextureAddressMode;
+ uint32_t t2 = t->TextureReadMode;
t2 &= ~(TRM_Mag_Mask | TRM_Min_Mask);
static void gammaSetTexBorderColor(gammaContextPtr gmesa,
gammaTextureObjectPtr t,
- GLubyte color[4])
+ const GLfloat color[4])
{
- t->TextureBorderColor = PACK_COLOR_8888(color[0], color[1], color[2], color[3]);
+ GLubyte c[4];
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+ t->TextureBorderColor = PACK_COLOR_8888(c[0], c[1], c[2], c[3]);
}
break;
case GL_TEXTURE_BORDER_COLOR:
- gammaSetTexBorderColor( gmesa, t, tObj->_BorderChan );
+ gammaSetTexBorderColor( gmesa, t, tObj->BorderColor );
break;
case GL_TEXTURE_BASE_LEVEL:
texImage);
}
-
static void gammaBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
if (target == GL_TEXTURE_2D) {
t->TextureAddressMode |= TAM_TexMapType_2D;
t->TextureReadMode |= TRM_TexMapType_2D;
- } else
- if (target == GL_TEXTURE_1D) {
+ }
+ else if (target == GL_TEXTURE_1D) {
t->TextureAddressMode |= TAM_TexMapType_1D;
t->TextureReadMode |= TRM_TexMapType_1D;
}
gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias );
- gammaSetTexBorderColor( gmesa, t, tObj->_BorderChan );
+ gammaSetTexBorderColor( gmesa, t, tObj->BorderColor );
}
}
-
static void gammaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
{
gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
return t && t->MemBlock;
}
-static void gammaInitTextureObjects( GLcontext *ctx )
+#ifdef UNUSED
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ */
+static struct gl_texture_object *
+gammaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ return obj;
+}
+#endif
+
+void gammaInitTextureObjects( GLcontext *ctx )
{
struct gl_texture_object *texObj;
GLuint tmp = ctx->Texture.CurrentUnit;
ctx->Texture.CurrentUnit = 0;
- texObj = ctx->Texture.Unit[0].Current1D;
+ texObj = ctx->Texture.Unit[0].CurrentTex[TEXTURE_1D_INDEX];
gammaBindTexture( ctx, GL_TEXTURE_1D, texObj );
- texObj = ctx->Texture.Unit[0].Current2D;
+ texObj = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];
gammaBindTexture( ctx, GL_TEXTURE_2D, texObj );
#if 0
ctx->Texture.CurrentUnit = 1;
- texObj = ctx->Texture.Unit[1].Current1D;
+ texObj = ctx->Texture.Unit[1].CurrentTex[TEXTURE_1D_INDEX];
gammaBindTexture( ctx, GL_TEXTURE_1D, texObj );
- texObj = ctx->Texture.Unit[1].Current2D;
+ texObj = ctx->Texture.Unit[1].CurrentTex[TEXTURE_2D_INDEX];
gammaBindTexture( ctx, GL_TEXTURE_2D, texObj );
#endif
}
-void gammaDDInitTextureFuncs( GLcontext *ctx )
+void gammaDDInitTextureFuncs( struct dd_function_table *functions )
{
- ctx->Driver.TexEnv = gammaTexEnv;
- ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
- ctx->Driver.TexImage1D = _mesa_store_teximage1d;
- ctx->Driver.TexImage2D = gammaTexImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
- ctx->Driver.TexSubImage2D = gammaTexSubImage2D;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
- ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
- ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
- ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
- ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
- ctx->Driver.BindTexture = gammaBindTexture;
- ctx->Driver.DeleteTexture = gammaDeleteTexture;
- ctx->Driver.TexParameter = gammaTexParameter;
- ctx->Driver.UpdateTexturePalette = 0;
- ctx->Driver.IsTextureResident = gammaIsTextureResident;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
-
- gammaInitTextureObjects( ctx );
+ functions->TexEnv = gammaTexEnv;
+ functions->TexImage2D = gammaTexImage2D;
+ functions->TexSubImage2D = gammaTexSubImage2D;
+ functions->BindTexture = gammaBindTexture;
+ functions->DeleteTexture = gammaDeleteTexture;
+ functions->TexParameter = gammaTexParameter;
+ functions->IsTextureResident = gammaIsTextureResident;
}