package demos.es2.perftst; import java.nio.*; import com.jogamp.opengl.*; import com.jogamp.opengl.util.*; import com.jogamp.opengl.util.glsl.ShaderState; public class PerfVBOLoad extends PerfModule { public PerfVBOLoad() { } public ShaderState initShaderState(GL2ES2 gl) { return 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("mgl_Color", 4, dataType, true, numVertices, GL.GL_STATIC_DRAW); colors[i].setVBOEnabled(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].getElementCount()); 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].getElementCount() * numObjs; int verticesBytes = verticesElements * vertices[0].getComponentSizeInBytes()* vertices[0].getComponentCount(); int colorsElements = colors[0].getElementCount() * colors.length; int colorsBytes = colorsElements * colors[0].getComponentSizeInBytes()* colors[0].getComponentCount(); dt = 0; for(int i=1; i