We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Processing OpenGL performance VS OpenFrameworks
Page Index Toggle Pages: 1
Processing OpenGL performance VS OpenFrameworks (Read 973 times)
Processing OpenGL performance VS OpenFrameworks
Jan 20th, 2010, 3:00am
 
Hi,

Just starting a new project with Processing for the first time.
Really love the simplicity and power of Processing !

We did a test with one 3D model containing 72 triangles, 36 vertices

Using this model 250 times in a spiral shape was really slow.
Updating video card drivers gave us a little boost but not satisfying.

CPU load is ok indicating hardware acceleration is working.

After a couple of hours we decided to give the same sample a shot in OpenFrameworks.
There was a huge difference in performance we could easily use 2500 instances.

So I was wondering did we miss something in Processing or is OpenGl in OF just better ?


Thx in advance !

Code we used

Code:

import javax.swing.JFrame;

import com.obj.WavefrontObject;

import processing.core.PApplet;
import processing.core.PImage;
import saito.objloader.OBJModel;

//import processing.opengl.PGraphicsOpenGL;

public class Test extends PApplet
{

private static final long serialVersionUID = -4255268276881618974L;

float X;
float Y;
float YPOS;
int lastTime;

OBJModel mdl;

WavefrontObject wfo;

PImage tex;

public void setup() {
// TODO Auto-generated method stub

mdl=new OBJModel(this,"data/A.obj");

//size(screen.width,screen.height-100,P3D);
size(1024,768,OPENGL);
background(0);
YPOS=0;
mdl.enableMaterial();
mdl.enableTexture();
//smooth();
noSmooth();
lastTime=millis();
noStroke();

tex = loadImage("tex.jpg");
hint(DISABLE_OPENGL_2X_SMOOTH);
//hint(DISABLE_ACCURATE_TEXTURES);
hint(DISABLE_DEPTH_SORT);
//hint(DISABLE_DEPTH_TEST);

//frustum(-1024, 1024, 0, 768, 0, 500);


}
@Override
public void draw() {

int now = millis();

int diff = now-lastTime;
float dt = (float)(diff)/1000;

lastTime = now;

background(0);
lights();

// TODO Auto-generated method stub

resetMatrix();
translate(0,100,-700);

rotateY(Y);
int l = 250;

YPOS+=((mouseY-(100))*0.25)*dt;

for(int i=0;i<l;i++)
{
//
float a = (float)(i*0.125);
float r = sin((float)(i*0.25))*100+100;


float y  = (float)(i * 5) - YPOS;
if(y<800 && y>-800)
{
pushMatrix();
float Z = sin(a)*r;
translate(cos(a)*r,y,Z);
rotateY((float)(-a+PI*0.5));

mdl.draw();
popMatrix();
}
}

Y+=((mouseX-300)*dt*0.004);
if(Y>PI*2)
{
Y=0;
}

}
public static void main(String[] args)
{
PApplet.main(new String[]{"--present","Test"});

}

}






Page Index Toggle Pages: 1