Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Beginner OpenGL 3.3+ Questions


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
1 reply to this topic

#1 blueskies9041   Members   -  Reputation: 138

Like
0Likes
Like

Posted 05 March 2014 - 02:39 PM

So I'm developing my first game " engine " for a game programming class assignment.

 

So my engine consists of a Quad Class, a Sprite Class (child of quad), and some child classes of Sprite that I use for testing purposes.

 

So the way I have it setup every " Quad "  has its own Vertex Buffer , Index Buffer , Vertex Array , Shader Program (vertex + frag), Texture, and some math structures (vectors, martrices etc) that I use in and outside of the vertex shader.

 

I am doing really simple 2D stuff at the moment so optimization isn't critical, however, when designing an engine that can produce multiple textured primitives would each primitive need to contain its own Vertex Buffer, Index Buffer, Vertex Array etc... Cause reading through articles I know it is possible to get multiple primitives on screen with only one VAO/VBO etc...

 

Sorry. I've been through a lot of tutorials and they all do things differently so I'm getting very confused.



Sponsor:

#2 3TATUK2   Members   -  Reputation: 730

Like
0Likes
Like

Posted 05 March 2014 - 06:32 PM

Well, frankly, if you're doing 2D based on mainly quads... You really don't need different VBOs. You just have one quad VBO that every sprite would use and just pass in scaling/translation for dimmension/position. You bind each proper texture before rendering each quad.

 

There can be variations, but I think this is the most straightforward. For example you could do some fancy stuff with instancing and possibly sending multiple textures through to one texture call using uniforms to specify which one to use and such.

 

In my own 3D engine, it's a bit different.. Since geometry consists of actual diverse unique information instead of just quads on a screen, basically what I do is automatically split the geometry up based on what texture it uses - then save that in it's own individual VBO. So I'll bind some texture, then bind the VBO related with it, and it will draw a "chunk" of my map. Then move on to the next texture, until all existing textures have been rendered. But again, this is static 3D geometry. Dynamic 2D quads is totally different and you would approach it more like I said above.






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.



PARTNERS