I made that change, but it didn’t make a difference. Are there any routines maybe I’m not seeing that I can use to help debug what’s going on?
My code now looks like this.
public void display(GLDrawable drawable) {
GL gl = drawable.getGL();
GLU glu = drawable.getGLU();
float[] transf = new float[16];
this.gldrawable = drawable;
if (!selectedFile) {
return;
}
eyeZ = centroid.getZ() < 0 ? centroid.getZ() * -2: centroid.getZ() * 2;
switch (cmd) {
case UPDATE:
// clear the window
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
// reset the modelview matrix
gl.glColor3f(1.0f, 1.0f, 1.0f);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
// viewing transformation
glu.gluLookAt(
centroid.getX() + xTrans,
centroid.getY() + yTrans,
centroid.getZ() + zTrans + eyeZ,
centroid.getX() + xTrans,
centroid.getY() + yTrans,
centroid.getZ(),
0.0, 1.0, 0.0);
// model tranformation
xScale = yScale < xScale ? yScale: xScale;
yScale = xScale < yScale ? xScale: yScale;
{
gl.glScalef(xScale, yScale, 0.0f);
arcBall.transform.get(transf);
gl.glMultMatrixf(transf);
drawModel(drawable, gl);
}
break;
case SELECT:
int hits = 0;
int buffSize = 512;
int[] viewPort = new int[4];
double x = (double) currMouseX, y = (double) currMouseY;
IntBuffer selectBuffer = BufferUtils.newIntBuffer(buffSize);
gl.glSelectBuffer(buffSize, selectBuffer);
gl.glGetIntegerv(GL.GL_VIEWPORT, viewPort);
gl.glRenderMode(GL.GL_SELECT);
gl.glInitNames();
gl.glPushName(0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(
centroid.getX() + xTrans,
centroid.getY() + yTrans,
centroid.getZ() + zTrans + eyeZ,
centroid.getX() + xTrans,
centroid.getY() + yTrans,
centroid.getZ(),
0.0, 1.0, 0.0);
// Save the current projection because we have a new
// clipping volume around the mouse cursor now.
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
// Establish the new clipping pane. Multiplies the current
// projection matrix by the picking matrix.
glu.gluPickMatrix(x, (double) viewPort[3] - y,
3.0d, 3.0d, viewPort);
gl.glOrtho(-winWidth / 2, winWidth / 2, -winHeight / 2, winHeight / 2, 100, -100);
xScale = yScale < xScale ? yScale: xScale;
yScale = xScale < yScale ? xScale: yScale;
{
gl.glScalef(xScale, yScale, 0.0f);
arcBall.transform.get(transf);
gl.glMultMatrixf(transf);
drawModel(drawable, gl);
}
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPopMatrix();
hits = gl.glRenderMode(GL.GL_RENDER);
processHits(hits, selectBuffer);
gl.glMatrixMode(GL.GL_MODELVIEW);
break;
}
cmd = UPDATE;
return;
}
Showing reshape because of the glOrtho here.
public void reshape(GLDrawable drawable, int x, int y, int width,
int height)
{
GL gl = drawable.getGL();
GLU glu = drawable.getGLU();
winWidth = width;
winHeight = height;
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(-width / 2, width / 2, -height / 2, height / 2, 100, -100);
if (selectedFile) {
initScaleXY();
}
arcBall.setBounds(width, height);
return;
}