# Textures not rendering with VBOs

After having used display lists for my programs since I started learning OpenGL, I've finally decided to switch to VBOs after experiencing a considerable amount of lag when I started work on a new game. I've nearly finished with my transition, but I'm still having a bit of trouble with rendering the textures to the screen. The way I'm working it is this: I have several sprites of the same dimensions for each type of "block" in the game (it's a Terraria port) which are loaded into the game via a convenience method, then after they're all loaded, they're compiled into a virtual texture atlas via Graphics2D, converted to a Slick texture, and their relative coordinates are saved to a HashMap. However, when it comes time to grab the textures out of the HashMap and render them, the game simply doesn't. Here's part of my code for adding a block to the VBO (this is executed 4 times per block, once for each corner):

// top left
// vertex
// light
// texture


(Note: values is a list which is later converted to an array.) Then comes my code for rendering the VBO:

public static void render(){
glPushMatrix();
glTranslatef(MineFlat.xOffset, MineFlat.yOffset, 0);
glBindTexture(GL_TEXTURE_2D, BlockUtil.atlas.getTextureID());
glVertexPointer(2, GL_FLOAT, 28, 0);
glColorPointer(3, GL_FLOAT, 28, 8);
glTexCoordPointer(2, GL_FLOAT, 28, 20);
glBindTexture(GL_TEXTURE_2D, 0);
glPopMatrix();
}


The blocks are properly rendered with the correct lighting, but they lack any sort of texture. Any suggestions as to how to get the code working? I apologize if the answer is obvious, but I still consider myself a bit of an OpenGL noob, especially in the area of VBOs.

One last thing; I should mention that I'm not using any shaders in my current game.

EDIT: I seem to be a bit mistaken. Upon experimenting with the code by manually setting all texture coords, I discovered that the game simply converts the texture to a uniform color by averaging the RGB value of all pixels. I didn't recognize this before because the color of most blocks is grey. I recall having this problem before with display lists, but that was quite a while ago, and so I don't remember how I resolved it.

SECOND EDIT: Screenshots of the expected and actual result, respectively: http://i.stack.imgur.com/3t4r4.png http://i.stack.imgur.com/edv8v.png

• It shouldn't be necessary but did you try to call glEnable(GL_TEXTURE_2D); and glActiveTexture(GL_TEXTURE0); – PeterT Jul 27 '13 at 18:31
• @mrproncace your edit sounds like a problem with glTexParameteri, the MIN / MAG filters or the mipmap level if you use mipmaps. – PeterT Jul 27 '13 at 18:35
• @PeterT No luck. While I didn't have GL_TEXTURE0 active, activating it didn't solve the problem. While I did have the lines glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); and glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); in my code in order to remove interpolation while scaling, commenting them out didn't seem to affect anything either. – caseif Jul 27 '13 at 18:43
• yeah, GL_NEAREST should give you the least problems. If it's really the average color that sounds kind of weird. Got no clue, if that wouldn't be what happened I'd check if the relevant glEnableClientState() calls have been made. You might also try to call glClientActiveTexture(GL_TEXTURE0) but just like glActiveTexture it should be default anyway. – PeterT Jul 27 '13 at 18:55
• I've made calls to GL_VERTEX_ARRAY, GL_COLOR_ARRAY, and GL_TEXTURE_COORD_ARRAY. As for the textures being rendered as the average color, I'm not entirely positive that's the case; I was really just eyeballing it. I'll add two screenshots to the main post showing the expected result and the actual result. – caseif Jul 27 '13 at 18:56