Wednesday, October 31, 2007

3rd week of my lab

Today what was taught was how to draw simple shape through coding.

For example to draw a triangle you have to type
glBegin(GL_TRIANGLES);
glVertex3f(0.5f, 0.5f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glVertex3f(0.75f,0.5f, 0.0f);
glEnd( );

into the void myDisplay(void) function.

The same goes for quadilaterals but as they have 4 points an additonal

glVertex3f(x.xf,y.yf, 0.0f); is needed

eg
glBegin(GL_QUADS);
glVertex3f(-0.5,-0.5,0);
glVertex3f(0.5,-0.5,0);
glVertex3f(0.5,0.5,0);
glVertex3f(-0.5,0.5,0);
glEnd( );

Also by placing a glColor3f(0.0,0.0f,1.0f); infront of a glBegin(GL_(your shape))

will give you a desired colour with 1 being the strongest i think.

This glColor gives a blue colour.

Now on the show pictures of what was done:
Triangle

1 comment:

Low said...

Your blog has not been updated to comment on week 4 and week 5.