images appearing upside down?

Started by
5 comments, last by unfinished 18 years, 12 months ago
how can i correct images appearing upside down i am using c++ is the only way to rotate the image 180 degrees?
Advertisement
If OGL is anything like DirectX regarding textures then cant u invert the texture coordinates?

ace
just swap the t component of your tex coordinates (s, t) (swap 0s with 1s and vice versa)
it's been a long time sense i've played arround in OGL, but try something like

GL_MatrixMode(GL_TEXTURE);
GL_Scalef(-1,0,0);
| Member of UBAAG (Unban aftermath Association of Gamedev)
#first:
try to rotate the GL_TEXTURE like this
glMatrixMode(GL_TEXTURE);
glRotatef(180,0,0,1);
glMatrixMode(GL_MODELVIEW);

#second:
try to swap the array buffers like
unsigned char tmp=new unsigned char[image.size];
for (int i=0;i<image.size;i++)
tmp=image.data[(size-1)-i];
for (i=0;i<image.size;i++)
image.data=tmp;
delete []tmp;

something like this ..
i hope you get it :)
Are you sure they're upside down and not mirrored horizontally?

If they're mirrored horizontally it's because you haven't taken into account the fact that opengl coordinates conventionally put 0,0 at the bottom left of the screen.

You can fix this several ways
- Invert the y component of your texture coordinates
- Create the texture the other way up

The latter is often a nicer approach.

Mark
are you in ortho mode?

I read somewhere that textures are drawn from bottom to top.

GL_Scalef(0,-1,0); // X,Y,Z

will invert the screen

This topic is closed to new replies.

Advertisement