No - nothing but an endless loop with a repaint() call.
I am working with a GLfixed buffer, allocated as native buffer.
The code is just simple:
Initialization:
protected boolean eglInitialize(int aWidth, int aHeight)
{
GL.getGL().glEnable(GL.GL_NORMALIZE);
GL.getGL().glEnable(GL.GL_SCISSOR_TEST);
GL.getGL().glDisable(GL.GL_DITHER);
GL.getGL().glEnableClientState(GL.GL_VERTEX_ARRAY);
GL.getGL().glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST);
return true;
}
Whenever a resize happens:
protected void eglReshape(int aWidth, int aHeight)
{
GL.getGL().glViewport(0, 0, aWidth, aHeight);
if (!getEgl().success())
{
System.out.println(“glViewport:” + getEgl().getError());
}
else
{
System.out.println(“glViewport:” + aWidth + “/” + aHeight);
}
GL.getGL().glScissor(0, 0, aWidth, aHeight);
GL.getGL().glMatrixMode(GL.GL_PROJECTION);
GL.getGL().glLoadIdentity();
float lAspect = ((float)aWidth / (float)aHeight);
GLU.gluPerspective(90.f, lAspect, _NearDistance, _FarDistance);
}
Initialization for the Line buffer (happens once)
private void initLinesTest02(Component aComponent)
{
int lIncrement = 10;
for (int Y = 0; Y < aComponent.getHeight(); Y += 2)
{
addLine( (float) 0, (float) Y/100f, (float) aComponent.getWidth()/100f, (float) Y/100f);
}
for (int X = 0; X < aComponent.getWidth(); X += 2)
{
addLine( (float) X/100f, (float) 0, (float) X/100f, (float) aComponent.getHeight()/100f);
}
}
… and last not least: the drawing:
lTime is just an incrementing variable to get different angles
_Mode is set to GL.GL_FIXED.
public int draw(EGL aEGL, java.awt.Color aColor, float aRotationX, float aRotationY, float aRotationZ)
{
GL.getGL().glMatrixMode(GL.GL_MODELVIEW);
GL.getGL().glLoadIdentity();
GL.getGL().glLineWidth(_LineWidth);
GL.getGL().glTranslatef(0.f, 0.f, -10f);
GL.getGL().glRotatef((float)(lTime), aRotationX, aRotationY, aRotationZ);
lTime++;
lTime = (short)(lTime%360);
if (lCount > 0)
{
GL.getGL().glVertexPointer(2, _Mode, 0, _ByteBufferVertices);
GL.getGL().glDrawArrays(GL.GL_LINES, 0, lCount);
if (!aEGL.success())
{
System.out.println("glDrawArrays FAILURE" + aEGL.getError());
}
}
return lCount/2;
}