🔒 Locked
Odd Texture Behavior
Advertisement
Original Post
I've been working with Textures for a little time. They have worked fine until now. I did a translate then re-applied my texture. The texture looks funny. It is in the place I expected and is the correct size. The texture just looks like it's in a lower resolution. This is what I do. glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glTranslatef(...); glBindTexture(GL_TEXTURE_2D, MyTex); glBegin(GL_QUADS); glTexCoord2d(0.0, 1.0); glVertex2d(Left, Top); glTexCoord2d(1.0, 1.0); glVertex2d(Right, Top); glTexCoord2d(1.0, 0.0); glVertex2d(Right, Bottom); glTexCoord2d(0.0, 0.0); glVertex2d(Left, Bottom); glEnd(); //detach texture glBindTexture(GL_TEXTURE_2D, 0); SwapBuffers(WinDC); Like I said, it's in the correct position and is the correct size as far as I can tell. The textured image just looks off. This is strange. Any ideas? I have never seen this before. Thanks in advance.
Perhaps you could post a screenshot of what it looked like before you did this and what it looks like in its "odd" state. I'm not entirely sure what you mean.
Your problem could just be a result of the texture's mipmapping, though. Try loading the texture into memory such that it doesn't enable mipmapping and see if you still have this problem.
Your problem could just be a result of the texture's mipmapping, though. Try loading the texture into memory such that it doesn't enable mipmapping and see if you still have this problem.
After some careful observations, I've come to the realization the image is being squeezed by a tiny bit. Enough to make the image look slightly off. I'm not sure why it's happening. Here is what I'm doing.
1. I create a texture map the size of my window.
2. I copy my entire render window/view port into the texture. This way I have a stored image of my render.
3. I perform a translation.
4. I draw rectangle with the my texture bond to it.
Shouldn't it produce an image that has moved by the translation amount? I don't see why the textured image should be squeezed. Thanks for the help.
1. I create a texture map the size of my window.
2. I copy my entire render window/view port into the texture. This way I have a stored image of my render.
3. I perform a translation.
4. I draw rectangle with the my texture bond to it.
Shouldn't it produce an image that has moved by the translation amount? I don't see why the textured image should be squeezed. Thanks for the help.
Hmm. That is rather strange. Can you perhaps post the full before/after code? Nothing comes to mind offhand. It's strange that it would work up until you translated it. Are you moving it along the Z axis? That could cause it to jump to a lower resolution mipmap of the image, like I mentioned, but that doesn't really sound like what you're talking about.
i've had a problem like this, but it involved scaling my texture. Do you ever scale it?
As a matter of fact, I sized my texture based on the size of my window (in pixels). And yes, the texture sizes were off (not powers of two). I fixed that mistake. However, the problem still exists. I only do a transform. I've been using this trick without problems. I tried manually moving the texture by shifting the values of Top, Bottom, Left, and Right; doing myself what glTranslate does.
Here are the options I set for the texture. I don't think I'm missing anyting.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
Thanks for the help. It's appreciated.
Here are the options I set for the texture. I don't think I'm missing anyting.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
Thanks for the help. It's appreciated.
I once had a texture that was also showing up funny and it turned out to be because I wasn't converting the source bitmap into Byte format. I'm not sure what you're using to load the files, but I was using DevIL library and the following code after loading the image solved my problem:
Maybe it helps...
ilConvertImage(IL.IL_RGB, IL.IL_BYTE);Maybe it helps...
Quote:
Original post by derethor
textures in basic OpenGL must be "power of 2" squared size (i meant 256x256, 512x512, etc
no.
There is no requirement that the textures are square, the sides must just be a power of two, so 256x512 is prefectly valid on default OpenGL.
I think you're on the right track. Here is what I do to set up the window.
//The size of my window in pixels
glViewport(0, 0, Width, Height);
.
.
//I use my own coordinate system for easier ploting,
//but it scales to my window
gluOrtho2D(Left, Right, Bottom, Top);
.
.
After rendering my image to the window, I make a copy the rendered image into the texture.
glBindTexture(GL_TEXTURE_2D, mRenderTexture);
glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0,0, Width, Height);
glBindTexture(GL_TEXTURE_2D, 0);
I think the problem is my texture does not scale exactly to my window. My window's dimensions are never powers of 2 like my texture. I found an example of some scaling texture and tried it. However, it do not fix my problem.
ScaledWidth = (Width / TexWidth);
glTexCoord2f(ScaledWidth, 0); //instead of 1,0
I think what I'm doing is pretty non-standard. I might be better off simply trying something new. Thanks anyways.
//The size of my window in pixels
glViewport(0, 0, Width, Height);
.
.
//I use my own coordinate system for easier ploting,
//but it scales to my window
gluOrtho2D(Left, Right, Bottom, Top);
.
.
After rendering my image to the window, I make a copy the rendered image into the texture.
glBindTexture(GL_TEXTURE_2D, mRenderTexture);
glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0,0, Width, Height);
glBindTexture(GL_TEXTURE_2D, 0);
I think the problem is my texture does not scale exactly to my window. My window's dimensions are never powers of 2 like my texture. I found an example of some scaling texture and tried it. However, it do not fix my problem.
ScaledWidth = (Width / TexWidth);
glTexCoord2f(ScaledWidth, 0); //instead of 1,0
I think what I'm doing is pretty non-standard. I might be better off simply trying something new. Thanks anyways.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement