Search code examples
javaspritelwjglvbovao

LWJGL - VBO's and Sprite Classes


I've recently found out that using immediate mode when rendering is a big no-no.

So I started looking up on VBO's and VAO's and if I understand correctly, VBO's are objects/buffers which containts data like position, color and so on.

You then put the VBO's in a VAO and render everything in the VAO?

All of this is very new and strange to me, so I was wondering on HOW I would use it, for example, how would a Sprite/Texture class look like, and am I able to modify things like textures once I've started rendering?

I've googled around but haven't found anything I've been able to grasp.

Thank you in advance!


Solution

  • Even though the question is quite wierd formulated, I think I get what you want(correct me if I don't)

    You have to think of a VAO as a list. In this list, there are a number of attributes, for example positions, texture coordinates, etc(up to 16). Each attribute is stored as an array(VBO). This array is filled with all data of one attribute(e.g. all vertex-positions). The function glVertexAttribPointer describes the properties of one VBO, like the size of one vertex, data type, etc.

    On the other hand, there are Uniform variables. These variables are loaded before the draw-call into a slot specified in the shader. These variables stay constant for the whole mesh and are used for values, which stay the same for all vertices(projection, view, etc.). These variables can also be of the datatype Sampler, which represents a texture.

    For more detailed information I suggest you read through some samples/tutorials.