I’m finally drawing lines on the screen (thanks for gluUnproject).
However, I have a question about how it works.
You send an array to another class, into another method. Java’s behaviour is to do this as a reference.
Can I assume that you guys are using pointers in memory in the background and writing from an unmanaged memory location to the managed memory location?
Oh and feel free to criticise my code. I assume this is done properly?
private Point2D.Float translateCoords(GL gl, GLU glu, Point2D.Float coord)
{
double[] projection = new double[16];
double[] modelView = new double[16];
int[] viewport = new int[4];
double[] pos = new double[] {coord.x, coord.y, 0};
gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, modelView);
gl.glGetDoublev(GL.GL_PROJECTION_MATRIX, projection);
gl.glGetIntegerv(GL.GL_VIEWPORT, viewport);
glu.gluUnProject(
coord.x, viewport[3] - coord.y, 0,
modelView, //pass by ref
projection, //pass by ref
viewport, //pass by ref
pos
);
coord.x = (float)pos[0];
coord.y = (float)pos[1];
return coord;
}