Beginner OpenGL 3.3+ Questions

Started by
0 comments, last by 3TATUK2 10 years, 1 month ago

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.

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.

This topic is closed to new replies.

Advertisement