opengl line drawing

Started by
4 comments, last by Uthman 18 years, 7 months ago
opengl line drawing is slow as hell.. espicially when the lines aren't clipped to the viewing frustrum. is there any way to sped this up without doing clipping? (aka by setting a parameter?) I'm working on a really simple program and I don't want to make it seem any more complicated than it already is for people once they view it.
"a low level aho master like you couldn't kill me even if I let you"
Advertisement
First try it with line strips, there may be a (very) slight performance increase. Also disable all unnecessary modes like lighting, blending etc.
Second, place everything in a display list & use that. I've never noticed a big increase worth writing home about with this method either though.
Last, try it using compiled vertex buffers or even better, hardware supported ones. This is the best performance gain you'll get.

Finally try disabling vsync (though if it's just slow in the first place then this will make no difference)

void setVSync(int interval){    char *extensions = (char*)glGetString( GL_EXTENSIONS );    if( strstr( extensions, "WGL_EXT_swap_control\0" ) == 0 )        return; // Error: WGL_EXT_swap_control extension not supported on your computer.n");    else    {        wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress( "wglSwapIntervalEXT\0" );        if( wglSwapIntervalEXT )            wglSwapIntervalEXT(interval);    }}


In the initialisation routine:
setVSync(0);

Always a nice bit of code to have in any case :D
"I must not fear. Fear is the mindkiller. Fear is the little death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past me I will turn to see fear's path. Where the fear has gone there will be nothing. Only I will remain." ~Frank Herbert, DuneMy slice of the web
Believe it or not modern cards (ATI & NV) suck when it comes to drawing lines as they arent setup for it, each line is infact 3 triangles setup to represent the line, which is why it tends to hurt the hardware.

The only high end CAD cards seem todo anything vaguely sane when it comes to drawing lines.
How many lines are you drawing? I had an openGL based line drawing 2D game, and it was runing at thousands of frames per second. Wasn't slow at all, and i wasn't useing displaylists or vertex arrays. So i'm confused on what slow is.
youre batching up the lines and drawing as many as possible in one go + not drawing them one at a time i take it.
eg youre not doing the following i hope.
loop {

glBegin( GL_LINES );
glVertex(A);
glVertex(B);
glEnd()l
}

also turn off everything u dont need before hand eg lighting/textures etc
thanks guys =D

it was the bloody textures that was making it slow down to a crawl
"a low level aho master like you couldn't kill me even if I let you"

This topic is closed to new replies.

Advertisement