I’ve determined a matrix that incorporates a scale and translation for my texture. This enables me to place a texture of varying sizes on to an object. All good.
The problem is that periodically, my texture is moved somewhere else… it is almost like my texture coordinates are being scaled/translated by something else.
I’m reasonably confident that I’m calling glMatrixMode appropriately. In fact, here’s the code that I’m using to set up my texture coords:
// Set our texture matrix
// Draw the world
// Restore our texture matrix
I’m pretty sure that mTextureMatrixP does not get mutated elsewhere in the proggy.
I’ve got this feeling that something else is effecting my texture’s world…
Here’s an image of my world when all is well (most of the time):
…and then when things go crazy:
There are other things going on like changing the raster position, drawing bitmaps etc., but this is all done when I’m in the model view matrix. I don’t jump out of the model view matrix anywhere else.
Originally posted by T101: 1. Are you using a single texture the whole time or is it with different textures?
2. Why do you need to scale and translate the texture? Why not just use standard texture coordinates? You may well have a valid reason for this, but I don’t think varying texture sizes should be one.
As I zoom in on the world, I want to pull in portions of bitmaps with higher resolutions. The portions equate to the dimensions of the viewport so my memory allocation for the texture remains static. Having the higher resolution bitmaps around in memory is not feasible.
3. In the bottom picture it looks like you might be getting some sort of clamping. Maybe you should try setting the wrapping mode for the texture.
I’ve done this:
I did the above for debugging purposes. I will comment out the two lines just in case that’s what’s causing my problems… why would this be a problem though?
4. If the matrix itself is as fault, that can only be caused by corruption of your mTextureMatrixP array, since you’re doing a glLoadMatrix, not a mult.
That’s what I thought. I’m pretty sure mTextureMatrixP isn’t getting corrupted though. I’ll check again.
5. Are you using TexGen? If so, are you moving the object or the camera in any way?
I’m not using TexGen.
The clamping would come in play if you’re using translation to rotate the world (you didn’t specify if you’re doing that). If you hit an edge, the texture just stops instead of wrapping around. And clamp-to-edge results in lines outside [0,1].