Introduction to openGL
Introduction to openGL
Chapter Five
Introduction to openGL
1
WHAT IS OPENGL?
void Display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor4f(1,1,0,1);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
….
SPECIFYING GEOMETRIC PRIMITIVES
primType:
GL_POINTS, GL_LINES,
GL_TRIANGLES, GL_QUADS, …
Primitive Types
SAMPLE EXAMPLE
glVertex2f(x, y)
Add ‘v’ for vector
form
number of B – byte
glVertex2fv(v)
Components/ ub – unsigned byte
Dimensions s – short
us – unsigned short
2 – (x,y) i – int
3 – (x,y,z) ui – unsigned int
4 – (x,y,z,w) or f – float
(r,g,b,a) d – double
SHAPE EXAMPLE
WINDOW-BASED PROGRAMMING
MainLoop() Mouse
Window
26