PDA

View Full Version : how to draw 2d lins fast?



Barbary
03-22-2005, 10:37 PM
about 1 million lines
display list? it seems too slow

How to draw them fast?

T101
03-22-2005, 11:05 PM
You could try rendering quads instead.
Might be more optimised.

brinck
03-22-2005, 11:21 PM
Since you're mentioning display lists I guess the geometry is static. I suggest you switch to Vertex Buffer Objects:

http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_buffer_object.txt

created with GL_STATIC_DRAW_ARB.

Regarding the primitive type I think you should stick with lines since they will use the least transform rate.

/A.B.

RigidBody
03-22-2005, 11:43 PM
using quads may be better. as far as i know, most graphic cards do not have hardware acceleration for drawing lines.

M/\dm/\n
03-23-2005, 01:29 AM
If I remember correctly, then setting polygon FRONT_AND_BACK mode to LINE did hurt performance too.

brinck
03-23-2005, 02:37 AM
Originally posted by RigidBody:
using quads may be better. as far as i know, most graphic cards do not have hardware acceleration for drawing lines.I would like some more information about this, can you give some examples of modern cards that don't have hardware accelerated line drawing?

Barbary should of course test and see which primitive is faster.

/A.B.

Barbary
03-23-2005, 03:00 AM
Originally posted by RigidBody:
using quads may be better. as far as i know, most graphic cards do not have hardware acceleration for drawing lines.but in my test using guads is even worse.

Barbary
03-23-2005, 03:04 AM
Originally posted by brinck:
Since you're mentioning display lists I guess the geometry is static. I suggest you switch to Vertex Buffer Objects:

http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_buffer_object.txt

created with GL_STATIC_DRAW_ARB.

Regarding the primitive type I think you should stick with lines since they will use the least transform rate.

/A.B.maybe it is useful.is it free to use it ? for commerce.

RigidBody
03-23-2005, 03:07 AM
do you use quads or quad strips? strips should have better performance.

about the line hardware acceleration- that's something i heard, don't remember when or where. but it seems probable to me because in stuff like games you are most likely to use filled polygons rather than lines. one application which could take advantage of accelerated lines could be a cad program, when you switch to wireframe view. in the product description of a nvidia quadro fx i found hardware accelerated antialiased ponits and lines listed as a feature.

but as i said, i'm not absolutely sure about this topic.

brinck
03-23-2005, 03:26 AM
Originally posted by Barbary:
maybe it is useful.is it free to use it ? for commerce.Yes.

/A.B.

Barbary
03-23-2005, 03:48 AM
actually this is a cad application.
we used GDI first , but it is very slow when draw millions of lines .so we want to try GL.
but it is no better in my test.
I dont know how to do it...


Originally posted by RigidBody:
do you use quads or quad strips? strips should have better performance.

about the line hardware acceleration- that's something i heard, don't remember when or where. but it seems probable to me because in stuff like games you are most likely to use filled polygons rather than lines. one application which could take advantage of accelerated lines could be a cad program, when you switch to wireframe view. in the product description of a nvidia quadro fx i found hardware accelerated antialiased ponits and lines listed as a feature.

but as i said, i'm not absolutely sure about this topic.

knackered
03-23-2005, 05:11 AM
If you want a cheap fast 'wireframe' mode, simple leave your glpolygonmode as GL_FILL, but enable texturing and use a texture with the edge texels filled in (RGBA=1,1,1,1) but all the middle texels empty (RGBA=0,0,0,0). Make sure you've set up your texture coordinates correctly on your geometry.
Enable alpha testing and bingo! Much, much faster than using GL_LINE on consumer cards...but obviously there are some artefacts.

def
03-23-2005, 07:38 AM
Workstation graphic cards such as the Quadro line from NVidia or FireGL from ATI should give you better line drawing performance than your average gaming card.

Mikkel Gjoel
03-23-2005, 07:48 AM
Originally posted by knackered:
Make sure you've set up your texture coordinates correctly on your geometry.- so basically, this requires drawing the mesh one triangle at a time, with one position/texcoord for each vertex, for each triangle (all vertices are "exploded"). This will mostly be equal to creating (and storing) an entirely new mesh for the wireframe-rendering.

A result of this approach, that might sometimes be desirable, is that thickness of the lines will scale with the rest of the object - ie. lines closer to the view will be thicker than lines further away (which would seem logical).

\\hornet

maximian
03-23-2005, 09:19 AM
Depends on your hardware. My Gefx renders 1 million lines @ about 4 fps. I suggest you use GL_LINE_STRIP.

knackered
03-23-2005, 10:24 PM
Originally posted by hornet:

Originally posted by knackered:
Make sure you've set up your texture coordinates correctly on your geometry.- so basically, this requires drawing the mesh one triangle at a time, with one position/texcoord for each vertex, for each triangle (all vertices are "exploded"). This will mostly be equal to creating (and storing) an entirely new mesh for the wireframe-rendering.

A result of this approach, that might sometimes be desirable, is that thickness of the lines will scale with the rest of the object - ie. lines closer to the view will be thicker than lines further away (which would seem logical).

\\hornetThat's correct. Limited use, but even rendering with filled texture with a huge number of duplicate vertices ends up being quicker than using GL_LINE on consumer cards. So use it where you absolutely need the speed...it's not the best solution.
Like you say, you get perspective correct line thickness which does look quite nice.
As a side note, I was staggered how slow GL_LINES were on the radeon 8500.