-/* $Id: texobj.c,v 1.36 2000/12/14 20:25:56 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"),
* 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;
+ GLint maxLog2 = 0;
t->Complete = GL_TRUE; /* be optimistic */
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 ||
}
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)
(*ctx->Driver.BindTexture)( ctx, target, newTexObj );
{
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;
}
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);
}
-