-/* $Id: texobj.c,v 1.35 2000/11/22 07:32:17 joukj Exp $ */
+/* $Id: texobj.c,v 1.36 2000/12/14 20:25:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
struct gl_texture_object *t )
{
const GLint baseLevel = t->BaseLevel;
+ GLint maxLog2;
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 */
*/
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;
-/* $Id: s_texture.c,v 1.3 2000/12/08 00:09:24 brianp Exp $ */
+/* $Id: s_texture.c,v 1.4 2000/12/14 20:25:59 brianp Exp $ */
/*
* Mesa 3-D graphics library
{ \
if (lambda < 0.0F) \
lambda = 0.0F; \
- else if (lambda > tObj->_M) \
- lambda = tObj->_M; \
+ else if (lambda > tObj->_MaxLambda) \
+ lambda = tObj->_MaxLambda; \
level = (GLint) (tObj->BaseLevel + lambda); \
}
{ \
if (lambda <= 0.5F) \
lambda = 0.0F; \
- else if (lambda > tObj->_M + 0.4999F) \
- lambda = tObj->_M + 0.4999F; \
+ else if (lambda > tObj->_MaxLambda + 0.4999F) \
+ lambda = tObj->_MaxLambda + 0.4999F; \
level = (GLint) (tObj->BaseLevel + lambda + 0.5F); \
- if (level > tObj->_P) \
- level = tObj->_P; \
+ if (level > tObj->_MaxLevel) \
+ level = tObj->_MaxLevel; \
}
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
- if (level >= tObj->_P) {
- sample_1d_nearest( tObj, tObj->Image[tObj->_P], s, rgba );
+ if (level >= tObj->_MaxLevel) {
+ sample_1d_nearest( tObj, tObj->Image[tObj->_MaxLevel], s, rgba );
}
else {
GLchan t0[4], t1[4];
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
- if (level >= tObj->_P) {
- sample_1d_linear( tObj, tObj->Image[tObj->_P], s, rgba );
+ if (level >= tObj->_MaxLevel) {
+ sample_1d_linear( tObj, tObj->Image[tObj->_MaxLevel], s, rgba );
}
else {
GLchan t0[4], t1[4];
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
- if (level >= tObj->_P) {
- sample_2d_nearest( tObj, tObj->Image[tObj->_P], s, t, rgba );
+ if (level >= tObj->_MaxLevel) {
+ sample_2d_nearest( tObj, tObj->Image[tObj->_MaxLevel], s, t, rgba );
}
else {
GLchan t0[4], t1[4]; /* texels */
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
- if (level >= tObj->_P) {
- sample_2d_linear( tObj, tObj->Image[tObj->_P], s, t, rgba );
+ if (level >= tObj->_MaxLevel) {
+ sample_2d_linear( tObj, tObj->Image[tObj->_MaxLevel], s, t, rgba );
}
else {
GLchan t0[4], t1[4]; /* texels */
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
- if (level >= tObj->_P) {
- sample_3d_nearest( tObj, tObj->Image[tObj->_P], s, t, r, rgba );
+ if (level >= tObj->_MaxLevel) {
+ sample_3d_nearest( tObj, tObj->Image[tObj->_MaxLevel], s, t, r, rgba );
}
else {
GLchan t0[4], t1[4]; /* texels */
COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level);
- if (level >= tObj->_P) {
- sample_3d_linear( tObj, tObj->Image[tObj->_P], s, t, r, rgba );
+ if (level >= tObj->_MaxLevel) {
+ sample_3d_linear( tObj, tObj->Image[tObj->_MaxLevel], s, t, r, rgba );
}
else {
GLchan t0[4], t1[4]; /* texels */
images = choose_cube_face(tObj, s, t, u, &newS, &newT);
- if (level >= tObj->_P) {
- sample_2d_nearest( tObj, images[tObj->_P], newS, newT, rgba );
+ if (level >= tObj->_MaxLevel) {
+ sample_2d_nearest( tObj, images[tObj->_MaxLevel], newS, newT, rgba );
}
else {
GLchan t0[4], t1[4]; /* texels */
images = choose_cube_face(tObj, s, t, u, &newS, &newT);
- if (level >= tObj->_P) {
- sample_2d_linear( tObj, images[tObj->_P], newS, newT, rgba );
+ if (level >= tObj->_MaxLevel) {
+ sample_2d_linear( tObj, images[tObj->_MaxLevel], newS, newT, rgba );
}
else {
GLchan t0[4], t1[4];