[ILUG] Re: [ILUG](not a) Stupid graphics questions?

Fowler fowler at indigo.ie
Mon Mar 13 20:18:41 GMT 2000


John Gay wrote:
> 
> I've been working on a simple project and just wanted a pointer to graphics
> programming. All I need is to be able to draw simple lines, in selected colours,
> quite similar to the basic linedraw commands. Would the svga libraries be what
> I'm looking for? or should I try the GGI project? I've read that this is still
> in beta, but if it provides simple graphics, that's all I need. Please be easy
> on me, as I'm not a programmer, just learning.
> 

Believe it or not I'm going to recommend OpenGL!  Fast portable and can accelerate line
draws on some drivers AND its device independant 
Most openGL tutors start with drawing in 2d Orthographic mode
to teach OpenGL concepts

Basically to draw a red line from 0,0 to 1,1 you do

glColor3f(1.0, 0.0 ,0.0);	/* Set Color as RGB 1,0,0  ie red */
glLineWidth(0.5);		/* set line width to 0.5 */
glBegin(GL_LINES)		/* Tell OpenGL We want to draw lines */
	glVertex2f(0.0 , 0.0);	/* The first point */
	glVertex2f(1.0 , 1.0);  /* The second line */
glEnd();			/* Finished drawing lines */

	Voila ! one red line of thickness 0.5 from 0,0 to 1,1

www.opengl.org has a list of great tutorials  (The POT -Personal OpenGL tutor is a very very
nice interactive openGL tutor ) linked from here.

Also mesa ships with tons of example 2d and 3d code for you to look at.
www.mesa3d.org for Mesa

THe beauty is that if your drawing graphs like a lot of people do actually use openGL
for you can realllly easily make it 3d with a few modifications for really funky effects :)

To setup a window use the glut library which provides a VERY simple (and again portable)
set of functions - www.mesa3d.org or www.openGL.org

	Colin Fowler




More information about the ILUG mailing list