how to draw 2d lins fast?

about 1 million lines
display list? it seems too slow

How to draw them fast?

You could try rendering quads instead.
Might be more optimised.

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.

using quads may be better. as far as i know, most graphic cards do not have hardware acceleration for drawing lines.

If I remember correctly, then setting polygon FRONT_AND_BACK mode to LINE did hurt performance too.

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.

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.

Originally posted by brinck:
[b]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.[/b]
maybe it is useful.is it free to use it ? for commerce.

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.

Originally posted by Barbary:
maybe it is useful.is it free to use it ? for commerce.
Yes.

/A.B.

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:
[b]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.[/b]

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.

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.

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

Depends on your hardware. My Gefx renders 1 million lines @ about 4 fps. I suggest you use GL_LINE_STRIP.

Originally posted by hornet:
[b] [quote]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[/b][/QUOTE]That’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.