Hey there, I started working more with VBOs now, rendering colored models does work.
I want now to use textures, but they somehow don’t work.
I get an access violation of the jvm.
private final int[] titleVertices = new int[]
{
0, 0, 0, 320, 0, 0, 320, 240, 0, 0, 240, 0
};
private final int[] textureCoords = new int[]
{
0, 1, 1, 1, 1, 0, 0, 0
};
private IntBuffer v_title;
private IntBuffer t_title;
private int vbo_v_title;
private int vbo_t_title;
private int t_title_id;
[...]
@Override
void render()
{
glBindTexture(GL_TEXTURE_2D,t_title_id);
glBindBuffer(GL_ARRAY_BUFFER,vbo_v_title);
glVertexPointer(3,GL_UNSIGNED_INT,0,0l);
glBindBuffer(GL_ARRAY_BUFFER,vbo_t_title);
glTexCoordPointer(2,GL_UNSIGNED_INT,0,0l);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_TRIANGLES,0,4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER,0);
glBindTexture(GL_TEXTURE_2D, 0);
}
@Override
void init()
{
v_title = createBuffer(v_title,titleVertices);
vbo_v_title = glGenBuffers();
bindVBO (vbo_v_title, v_title, GL_STATIC_DRAW);
t_title = createBuffer(t_title,textureCoords);
vbo_t_title = glGenBuffers();
bindVBO (vbo_t_title, t_title, GL_STATIC_DRAW);
BufferedImage screen = TextureLoader.loadImage ("images/gui.png");
screen = screen.getSubimage (28, 1, 32, 32);
t_title_id = TextureLoader.loadTexture (screen);
System.out.println("Init Ende");
}
@Override
void exit()
{
}
private void bindVBO(int vbo, IntBuffer data, int GL_METHOD)
{
glBindBuffer (GL_ARRAY_BUFFER, vbo);
glBufferData (GL_ARRAY_BUFFER, data, GL_METHOD);
glBindBuffer (GL_ARRAY_BUFFER, 0);
}
private IntBuffer createBuffer(IntBuffer buffer, int[] data)
{
buffer = BufferUtils.createIntBuffer (data.length);
buffer.put(data);
buffer.flip();
return buffer;
}
Can you tell me, what I am doing wrong?