How do i di that with the new version, just started JOGL today, could someone give me a simple example say if i wanted to call gluOrtho2D in the init method.
Thanks.
How do i di that with the new version, just started JOGL today, could someone give me a simple example say if i wanted to call gluOrtho2D in the init method.
Thanks.
In your class body, add “GLU glu = new GLU();”. Then call glu.gluOrtho2D(…) in your init() method. You can reuse the same GLU object anywhere as long as an OpenGL context is current, but should be careful not to access it from multiple threads as the implementation isn’t thread-safe.
I have
public class NetworkDrawer implements GLEventListener
{
GLU glu = new GLU();
public static ArrayList<Node> nodes = new ArrayList<Node>();
public static ArrayList<Arc> arcs = new ArrayList<Arc>();
At the top of my class, then i have my init method as:
public void init(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
glu.gluOrtho2D(-40.0,40.0,-40.0,40.0);
}
So all i want to do where is chage the clipping volume to -40 to 40 in both the x and y direction, as i have a set of 2d coordinated i want to play as points and that seemed the natural way.
My display method:
public void display(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glLoadIdentity();
gl.glColor3f(1F, 0F, 0F);
gl.glVertex2d(0, 0);
gl.glVertex2d(0.5, 0);
//drawNodes(drawable);
gl.glColor3f(1F, 1F, 0F);
//drawArcs(drawable);
}
Im drawing two points to test my new co-ordinate system is in place, so they should be very close, but instead they are bing drawn with the default co-ordinate system -1 to 1 in both x and y, so one point in the middle, and the other half way between the middle and the right hand side of the window.
Any idea how i get my correct -40 to 40 system in place?
lol, gl.glLoadIdentity();, i noticed it in my post and not my source file haha