Advertisement

Drawing lines in OpenGL

Started by May 25, 2000 04:12 AM
4 comments, last by Crazie Joey 24 years, 6 months ago
Is there a way that you can draw a line in open GL and specify it''s thickness? i''m creating a cartoon renderer as a side projects and i''m trying to create a "border" around the outside. i know how to get the border, i just dont know how to draw the lines!! Any help appreciated Crazie Joey
Lines isn''t too difficult:
glBegin( GL_LINES );
// ( or GL_LINE_STRIP, or GL_LINE_LOOP )
// Vertex/colour calls here
glEnd();

Setting the line qualities is a bit more involved.
If you have the OpenGL documentation, search for the GL_LINE* constants, the ones you''d probably want to look at are:
GL_LINE_WIDTH, and GL_LINE_SMOOTH
They are used with glGet and glSet calls.

I hope that''s what you were looking for.


#pragma DWIM // Do What I Mean!
~ Mad Keith ~
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
Advertisement
thank you - this is what i''m looking for. I''m new-ish to openGL so i dont know all of the commands yet.

hmmm... my first two posts and the same person replies. are you my gaurdian angel or somethin''?

Crazie Joey
Hehehe I just have nothing better to do at work but answering questions here on GameDev


#pragma DWIM // Do What I Mean!
~ Mad Keith ~
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
you should have a look at Nehe''s 21''st tutorial. It goes over lines. I remember seeing a command that set the line width.
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
glLineWidth ( GLfloat blah );

Becareful though, many OpenGL drivers have sucky thick line drawing.

For antialiased lines you need to turn on blending and GL_LINE_SMOOTH as MadKeith said:

   glEnable    ( GL_LINE_SMOOTH );   glEnable    ( GL_BLEND       );   glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );   glHint ( GL_LINE_SMOOTH_HINT,GL_NICEST );   glLineWidth ( 2.0 ); 


HTH,

Paul Groves.
http://home.clara.net/paulyg/ogl.htm
OpenGL for Beginners
Paul Grovespauls opengl page

This topic is closed to new replies.

Advertisement