Hi all,
I want to display e.g 3 points in a Jpanel using jogl. But that’s not the problem! I tried to make them twinkle periodically using an animator which is started by pressing a start button. But everytime I press the button the following error occurrs:
net.java.games.jogl.GLException: Attempt to re-set or change rendering thread
at net.java.games.jogl.impl.GLContext.setRenderingThread(GLContext.java:238)
at net.java.games.jogl.GLCanvas.setRenderingThread(GLCanvas.java:148)
at net.java.games.jogl.Animator$1.run(Animator.java:89)
at java.lang.Thread.run(Thread.java:534)
the code implemented for the button is the following:
private void Start_ButtonActionPerformed(java.awt.event.ActionEvent evt)
{
opgl_Display1.startAnimator(1);
opgl_Display2.startAnimator(1);
setClearStat(false);
the code implemented for the listener is the following:
class listener implements GLEventListener
{
private int i;
ApplicationFrame applFrame;
public void setApplicationFrame(ApplicationFrame frame)
{
this.applFrame = frame;
}
public void display(GLDrawable drawable)
{
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
if ((i%2 == 0) && applFrame.getClearStat() == false)
{
//draw three points with various x- and y-coordinates
gl.glBegin(GL.GL_POINTS);
gl.glVertex2i(100,50);
gl.glVertex2i(100,130);
gl.glVertex2i(150,130);
gl.glEnd();
i++;
}
else if (applFrame.getClearStat() == false)
{
//draw two lines, each specified by various x- and y-coordinates
gl.glColor3f(0.5f,0.6f,0.6f);
gl.glBegin(GL.GL_LINES);
gl.glVertex2i(50,200);
gl.glVertex2i(75,250);
gl.glVertex2i(60,200);
gl.glVertex2i(85,250);
gl.glEnd();
i++;
}
}
public void displayChanged(GLDrawable gLDrawable, boolean param, boolean param2)
{
}
public void init(GLDrawable drawable)
{
GL gl = drawable.getGL();
gl.glClearColor(1.0f,1.0f,1.0f,1.0f);
gl.glColor3f(0.0f,0.0f,0.0f);
gl.glPointSize(4.0f);
}
public void reshape(GLDrawable drawable, int left, int right, int width, int height)
{
GL gl = drawable.getGL();
GLU glu = drawable.getGLU(); //GLU OpenGl Utility Routines
gl.glViewport(0,0,width,height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluOrtho2D(0.0,450.0,0.0,375.0);
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
//draw three points with various x- and y-coordinates
gl.glBegin(GL.GL_POINTS);
gl.glVertex2i(100,50);
gl.glVertex2i(100,130);
gl.glVertex2i(150,130);
gl.glEnd();
//draw two lines, each specified by various x- and y-coordinates
gl.glColor3f(0.5f,0.6f,0.6f);
gl.glBegin(GL.GL_LINES);
gl.glVertex2i(50,200);
gl.glVertex2i(75,250);
gl.glVertex2i(60,200);
gl.glVertex2i(85,250);
gl.glEnd();
}
}
Can somebody please tell me what possibly can cause this error?
Thanks a lot
Greetings Samson