Jump to content
  • Advertisement
Sign in to follow this  
Uthman

OpenGL opengl line drawing

This topic is 4729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!