CIT 2211 - Lecture 3 - Graphics Software
CIT 2211 - Lecture 3 - Graphics Software
Graphics Software
There are two types of graphics software
Special purpose packages
For non programmers
The interface is a set of menus that facilitate communication
E.g. CAD, CAM, painting, animation
General programming packages
Provides a library of graphics functions that can be used in
a programming language such as C, C++, Java, …
Library of graphics functions (OpenGL)
Picture components (lines, shapes, …)
Transformations (color, texture, shading, rotating, …)
Coordinate Representations
To generate a picture using a programming
package, we first need to give the geometric
descriptions of the objects – location and shape
For example, a box is specified by the positions of
its corners, a sphere is specified by its center
position and radius
General graphics packages require geometric
descriptions to be specified in a standard, right-
handed, Cartesian-coordinate reference frame.
Graphics Rendering Pipeline
Rendering: conversion from scene to image
application program
OpenGL Motif
widget or similar GLUT
GLX, AGL
or WGL GLU
Texture
Memory
Pixel
Operations
OpenGL Functions
Primitives
Points
Line Segments
Polygons
Attributes
Transformations
Viewing
Modeling
Control (GLUT)
Input (GLUT)
Query
OpenGL State
function name
dimensions
glVertex3f(x,y,z)
glVertex3fv(p)
p is a pointer to an array
OpenGL Command Formats
glVertex3fv( v )
nonconvex polygon
nonsimple polygon
Attributes
Attributes are part of the OpenGL state and
determine the appearance of objects
Color (points, lines, polygons)
Size and width (points, lines)
Stipple pattern (lines, polygons)
Polygon mode
Display as filled: solid color or stipple pattern
Display edges
Display vertices
RGB color
Each color component is stored separately in the
frame buffer
Usually 8 bits per component in buffer
Note in glColor3f the color values range from 0.0
(none) to 1.0 (all), whereas in glColor3ub the
values range from 0 to 255
Color and State
The color as set by glColor becomes part of the
state and will be used until changed
Colors and other attributes are not part of the
• #include <stdio.h>
• #include <stdlib.h>
• #include <math.h>
DISPLAY WINDOW MANAGEMENT USING GLUT
glBegin(GL_TRIANGLES);
glColor3f(1.0, 0.0, 0.0); // red
glVertex3f(-4.0, -2.0, 0.0);
glColor3f(0.0, 1.0, 0.0); // green
glVertex3f(4.0, -2.0, 0.0);
glColor3f(0.0, 0.0, 1.0); // blue
glVertex3f(0.0, 5.0, 0.0);
glEnd();