Thank you for the answer. But it does not change anything on the speed
Maybe I should post more -Code ?
public class SimpleRoutine extends JOGLMainRoutine implements KeyListener
{
private GL gl = null;
private final GLU glu = new GLU();
public SimpleRoutine(JOGLMainFrameInterf mainFrame)
{
super(mainFrame);
}
Texture cubeTex = null;
TextureCoords coords = null;
final int numCubes = 1000;
float[] angle1 = new float[numCubes];
float[] angle1Speed = new float[numCubes];
float[] angle1X = new float[numCubes];
float[] angle1Y = new float[numCubes];
float[] angle1Z = new float[numCubes];
float[] angle2 = new float[numCubes];
float[] angle2Speed = new float[numCubes];
float[] angle2X = new float[numCubes];
float[] angle2Y = new float[numCubes];
float[] angle2Z = new float[numCubes];
//Platzieren an Pos
float[] posX = new float[numCubes];
float[] posY = new float[numCubes];
float[] posZ = new float[numCubes];
float[] distX = new float[numCubes];
float[] distY = new float[numCubes];
float[] distZ = new float[numCubes];
private long now = 0;
private long before = 0;
private long latency = 0;
private long fullatency = 0;
private int frames = 0;
private int fps = 0;
public void init(GLAutoDrawable glDrawable)
{
glDrawable.addKeyListener(this);
gl = glDrawable.getGL();
gl.glShadeModel(GL.GL_SMOOTH);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
gl.glClearDepth(1.0f);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glDepthFunc(GL.GL_LEQUAL);
gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
try
{
cubeTex = TextureIO.newTexture(new File ("AppGfx/cubeTex2.png"), true);
cubeTex.bind();
cubeTex.enable();
coords = cubeTex.getImageTexCoords();
}
catch(Exception e) {}
for (int i=0;i < numCubes; i++)
{
Random Zufallsgenerator = new Random();
angle1[i] = Zufallsgenerator.nextFloat()*360.0f;
angle1Speed[i] = Zufallsgenerator.nextFloat()*3.0f;
angle1X[i] = (float)Zufallsgenerator.nextInt(2);
angle1Y[i] = (float)Zufallsgenerator.nextInt(2);
angle1Z[i] = (float)Zufallsgenerator.nextInt(2);
angle2[i] = Zufallsgenerator.nextFloat()*360.0f;
angle2Speed[i] = Zufallsgenerator.nextFloat()*3.0f;
angle2X[i] = (float)Zufallsgenerator.nextInt(2);
angle2Y[i] = (float)Zufallsgenerator.nextInt(2);
angle2Z[i] = (float)Zufallsgenerator.nextInt(2);
if (Zufallsgenerator.nextInt(2) == 0)
posX[i] = Zufallsgenerator.nextFloat()*5.0f;
else
posX[i] = Zufallsgenerator.nextFloat()*(-5.0f);
if (Zufallsgenerator.nextInt(2) == 0)
posY[i] = Zufallsgenerator.nextFloat()*5.0f;
else
posY[i] = Zufallsgenerator.nextFloat()*(-5.0f);
posZ[i] = Zufallsgenerator.nextFloat()*(-10.0f)-3.0f;
if (Zufallsgenerator.nextInt(2) == 0)
distX[i] = Zufallsgenerator.nextFloat()*5.0f;
else
distX[i] = Zufallsgenerator.nextFloat()*(-5.0f);
if (Zufallsgenerator.nextInt(2) == 0)
distY[i] = Zufallsgenerator.nextFloat()*5.0f;
else
distY[i] = Zufallsgenerator.nextFloat()*(-5.0f);
if (Zufallsgenerator.nextInt(2) == 0)
distZ[i] = Zufallsgenerator.nextFloat()*2.0f;
else
distZ[i] = Zufallsgenerator.nextFloat()*(-2.0f);
}
gl.glNewList (1234, GL.GL_COMPILE);
gl.glBegin(GL.GL_QUADS);
gl.glTexCoord2f(coords.left(), coords.top());
gl.glVertex3f(-0.2f, 0.2f, 0.2f);
gl.glTexCoord2f(coords.right(), coords.top());
gl.glVertex3f( 0.2f, 0.2f, 0.2f);
gl.glTexCoord2f(coords.right(), coords.bottom());
gl.glVertex3f( 0.2f, -0.2f, 0.2f);
gl.glTexCoord2f(coords.left(), coords.bottom());
gl.glVertex3f(-0.2f, -0.2f, 0.2f);
gl.glTexCoord2f(coords.left(), coords.top());
gl.glVertex3f(-0.2f, 0.2f, -0.2f);
gl.glTexCoord2f(coords.right(), coords.top());
gl.glVertex3f( 0.2f, 0.2f, -0.2f);
gl.glTexCoord2f(coords.right(), coords.bottom());
gl.glVertex3f( 0.2f, -0.2f, -0.2f);
gl.glTexCoord2f(coords.left(), coords.bottom());
gl.glVertex3f(-0.2f, -0.2f, -0.2f);
gl.glTexCoord2f(coords.left(), coords.top());
gl.glVertex3f(-0.2f, 0.2f, -0.2f);
gl.glTexCoord2f(coords.right(), coords.top());
gl.glVertex3f(-0.2f, 0.2f, 0.2f);
gl.glTexCoord2f(coords.right(), coords.bottom());
gl.glVertex3f(-0.2f, -0.2f, 0.2f);
gl.glTexCoord2f(coords.left(), coords.bottom());
gl.glVertex3f(-0.2f, -0.2f, -0.2f);
gl.glTexCoord2f(coords.left(), coords.top());
gl.glVertex3f(0.2f, 0.2f, -0.2f);
gl.glTexCoord2f(coords.right(), coords.top());
gl.glVertex3f(0.2f, 0.2f, 0.2f);
gl.glTexCoord2f(coords.right(), coords.bottom());
gl.glVertex3f(0.2f, -0.2f, 0.2f);
gl.glTexCoord2f(coords.left(), coords.bottom());
gl.glVertex3f(0.2f, -0.2f, -0.2f);
gl.glTexCoord2f(coords.left(), coords.top());
gl.glVertex3f(-0.2f, -0.2f, -0.2f);
gl.glTexCoord2f(coords.right(), coords.top());
gl.glVertex3f( 0.2f, -0.2f, -0.2f);
gl.glTexCoord2f(coords.right(), coords.bottom());
gl.glVertex3f( 0.2f, -0.2f, 0.2f);
gl.glTexCoord2f(coords.left(), coords.bottom());
gl.glVertex3f(-0.2f, -0.2f, 0.2f);
gl.glTexCoord2f(coords.left(), coords.top());
gl.glVertex3f(-0.2f, 0.2f, -0.2f);
gl.glTexCoord2f(coords.right(), coords.top());
gl.glVertex3f( 0.2f, 0.2f, -0.2f);
gl.glTexCoord2f(coords.right(), coords.bottom());
gl.glVertex3f( 0.2f, 0.2f, 0.2f);
gl.glTexCoord2f(coords.left(), coords.bottom());
gl.glVertex3f(-0.2f, 0.2f, 0.2f);
gl.glEnd();
gl.glEndList();
before = System.nanoTime();
now = System.nanoTime();
latency = now - before;
now = 0;
before = 0;
}
public void display(GLAutoDrawable glDrawable)
{
now = System.nanoTime();
fullatency+=latency;
if ((now-fullatency) >= (before + 1000000000))
{
before = System.nanoTime();
fullatency=latency;
fps = frames;
frames = 1;
}
else
frames++;
gl = glDrawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
for (int i=0;i < numCubes; i++)
{
gl.glPushMatrix();
gl.glTranslatef(posX[i], posY[i], posZ[i]);
gl.glRotatef(angle2[i]+=angle2Speed[i], angle2X[i], angle2Y[i], angle2Z[i]);
gl.glTranslatef(distX[i], distY[i], distZ[i]);
gl.glRotatef(angle1[i]+=angle1Speed[i], angle1X[i], angle1Y[i], angle1Z[i]);
gl.glCallList(1234);
gl.glPopMatrix();
}
}
public void reshape(GLAutoDrawable glDrawable, int x, int y, int width, int height)
{
gl = glDrawable.getGL();
if (height <= 0) height = 1;
final float ratio = (float)width / (float)height;
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45.0f, ratio, 0.1, 1000.0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
}
............
...........
}