Quicktime and Texture Coordinates
Hi.
This seems simple enough, but it's been bothering me all day.
I just added textured text, at the moment copied from a NeHe tutorial. I copied the bit that makes the display lists for the letters.
It uses the usual image containing the characters evenly spaced:
![[Image: font1.png]](http://griggs.idevgames.com/images/font1.png)
The problem is that because I'm using Quicktime to load the textures the texture coordinates don't work. When I try for " A B C D E F G" I get "…q…r…s…t…u…v…w" Opposite from what I want.
Now, my question is how should I modify this code:
To compensate for the texture coordinate change? I haven't hit on what I need yet, it's really quite frustrating.
Thanks
This seems simple enough, but it's been bothering me all day.
I just added textured text, at the moment copied from a NeHe tutorial. I copied the bit that makes the display lists for the letters.
It uses the usual image containing the characters evenly spaced:
![[Image: font1.png]](http://griggs.idevgames.com/images/font1.png)
The problem is that because I'm using Quicktime to load the textures the texture coordinates don't work. When I try for " A B C D E F G" I get "…q…r…s…t…u…v…w" Opposite from what I want.
Now, my question is how should I modify this code:
Code:
for (int i = 0; i < 256; i++)
{
cx=float(i % 16) / 16.0f;
cy=float(i / 16) / 16.0f;
glNewList(fontListBase + i,GL_COMPILE);
glBegin(GL_QUADS);// Use A Quad For Each Character
glTexCoord2f(cx,1-cy-0.0625f); // Texture Coord (Bottom Left)
glVertex2i(0,0); // Vertex Coord (Bottom Left)
glTexCoord2f(cx+0.0625f,1-cy-0.0625f); // Texture Coord (Bottom Right)
glVertex2i(16,0); // Vertex Coord (Bottom Right)
glTexCoord2f(cx+0.0625f,1-cy); // Texture Coord (Top Right)
glVertex2i(16,16); // Vertex Coord (Top Right)
glTexCoord2f(cx,1-cy); // Texture Coord (Top Left)
glVertex2i(0,16); // Vertex Coord (Top Left)
glEnd();
glTranslated(10,0,0);
glEndList();
}//end for loopThanks
OpenGL's origin is bottom left whereas quicktime's origin is top left so you need to flip the image when you load it which is pretty trivial operation with quicktime. You just flip the bounds rect before you load the image.
This is only correct though if you were getting the glyphs upside down as well, which you didn't mention.
This is only correct though if you were getting the glyphs upside down as well, which you didn't mention.
No, they weren't upside down. The glyphs were exactly as they should look, but I'm getting the wrong ones.
Quote:Code:
glTexCoord2f(cx,1-cy-0.0625f)
get rid of the 1-
Code:
glTexCoord2f(cx,cy-0.0625f)
Would this also explain why my PNG textures come out upside down when I load with libpng and display with OpenGL?
Maybe so, though oddly enough i my case the image was right side up, only the coordinates were messed up.
Anyway, I have it fixed now, turns out I needed to change the loop a bit and change the display list base.
Thanks for your patience with my newbie questions. OpenGL is really quite new to me, but I think I'm getting things the way I want them. Currently a 640x480x32 full-scrolling tiled environment gets me about 110FPS on my iBook, and about 250 on my G4/400. I think I'm entirely fillrate limited in this case, which is hard to overcome. But 110 (with speed governors off) is good enough for me.
Anyway, I have it fixed now, turns out I needed to change the loop a bit and change the display list base.
Thanks for your patience with my newbie questions. OpenGL is really quite new to me, but I think I'm getting things the way I want them. Currently a 640x480x32 full-scrolling tiled environment gets me about 110FPS on my iBook, and about 250 on my G4/400. I think I'm entirely fillrate limited in this case, which is hard to overcome. But 110 (with speed governors off) is good enough for me.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Render video (e.g. QuickTime) to buffer or texture? | Ingemar | 14 | 11,133 |
Jun 8, 2011 04:09 PM Last Post: mdejong1024 |
|
| openal coordinates vs. opengl coordinates | gerald | 1 | 5,417 |
Feb 3, 2011 10:04 PM Last Post: OneSadCookie |
|
| Flipping a texture loaded using QuickTime.. | Craig | 3 | 3,122 |
Nov 17, 2005 08:52 PM Last Post: arekkusu |
|
| Integer texture coordinates. | Skorche | 5 | 3,640 |
Apr 28, 2005 10:49 AM Last Post: Puzzler183 |
|
| vertex/texture coordinates screwy | reubert | 1 | 2,449 |
Aug 10, 2004 08:29 AM Last Post: phydeaux |
|

