It is not possible for the OpenGL implementation to cache the date on the server side, because it does not if it was changed by the client. Thus the client has to take over control using VBOs.
VBOs are vertex arrays on the server side.
// Buffer for the vertex data
FloatBuffer points;
// Array to hold Vertex Buffers Objects (VBOs).
int[] VBO = new int[ nbVBO ];
gl.glGenBuffersARB( nbVBO, VBO, 0 );
// Enable same as for vertex buffers.
gl.glEnableClientState( GL.GL_VERTEX_ARRAY );
// Init VBOs and transfer data.
gl.glBindBufferARB( GL.GL_ARRAY_BUFFER_ARB, VBO[0] );
// Copy data to the server into the VBO.
gl.glBufferDataARB( GL.GL_ARRAY_BUFFER_ARB,
nbValues, points,
GL.GL_STATIC_DRAW_ARB );
// Draw.
gl.glBindBuffer( GL.GL_ARRAY_BUFFER_ARB, VBO[0] );
gl.glVertexPointer( 3, GL.GL_FLOAT, 0, 0 );
gl.glDrawArrays( GL.GL_POINTS, 0, nbPoints );
gl.glDeleteBuffers( nbVBO, VBO, 0 );
STREAM_DRAW_ARB The data store contents will be specified once
by the application, and used at most a few
times as the source of a GL (drawing) command.
STREAM_READ_ARB The data store contents will be specified once
by reading data from the GL, and queried at
most a few times by the application.
STREAM_COPY_ARB The data store contents will be specified once
by reading data from the GL, and used at most
a few times as the source of a GL (drawing)
command.
STATIC_DRAW_ARB The data store contents will be specified once
by the application, and used many times as the
source for GL (drawing) commands.
STATIC_READ_ARB The data store contents will be specified once
by reading data from the GL, and queried many
times by the application.
STATIC_COPY_ARB The data store contents will be specified once
by reading data from the GL, and used many
times as the source for GL (drawing) commands.
DYNAMIC_DRAW_ARB The data store contents will be respecified
repeatedly by the application, and used many
times as the source for GL (drawing) commands.
DYNAMIC_READ_ARB The data store contents will be respecified
repeatedly by reading data from the GL, and
queried many times by the application.
DYNAMIC_COPY_ARB The data store contents will be respecified
repeatedly by reading data from the GL, and
used many times as the source for GL (drawing)
commands.
// Check version.
String versionStr = gl.glGetString( GL.GL_VERSION );
System.out.println( "GL version:"+versionStr );
versionStr = versionStr.substring( 0, 4);
float version = new Float( versionStr ).floatValue();
boolean versionOK = ( version >= 1.59f ) ? true : false;
System.out.println( "GL version:"+versionStr+" ->"+versionOK );
// Check if extension is available.
boolean extensionOK = gl.isExtensionAvailable
("GL_ARB_vertex_buffer_object");
System.out.println( "VBO extension: "+extensionOK );
// Check for VBO functions.
boolean functionsOK =
gl.isFunctionAvailable("glGenBuffersARB") &&
gl.isFunctionAvailable("glBindBufferARB") &&
gl.isFunctionAvailable("glBufferDataARB") &&
gl.isFunctionAvailable("glDeleteBuffersARB");
System.out.println( "Functions: "+ functionsOK);
if( ! extensionOK || ! functionsOK )
{
// VBO not supported.
System.out.println( "VBOs not supported." );
useVBO = false;
return;
}