Edit: Problem solved! See post near the end.
I’m porting some code from the old net.java.games.jogl packages to JSR-231 (beta5).
This example has a first-person camera class that can look and move around an XZ grid.
Problem is, the grid seems to clip against the near plane, but altering near/far values, FOV, start points, etc all has no effect:
http://vault101.co.uk/downloads/jsr231_clipping.jpg
Current values:
Grid spacing: 1 OGL unit
Camera height from ground: 1 OGL unit
FOV: 45
Near plane: 0.5
Far plane: 50
frame/canvas setup:
frame = new Frame ();
canvas = new GLCanvas ();
canvas.addGLEventListener (new Renderer (canvas));
final Animator animator = new Animator (canvas);
frame.add (canvas);
frame.setSize (1024, 768);
frame.setVisible (true);
animator.start ();
canvas.requestFocus ();
init() // outside the rendering loop
{
gl.glEnable (gl.GL_TEXTURE_2D);
gl.glClearDepth (1.0);
gl.glDepthFunc (gl.GL_LESS);
gl.glEnable (gl.GL_DEPTH_TEST);
gl.glShadeModel (gl.GL_SMOOTH);
gl.glMatrixMode (gl.GL_PROJECTION);
gl.glLoadIdentity ();
glu.gluPerspective (45, ((double)1024/ (double)768), 0.5, 50);
gl.glMatrixMode (gl.GL_MODELVIEW);
gl.glHint (gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST);
gl.setSwapInterval (1);
gl.glClearColor (0.5f, 0.5f, 0.5f, 1f);
}
renderingloop
{
gl.glClear (gl.GL_DEPTH_BUFFER_BIT);
gl.glPolygonMode (gl.GL_FRONT_AND_BACK, gl.GL_FILL);
gl.glLoadIdentity ();
glu.gluLookAt (cam.pos.x, cam.pos.y, cam.pos.z, cam.view.x, cam.view.y, cam.view.z, 0, 1, 0);
drawGrid();
}
Getting it working with JSR-231 was a copy-paste operation from code that used to work fine using the old net.java.games.jogl packages.
I must be doing something stupid here but I can see what! Any help much appreciated!
Thanks.