}
-/*
- * Compute linear mipmap levels for given lambda.
+/**
+ * For linear interpolation between mipmap levels N and N+1, this function
+ * computes N.
*/
-#define COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level) \
-{ \
- if (lambda < 0.0F) \
- level = tObj->BaseLevel; \
- else if (lambda > tObj->_MaxLambda) \
- level = (GLint) (tObj->BaseLevel + tObj->_MaxLambda); \
- else \
- level = (GLint) (tObj->BaseLevel + lambda); \
+static INLINE GLint
+linear_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda)
+{
+ if (lambda < 0.0F)
+ return tObj->BaseLevel;
+ else if (lambda > tObj->_MaxLambda)
+ return (GLint) (tObj->BaseLevel + tObj->_MaxLambda);
+ else
+ return (GLint) (tObj->BaseLevel + lambda);
}
-/*
- * Compute nearest mipmap level for given lambda.
+/**
+ * Compute the nearest mipmap level to take texels from.
*/
-#define COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level) \
-{ \
- GLfloat l; \
- if (lambda <= 0.5F) \
- l = 0.0F; \
- else if (lambda > tObj->_MaxLambda + 0.4999F) \
- l = tObj->_MaxLambda + 0.4999F; \
- else \
- l = lambda; \
- level = (GLint) (tObj->BaseLevel + l + 0.5F); \
- if (level > tObj->_MaxLevel) \
- level = tObj->_MaxLevel; \
+static INLINE GLint
+nearest_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda)
+{
+ GLfloat l;
+ GLint level;
+ if (lambda <= 0.5F)
+ l = 0.0F;
+ else if (lambda > tObj->_MaxLambda + 0.4999F)
+ l = tObj->_MaxLambda + 0.4999F;
+ else
+ l = lambda;
+ level = (GLint) (tObj->BaseLevel + l + 0.5F);
+ if (level > tObj->_MaxLevel)
+ level = tObj->_MaxLevel;
+ return level;
}
GLuint *magStart, GLuint *magEnd )
{
ASSERT(lambda != NULL);
+
#if 0
- /* Verify that lambda[] is monotonous.
+ /* DEBUG CODE: Verify that lambda[] is monotonic.
* We can't really use this because the inaccuracy in the LOG2 function
* causes this test to fail, yet the resulting texturing is correct.
*/
}
#endif /* DEBUG */
- /* since lambda is monotonous-array use this check first */
if (lambda[0] <= minMagThresh && lambda[n-1] <= minMagThresh) {
/* magnification for whole span */
*magStart = 0;
GLuint i;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_1d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
GLuint i;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_1d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
GLuint i;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
GLuint i;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
{
GLuint i;
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_2d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
GLuint i;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_2d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
GLuint i;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
sample_2d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
GLuint i;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
sample_2d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
ASSERT(tObj->WrapT == GL_REPEAT);
ASSERT(tObj->_IsPowerOfTwo);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
{
GLuint i;
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_3d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
GLuint i;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = nearest_mipmap_level(tObj, lambda[i]);
sample_3d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
}
}
GLuint i;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
sample_3d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
GLuint i;
ASSERT(lambda != NULL);
for (i = 0; i < n; i++) {
- GLint level;
- COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = linear_mipmap_level(tObj, lambda[i]);
if (level >= tObj->_MaxLevel) {
sample_3d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
texcoord[i], rgba[i]);
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
GLfloat newCoord[4];
- GLint level;
- COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = nearest_mipmap_level(tObj, lambda[i]);
images = choose_cube_face(tObj, texcoord[i], newCoord);
sample_2d_nearest(ctx, tObj, images[level], newCoord, rgba[i]);
}
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
GLfloat newCoord[4];
- GLint level;
- COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = nearest_mipmap_level(tObj, lambda[i]);
images = choose_cube_face(tObj, texcoord[i], newCoord);
sample_2d_linear(ctx, tObj, images[level], newCoord, rgba[i]);
}
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
GLfloat newCoord[4];
- GLint level;
- COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = linear_mipmap_level(tObj, lambda[i]);
images = choose_cube_face(tObj, texcoord[i], newCoord);
if (level >= tObj->_MaxLevel) {
sample_2d_nearest(ctx, tObj, images[tObj->_MaxLevel],
for (i = 0; i < n; i++) {
const struct gl_texture_image **images;
GLfloat newCoord[4];
- GLint level;
- COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ GLint level = linear_mipmap_level(tObj, lambda[i]);
images = choose_cube_face(tObj, texcoord[i], newCoord);
if (level >= tObj->_MaxLevel) {
sample_2d_linear(ctx, tObj, images[tObj->_MaxLevel],