# Nachträgliches ändern von Vertex Arrays. Wie geht das?



## Rene (27. Aug 2008)

Hallo,

kann man Vertex Arrays nachtäglich noch ändern? Ich lese überall, dass dies der größte Vorteil von Vertex Arrays und Vertex Buffer Objekten im Gegensatz zu Displaylisten ist. Leider bekomme ich das nicht hin.

Im einen Fall habe ich einen einfachen Würfel mit 6 Seiten das macht 72 Vertexe. Wenn ich dann die Vertexdaten austausche während er rotiert passt gar nichts oder ganz sporadisch ändert er sich so wie er soll. Aber nur einmal und nicht wieder zurück beim nächsten Vertex update. Also nicht zuverlässig.

Im zweiten Fall, habe ich ein matematisches Objekt mit Teilweise über 1.000.000 Vertexen. Wenn ich da ein Update versuche stürzt die ganze Applikation ab 

Hier mal einen Auszug aus dem Code vom Würfel:
	
	
	
	





```
private void buildVertexArray()
    {
    	float cArray[];
    	float vArray[];

    	if(huhu)
    	{
    		vArray = new float[] { 1.0f, 1.0f,-1.0f,  -1.0f, 1.0f,-1.0f,  -1.0f, 1.0f, 1.0f,   1.0f, 1.0f, 1.0f,
					   1.0f,-1.0f, 1.0f,  -1.0f,-1.0f, 1.0f,  -1.0f,-1.0f,-1.0f,   1.0f,-1.0f,-1.0f,
					   1.0f, 1.0f, 1.0f,  -1.0f, 1.0f, 1.0f,  -1.0f,-1.0f, 1.0f,   1.0f,-1.0f, 1.0f,
					   1.0f,-1.0f,-1.0f,  -1.0f,-1.0f,-1.0f,  -1.0f, 1.0f,-1.0f,   1.0f, 1.0f,-1.0f,
					  -1.0f, 1.0f, 1.0f,  -1.0f, 1.0f,-1.0f,  -1.0f,-1.0f,-1.0f,  -1.0f,-1.0f, 1.0f,
					   1.0f, 1.0f,-1.0f,   1.0f, 1.0f, 1.0f,   1.0f,-1.0f, 1.0f,   1.0f,-1.0f,-1.0f };
    	}
    	else
    	{
    		vArray = new float[] { 2.0f, 2.0f,-2.0f,  -2.0f, 2.0f,-2.0f,  -2.0f, 2.0f, 2.0f,   2.0f, 2.0f, 2.0f,
					   2.0f,-2.0f, 2.0f,  -2.0f,-2.0f, 2.0f,  -2.0f,-2.0f,-2.0f,   2.0f,-2.0f,-2.0f,
					   2.0f, 2.0f, 2.0f,  -2.0f, 2.0f, 2.0f,  -2.0f,-2.0f, 2.0f,   2.0f,-2.0f, 2.0f,
					   2.0f,-2.0f,-2.0f,  -2.0f,-2.0f,-2.0f,  -2.0f, 2.0f,-2.0f,   2.0f, 2.0f,-2.0f,
					  -2.0f, 2.0f, 2.0f,  -2.0f, 2.0f,-2.0f,  -2.0f,-2.0f,-2.0f,  -2.0f,-2.0f, 2.0f,
					   2.0f, 2.0f,-2.0f,   2.0f, 2.0f, 2.0f,   2.0f,-2.0f, 2.0f,   2.0f,-2.0f,-2.0f };	
    	}
    	cArray = new float[] {0.0f,1.0f,0.0f, 0.0f,1.0f,0.0f, 0.0f,1.0f,0.0f, 0.0f,1.0f,0.0f,
    			 			  1.0f,0.5f,0.0f, 1.0f,0.5f,0.0f, 1.0f,0.5f,0.0f, 1.0f,0.5f,0.0f,
    			 			  1.0f,0.0f,0.0f, 1.0f,0.0f,0.0f, 1.0f,0.0f,0.0f, 1.0f,0.0f,0.0f,
    			 			  1.0f,1.0f,0.0f, 1.0f,1.0f,0.0f, 1.0f,1.0f,0.0f, 1.0f,1.0f,0.0f,
    			 			  0.0f,0.0f,1.0f, 0.0f,0.0f,1.0f, 0.0f,0.0f,1.0f, 0.0f,0.0f,1.0f,
    			 			  1.0f,0.0f,1.0f, 1.0f,0.0f,1.0f, 1.0f,0.0f,1.0f, 1.0f,0.0f,1.0f
    	};
    	FloatBuffer vertexBufferTemp = BufferUtil.newFloatBuffer(vArray.length);
        FloatBuffer colorsBufferTemp = BufferUtil.newFloatBuffer(cArray.length);
    	
        for (int i = 0; i < vArray.length; i++)
        {
        	vertexBufferTemp.put(vArray[i]);
        }            
        for (int j = 0; j < cArray.length; j++)
        {
        	colorsBufferTemp.put(cArray[j]);
        } 
        vertexBufferTemp.rewind();
        colorsBufferTemp.rewind();


        gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL.GL_COLOR_ARRAY);

        gl.glVertexPointer(3, GL.GL_FLOAT, 0, vertexBufferTemp);
        gl.glColorPointer(3, GL.GL_FLOAT, 0, colorsBufferTemp);
        System.out.println("!!Neue Daten!!");
    }

    public void display(GLAutoDrawable gLDrawable)
    {
      gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

      gl.glLoadIdentity();
      gl.glTranslatef(1.5f, 0.0f, -6.0f);
      gl.glRotatef(rquad, 1.0f, 1.0f, 1.0f);
      
      gl.glDrawArrays(GL.GL_QUADS, 0, 72);
      gl.glFlush();
      
      rtri += 0.2f;
      rquad += 0.15f;
    }

    public void init(GLAutoDrawable gLDrawable)
    {
      gl = gLDrawable.getGL();
      gl.glShadeModel(GL.GL_SMOOTH);              // Enable Smooth Shading
      gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);    // Black Background
      gl.glClearDepth(1.0f);                      // Depth Buffer Setup
      gl.glEnable(GL.GL_DEPTH_TEST);							// Enables Depth Testing
      gl.glDepthFunc(GL.GL_LEQUAL);								// The Type Of Depth Testing To Do
      gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);	// Really Nice Perspective Calculations
      gLDrawable.addKeyListener(this);
      buildVertexArray();
    }

   public void keyPressed(KeyEvent e)
    {
      if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
      {
        animator.stop();
        System.exit(0);
      }
      else
      {
    	  huhu = !huhu;
    	  buildVertexArray(); // HIERMIT SOLL SICH DER WÜRFEL VERÄNDERN!!!!!!
    	  System.out.println("HUHU--->" + huhu);
      }
```

