I have just finished codeing a viewer that will rotate (along X, Y, and Z Axis), Move the Object, and Zoom in and out. I works fine most of the time but sometimes has issues. Can someone take a quick look at my code and tell if there are some obvious problems and if so provide some suggestions as to how to address them? Thanks in advance.
Inside of display():
gl.glViewport(0, 0, width, height); // Where stpModel is the Class with data // on Object to be "drawn" ... double diameter = stpModel.getDiameter(); float cenX = stpModel.getCenterX(); float cenY = stpModel.getCenterY(); float cenZ = stpModel.getCenterZ(); double zNear = 1.0; double zFar = 2*(diameter + zNear); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); float ratio = (float)width/(float)height; glu.gluPerspective(45, ratio, zNear, zFar); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glRotatef(angleX, 1.0f, 0.0f, 0.0f); gl.glRotatef(angleY, 0.0f, 1.0f, 0.0f); gl.glRotatef(angleZ, 0.0f, 0.0f, 1.0f); // Where xTrans and yTrans are calculate by Mouse // Event "clicks" --> taking the differences of // Points ... gl.glTranslatef(this.xTrans, this.yTrans, 1.0f); // Where zoom is adjusted by the user, starts at // the value of 1.0f ... gl.glScalef(zoom, zoom, zoom); // Method draws the Object with primatives // Triangles ... drawTriangles();