PDA

View Full Version : very simple texture problem



appdeveloper
10-12-2009, 04:51 AM
I'm a rookie on OpenGL and i feel like being stuck on a very simple problem. I'm trying to texture a polygon
with an image of a face. the following code makes the face look at the left, but i need to flip it so that the face looks at right. Can anyone give me a help, please?

Gl.glBegin(Gl.GL_TRIANGLE_STRIP)

Gl.glColor3f(1.0F, 0.0F, 0.0F)
Gl.glTexCoord2f(1.0, 0.0) : Gl.glVertex3f(0.0, m_size.Height, 0.0)
Gl.glTexCoord2f(1.0, 1.0) : Gl.glVertex3f(0.0, 0.0, 0.0)
Gl.glTexCoord2f(0.0, 0.0) : Gl.glVertex3f(m_size.Width, m_size.Height, 0.0)
Gl.glTexCoord2f(0.0, 1.0) : Gl.glVertex3f(m_size.Width, 0.0, 0.0)

Gl.glEnd()

Coolcat
10-12-2009, 05:00 AM
You just need to flip the texture coordinates on that axis. If the coordinate is (u,v) and you want to flip on V-axis set it to (u, 1.0 - v).


Gl.glBegin(Gl.GL_TRIANGLE_STRIP)
Gl.glColor3f(1.0F, 0.0F, 0.0F)
Gl.glTexCoord2f(1.0, 1.0) : Gl.glVertex3f(0.0, m_size.Height, 0.0)
Gl.glTexCoord2f(1.0, 0.0) : Gl.glVertex3f(0.0, 0.0, 0.0)
Gl.glTexCoord2f(0.0, 1.0) : Gl.glVertex3f(m_size.Width, m_size.Height, 0.0)
Gl.glTexCoord2f(0.0, 0.0) : Gl.glVertex3f(m_size.Width, 0.0, 0.0)
Gl.glEnd()

appdeveloper
10-12-2009, 06:25 AM
Great, Thanks