I have spent about a week trying to get this code to work. I have gone to about 10 different websites and watched multiple videos on VBOs and VAOs. I think that I am just making a stupid mistake but I am not sure. I just need someone else to look at this code and tell me if something is wrong.

I have spent about a week trying to get this code to work. I have gone to about 10 different websites and watched multiple videos on VBOs and VAOs.

Already have. I have copied down the exact code from LWJGL's wiki to see if VBOs in general weren't working, but they work perfectly. I think that it might be a combination of 3d space with the VBO that is causing the error.

You seem a bit confused when it comes to shader attributes. GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); is deprecated. It's used to enable you to send stuff to the built-in gl_Vertex attribute (also deprecated), meaning that it's a batch version of glVertex3f(). Remove all references to it, it's not doing anything at the moment (except throwing an error if you've disabled compatibility mode).

You've also completely misunderstood VAOs. They store all the vertex settings, so there's no need to enable attributes or bind buffers when rendering after you've set it up. First of all, glEnableVertexAttribArray() is also stored in VAOs, so enable it when you create your VAO and get it done with. Your current render code basically does the full VAO setup every time you want to render it, so a lot of work is unneeded. Also, index arrays are also stored in the VAO, so move those to before you unbind the VAO.

vboid = GL15.glGenBuffers();GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboid);GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW);GL20.glEnableVertexAttribArray(0); //Stored in the VAO so enable it here and you won't have to bother with it later.GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

vboindicesid = GL15.glGenBuffers();GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboindicesid);GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_STATIC_DRAW);//GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); the bind is stored in the VAO so it won't have any effect on the global state

GL30.glBindVertexArray(0); //Moved here to make sure that the index buffer is also being registered in the VAO.

//GL20.glDisableVertexAttribArray(0); unneededGL30.glBindVertexArray(0); //shouldn't be needed since you should always be binding a new VAO before rendering (or else you're using deprecated functionality)

Util.exitOnGLError("TriangularPrism.render"); }

publicvoiddestroy(){//GL20.glDisableVertexAttribArray(0); not needed, this setting is stored in the VAO

//GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); nothing's bound in the first place, it was stored in the VAOGL15.glDeleteBuffers(vboid);

//GL30.glBindVertexArray(0); shouldn't be needed since you should always be binding a new VAO before rendering (or else you're using deprecated functionality)GL30.glDeleteVertexArrays(vaoid);

Now, I believe the reason why it's not rendering "anything" is (in addition to the missing index buffer) because you're not passing in a color, so the color attribute is set to black. Try to hardcode the fragment shader to output a specific color and see if it works.

I have changed the code to how you showed me and I hard-coded a color but nothing is rendering. Is there any other code that is critical to VBO rendering?

Argh!!!!!! Accidentally hit the appreciate button.

Anyway, try finding a diagram of how the OpenGL pipeline works.If one part doesn't work, the whole thing fails creating a big blank space on the screen. Finding what went wrong is annoying.Try following what theagentd said.

Why are your indices float value? They should be (unsigned) short values! You've also specified the indices as GL_UNSIGNED_BYTE in glDrawElements(). Change that to GL_UNSIGNED_SHORT, and change the index FloatBuffer to a ShortBuffer.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org