0
$\begingroup$

I have successfully completed a working program that draw a rotating sphere with a map of the world as the texture, simulating the earth in space. However, the texture is bound on it's side, i.e. all the continents are on their sides and the poles are shown as the sphere spins on the y-axis. I used the following reference to build the rotating sphere:

http://www.songho.ca/opengl/gl_sphere.html#:~:text=In%20order%20to%20draw%20the,triangle%20strip%20cannot%20be%20used.

and the stb_image library (https://github.com/nothings/stb) to load a JPEG image for the texture.

I've tried a couple of things like: actual rotation of the JPEG image, rotating the array that holds the texture coordinates, rotating the array that holds the indices

Everything is good apart from the orientation of the image bound for texturing. Any advice/pointers would be appreciated.

$\endgroup$

1 Answer 1

1
$\begingroup$

Binding the image is unrelated to its orientation. A shot in the dark is that your texture coordinates are either reversed or computed with the orientation in the wrong direction. You could just rotate the image as a work around. The main issue here is whether the upper left corner is your origin, or the lower left corner is the origin. But neither of these explain the image being sideways. At any rate, look at your texture coordinates, how the image is being copied into memory, how is is being passed to opengl, and the texture coordinates.

$\endgroup$
2
  • $\begingroup$ Thanks for your reply. I've tried rotating the JPEG image and this this did not help. Rotating using glm_rotate around z-axis conflicts with what I am doing with rotating around the y-axis. The pointer to texture coord used as origin is a good suggestion and will investigate. I'm also looking at using a .bmp texture which seems to give me more control loading and binding, and understanding the related texture coordinates. $\endgroup$
    – HSON
    Mar 25, 2021 at 8:42
  • $\begingroup$ Actually, what I meant by rotating the image is just to load it into an image editor and rotate it 90 degrees. (a serious hack but might help provide insight into what is happening) $\endgroup$
    – pmw1234
    Mar 25, 2021 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.