Login  Register

glBegin/glEnd inside methods of MouseListener

Posted by rhdxmr on Dec 05, 2010; 5:14pm
URL: https://forum.jogamp.org/glBegin-glEnd-inside-methods-of-MouseListener-tp2023145.html

public void mousePressed(MouseEvent me) {
            gl.glBegin(GL.GL_LINE_STRIP);
            gl.glVertex3f(0,0,0);
            gl.glVertex3f(100,50,0);
            gl.glVertex3f(200,100,0);
            gl.glVertex3f(100,150,0);
            gl.glEnd();
            gl.glFlush();
}
as you already know, mousePressed(..) method is called when mouse button is pressed.


I tested that calling mousePressed from from display(..) method as follows

public void display(GLAutoDrawable drawable) {
...
mousePressed(new MouseEvent(canvas, 1, 1L, 1, 1,1,1,true));
...
}

it shows line.


But when mousePressed is called by event, it does not.

I wonder why the latter doesn't work and how i can fix this?