Click here to Skip to main content
15,897,704 members
Articles / Multimedia / OpenGL

Drawing nearly perfect 2D line segments in OpenGL

Rate me:
Please Sign up or sign in to vote.
4.80/5 (29 votes)
18 Jul 2011CPOL5 min read 246K   8.4K   87  
With premium quality anti- aliasing, color, thickness, and minimum CPU overhead.
using the code:
just include vase_rend_draft_2.h to your project files and it should work.

to test by drawing a spectrum:
	for ( int i=0; i<20; i++)
	{
		line ( 5+29.7*i,187, 35+29.7*i,8, //coordinates
			0.3*(i+1),		//thickness in px
			0.5, 0.0, 1.0, 1.0,	//color RGBA
			0,0,			//not used
			true);			//enable alphablend
	}

more info at:

http://www.codeproject.com/KB/openGL/gllinedraw.aspx

http://artgrammer.blogspot.com/2011/05/drawing-nearly-perfect-2d-line-segments.html

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Hong Kong Hong Kong
Chris H.F. Tsang
tyt2y3@gmail.com

Comments and Discussions