Ich hoffe das ist jetzt nicht schon zu viel Code   
Wenn mir einfach bzgl. Vertex Arrays helfen könnte wäre ich sehr dankbar. Anbei versuche ich ja noch die 1.000.000 Vertexe zu reduzieren. Einen guten Ansatz habe ich da aber leider auch noch nicht.

Gruß
René


----------



## Illuvatar (28. Aug 2008)

Was heißt, es stürzt ab? Gibt es eine Fehlermeldung?


----------



## Guest (28. Aug 2008)

Ich bekomme nur den Java VM Report. Mit dem kann ich aber nichts anfangen. Da steht folgendes drin:
	
	
	
	





```
#
# An unexpected error has been detected by Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x06071211, pid=2064, tid=1556
#
# Java VM: Java HotSpot(TM) Client VM (10.0-b23 mixed mode, sharing windows-x86)
# Problematic frame:
# C  0x06071211
#
# If you would like to submit a bug report, please visit:
#   [url]http://java.sun.com/webapps/bugreport/crash.jsp[/url]
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x0307c000):  JavaThread "AWT-EventQueue-0" [_thread_in_native, id=1556, stack(0x02f80000,0x02fd0000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x062d7010

Registers:
EAX=0x05345cc4, EBX=0x04e9c840, ECX=0x00002400, EDX=0x00000031
ESP=0x02fcf7e4, EBP=0x02fcf7f0, ESI=0x062d7000, EDI=0x00006c00
EIP=0x06071211, EFLAGS=0x00010202

Top of Stack: (sp=0x02fcf7e4)
0x02fcf7e4:   00000055 04e9c840 000023dc 00016a2f
0x02fcf7f4:   6978b8c5 04e9c840 05345960 000023dc
0x02fcf804:   00000055 0307c000 04e9c840 02fcf848
0x02fcf814:   26ab65f0 00000055 060711c0 695ecac4
0x02fcf824:   00000006 00000000 00000000 00018e60
0x02fcf834:   26ab65f0 10003ff5 00000007 00000000
0x02fcf844:   00018e60 02fcf88c 008f9c71 0307c0f4
0x02fcf854:   02fcf8a8 00000007 00000000 00018e60 

Instructions: (pc=0x06071211)
0x06071201:   08 8b 35 64 5c ea 04 8b 76 2c 8d 3c 49 8d 34 fe
0x06071211:   dd 46 10 dd 46 08 dd 06 d9 58 0c d9 58 10 d9 58 


Stack: [0x02f80000,0x02fd0000],  sp=0x02fcf7e4,  free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  0x06071211

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::Interpreter
v  ~BufferBlob::StubRoutines (1)

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x03280800 JavaThread "Timer-2" [_thread_blocked, id=2264, stack(0x062e0000,0x06330000)]
  0x030ea000 JavaThread "Timer-1" [_thread_blocked, id=632, stack(0x06950000,0x069a0000)]
  0x0331c400 JavaThread "Timer-0" [_thread_blocked, id=2652, stack(0x064c0000,0x06510000)]
  0x032f0400 JavaThread "TimerQueue" daemon [_thread_blocked, id=3652, stack(0x049c0000,0x04a10000)]
  0x00395400 JavaThread "DestroyJavaVM" [_thread_blocked, id=512, stack(0x003b0000,0x00400000)]
=>0x0307c000 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=1556, stack(0x02f80000,0x02fd0000)]
  0x02b13000 JavaThread "AWT-Windows" daemon [_thread_in_native, id=3264, stack(0x02ec0000,0x02f10000)]
  0x02b12000 JavaThread "AWT-Shutdown" [_thread_blocked, id=2944, stack(0x02e70000,0x02ec0000)]
  0x02b11400 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=668, stack(0x02e20000,0x02e70000)]
  0x02a65c00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3236, stack(0x02d10000,0x02d60000)]
  0x02a57c00 JavaThread "CompilerThread0" daemon [_thread_blocked, id=1424, stack(0x02cc0000,0x02d10000)]
  0x02a56800 JavaThread "Attach Listener" daemon [_thread_blocked, id=3588, stack(0x02c70000,0x02cc0000)]
  0x02a55c00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3844, stack(0x02c20000,0x02c70000)]
  0x02a51400 JavaThread "Finalizer" daemon [_thread_blocked, id=2004, stack(0x02bd0000,0x02c20000)]
  0x02a4d000 JavaThread "Reference Handler" daemon [_thread_blocked, id=3884, stack(0x02b80000,0x02bd0000)]

Other Threads:
  0x02a4bc00 VMThread [stack: 0x02b30000,0x02b80000] [id=3580]
  0x02a66c00 WatcherThread [stack: 0x02d60000,0x02db0000] [id=1524]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
```


----------



## Fancy (30. Aug 2008)

Moin,

die gl*Pointer müssen einfach unmittelbar vor jedem glDrawArrays gesetzt werden, dann sollte das gehen. Als Beispiel, Dein Code, wie er bei mir läuft:


```
package fancy.jf.va;

import java.awt.Frame;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.nio.FloatBuffer;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.BufferUtil;

public class VA implements GLEventListener, KeyListener {
	
	
    private static final float[] vArray1 = new float[] { 
        1.0f, 1.0f,-1.0f,  -1.0f, 1.0f,-1.0f,  -1.0f, 1.0f, 1.0f,   1.0f, 1.0f, 1.0f,
        1.0f,-1.0f, 1.0f,  -1.0f,-1.0f, 1.0f,  -1.0f,-1.0f,-1.0f,   1.0f,-1.0f,-1.0f,
        1.0f, 1.0f, 1.0f,  -1.0f, 1.0f, 1.0f,  -1.0f,-1.0f, 1.0f,   1.0f,-1.0f, 1.0f,
        1.0f,-1.0f,-1.0f,  -1.0f,-1.0f,-1.0f,  -1.0f, 1.0f,-1.0f,   1.0f, 1.0f,-1.0f,
       -1.0f, 1.0f, 1.0f,  -1.0f, 1.0f,-1.0f,  -1.0f,-1.0f,-1.0f,  -1.0f,-1.0f, 1.0f,
        1.0f, 1.0f,-1.0f,   1.0f, 1.0f, 1.0f,   1.0f,-1.0f, 1.0f,   1.0f,-1.0f,-1.0f};

	private static final float[] vArray2 = new float[] {
	    2.0f, 2.0f,-2.0f,  -2.0f, 2.0f,-2.0f,  -2.0f, 2.0f, 2.0f,   2.0f, 2.0f, 2.0f,
	    2.0f,-2.0f, 2.0f,  -2.0f,-2.0f, 2.0f,  -2.0f,-2.0f,-2.0f,   2.0f,-2.0f,-2.0f,
	    2.0f, 2.0f, 2.0f,  -2.0f, 2.0f, 2.0f,  -2.0f,-2.0f, 2.0f,   2.0f,-2.0f, 2.0f,
	    2.0f,-2.0f,-2.0f,  -2.0f,-2.0f,-2.0f,  -2.0f, 2.0f,-2.0f,   2.0f, 2.0f,-2.0f,
	   -2.0f, 2.0f, 2.0f,  -2.0f, 2.0f,-2.0f,  -2.0f,-2.0f,-2.0f,  -2.0f,-2.0f, 2.0f,
	    2.0f, 2.0f,-2.0f,   2.0f, 2.0f, 2.0f,   2.0f,-2.0f, 2.0f,   2.0f,-2.0f,-2.0f};
	
	private static final float[] cArray = new float[] {
	    0.0f, 1.0f, 0.0f,  0.0f, 1.0f, 0.0f,  0.0f, 1.0f, 0.0f,  0.0f, 1.0f, 0.0f,
	    1.0f, 0.5f, 0.0f,  1.0f, 0.5f, 0.0f,  1.0f, 0.5f, 0.0f,  1.0f, 0.5f, 0.0f,
	    1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,  1.0f, 0.0f, 0.0f,
	    1.0f, 1.0f, 0.0f,  1.0f, 1.0f, 0.0f,  1.0f, 1.0f, 0.0f,  1.0f, 1.0f, 0.0f,
	    0.0f, 0.0f, 1.0f,  0.0f, 0.0f, 1.0f,  0.0f, 0.0f, 1.0f,  0.0f, 0.0f, 1.0f,
	    1.0f, 0.0f, 1.0f,  1.0f, 0.0f, 1.0f,  1.0f, 0.0f, 1.0f,  1.0f, 0.0f, 1.0f};
	
	private static final int     vaSize              = Math.max(vArray1.length, vArray2.length);

    private GL                   gl                  = null;
    private GLU                  glu                 = null;

    private FloatBuffer          vertexArrayVertices = null;
    private FloatBuffer          vertexArrayColor    = null;

    private boolean              flag                = false;
    private float                rquad               = 0;

    
    @Override
    public void init(GLAutoDrawable drawable) {

        gl = drawable.getGL();
        glu = new GLU();

        vertexArrayVertices = BufferUtil.newFloatBuffer(vaSize);
        buildVertexArray();

        vertexArrayColor = BufferUtil.newFloatBuffer(cArray.length);
        vertexArrayColor.put(cArray, 0, cArray.length);
        vertexArrayColor.rewind();

        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);

        gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL.GL_COLOR_ARRAY);
    }

    
    @Override
    public void display(GLAutoDrawable drawable) {

        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

        gl.glLoadIdentity();
        gl.glTranslatef(1.5f, 0.0f, -6.0f);
        gl.glRotatef(rquad, 1.0f, 1.0f, 1.0f);

        gl.glVertexPointer(3, GL.GL_FLOAT, 0, vertexArrayVertices);
        gl.glColorPointer(3, GL.GL_FLOAT, 0, vertexArrayColor);
        gl.glDrawArrays(GL.GL_QUADS, 0, vaSize);

        rquad += 0.15f;
    }

    
    private void buildVertexArray() {

        vertexArrayVertices.clear();
        if (flag) vertexArrayVertices.put(vArray1, 0, vArray1.length);
        else vertexArrayVertices.put(vArray2, 0, vArray2.length);

        vertexArrayVertices.rewind();
    }

    
    public void keyPressed(KeyEvent e) {

        flag = !flag;
        buildVertexArray();
        System.out.println("HUHU--->" + flag);
    }

    
    @Override
    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {

        if (height <= 0) height = 1;

        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        glu.gluPerspective(45.0f, (float) width / (float) height, 1.0, 20.0);
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();
    }

    
    @Override
    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}

    
    @Override
    public void keyReleased(KeyEvent arg0) {}

    
    @Override
    public void keyTyped(KeyEvent arg0) {}

    
    public static void main(String[] args) {

        final VA va = new VA();
        final Frame frame = new Frame();
        final GLCanvas canvas = new GLCanvas();
        final Animator animator = new Animator(canvas);
        canvas.addGLEventListener(va);
        canvas.addKeyListener(va);
        frame.add(canvas);
        frame.setSize(500, 500);
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                new Thread(new Runnable() {
                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        frame.setVisible(true);
        animator.start();
    }

}
```

