I've written a basic program so I can make sure I'm properly learning VBOs before converting my 3d game's rendering to them.
Essentially, this question is why changing the perspective is the GL setup code stops my triangle from rendering:
GLU.gluPerspective(60f, (width/height), 0.1f, 200.0f);
Wihout that code, the triangle renders as expected. With it, only an empty screen is visible. I tried changing the triangle vertices but nothing worked. This may help explain why the VBO rendering isn't working in my game.
I've spent more time reading about gluPerspective but I'm not catching why it prevents the images from rendering.
My display/gl init code:
// Init display
Display.setResizable(true);
Display.setTitle( Game.name );
Display.setVSyncEnabled(true);
Display.setDisplayMode(new DisplayMode(Game.GAME_WIDTH, Game.GAME_HEIGHT));
// Set viewport
PixelFormat pixelFormat = new PixelFormat();
ContextAttribs contextAtrributes = new ContextAttribs(3, 0);
Display.create(pixelFormat, contextAtrributes);
glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glViewport(0, 0, Display.getWidth(), Display.getHeight());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GLU.gluPerspective(60f, ((float) Display.getWidth() / (float) Display.getHeight()), 0.1f, 200.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
I have a simple triangle drawing class that uses and interleaved VBO
triangleTesselator.addVertex(-0.5f, -0.5f, 0f);
triangleTesselator.addColor(1, 0, 0);
triangleTesselator.addVertex(+0.5f, -0.5f, 0f);
triangleTesselator.addColor(0, 1, 0);
triangleTesselator.addVertex(+0.5f, +0.5f, 0f);
triangleTesselator.addColor(0, 0, 1);
triangleTesselator.render();
I also tried several different vertex coords thinking the 0 was behind the clipping (near) plane of the perspective but that didn't work.
Update: I've added a basic camera system to this rendering test app, and after looking around a bit I've found the rendered cube behind me...