[LWJGL] I'm VBO'ing wrong...

Hi! My problem is hopefully pretty straightforward. I’m starting to move away from immediate mode rendering and getting my feet wet with VBO’s! I’ve seen a couple of tutorials, but when I try to write it out myself, it just won’t render. I’m trying to render this 64x64 texture I made, which works fine in immediate mode, but when I try to use a VBO, nothing renders.

Here it is: http://pastebin.com/mc4yvdvK

Any idea why it doesn’t render? (like I said, immediate mode works just fine)

Do you make sure to bind the texture?

CopyableCougar4

Yep, he is.

@OP: Does glGetError print out anything other than 0?

Shouldn’t there be something in the third argument, similar to [icode]2 << 2[/icode]? I’m not an expert, but that’s what it’s like in my VBO helper class.

glVertexPointer(2, GL_FLOAT, 0, 0);

CopyableCougar4

You mean to put 2 << 2 as the third argument? Well in that case I tried it, and it still doesn’t work. I swear I’m just missing one line somewhere, or I need to rearrange a couple of lines, but I just can’t find which. Anyone else?

No your array is tightly pack that looks fine, have you tried rendering without texture coords? You’re positive your quad is built the same way(same vert order)? Maybe you’re rendering the back face?

Why are you dividing your vertex size by two? Does RenderUtils.createFlippedBuffer expect to have the size halved? You still need a buffer to fit all the data… edit: I can read I promise…

Also, you aren’t using the right buffers for your binds.
glVertexPointer(2, GL_FLOAT, 0, 0);
glTexCoordPointer(2, GL_FLOAT, 0, 0);

should be

glVertexPointer(2, GL_FLOAT, 0, vboVertices);
glTexCoordPointer(2, GL_FLOAT, 0, vboTexCoords);

Nope, what you are saying is vertex arrays. That is not vbo.

…those are the variables for his buffers? I don’t know what you mean

Check out my article:

@thedanisaur: like SHC said, you are suggesting the way it works for VAs when the OP needs VBOs. If you’re not familiar with the difference you could read up on how to use VBOs in OpenGL.

@Riven

I don’t mean any offence, but I think your article needs more text, at least that’s what I think. I’ve stumbled upon your article so many times when I was learning, but the amount of code always confused me, until I got to OpenGL Documentation to understand some (stride and offset, especially). I don’t mean any offence, if it sounds as such, I’m sorry :wink:

I could improve it - the bit shifting (n << 2) seems to be too confusing for some, but then again, OpenGL is not a library for newbies. You are bound to have to read the documentation, so duplicating this effort seemed like a waste. I could add some links to docs in strategic places though.

If anything, the tutorial provides a lot of handholding already, and working code that you can tinker with, discovering what works and what crashes the JVM.