Hi you all,
I want to use two different buffers for animating a windo showing a moving membran.
The following part of the code shows where the window is set visible:
…
final Beispielszene app = new Beispielszene(input.getFeminPoints(), input.getFeminElements(), wtsumforout);
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
app.setVisible(true);
}
});
}
In our file BeispielszeneView.java we gonna draw all the elements which have to be drawn. We have a double array of elements including values. We first draw the first column of this array. then the picture should be refreshed and a new window should be drawn with the new values out of column 2.
this is the code:
//the loop for the double-array:
for (int i = 0; i < 20 ; i++)
{
gl.glColor3f(1.0f, 1.0f, 1.0f );
drawElements(gl, glu,i);
/try
{
sleep();
}
catch ( InterruptedException e )
{
}/
gl.glColor3f(0.0f, 0.0f, 0.0f );
drawElements(gl,glu, i);
//gl.swapBuffers(hDC);
}
}
drawLine(gl, glu, 1.0f, 0.0f, -2.12f,1.0f, 0.0f, 0.0f );
drawLine(gl, glu, 1.0f, 0.0f, 0.0f,1.0f, 0.0f, 2.12f );
drawLine(gl, glu, 1.0f, 0.0f, -2.12f,1.0f, 3.0f, 0.0f );
drawLine(gl, glu, 1.0f, 3.0f, 0.0f,1.0f, 0.0f, 2.12f );
*/
}
public void drawElements(GL gl, GLU glu, int t)
{
for (int i = 0; i < elementArray.length; i++)
{
drawElement(gl, glu, elementArray[i],t);
}
}
public void drawElement(GL gl, GLU glu, Element elem, int t)
{
Point [] pointsList = elem.getPointslist();
if (pointsList.length == 6)
// bin im Dreieck
{
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex3f((new Double(pointsList[0].getX())).floatValue(),(new Double(loesungen[pointsList[0].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[0].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[3].getX())).floatValue(),(new Double(loesungen[pointsList[3].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[3].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[1].getX())).floatValue(),(new Double(loesungen[pointsList[1].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[1].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[4].getX())).floatValue(),(new Double(loesungen[pointsList[4].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[4].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[2].getX())).floatValue(),(new Double(loesungen[pointsList[2].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[2].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[5].getX())).floatValue(),(new Double(loesungen[pointsList[5].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[5].getY())).floatValue());
gl.glEnd();
}
else
// bin im viereck
{
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex3f((new Double(pointsList[0].getX())).floatValue(),(new Double(loesungen[pointsList[0].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[0].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[4].getX())).floatValue(),(new Double(loesungen[pointsList[4].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[4].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[1].getX())).floatValue(),(new Double(loesungen[pointsList[1].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[1].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[5].getX())).floatValue(),(new Double(loesungen[pointsList[5].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[5].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[2].getX())).floatValue(),(new Double(loesungen[pointsList[2].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[2].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[6].getX())).floatValue(),(new Double(loesungen[pointsList[6].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[6].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[3].getX())).floatValue(),(new Double(loesungen[pointsList[3].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[3].getY())).floatValue());
gl.glVertex3f((new Double(pointsList[7].getX())).floatValue(),(new Double(loesungen[pointsList[7].getKnotnr()-1][t])).floatValue(), (new Double(pointsList[7].getY())).floatValue());
gl.glEnd();
}
}
My question is: How can I use buffers for refreshing my window and building an animation???
Thanks + Regards,
Andreas