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:


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.


1 Answer 1


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.

  • $\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
    Commented 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
    Commented Mar 25, 2021 at 11:16

Your Answer

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

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