PDA

View Full Version : Reversing Up-Vector of the camera



Neuron
01-12-2012, 03:30 AM
Hi,
I have a texture(jpg) and when I map it to a cylinder OpenGL maps it upside down(I do not know why?)!
Now I decided to reverse my Up-Vector instead of rotating my texture which is(I think) computationally expensive.
Here is my code:
gluLookAt(0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0);

Is it a good idea?

thokra
01-12-2012, 03:33 AM
Why don't you just mirror the UVs?

tksuoran
01-12-2012, 10:22 AM
In general, GL functions assume (1, 1) is to the right and up from (0, 0). TexImage2D assumes data for (0, 0) come in first and (1, 1) come in last. Your image loading routine might assume top row first.

Mirroring UV*like thokra advised is efficient and easy fix.

Neuron
01-12-2012, 12:09 PM
Thanks,
When I use JIG's jpeg-8 library the image is mapped upside down, but when I use FreeImage library everything is OK.

carsten neumann
01-12-2012, 01:45 PM
Some libraries already flip the image in anticipation that it will be used as an OpenGL texture, others simply give you the data in the file, and some allow you to configure this. Check the documentation of the libs to see if you can make them behave consistently (if you need to keep the option to use both) or just pick one and stick with it ;)

awhig
01-12-2012, 02:03 PM
When I use JIG's jpeg-8 library the image is mapped upside down, but when I use FreeImage library everything is OK.

I second to carsten's reply. Images like BMP (MS version) arrange data such that the first row is last and last row is first. So you need to first check the file format and then check with the library.