I am making a TileMap used VBO.However, Error occurs. Why?
Following phenomenon occurs.
・Display is odd.
_2016-6-12_21-39-31_No-00.png)
・display is different whenever Moving program
・Program fall
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x174c4a93, pid=4572, tid=7424
#
# JRE version: Java(TM) SE Runtime Environment (8.0_91-b14) (build 1.8.0_91-b14)
# Java VM: Java HotSpot(TM) Client VM (25.91-b14 mixed mode windows-x86 )
# Problematic frame:
# C [ig4icd32.dll+0x1e4a93]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
source code
class TileImage
{
protected static final int POSITION_INDEX = 0; // index of vertex attribute "in_Position"
protected static final int COLOR_INDEX = 1; // index of vertex attribute "in_Color"
protected static final int FLOAT_NUM_BYTES; // sizeof(float) in bytes
protected static final int INT_NUM_BYTES; // sizeof(int) in bytes
protected static final int VEC4_BYTES; // sizeof(vec4) in bytes
static {
FLOAT_NUM_BYTES = Float.SIZE / Byte.SIZE;
INT_NUM_BYTES = Integer.SIZE / Byte.SIZE;
VEC4_BYTES = 4 * FLOAT_NUM_BYTES;
}
//Texture Class
protected Bitmap bitmap;
protected int vboIndexId;
protected int vboTexId;
protected float[] indexesArray;
protected float[] texturesArray;
protected FloatBuffer textures;
protected FloatBuffer indexes;
public TileImage(Bitmap bitmap)
{
this.bitmap = bitmap;
}
public void dispose()
{
bitmap.dispose();
glDisableVertexAttribArray(POSITION_INDEX);
glDisableVertexAttribArray(COLOR_INDEX);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDeleteBuffers(vboIndexId);
glDeleteBuffers(vboTexId);
glBindVertexArray(0);
}
public void draw()
{
if(!bitmap.getImagePath().equals(""))
{
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
bitmap.bind();
glBindBuffer(GL_ARRAY_BUFFER, vboIndexId);
GL11.glVertexPointer(3, GL_FLOAT, 0, 0l);
glBindBuffer(GL_ARRAY_BUFFER, vboTexId);
GL11.glTexCoordPointer(2, GL_FLOAT, 0, 0l);
GL11.glDrawArrays(GL_QUADS, 0, indexesArray.length);
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
bitmap.unBind();
}
}
public void vBOSet()
{
textures = BufferUtils.createFloatBuffer(texturesArray.length);
textures.put(texturesArray);
textures.rewind();
vboTexId = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboTexId);
glBufferData(GL_ARRAY_BUFFER, textures, GL_STATIC_DRAW);
indexes = BufferUtils.createFloatBuffer(indexesArray.length);
indexes.put(indexesArray);
indexes.rewind();
vboIndexId = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboIndexId);
glBufferData(GL_ARRAY_BUFFER, indexes, GL_STATIC_DRAW);
}
}
```