/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 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"),
/*@{*/
/**
- * Allocate and initialize a new texture object and add it to the linked list of
- * texture objects.
+ * Allocate and initialize a new texture object. But don't put it into the
+ * texture object hash table.
*
* Called via ctx->Driver.NewTextureObject, unless overridden by a device
* driver.
* of GenTextures()
*
* \return pointer to new texture object.
- *
- * Allocate and initialize a gl_texture_object structure, and insert in the
- * shared state texture list while holding its mutex.
- * If <tt>name > 0</tt> then also insert the new texture object into the hash
- * table.
- *
*/
struct gl_texture_object *
_mesa_new_texture_object( GLcontext *ctx, GLuint name, GLenum target )
{
struct gl_texture_object *obj;
- obj = CALLOC_STRUCT(gl_texture_object);
+ obj = MALLOC_STRUCT(gl_texture_object);
_mesa_initialize_texture_object(obj, name, target);
return obj;
}
/* init the non-zero fields */
_glthread_INIT_MUTEX(obj->Mutex);
+ _mesa_bzero(obj, sizeof(*obj));
obj->RefCount = 1;
obj->Name = name;
obj->Target = target;
obj->MagFilter = GL_LINEAR;
obj->MinLod = -1000.0;
obj->MaxLod = 1000.0;
+ obj->LodBias = 0.0;
obj->BaseLevel = 0;
obj->MaxLevel = 1000;
obj->MaxAnisotropy = 1.0;
obj->CompareFunc = GL_LEQUAL; /* ARB_shadow */
obj->DepthMode = GL_LUMINANCE; /* ARB_depth_texture */
obj->ShadowAmbient = 0.0F; /* ARB/SGIX_shadow_ambient */
- _mesa_init_one_colortable(&obj->Palette);
+ _mesa_init_colortable(&obj->Palette);
}
*
* \param shared the shared GL state to which the object belongs.
* \param texOjb the texture object to delete.
- *
- * Unlink the texture object from the shared state texture linked list while
- * holding its lock. If the texture is a name number it's also removed from the
- * hash table. Finally frees the texture images and the object itself.
*/
void
_mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
assert(texObj);
- _mesa_free_one_colortable(&texObj->Palette);
+ _mesa_free_colortable_data(&texObj->Palette);
/* free the texture images */
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
dest->MagFilter = src->MagFilter;
dest->MinLod = src->MinLod;
dest->MaxLod = src->MaxLod;
+ dest->LodBias = src->LodBias;
dest->BaseLevel = src->BaseLevel;
dest->MaxLevel = src->MaxLevel;
dest->MaxAnisotropy = src->MaxAnisotropy;
/* Always need the base level image */
if (!t->Image[baseLevel]) {
- incomplete(t, "Image[baseLevel] == NULL");
+ char s[100];
+ sprintf(s, "obj %p (%d) Image[baseLevel=%d] == NULL",
+ (void *) t, t->Name, baseLevel);
+ incomplete(t, s);
+ t->Complete = GL_FALSE;
+ return;
+ }
+
+ /* Check width/height/depth for zero */
+ if (t->Image[baseLevel]->Width == 0 ||
+ t->Image[baseLevel]->Height == 0 ||
+ t->Image[baseLevel]->Depth == 0) {
+ incomplete(t, "texture width = 0");
t->Complete = GL_FALSE;
return;
}
}
else if (t->Target == GL_TEXTURE_RECTANGLE_NV) {
/* XXX special checking? */
-
}
else {
/* Target = ??? */
* to find a block of free texture IDs which are stored in \p texName.
* Corresponding empty texture objects are also generated.
*/
-void
+void GLAPIENTRY
_mesa_GenTextures( GLsizei n, GLuint *texName )
{
GET_CURRENT_CONTEXT(ctx);
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n);
- /* Return the texture names */
- for (i=0;i<n;i++) {
- texName[i] = first + i;
- }
-
/* Allocate new, empty texture objects */
for (i = 0; i < n; i++) {
struct gl_texture_object *texObj;
return;
}
_mesa_save_texture_object(ctx, texObj);
+ texName[i] = name;
}
_glthread_UNLOCK_MUTEX(GenTexturesLock);
* it and decrementing the reference count if so. If the texture reference
* count is zero, delete its object.
*/
-void
+void GLAPIENTRY
_mesa_DeleteTextures( GLsizei n, const GLuint *texName)
{
GET_CURRENT_CONTEXT(ctx);
* calls dd_function_table::BindTexture. Decrements the old texture reference
* count and deletes it if it reaches zero.
*/
-void
+void GLAPIENTRY
_mesa_BindTexture( GLenum target, GLuint texName )
{
GET_CURRENT_CONTEXT(ctx);
* Looks up each texture in the hash, clamps the corresponding priority between
* 0.0 and 1.0, and calls dd_function_table::PrioritizeTexture.
*/
-void
+void GLAPIENTRY
_mesa_PrioritizeTextures( GLsizei n, const GLuint *texName,
const GLclampf *priorities )
{
* Looks up each texture in the hash and calls
* dd_function_table::IsTextureResident.
*/
-GLboolean
+GLboolean GLAPIENTRY
_mesa_AreTexturesResident(GLsizei n, const GLuint *texName,
GLboolean *residences)
{
*
* Calls _mesa_HashLookup().
*/
-GLboolean
+GLboolean GLAPIENTRY
_mesa_IsTexture( GLuint texture )
{
GET_CURRENT_CONTEXT(ctx);