I'm sure that I missed something.
The following code compiles fine, and when it runs, I get no errors. All that happens is I see a white background (the clear color).
As I understand it, I should see one white triangle filling the lower-left half of the screen.
package lwjgltest;
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;
import org.lwjgl.opengl.GL20;
/**
*
* @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...
GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
// create the vertex buffer data
FloatBuffer vert_b = BufferUtils.createFloatBuffer(8);
float[] verts = {
-1.0f, -1.0f,
1.0f, -1.0f,
-1.0f, 1.0f,
1.0f, 1.0f
};
vert_b.put(verts);
//'buffer' here holds the one int of data that becomes the vram buffer's id
IntBuffer buffers = BufferUtils.createIntBuffer(1);
GL15.glGenBuffers(buffers);
int v_buffer_id = buffers.get(0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, v_buffer_id);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vert_b, GL15.GL_STATIC_DRAW);
//run loop
while( !Display.isCloseRequested() ) {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, v_buffer_id);
GL20.glEnableVertexAttribArray(0);
GL20.glVertexAttribPointer(0, 2, GL11.GL_FLOAT, false, 0, 0L);
GL11.glColor3f(1.0f, 1.0f, 1.0f);
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
Display.update();
}
Display.destroy();
}
public static void main(String[] args) {
LwjglTest test = new LwjglTest();
test.run();
}
}
My sincerest apologies for what I know is going to have been a stupid mistake. It's been a while since I did any VBOs in OpenGL, and now I'm trying to refresh my memory while also learning the java library for it.
The VBO tutorial on the wiki looks VERY unlike the vanilla OpenGL tutorials I've found online. So I'm trying to reconcile the two, and hopefully I can give back by updating the wiki's VBO tutorial to not have to use ARB extensions, etc.
Thanks in advance for any help.