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.
Page Index Toggle Pages: 1
OpenGL optimizing?? (Read 2699 times)
OpenGL optimizing??
May 17th, 2007, 1:13am
 
hi
i'm starting some new code, building relatively complex 3D models, let's say 10,000 to 50,000 polygons, including some lighting and textures.

i would like to get into some animation/physics of these models.

can some experts here give me some general ideas about how to optimize my code so that it's the fastest it can possibly be?

- first what can i do in processing to make sure i'm rendering as fast as possible?
- second what might i do if i wanted to get into actually coding in opengl to make it all faster (and would this actually make any sense? or is my bottleneck going to be elsewhere)

this is only for my own machine so i don't need to worry about compatibility issues.

thanks for any pointers!
Re: OpenGL optimizing??
Reply #1 - May 17th, 2007, 3:38am
 
You might have a look at this: http://www.texone.org/progl/
Re: OpenGL optimizing??
Reply #2 - May 17th, 2007, 10:54am
 
i tried that but i'm getting the same errors (on win XP) as the folks on this thread:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=os_libraries_tools;action=display;num=1153347034;start=11#10
so i'm guessing there's something incompatible with more recent processing releases.

in general i'm interested in any other techniques people can suggest.

thanks
Re: OpenGL optimizing??
Reply #3 - May 17th, 2007, 11:32am
 
progl only uses OpenGL Display Lists (IIRC) which aren't actually that fast from java.

The fastest way is through the use of OpenGL's Vertex Buffer Objects. This stores the geometry actualyl on the video card, adn then you just need to tell it to draw the object.

I have done a program which uses them here: http://www.hardcorepawn.com/Speedy/
all the VBO code is in MultiObject.pde I think.

I am working on a new .obj loader for OpenGL mode that uses VBO to draw things fast, though I've not had time to package it up as a library, or work with all variations of .obj files.
Re: OpenGL optimizing??
Reply #4 - May 17th, 2007, 4:16pm
 
i see... that's good to know.
i had a look at your applet, very nice; do you know off hand how many polygons you have there? is the hardcorepawn.opengl.* library something you've released to the public?
thanks...
Re: OpenGL optimizing??
Reply #5 - May 17th, 2007, 4:33pm
 
Hardcorepawn.opengl was just something I was playing with, it's not actually necessary anymore, now there's the beginGL()/endGL() methods in PGraphicsOpenGL.

There's ~330,000 triangles in that scene.
Re: OpenGL optimizing??
Reply #6 - May 17th, 2007, 5:08pm
 
great! i'll try out your method; many thanks!
Re: OpenGL optimizing??
Reply #7 - May 28th, 2007, 8:48pm
 
Hey John, about the VBO stuff. Once you make your array of vertices, is it possible to change the values dynamically? Or does opengl expect that it is static geometry?

EDIT:

Actually, I spoke too soon. Looking at the code again I see that the point is to send a vertex array to the card and then use the same array multiple times as a way of mesh sharing. I can't imagine this method would be all that useful if you've got 40 different meshes that each need to be drawn once.
Re: OpenGL optimizing??
Reply #8 - May 28th, 2007, 9:10pm
 
You can have many VBOs at once, as long as you keep track of the ID's generated. So you can put all your geometry/normals/texture coords onto the video card, and then call them as and when necessary.

If each is only ever going ot be drawn once, then it may not offer any speed increase in total, but maybe a percieved increase, since you load them all in the beginning causing a pause and then draw them quickly, rather than lots of smaller pauses due to drawing them the slow way.
Re: OpenGL optimizing??
Reply #9 - May 28th, 2007, 9:17pm
 
Ok, got that. Which I guess brings me back to my first question:

I've got a cloth simulation going on, but I'm rendering the grid of particles as a textured mesh. So if I put the grid into a vertex array at loadup and hand that to the card, can I then continue to update the values in the array with the positions of the particles (which I'm using as vertices)?
Re: OpenGL optimizing??
Reply #10 - May 28th, 2007, 9:38pm
 
I think it is possible.. but I've never done it. There's the "GL.GL_STATIC_DRAW" part of glBufferData, that can also be GL.GL_DYNAMIC_DRAW which I assume means that data can be altered.. but I'm not sure of the methods to go about doing it.

I assume there'd be some speed increase, since texture coords need not change as geometry does.. and it might be quicker to bulk uploade the data to the video card, than manually iterate through the data, drawing everything seperately.
Re: OpenGL optimizing??
Reply #11 - Jul 24th, 2007, 10:05am
 
by the sounds of this tutorial:

http://www.ozone3d.net/tutorials/opengl_vbo_p1.php

GL_STREAM_DRAW might be more appropriate to your needs...?
Re: OpenGL optimizing??
Reply #12 - Mar 25th, 2009, 10:02pm
 
JohnG, I'm trying to download and play with your code but it's missing "ball3.obj".  Could you post this on your site?  

Thanks,
JeffG
Page Index Toggle Pages: 1