protected static void setup( GL2 gl2, int width, int height ) { gl2.glMatrixMode( GL2.GL_PROJECTION ); gl2.glLoadIdentity(); // coordinate system origin at lower left with width and height same as the window GLU glu = new GLU(); glu.gluOrtho2D( 0.0f, width, 0.0f, height ); gl2.glMatrixMode( GL2.GL_MODELVIEW ); gl2.glLoadIdentity(); gl2.glViewport( 0, 0, width, height ); }
gl.glDisable(GL_DEPTH_TEST); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); } else { gl.glMatrixMode(GL_PROJECTION); // choose projection matrix gl.glMatrixMode(GL_MODELVIEW);
gl2.glMatrixMode(GL2.GL_PROJECTION); // choose projection matrix gl2.glMatrixMode(GL2.GL_MODELVIEW);
public void setup(GL2 gl2, int width, int height) gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glLoadIdentity(); glu.gluOrtho2D(0.0f, width, 0.0f, height); gl2.glMatrixMode(GL2.GL_MODELVIEW); gl2.glLoadIdentity();
@Override public void pop(GLGraphics2D parentG2d) { gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPopMatrix(); }
@Override public void push(GLGraphics2D newG2d) { gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPushMatrix(); }
@Override public void translate(int x, int y) { gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glTranslatef(x, y, 0); }
@Override public void translate(double tx, double ty) { gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glTranslatef((float) tx, (float) ty, 0); }
@Override public void rotate(double theta) { gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glRotatef((float) theta * RAD_TO_DEG, 0, 0, 1); }
@Override public void scale(double sx, double sy) { gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glScaled(sx, sy, 1); }
@Override public void transform(AffineTransform Tx) { gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); GLG2DUtils.multMatrix(gl, Tx); }
glcanvas.addGLEventListener(new GLEventListener() { @Override public void reshape(GLAutoDrawable glautodrawable, int x, int y, int width, int height) { GL2 gl = glautodrawable.getGL().getGL2(); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); // Resets any previous projection matrices gl.glOrtho(0, width, 0, height, 1, -1); gl.glMatrixMode(GL2.GL_MODELVIEW); } ... Other methods }
/** * set up the correct modelview so the robot appears where it hsould. * * @param gl2 */ private void paintCamera(GL2 gl2) { gl2.glMatrixMode(GL2.GL_MODELVIEW); gl2.glLoadIdentity(); gl2.glTranslated(-cameraOffsetX, cameraOffsetY, -cameraZoom); }
@Override public void beginPoly(int windingRule) { /* * pen hangs down and to the right. See java.awt.Graphics */ gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPushMatrix(); gl.glTranslatef(0.5f, 0.5f, 0); super.beginPoly(windingRule); }
@Override public void rotate(double theta, double x, double y) { gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glTranslatef((float) x, (float) y, 0); gl.glRotated(theta * RAD_TO_DEG, 0, 0, 1); gl.glTranslatef((float) -x, (float) -y, 0); }
public void setFrustrum(GL2 gl) { GLU glu = new GLU(); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluOrtho2D(viewBounds.minX, viewBounds.maxX, viewBounds.minY, viewBounds.maxY); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); // update matrices for mouse position calculation gl.glGetDoublev( GL2.GL_MODELVIEW_MATRIX, modelview,0); gl.glGetDoublev( GL2.GL_PROJECTION_MATRIX, projection,0); gl.glGetIntegerv( GL2.GL_VIEWPORT, viewport,0 ); }
public void aimCamera(Vector3 cameraPoint, double angleX, double angleY, double angleZ) { gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glRotated(360-angleX, 1, 0, 0); gl.glRotated(360-angleY, 0, 1, 0); gl.glRotated(360-angleZ, 0, 0, 1); gl.glTranslated(-cameraPoint.x, -cameraPoint.y, -cameraPoint.z); }
@Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl = drawable.getGL().getGL2(); GLU glu = new GLU(); if (height <= 0) { // avoid a divide by zero error! height = 1; } gl.glViewport(0, 0, width, height); // size of drawing area gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45.0, (float) width / (float) height, 1.0, 1500.0); // 5 }
protected void begin(TextRenderer renderer) { setTextColorRespectComposite(renderer); GL2 gl = g2d.getGLContext().getGL().getGL2(); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPushMatrix(); gl.glScalef(1, -1, 1); gl.glTranslatef(0, -g2d.getCanvasHeight(), 0); renderer.begin3DRendering(); }
protected void begin(TextRenderer renderer) { setTextColorRespectComposite(renderer); GL2 gl = g2d.getGLContext().getGL().getGL2(); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glPushMatrix(); gl.glScalef(1, -1, 1); gl.glTranslatef(0, -g2d.getCanvasHeight(), 0); renderer.begin3DRendering(); }