Lecture4b. OpenGL
Lecture4b. OpenGL
UNIT 1
Introduction to Computer Graphics and
OpenGL
(Part-2)
Objectives
• OpenGL Architecture
• Primitives & Attributes
• GLUT Basics
• Interaction, Events & Callbacks
• Simple modeling and Rendering
• Indexed & RGB Color Models
• Frame buffer Double Buffering
• #include <GL/glu.h>
• #include <GL/glut.h>
3. Transformations – scaling
4. viewing functions
5. projections
• primType
GL_POINTS, GL_LINES, GL_TRIANGLES,
GL_QUADS, …
void main(int argc, char** argv) //(argc for count and ** argv is a
pointer type character array)
{
glutInit(&argc, argv); // to initialize graphics
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow(“Simple”);
init();
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutMainLoop();
Madhulika(18010), Assistant Professor,
} LPU.
Sample Program
#include <GL/glut.h>
#include <GL/gl.h>
MainLoop() Mouse
Window
Shading
glShadeModel(GL_SMOOTH);
glShadeModel(GL_FLAT);
Parallel Projection
Madhulika(18010), Assistant Professor,
LPU.
Rendering
•...transforms primitive and complex graphic objects into
pictures on the drawing surface
•...for 3D pictures it is the process of creating a 2D image
on the drawing surface
•...includes culling back-facing polygons
•...scan converts (or rasterizes) objects into device-
dependent units (usually called pixels)
•...uses the appropriate light sources, atmosphere effects,
shading, anti-aliasing, and color models
GL_FRONT
GL_BACK
By default, mode is GL_FRONT for single-buffered contexts and
GL_BACK for double-buffered contexts.