Da Du ja auch VBOs angesprochen hast, damit sollte das in etwa so aussehen (anderes Beispiel): 


```
package fancy.jf.vbo;

import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;

import com.sun.opengl.util.Animator;

public class VBO implements GLEventListener {

    
    private static final float[] staticVertices = new float[] {
        1.0f,  1.0f, 
       -1.0f,  1.0f,  
       -1.0f, -1.0f, 
        1.0f, -1.0f,   
        1.0f,  1.0f};
	
	private static final int     vboSize        = staticVertices.length;

    private GL                   gl             = null;
    private GLU                  glu            = null;

    private int                  vboHandle      = 0;

    
    @Override
    public void init(GLAutoDrawable drawable) {

        gl = drawable.getGL();
        glu = new GLU();

        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);

        if (!gl.isExtensionAvailable("GL_ARB_vertex_buffer_object")) {
            System.out.println("Missing: GL_ARB_vertex_buffer_object");
            System.exit(1);
        }

        final int[] vboHandleBuffer = new int[1];
        gl.glGenBuffersARB(1, vboHandleBuffer, 0);
        vboHandle = vboHandleBuffer[0];

        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, vboHandle);
        gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB, vboSize * (Float.SIZE / Byte.SIZE), (Buffer) null, GL.GL_DYNAMIC_DRAW_ARB);
        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0);

        gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
    }

    
    @Override
    public void display(GLAutoDrawable drawable) {

        calculateVBO();

        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        gl.glLoadIdentity();
        gl.glTranslatef(0.0f, 0.0f, -12.0f);

        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, vboHandle);
        gl.glVertexPointer(2, GL.GL_FLOAT, 0, 0);
        gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, vboSize);
        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0);
    }

    
    private void calculateVBO() {

        final double time = System.currentTimeMillis();

        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, vboHandle);

        final ByteBuffer vboBytes = gl.glMapBufferARB(GL.GL_ARRAY_BUFFER_ARB, GL.GL_WRITE_ONLY_ARB);
        vboBytes.order(ByteOrder.nativeOrder());

        final FloatBuffer vboBuffer = vboBytes.asFloatBuffer();

        for (int i = 0; i < staticVertices.length; i++) {
            vboBuffer.put(i, staticVertices[i] * ((float) Math.sin(time / 1000) + 1));
        }

        gl.glUnmapBufferARB(GL.GL_ARRAY_BUFFER_ARB);
        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, 0);
    }

    
    @Override
    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {

        if (height <= 0) height = 1;

        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        glu.gluPerspective(45.0f, (float) width / (float) height, 1.0, 20.0);
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();
    }

    
    @Override
    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}

    
    public static void main(String[] args) {

        final Frame frame = new Frame();
        final GLCanvas canvas = new GLCanvas();
        final Animator animator = new Animator(canvas);
        canvas.addGLEventListener(new VBO());
        frame.add(canvas);
        frame.setSize(500, 500);
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                new Thread(new Runnable() {
                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        frame.setVisible(true);
        animator.start();
    }

}
```

Was Dein Problem mit den 1M Vertices angeht, so würde ich vermuten, dass das einfach zu viele sind um mit einem Aufruf gerendert zu werden. Wenn Du den ganzen Satz auf viele verhältnismäßig kleinere VA oder VBO aufteilst, müsste das eigentlich auch gehen. 

Gruß,
Michael


----------

