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 › Create a line texture
Page Index Toggle Pages: 1
Create a line texture? (Read 1089 times)
Create a line texture?
Sep 2nd, 2009, 1:32pm
 
One of the largest performance hits I take is with lines.  Even using the direct OpenGL commands for a line, really drags down the fps when your talking about 20,000+ lines.

Code:

gl.glBegin(gl.GL_LINES);
gl.glColor4f(red(c), green(c), blue(c), linealpha);
gl.glVertex3f(x,y,z); //creates line
gl.glVertex3f(x,y,z);
gl.glEnd();


I've had no such performance loss using textures on a quad.  I've loaded up 500,000+ textured quads without much performance loss.  Is there any way to create a line using a texture in OpenGL, perhaps a rectangle quad?

I wrap the code in a display list.
Re: Create a line texture?
Reply #1 - Sep 2nd, 2009, 8:00pm
 
Sure, quads with a low height will look just like lines.  But VBOs will also give you a performance boost over display lists...Oh, and a triangle_strip with the same points as a quad, just in a Z shape rather than a |_| shape, will be marginally faster and more compatible.  
--Ben
Re: Create a line texture?
Reply #2 - Sep 3rd, 2009, 5:41am
 
Ok, but how would I apply a texture to it?  Could you give an example?  What would the size of the image for stretching (or repeating) it across the defined line space.  Interesting thought on the triangle!  I've tried VBO's before and did not see any increase but am willing to give it a try.  The main performance issue seemed to be in creating the lines themselves, and not how I called it, but I'm open to whatever to get it to perform better.
Re: Create a line texture?
Reply #3 - Sep 4th, 2009, 7:11pm
 
This isn't specific to lines, but GL texture plays nice with a Texture object in P5.  Here is my method (see posts 2 and 3):

http://processing.org/discourse/yabb2/?num=1249550693
Page Index Toggle Pages: 1