Advertisement Jump to content
Sign in to follow this  
blueskies9041

OpenGL Beginner OpenGL 3.3+ Questions

This topic is 1778 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

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.

Share this post


Link to post
Share on other sites
Advertisement

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.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!