-/* $Id: texstate.c,v 1.10 2000/05/22 16:33:21 brianp Exp $ */
+/* $Id: texstate.c,v 1.13 2000/05/23 20:10:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "macros.h"
#include "matrix.h"
#include "texobj.h"
+#include "teximage.h"
#include "texstate.h"
#include "texture.h"
#include "types.h"
break;
case GL_TEXTURE_CUBE_MAP_ARB:
if (ctx->Extensions.HaveTextureCubeMap) {
- texObj = texUnit->CurrentPosX;
+ texObj = texUnit->CurrentCubeMap;
break;
}
/* fallthrough */
}
+static GLuint
+tex_image_dimensions(GLcontext *ctx, GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_1D:
+ return 1;
+ case GL_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_2D:
+ return 2;
+ case GL_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_3D:
+ return 3;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ return ctx->Extensions.HaveTextureCubeMap ? 2 : 0;
+ default:
+ gl_problem(ctx, "bad target in _mesa_tex_target_dimensions()");
+ return 0;
+ }
+}
+
void
_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
const struct gl_texture_image *img = NULL;
GLuint dimensions;
+ GLboolean isProxy;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexLevelParameter");
return;
}
- switch (target) {
- case GL_TEXTURE_1D:
- img = texUnit->CurrentD[1]->Image[level];
- dimensions = 1;
- break;
- case GL_TEXTURE_2D:
- img = texUnit->CurrentD[2]->Image[level];
- dimensions = 2;
- break;
- case GL_TEXTURE_3D:
- img = texUnit->CurrentD[3]->Image[level];
- dimensions = 3;
- break;
- case GL_TEXTURE_CUBE_MAP_ARB:
- if (ctx->Extensions.HaveTextureCubeMap) {
- img = texUnit->CurrentPosX->Image[level];
- dimensions = 2;
- }
- else {
- gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
- return;
- }
- break;
- case GL_PROXY_TEXTURE_1D:
- img = ctx->Texture.Proxy1D->Image[level];
- dimensions = 1;
- break;
- case GL_PROXY_TEXTURE_2D:
- img = ctx->Texture.Proxy2D->Image[level];
- dimensions = 2;
- break;
- case GL_PROXY_TEXTURE_3D:
- img = ctx->Texture.Proxy3D->Image[level];
- dimensions = 3;
- break;
- case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
- if (ctx->Extensions.HaveTextureCubeMap) {
- img = ctx->Texture.ProxyCubeMap->Image[level];
- dimensions = 2;
- }
- else {
- gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
- return;
- }
- break;
- default:
- gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
- return;
+ dimensions = tex_image_dimensions(ctx, target); /* 1, 2 or 3 */
+ if (dimensions == 0) {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
+ return;
}
+ img = _mesa_select_tex_image(ctx, texUnit, target, level);
if (!img) {
if (pname == GL_TEXTURE_COMPONENTS)
*params = 1;
return;
}
+ isProxy = (target == GL_PROXY_TEXTURE_1D) ||
+ (target == GL_PROXY_TEXTURE_2D) ||
+ (target == GL_PROXY_TEXTURE_3D) ||
+ (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB);
+
switch (pname) {
case GL_TEXTURE_WIDTH:
*params = img->Width;
case GL_TEXTURE_INDEX_SIZE_EXT:
*params = img->IndexBits;
return;
+
+ /* GL_ARB_texture_compression */
+ case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB:
+ if (ctx->Extensions.HaveTextureCompression) {
+ if (img->IsCompressed && !isProxy)
+ *params = img->CompressedSize;
+ else
+ gl_error(ctx, GL_INVALID_OPERATION,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_COMPRESSED_ARB:
+ if (ctx->Extensions.HaveTextureCompression) {
+ *params = (GLint) img->IsCompressed;
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+
default:
- gl_error( ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)" );
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)");
}
}
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexParameterfv");
- switch (target) {
- case GL_TEXTURE_1D:
- obj = texUnit->CurrentD[1];
- break;
- case GL_TEXTURE_2D:
- obj = texUnit->CurrentD[2];
- break;
- case GL_TEXTURE_3D_EXT:
- obj = texUnit->CurrentD[3];
- break;
- default:
- gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
- return;
+ obj = _mesa_select_tex_object(ctx, texUnit, target);
+ if (!obj) {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
+ return;
}
switch (pname) {
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexParameteriv");
- switch (target) {
- case GL_TEXTURE_1D:
- obj = texUnit->CurrentD[1];
- break;
- case GL_TEXTURE_2D:
- obj = texUnit->CurrentD[2];
- break;
- case GL_TEXTURE_3D_EXT:
- obj = texUnit->CurrentD[3];
- break;
- default:
- gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(target)");
- return;
+ obj = _mesa_select_tex_object(ctx, texUnit, target);
+ if (!obj) {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(target)");
+ return;
}
switch (pname) {
case GL_T:
if (pname==GL_TEXTURE_GEN_MODE) {
GLenum mode = (GLenum) (GLint) *params;
- switch(mode) {
- case GL_OBJECT_LINEAR:
- texUnit->GenModeT = GL_OBJECT_LINEAR;
- texUnit->GenBitT = TEXGEN_OBJ_LINEAR;
- break;
- case GL_EYE_LINEAR:
- texUnit->GenModeT = GL_EYE_LINEAR;
- texUnit->GenBitT = TEXGEN_EYE_LINEAR;
- break;
- case GL_REFLECTION_MAP_NV:
- texUnit->GenModeT = GL_REFLECTION_MAP_NV;
- texUnit->GenBitT = TEXGEN_REFLECTION_MAP_NV;
- break;
- case GL_NORMAL_MAP_NV:
- texUnit->GenModeT = GL_NORMAL_MAP_NV;
- texUnit->GenBitT = TEXGEN_NORMAL_MAP_NV;
- break;
- case GL_SPHERE_MAP:
- texUnit->GenModeT = GL_SPHERE_MAP;
- texUnit->GenBitT = TEXGEN_SPHERE_MAP;
- break;
- default:
- gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
- return;
+ switch (mode) {
+ case GL_OBJECT_LINEAR:
+ texUnit->GenModeT = GL_OBJECT_LINEAR;
+ texUnit->GenBitT = TEXGEN_OBJ_LINEAR;
+ break;
+ case GL_EYE_LINEAR:
+ texUnit->GenModeT = GL_EYE_LINEAR;
+ texUnit->GenBitT = TEXGEN_EYE_LINEAR;
+ break;
+ case GL_REFLECTION_MAP_NV:
+ texUnit->GenModeT = GL_REFLECTION_MAP_NV;
+ texUnit->GenBitT = TEXGEN_REFLECTION_MAP_NV;
+ break;
+ case GL_NORMAL_MAP_NV:
+ texUnit->GenModeT = GL_NORMAL_MAP_NV;
+ texUnit->GenBitT = TEXGEN_NORMAL_MAP_NV;
+ break;
+ case GL_SPHERE_MAP:
+ texUnit->GenModeT = GL_SPHERE_MAP;
+ texUnit->GenBitT = TEXGEN_SPHERE_MAP;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
+ return;
}
}
else if (pname==GL_OBJECT_PLANE) {
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGendv");
- switch( coord ) {
+ switch (coord) {
case GL_S:
if (pname==GL_TEXTURE_GEN_MODE) {
params[0] = ENUM_TO_DOUBLE(texUnit->GenModeS);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGenfv");
- switch( coord ) {
+ switch (coord) {
case GL_S:
if (pname==GL_TEXTURE_GEN_MODE) {
params[0] = ENUM_TO_FLOAT(texUnit->GenModeS);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGeniv");
- switch( coord ) {
+ switch (coord) {
case GL_S:
if (pname==GL_TEXTURE_GEN_MODE) {
params[0] = texUnit->GenModeS;
struct gl_texture_object *t, *next;
for (t = ctx->Shared->DirtyTexObjList; t; t = next) {
next = t->NextDirty;
- gl_test_texture_object_completeness(ctx, t);
- gl_set_texture_sampler(t);
+ _mesa_test_texobj_completeness(ctx, t);
+ _mesa_set_texture_sampler(t);
t->NextDirty = NULL;
t->Dirty = GL_FALSE;
}