Pregunta

I'm working on my own game engine these days, and I'd like to make the rendering process as efficient as I can. With "immidiate mode" I found that it's very easy to implement the features I want to include.

Here's the list:

  • transforming(translation,rotation, scaling, pivot)
  • parenting (child sprites are affected by parent sprite e.g transform)
  • simple vector graphic - well this isn't that important now
  • depth management

But with VBOs and shaders it's quite hard to determine a good rendering structure. At first I put four vertices in a VBO and transformed it with matrix(gluniform), but many people said this is the worst way. So, I'd like to hear your general ideas about efficiently implement those features and how I should VBOs.

¿Fue útil?

Solución

You could have one square VBO that you use for all of your sprites by scaling it for the width and height and transforming it with matrices and binding the right texture for each sprite. Child sprites could multiply their matrices with the matrices of their parent sprite. Depth management can be done with the depth buffer, just glEnable(GL_DEPTH_TEST) and GL_LEQUAL depth function and translate along the z-axis to what layer you want it drawn on. You probably don't even need to worry about doing everything the best and fastest way for just 2D sprites anyway.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top