Commit 9d7842be authored by Henri Verbeet's avatar Henri Verbeet
Browse files

Add some extra filter types to the mipmap_limits demo.

parent 0b38828b
......@@ -57,7 +57,22 @@ static GLint BaseLevel = 0, MaxLevel = 8;
static GLfloat MinLod = -1, MaxLod = 9;
static GLfloat LodBias = 0.0;
static GLboolean NearestFilter = GL_TRUE;
static unsigned int min_filter;
static const struct
{
GLint value;
const char *name;
}
min_filters[] =
{
{GL_LINEAR_MIPMAP_LINEAR, "LINEAR_MIPMAP_LINEAR"},
{GL_NEAREST_MIPMAP_LINEAR, "NEAREST_MIPMAP_LINEAR"},
{GL_LINEAR_MIPMAP_NEAREST, "LINEAR_MIPMAP_NEAREST"},
{GL_NEAREST_MIPMAP_NEAREST, "NEAREST_MIPMAP_NEAREST"},
{GL_LINEAR, "LINEAR"},
{GL_NEAREST, "NEAREST"},
};
static void MakeImage(int level, int width, int height, const GLubyte color[4])
{
......@@ -125,8 +140,8 @@ static void myinit(void)
static void display(void)
{
GLfloat tcm = 4.0;
printf("BASE_LEVEL = %d MAX_LEVEL = %d MIN_LOD = %f MAX_LOD = %f Bias = %.2g filter = %s\n",
BaseLevel, MaxLevel, MinLod, MaxLod, LodBias,
printf("BASE_LEVEL = %d MAX_LEVEL = %d MIN_LOD = %f MAX_LOD = %f Bias = %.2g filter = %s / %s\n",
BaseLevel, MaxLevel, MinLod, MaxLod, LodBias, min_filters[min_filter].name,
NearestFilter ? "NEAREST" : "LINEAR");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel);
......@@ -134,16 +149,8 @@ static void display(void)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLod);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLod);
if (NearestFilter) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST_MIPMAP_NEAREST);
}
else {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
}
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filters[min_filter].value);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, NearestFilter ? GL_NEAREST : GL_LINEAR);
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias);
......@@ -212,6 +219,16 @@ key(unsigned char k, int x, int y)
MaxLod += 0.02;
break;
case 'f':
if (!min_filter)
min_filter = sizeof(min_filters) / sizeof(*min_filters);
min_filter--;
break;
case 'F':
min_filter++;
if (min_filter == sizeof(min_filters) / sizeof(*min_filters))
min_filter = 0;
break;
case 'g':
NearestFilter = !NearestFilter;
break;
case 27: /* Escape */
......@@ -232,7 +249,8 @@ static void usage(void)
printf(" n/N decrease/increase GL_TEXTURE_MIN_LOD\n");
printf(" x/X decrease/increase GL_TEXTURE_MAX_LOD\n");
printf(" l/L decrease/increase GL_TEXTURE_LOD_BIAS\n");
printf(" f toggle nearest/linear filtering\n");
printf(" f/F cycle minification filter\n");
printf(" g toggle nearest/linear magnification filter\n");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment