package demos.es2.perftst; import java.nio.*; import javax.media.opengl.*; import com.jogamp.opengl.util.*; import com.jogamp.javafx.newt.*; import com.jogamp.javafx.newt.opengl.*; public class PerfVBOLoad extends PerfModule { public PerfVBOLoad() { } public void initShaderState(GL2ES2 gl) { initShaderState(gl, "vbo-vert-col", "fcolor"); } protected void runOneSet(GLAutoDrawable drawable, int dataType, int numObjs, int numVertices, int loops, boolean useVBO) { GL2ES2 gl = drawable.getGL().getGL2ES2(); // // data setup // GLArrayDataServer[] vertices = new GLArrayDataServer[numObjs]; GLArrayDataServer[] colors = new GLArrayDataServer[numObjs]; float x=0f, y=0f, z=0f; float r=1f, g=1f, b=1f; for(int i=0; i1f) { x=0f; y=0f; z+=0.01f; } } } colors[i] = GLArrayDataServer.createGLSL(gl, "mgl_Color", 4, dataType, true, numVertices, GL.GL_STATIC_DRAW); colors[i].setVBOUsage(useVBO); { // Fill them up Buffer colorb = colors[i].getBuffer(); for(int j =0; j1) { // we need to re-enable the buffer, // incl. the vertex attribute refresh // in case we switch to another buffer vertices[j].enableBuffer(gl, true); } t1[i][j] = System.currentTimeMillis(); if(i==0) { colors[j].seal(gl, true); } else { colors[j].enableBuffer(gl, true); } t2[i][j] = System.currentTimeMillis(); gl.glDrawArrays(GL.GL_LINE_STRIP, 0, vertices[j].getElementNumber()); if(numObjs>1) { vertices[j].enableBuffer(gl, false); colors[j].enableBuffer(gl, false); } t3[i][j] = System.currentTimeMillis(); } gl.glFinish(); tF[i] = System.currentTimeMillis(); drawable.swapBuffers(); tS[i] = System.currentTimeMillis(); } if(numObjs==1) { vertices[0].enableBuffer(gl, false); colors[0].enableBuffer(gl, false); } int verticesElements = vertices[0].getElementNumber() * numObjs; int verticesBytes = verticesElements * vertices[0].getComponentSize()* vertices[0].getComponentNumber(); int colorsElements = colors[0].getElementNumber() * colors.length; int colorsBytes = colorsElements * colors[0].getComponentSize()* colors[0].getComponentNumber(); dt = 0; for(int i=1; i