Ok, please don’t bash me, and I feel really stupid for even having to ask for help right now, but this is my first attempt with Vertex Buffer Objects doing anything and I’m failing miserably. It doesn’t help matters I’m using an old Win98 computer right now which likes to crash every 3-10 minutes depending on it’s mood. I did check and it does say it supports VBOs however. Anyway, I’m using the methods listed on this http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/opengl/basicvbo tutorial. All significant code is as follows:
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.create();
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(-WIDTH/2, WIDTH/2, -HEIGHT/2, HEIGHT/2, -1, 1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
int id = createVBOID();
ByteBuffer bytebuffer = ByteBuffer.allocateDirect(6 * 4);
bytebuffer.order(ByteOrder.nativeOrder());
FloatBuffer fbuffer = bytebuffer.asFloatBuffer();
fbuffer.put(-10f);
fbuffer.put(-10f);
fbuffer.put(10f);
fbuffer.put(-10f);
fbuffer.put(10f);
fbuffer.put(10f);
bufferData(id, fbuffer);
long start = System.nanoTime();
int frames = 10000;
for (int i = 0; i < frames; i++){
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, id);
GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
// GL11.glBegin(GL11.GL_TRIANGLES);
// GL11.glVertex2f(-10, -10);
// GL11.glVertex2f(10, -10);
// GL11.glVertex2f(10, 10);
// GL11.glEnd();
Display.update();
}
The commented out code at the bottom draws a little white triangle in the center of the screen if I uncomment it. Code as is draws nothing, a blank black screen. I looked through several tutorials and thought I copied everything I needed, but evidently I didn’t. Could someone point out what I missed?
