-/* $Id: texobj.c,v 1.34 2000/11/19 23:10:25 brianp Exp $ */
+/* $Id: texobj.c,v 1.45 2001/03/18 08:53:49 gareth Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
- *
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
#include "teximage.h"
#include "texstate.h"
#include "texobj.h"
-#include "types.h"
+#include "mtypes.h"
#endif
* Return: pointer to new texture object
*/
struct gl_texture_object *
-_mesa_alloc_texture_object( struct gl_shared_state *shared, GLuint name,
- GLuint dimensions)
+_mesa_alloc_texture_object( struct gl_shared_state *shared,
+ GLuint name, GLuint dimensions )
{
struct gl_texture_object *obj;
obj->MaxLod = 1000.0;
obj->BaseLevel = 0;
obj->MaxLevel = 1000;
+ obj->MaxAnisotropy = 1.0;
+ obj->CompareFlag = GL_FALSE;
+ obj->CompareOperator = GL_TEXTURE_LEQUAL_R_SGIX;
+ obj->ShadowAmbient = 0;
_mesa_init_colortable(&obj->Palette);
/* insert into linked list */
struct gl_texture_object *t )
{
const GLint baseLevel = t->BaseLevel;
+ GLint maxLog2 = 0;
t->Complete = GL_TRUE; /* be optimistic */
return;
}
- /* Compute number of mipmap levels */
+ /* Compute _MaxLevel */
if (t->Dimensions == 1) {
- t->_P = t->Image[baseLevel]->WidthLog2;
+ maxLog2 = t->Image[baseLevel]->WidthLog2;
}
else if (t->Dimensions == 2 || t->Dimensions == 6) {
- t->_P = MAX2(t->Image[baseLevel]->WidthLog2,
- t->Image[baseLevel]->HeightLog2);
+ maxLog2 = MAX2(t->Image[baseLevel]->WidthLog2,
+ t->Image[baseLevel]->HeightLog2);
}
else if (t->Dimensions == 3) {
GLint max = MAX2(t->Image[baseLevel]->WidthLog2,
t->Image[baseLevel]->HeightLog2);
- max = MAX2(max, (GLint)(t->Image[baseLevel]->DepthLog2));
- t->_P = max;
+ maxLog2 = MAX2(max, (GLint)(t->Image[baseLevel]->DepthLog2));
}
- /* Compute M (see the 1.2 spec) used during mipmapping */
- t->_M = (GLfloat) (MIN2(t->MaxLevel, t->_P) - t->BaseLevel);
+ t->_MaxLevel = baseLevel + maxLog2;
+ t->_MaxLevel = MIN2(t->_MaxLevel, t->MaxLevel);
+ t->_MaxLevel = MIN2(t->_MaxLevel, ctx->Const.MaxTextureLevels - 1);
+ /* Compute _MaxLambda = q - b (see the 1.2 spec) used during mipmapping */
+ t->_MaxLambda = (GLfloat) (t->_MaxLevel - t->BaseLevel);
if (t->Dimensions == 6) {
/* make sure that all six cube map level 0 images are the same size */
- const GLint w = t->Image[baseLevel]->Width2;
- const GLint h = t->Image[baseLevel]->Height2;
+ const GLuint w = t->Image[baseLevel]->Width2;
+ const GLuint h = t->Image[baseLevel]->Height2;
if (!t->NegX[baseLevel] ||
t->NegX[baseLevel]->Width2 != w ||
t->NegX[baseLevel]->Height2 != h ||
*/
GLint i;
GLint minLevel = baseLevel;
- GLint maxLevel = MIN2(t->_P, ctx->Const.MaxTextureLevels-1);
- maxLevel = MIN2(maxLevel, t->MaxLevel);
+ GLint maxLevel = t->_MaxLevel;
if (minLevel > maxLevel) {
t->Complete = GL_FALSE;
}
else {
/* Dimensions = ??? */
- gl_problem(NULL, "Bug in gl_test_texture_object_completeness\n");
+ _mesa_problem(ctx, "Bug in gl_test_texture_object_completeness\n");
}
}
}
GET_CURRENT_CONTEXT(ctx);
GLuint first;
GLint i;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGenTextures");
if (n < 0) {
- gl_error( ctx, GL_INVALID_VALUE, "glGenTextures" );
+ _mesa_error( ctx, GL_INVALID_VALUE, "glGenTextures" );
return;
}
for (i=0;i<n;i++) {
GLuint name = first + i;
GLuint dims = 0;
- (void) _mesa_alloc_texture_object(ctx->Shared, name, dims);
+ (void) _mesa_alloc_texture_object( ctx->Shared, name, dims);
}
_glthread_UNLOCK_MUTEX(GenTexturesLock);
{
GET_CURRENT_CONTEXT(ctx);
GLint i;
-
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDeleteTextures");
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */
if (!texName)
return;
GLuint unit = ctx->Texture.CurrentUnit;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
struct gl_texture_object *oldTexObj;
- struct gl_texture_object *newTexObj;
+ struct gl_texture_object *newTexObj = 0;
GLuint targetDim;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
fprintf(stderr, "glBindTexture %s %d\n",
- gl_lookup_enum_by_nr(target), (GLint) texName);
-
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glBindTexture");
+ _mesa_lookup_enum_by_nr(target), (GLint) texName);
switch (target) {
case GL_TEXTURE_1D:
}
/* fallthrough */
default:
- gl_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
return;
}
/* error checking */
if (newTexObj->Dimensions > 0 && newTexObj->Dimensions != targetDim) {
/* the named texture object's dimensions don't match the target */
- gl_error( ctx, GL_INVALID_OPERATION, "glBindTexture" );
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glBindTexture" );
return;
}
}
else {
/* if this is a new texture id, allocate a texture object now */
- newTexObj = _mesa_alloc_texture_object(ctx->Shared, texName, targetDim);
+ newTexObj = _mesa_alloc_texture_object( ctx->Shared, texName,
+ targetDim);
if (!newTexObj) {
- gl_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture");
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture");
return;
}
}
newTexObj->RefCount++;
- /* do the actual binding */
+
+ /* do the actual binding, but first flush outstanding vertices:
+ */
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+
switch (target) {
case GL_TEXTURE_1D:
texUnit->Current1D = newTexObj;
texUnit->CurrentCubeMap = newTexObj;
break;
default:
- gl_problem(ctx, "bad target in BindTexture");
+ _mesa_problem(ctx, "bad target in BindTexture");
}
- ctx->NewState |= _NEW_TEXTURE;
-
/* Pass BindTexture call to device driver */
- if (ctx->Driver.BindTexture)
+ if (ctx->Driver.BindTexture)
(*ctx->Driver.BindTexture)( ctx, target, newTexObj );
if (oldTexObj->Name > 0) {
{
GET_CURRENT_CONTEXT(ctx);
GLint i;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPrioritizeTextures");
if (n < 0) {
- gl_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" );
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" );
return;
}
/*
- * Execute glAreTexturesResident
+ * Execute glAreTexturesResident
*/
GLboolean
_mesa_AreTexturesResident(GLsizei n, const GLuint *texName,
GET_CURRENT_CONTEXT(ctx);
GLboolean allResident = GL_TRUE;
GLint i;
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx,
- "glAreTexturesResident", GL_FALSE);
if (n < 0) {
- gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)");
return GL_FALSE;
}
for (i = 0; i < n; i++) {
struct gl_texture_object *t;
if (texName[i] == 0) {
- gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)");
return GL_FALSE;
}
t = (struct gl_texture_object *)
}
}
else {
- gl_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(textures)");
return GL_FALSE;
}
}
_mesa_IsTexture( GLuint texture )
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glIsTextures",
- GL_FALSE);
- if (texture > 0 && _mesa_HashLookup(ctx->Shared->TexObjects, texture)) {
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ return texture > 0 && _mesa_HashLookup(ctx->Shared->TexObjects, texture);
}
-