<p>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.</p>

CC BY-SA 4.0
2021-03-25T08:42:51.433Z
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.
HSON
CC BY-SA 4.0
2021-03-25T11:16:04.547Z
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)
pmw1234
CC BY-SA 4.0
2021-03-23T22:39:33.557Z
2021-03-23T22:39:33.557Z
pmw1234
<p>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:</p>
<p><a href="http://www.songho.ca/opengl/gl_sphere.html#:%7E:text=In%20order%20to%20draw%20the,triangle%20strip%20cannot%20be%20used" rel="nofollow noreferrer">http://www.songho.ca/opengl/gl_sphere.html#:~:text=In%20order%20to%20draw%20the,triangle%20strip%20cannot%20be%20used</a>.</p>
<p>and the stb_image library (<a href="https://github.com/nothings/stb" rel="nofollow noreferrer">https://github.com/nothings/stb</a>) to load a JPEG image for the texture.</p>
<p>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</p>
<p>Everything is good apart from the orientation of the image bound for texturing.  Any advice/pointers would be appreciated.</p>

<opengl><texture>
How can I bind my texture in the correct orientation?
HSON
# How can I bind my texture in the correct orientation?

(Asked by: username_0 on 2021-03-23)

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](http://www.songho.ca/opengl/gl_sphere.html#:%7E: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.

**Tags:** opengl, texture


---

## 1 answers

### Answer by username_1 on 2021-03-23. Score: 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.

> **Comments:**
> **username_0**: 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.  
> **username_1**: 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)  

---

