Reputation: 3580
My game normally uses GL_TEXTURE_RECTANGLE_EXT to draw 2D textures. However, since this isn't supported on all hardware, I am trying to get GL_TEXTURE_2D to work. Initially most images showed up as pure white until I started calling
glTexParameteri(caps->extension, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(caps->extension, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
once per image drawn, instead of once per frame. (With RECTANGLE_EXT, I can get away with once per frame and it works fine.)
Okay, so now the images show up. Problem is though, they draw as solid white once the very first time that texture is drawn. Then after that, they draw properly. This results in lots of flashes of white the first time any images are drawn, and this resolves itself as the images get reused. Any ideas what could cause this?
I have "power of 2" rounding up turned on at the moment as well, so all textures are being rounded to the nearest power of 2 when first created.
Upvotes: 1
Views: 769
Reputation: 3580
Someone answered this on the SDL forums. "By default, OpenGL DOES enable mipmapping unless you specifically tell it to use GL_LINEAR or GL_NEAREST in glTexParameteri(), which is why it will be white until you set it to that otherwise." (i.e. the mipmaps are being used, but they are not set up.)
Another poster wrote: "Technically OpenGL expects (by default) you to upload all the mipmaps, like calling gluBuild2DMipmaps on every texture (even 2D UI art) or your own mipmapping routine (my choice, much faster than the glu32.dll on Windows at least), but of course one does not even desire mipmapping on these textures (or the wasted 33% extra memory involved) so it is far more elegant to just change the glTexParameter settings."
Upvotes: 1
Reputation: 7436
Means that some state required to work is set only after first frame is drawn. Take a look at NeHe texturing tutorials and how it should be done properly.
Upvotes: 0