hi, i’m asking myself how many different vertex array objects i should use to accomplish my (current) goal to create a renderer for a simple 3D game / scene
currently i can only render models, therefore i use 2 buffers and 1 vertex array:
1 instance buffer for instanced rendering infos (model transformation matrix + integer as “object identifier”)
1 vertex buffer with ALL models vertices / texcoords / normals in it
so the only verex array i have is for models, and streams to the shader:
// per vertex
in vec3 position
in vec2 texcoords
in vec3 normal
in int material
// per instance
in mat4 modelmatrix
in int objectID
i’m rendering all models deferred, the first pass to populate a “G-buffer” (textures), the second pass i render a [-1;+1]x[-1;+1] screen sized rectangle (to cover all pixels) and do some lighting calculations, or discarting if (pixelmaterial == -1)
now i want to implement simple (dynamic) 2D text rendering, in previous days i did that using a font texture (16 x 16 for all chars possible) and 1 extra vertex array:
struct TextVertex {
vec2 position;
vec2 texcoords;
};
each frame i created the vertices for the textured rectangles representing a char in a string which i wanted to render at a certain position
the width / height for each char i read from a separate file (once at initialization)
as described here: Tutorial 11 : 2D text
i could simply “fit” this type of textvertex in the current vertexarray for models, but is this a good idea ??
the models vertices are all in one GL_STATIC_DRAW buffer, for the text vertices i have to use a GL_DYNAMIC_DRAW buffer
should i just use another vertex array ? if not, i would only have to call glBindVertexArray(VAO);only once at initialization
but wit more different VAOs, that not true anymore …
if i should use only 1 VAO: should i disable each frame the unused attrib arrays for the text rendering program (and re-enable them when rendering models) ??
(in other words: are those kind of VAO state changes expensive ?)
thanks for your advice(s)!