Is it possible to use Textures from the Slick2D library in conjunction with VBOs from GL15? I’ve got everything working, the image is loaded etc. I’m just not quite sure how to bind the image to openGL.
I’m currently using only 1 float buffer with position vertices, colors, and texture coordinates.
My FloatBuffer is as follows:
FloatBuffer buffer = BufferHelper.reserveData(32);
buffer.put(new float[]{
//position vertices
x - width, y - height, 0,
x + width, y - height, 0,
x + width, y + height, 0,
x - width, y + height, 0,
//color vertices
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
//texture vertices
0, 0,
1, 0,
1, 1,
0, 1
});
My drawing method is as follows:
public void draw() {
texture.bind();
glBindBuffer(GL_ARRAY_BUFFER, vboHandle);
glVertexPointer(3, GL_FLOAT, 0, 0L);
glColorPointer(3, GL_FLOAT, 0, 48L);
glTexCoordPointer(2, GL_FLOAT, 0, 96L);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_QUADS, 0, 4);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
Is there a client state that needs to be enabled?
Am I binding the texture correctly?
Should I be using GL_TEXTURE_2D instead of slick?
Any input would be appreciated, even pointing out bad coding practices! (please do!)
P.S. - if anybody could explain to me why 48L is the correct offset for the colors, that would be great!
Edit: Sorry, guess I should have brushed up on basic openGL texturing first. Fixed it by enabling GL_TEXTURE_2D and GL_BLEND. (using a .png)