Overview CG
Overview CG
Jayanta Mukhopadhyay
Use three separate color planes (2-D arrays) for a frame buffer.
Halftoning algorithms.
Specialized environments
Client-server computing.
Event driven computing.
Normalized device
coordinates.
Outline
Input-Output
Projection
Viewing
Transformation
Camera metaphor
Industry standard
A State Machine
Put OpenGL into a state (or mode) & that state remains in effect until
you change it
Extensible
Courtesy: From this slide onwards, the rest are from Prof. Ayan Chaudhury, CSE, IIT Kharagpur.
callback function
event loop
Shading
Texture mapping
Basic drawing
Lighting
Shading
Texture mapping
There are limitations of geometric modelling
Many natural phenomena and objects are hard to model
E.g. Cloud, grass, terrain, skin,..
Take a picture of a real orange, scan it, and “paste” onto simple
geometric model
This process is called texture mapping
2. Environment Mapping
Uses a picture of the environment for texture maps
3. Bump Mapping
Emulates altering normal vectors during the rendering process
Basic GL
OpenGL32 on Windows
GLUT
GL utility toolkit
GLU
GL utility library
A letter {i, f , d, ub} indicating the data type of the arguments (e.g.
glRectf())
Most constants are defined in the include files gl.h, glu.h and glut.h
glColor3f(0.0,0.5,1.0);
(0% Red, 50% Green, 100% Blue)
glColor4f(0.0,0.5,1.0,0.3);
(0% Red, 50% Green, 100% Blue, 30% opacity)
glColor3ub(0,127,255);
(0% Red, 50% Green, 100% Blue)
glColor4f(0,127,255,76);
(0% Red, 50% Green, 100% Blue, 30% opacity)
glBegin(GL POINTS);
glVertex2i(0,0);
glVertex2i(1,0) ;
glVertex2i(1,1) ;
glVertex2i(0,1) ;
glEnd() ;
glBegin(GL LINES);
glVertex2i(0,0);
glVertex2i(1,0) ;
glVertex2i(1,1) ;
glVertex2i(0,1) ;
glEnd() ;
This code draws 2 lines: The first one from (0,0) to (1,0) and the second
one from (1,1) to (0,1)
glBegin(GL QUADS);
glVertex2i(0,0);
glVertex2i(1,0) ;
glVertex2i(1,1) ;
glVertex2i(0,1) ;
glEnd() ;
So how will the display() function look like for drawing a black
quadrilateral?
//initialization
void init( void )
{
glClearColor( 1.0, 1.0, 1.0, 0.0 ); //get white background color
glColor3f( 0.0f, 0.0f, 0.0f ); //set drawing color
glPointSize( 6.0 ); //a dot is 4x4
glMatrixMode( GL PROJECTION );
glLoadIdentity(); //replace current matrix with identity matrix
gluOrtho2D( 0.0, 500.0, 0.0, 500.0 );
}
Must determine the part of the world that the camera will see.
determining the part of the world that the camera will see
Perspective
Why not use two separate transformation matrices, one for the camera (a
view transformation) and one for the objects in the world (a model
transformation) instead of one composite modelview transformation?
Suppose the camera, or eye, and the object the camera is to view are
in the same location, the origin.
In order to view the object either the camera or the object must be
moved
No Difference !!!
Camera is at -5 on z-axis
Camera is at 10 on x-axis
Set the transformation state for the projection mode and the
modelview mode back to a default ’no transformation’ state.
glMatrixMode(GL PROJECTION) ;
glMatrixMode(GL MODELVIEW) ;
0 0 0 1
A common example:
glMatrixMode(GL PROJECTION) ;
glLoadIdentity() ;
gluPerspective(45,1,5,100) ;
A common example:
glMatrixMode(GL MODELVIEW) ;
glLoadIdentity() ;
gluLookAt(0,0,0, 0,0,-1, 0,1,0) ;
glMatrixMode(GL PROJECTION) ;
glLoadIdentity() ;
gluPerspective(45,1,5,100) ;
glMatrixMode(GL MODELVIEW) ;
glLoadIdentity() ;
gluLookAt(0,0,10, 0,0,-1, 0,1,0) ;
}
This approach could easily get out of hand if there were no way to
save and restore the modelview matrix state. Fortunately, there is.