set opengl Draw Position - Java javax.media.opengl

Java examples for javax.media.opengl:GL

Description

set opengl Draw Position

Demo Code


import java.awt.Color;
import javax.media.opengl.GL;

public class Main{
    public static void setDrawPosition(GL gl, CanvasModel cm, int x, int y) {
        resetPosition(gl, cm);/*from  w  ww .  j av  a2  s.com*/
        setDrawOffset(gl, x, y);
    }
    public static void resetPosition(GL gl, CanvasModel cm) {
        gl.glLoadIdentity();
        gl.glScalef(1f, -1f, 0f);
        gl.glTranslatef(-cm.halfWidth, -cm.halfHeight, 0f);
    }
    public static void setDrawOffset(GL gl, int offsetX, int offsetY) {
        gl.glTranslatef((float) offsetX, (float) offsetY, 0f);
    }
}

Related Tutorials