Okay, I got things working by removing the GL20 lines and using some GL11.glVertexPointer action.
Here's the working demo thus far -- let me know if I'm doing something in a manner less than proper for modern OpenGL. (I know, I should be using shaders instead of letting the fixed-function do its thing; that comes next...)
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
/**
*
* @author Scott
*/
public class LwjglTest {
/**
* @param args the command line arguments
*/
public void run() {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.create();
} catch (LWJGLException ex) {
ex.printStackTrace();
System.exit(0);
}
// init opengl here...
// vertex locations
float[] verts = {
-1.0f, -1.0f,
1.0f, -1.0f,
-1.0f, 1.0f,
1.0f, 1.0f
};
// vertex indices
int[] idxs = {
0, 1, 2, 3
};
// create the vertex and index buffer data
FloatBuffer vert_b = BufferUtils.createFloatBuffer(8);
vert_b.put(verts).rewind();
IntBuffer indices = BufferUtils.createIntBuffer(4);
indices.put(idxs).rewind();
//'buffer' here holds the one int of data that becomes the vram buffer's id
IntBuffer buffers = BufferUtils.createIntBuffer(2);
GL15.glGenBuffers(buffers);
System.out.println("buffers: " + buffers.get(0) + " " + buffers.get(1));
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, buffers.get(0));
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vert_b, GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, buffers.get(1));
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_STATIC_DRAW);
//run loop
while( !Display.isCloseRequested() ) {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, buffers.get(0));
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, buffers.get(1));
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
GL11.glDrawElements(GL11.GL_TRIANGLE_STRIP, 3, GL11.GL_UNSIGNED_INT, 0);
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
Display.update();
}
GL15.glDeleteBuffers(buffers);
Display.destroy();
}
public static void main(String[] args) {
LwjglTest test = new LwjglTest();
test.run();
}
}
I would like very much to use my experience to update the VBO tutorial on the main site, also. In fact, I would very much enjoy the challenge of getting a complete "Getting Started with LWJGL and modern OpenGL" series. Should I start a new thread to ask for permissions?