Jump to content
  • Advertisement
Sign in to follow this  
Sundeepkahlon

Setting up a camera with SFML and raw opengl calls

This topic is 1414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,
 
I'm having some trouble with using an sf::VIew as a camera when mixing raw opengl calls with SFML. For example, here in my code I'm mixing opengl calls with SFML: https://github.com/SundeepK/Clone/blob/wip/add_splittable_enviroment/src/Game.cpp#L58. Everything drawn by SFML is correct but the textures drawn manually using opengl calls follow the camera when the player moves, rather than staying put. Here's an example image: http://i.imgur.com/umME791.png?1 . When I move, you can see that the wooden texture follows rather than staying where it's box2d body is.
 
What would be the general way of handling a camera in this scenario? Would I need to write a custom camera class?

Share this post


Link to post
Share on other sites
Advertisement

I managed to fix the problem by using a camera specific for opengl. So I maintain an sf::View for SFML related drawing and a camera class for opengl related calls. I don't know if this is best practice, but it seems to work. I also read that raw opengl calls should be maintained sperate from sfml, so I guess it would make sense to have seperate camera's. On a side note, my texture still ins't being drawn in the correct place. Here's an image showing what I mean: http://postimg.org/image/vfzruhsv7/ . Moving around correctly leave the texture in one place, but it's not located where the green box should be.

 

I suspect the problem maybe with how I draw my texture  (https://github.com/SundeepK/Clone/blob/wip/add_splittable_enviroment/src/systems/OpenGLTextureRenderer.cpp).  Though I cannot see what maybe wrong.

Edited by sunk

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!