1 Replies - 758 Views - Last Post: 31 March 2017 - 05:35 AM

#1 Publius190   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-December 13

Drawing in Game VS Withing GameObject

Posted 29 March 2017 - 04:50 PM

Hi everyone,

I have a slightly more opinion based question to that I'm having a hard time finding online. I'm starting a new project that I am actually passionate about this time so I'm hoping I can see it through.

My question is: Do people prefer to draw all of their textures within the main draw method, or just call a draw method within each game object. For the latter, would you just create a new spritebatch in each object? Would this slow down code? I like the idea of calling separate draw methods, but I'm just worried about processing time when drawing.


Is This A Good Question/Topic? 0
  • +

Replies To: Drawing in Game VS Withing GameObject

#2 BBeck   User is offline

  • Here to help.
  • member icon

Reputation: 792
  • View blog
  • Posts: 1,886
  • Joined: 24-April 12

Re: Drawing in Game VS Withing GameObject

Posted 31 March 2017 - 05:35 AM

Draw calls are extremely expensive and you want to minimize the number of them. It's called a sprite "batch" for a reason. Ideally, you would load up one vertex buffer and have one texture and draw everything that way. That's not practical. My understanding of a sprite batch is that it's basically gathering up all the textures into one buffer and doing a single draw call. You want to stick to that as much as possible. You may want a single class that handles drawing, especially when working with sprites, so that you can get it all in as few draw calls as possible.

I always had individual classes drawing themselves, but I was doing 3D, had less experience back then, and wasn't doing enough objects for it to be a problem in most cases.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1