Ok, so I ran into an issue with VBO’s now. I know there’s a tutorial/example someone made on here for it, but it didn’t really make sense for me. Also, I watched some video tutorials, and I thought I understood how it worked. The issue is though, I tried doing it for creatures/player… but when i run it, I get a fatal error.
Fatal Error
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000572cbb80, pid=4228, tid=2236
#
# JRE version: Java(TM) SE Runtime Environment (8.0_45-b14) (build 1.8.0_45-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [atio6axx.dll+0x16bb80]
So
I guess I’m not using VBO’s correctly. Also, I was confused on how I would efficiently update data/the location in them.
I really want to learn/use VBO’s, but I guess the way I want to use them makes it a little more complicated for me. I can show how I’m using them, but any suggestions/advice would be great.
—draw method—
public void drawCreature()
{
if (hasinit == false)
{
setTexture("PNG", "Player.png");
initVBO();
hasinit = true;
}
updateVBO();
}
public void initVBO()
{
glBindTexture(GL_TEXTURE_2D, texture.getTextureID());
vertexData = BufferUtils.createFloatBuffer(amountOfVertices * vertexSize);
vertexData.put(new float[]{x, y, x + width, y, x + width, y + height, x, y + height});
vertexData.flip();
colorData = BufferUtils.createFloatBuffer(amountOfVertices * colorSize);
colorData.put(new float[]{1, 1, 1});
colorData.flip();
textureData = BufferUtils.createFloatBuffer(amountOfVertices * vertexSize);
textureData.put(new float[]{0, 1, 1, 1, 1, 0, 0, 0});
textureData.flip();
vboVertexHandle = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
glBufferData(GL_ARRAY_BUFFER, vertexData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
vboColorHandle = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboColorHandle);
glBufferData(GL_ARRAY_BUFFER, colorData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
vboTexCoordHandle = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboTexCoordHandle);
glBufferData(GL_ARRAY_BUFFER, textureData, GL_STATIC_DRAW);
glTexCoordPointer(3, GL_FLOAT, 0, 0);
}
public void updateVBO()
{
glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
glVertexPointer(vertexSize, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ARRAY_BUFFER, vboColorHandle);
glColorPointer(colorSize, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ARRAY_BUFFER, vboTexCoordHandle);
glTexCoordPointer(vertexSize, GL_FLOAT, 0, 0L);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_QUADS, 0, amountOfVertices);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
You can assume I use int’s and FloatBuffers when appropriate. I hate asking for help over and over, but VBO’s have been something I waited to learn cause of something like this…