Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Setting the origin of a single OpenGL texture  (Read 1401 times)

0 Members and 1 Guest are viewing this topic.

WDR

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Setting the origin of a single OpenGL texture
« on: October 18, 2014, 05:49:28 pm »
Hi... I previously did a project in SFML 2.0 and got used to the API. Now, for my next project, I am going to the next level by using OpenGL for graphics. I am still not perfect in using OpenGL, but I'm learning. In OpenGL, I managed to load a texture and display it. I am now trying to set the origin of the texture to its center (individual object, not global origin). By default, this is at the bottom left corner of the texture, similar to SFML's top left corner. I want to set a different origin at its center, similar to SFML's setOrigin(). I checked SFML's source to see how this function is defined, but I really couldn't understand it. I even googled on how to change the origin of an OpenGL texture, but nothing relevant came up. Can someone please tell me what the logic behind setOrigin() is and how it works, so I may apply it in my OpenGL texture code? This is a theoretical query and not really about SFML but it was somewhat related, so I posted it. Apologies for any irrelevance. Please help. Thank you.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Setting the origin of a single OpenGL texture
« Reply #1 on: October 19, 2014, 08:03:04 pm »
From what I can see, the origin in SFML is just a vector storing an offset which is used in creating the transform.
In your case, could you not just subtract the origin from the given position whenever setting its location.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything