How should I texture VBOs in my game?

I’m at the point in my game-development “career” where I’m finally learning about Shaders. I find them very interesting and there are so many possibilities for what they could be used for, but I’m currently stuck on where I should use them and where I shouldn’t (in terms of optimization, practicality, etc). I’m currently designing an Multiplayer-FPS, and I use blender models for all of my entities. I use the UV-Mapping of the model provided by the .obj file to texture my model using a FloatBuffer in all my VBOs, however I’m now wondering if it would be smarter to just use a texturing-shader for all my VBOs and pass the texture coordinates to the shader.

What do you guys think, should I use a shader to texture all my objects and pass texture coordinate/texture file parameters to the shader, or should I use a FloatBuffer for the texture coordinates like I currently am and draw them using the standard procedure for applying texture with a VBO (glTexCoordPointer, GL_TEXTURE_COORD_ARRAY, etc)?

Here, have a picture of me screwing around with shaders. Because why not?

Just to clarify, you mean you are using VBOs without shaders and would like to know if you should just use shaders with the VBOs.

Short answer: Yes.

Long answer: The only real downside is learning how to write and use the shaders (which I wouldn’t even really consider a downside), and there is plenty of information in books and on the internet for it. Obviously there are a lot more things to consider, but I say just go for it.

Pretty close…I’m currently using VBOs to hold vertice data, normal data, and texture/texture-coordinate data. I also use glTranslate* and glRotate* to draw the VBO in its correct position in the game (instead of everything being drawn at the origin or editing the vertices every time the VBO should move I use a position vector and use glTranslate/Rotate to make it appear as though it’s in the correct position). So yeah I guess you are kind of right, I’m wanting to know if I should use a shader for texturing/translating my VBO instead of texturing/translating without a shader.

My only worry is won’t I have to pass all those variables (texture coordinates, position, rotation, vertices, etc) to the shader program every time I want to use it? I’m learning about shaders as we speak so I apologize if I’m wrong. But hey, that’s why I’m asking. :slight_smile:

I’ve looked into it and there seems to be no point in using a shader to texture all of my objects, because it would seem that I have to render it textured anyway so that I can pass all the texture coordinates and the texture to the shader if that makes sense. For example, in order to pass the texture coordinates of my model to the shader I have to use:


glBindBuffer(GL_ARRAY_BUFFER, textureHandle);	
glTexCoordPointer(2, GL_FLOAT, 0, 0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

If I use those statements so that the coordinates are passed to the shader, then when I call glDrawArrays() to render my VBO it will render the texture anyway.

Well…what I said still stands. The only difference between what you’re doing and shaders is writing the vertex and fragment shaders (and removing the use of glRotate/Translate/Scale), and then you’ll have a lot more flexibility in the future.

If you don’t want to that’s obviously fine, but the reason I recommend it is that you’ll probably want some extra/more fancy effects in the future and since you’re messing with rendering code now it’s a great time to just do it.