Jump to content

View more

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

OpenGL and Spritesheets (2D game)

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 ChainedHollow   Members   

158
Like
0Likes
Like

Posted 27 September 2013 - 11:49 AM

I have been working on a 2D game using SDL for a while now and got to a point where I felt OpenGL would be needed for rotating sprites. I have been trying to learn it to get it implemented into the game, and I am having some trouble. What I am mainly wondering right now, is the best method of using sprites. Is it still best practice to have all my sprites on one sheet for multiple objects? Or have a separate sheet for each object. 

 

Thank you!



#2 Goran Milovanovic   Members   

1104
Like
1Likes
Like

Posted 27 September 2013 - 12:02 PM

It's better for performance to use a single texture for multiple objects. The industry term is "texture atlas".


+---------------------------------------------------------------------+

| Game Dev video tutorials  ->   http://www.youtube.com/goranmilovano |
+---------------------------------------------------------------------+

#3 BeerNutts   Members   

4379
Like
2Likes
Like

Posted 27 September 2013 - 01:14 PM

I'd suggest moving to SFML if you are concerned with rotating sprites.  It's graphics API runs on top of OpenGL, and all sprite manipulations (rotations, scaling, etc.) are done in HW.  Check out the Sprite class in the SFML documentation for more details.

 

Good Luck!


My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#4 TheUnnamable   Members   

1129
Like
0Likes
Like

Posted 27 September 2013 - 06:22 PM

The theory behind this is that switching textures has its cost.

So when you have, let's say, a sheet for every object, then first you have to switch to sheet A, draw every instance of object A, then the same with sheet/object B, C, and so on. That's one texture switch for each object.

Now, if you merge sheets A, B, C, D into one single sheet, you just switch to your merged sheet, draw *lots* of instances, and then move on.

 

When merging sheets, keep in mind that depending on your target audience, GPUs have a limit on maximum texture size. On modern GPUs it's 8192x8192 or bigger, as far as I know. If you want to support older cards too, using 1024x1024 sheets is a nice bet. Also, rounding texture dimensions to powers of two is another good practice ( afaik ).



#5 Dragonsoulj   Members   

3180
Like
0Likes
Like

Posted 27 September 2013 - 09:35 PM

If you are going the SFML route, or wish to learn a bit more about Spritesheets: http://www.gamedev.net/page/resources/_/technical/game-programming/introduction-to-spritesheets-r2985

I advise at least taking a look at the link at the beginning of the article.






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.