Setting texture base and max levels not working in pspgl

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
NeoXeno
Posts: 10
Joined: Thu Oct 20, 2005 5:35 am

Setting texture base and max levels not working in pspgl

Post by NeoXeno »

Ok, I want to restrict the mipmap levels of my textures. For this example, I only want to create 3 levels. Here are the relevant parts of my code.

glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0 );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2 );

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, image1);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, image2);
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, image3);

Now I just draw the image with this.

glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glEnd();


Now when I run the program, it would work great until I zoom out far enough to where the 3rd level texture (64 x 64) is drawn which results in a crash. However, it doesn't crash when I specify all the levels from 256 x256 to 1 x 1. I believe it crashes because it is trying to load the next level even though I set the max level to 2 to prevent this.

Why is it ignoring the level settings? Is there something I'm missing?
Post Reply