


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
In Introduction to Computer Graphics course we study the basic concept of the principle of computer architecture. In these lecture slides the key points are:Open Gl, Fixed-Function, Conceptual Graphics Framework, State Machine, State Variables, Pseudo Code, Programming Strategies, Multi-Threaded Applications, Typical Opengl Application, Boilerplate Initialization
Typology: Slides
1 / 26
This page cannot be seen from the preview
Don't miss anything!



















05 – OpenGL 1/
OpenGL (Fixed-Function)
05 – OpenGL 2/
Graphics System/ GPU Application Model/data base
Application program
Graphics Library
05 – OpenGL 4/
SetState (LineStyle, DASHED);
SetState (LineColor, RED);
DrawLine ( PtStart = (x1,y1), PtEnd = (x2,y2) );
SetState (LineColor, BLUE);
DrawLine ( PtStart = (x2,y2), PtEnd = (x3,y3) );
SetState (LineStyle, SOLID);
DrawLine ( PtStart = (x3,y3), PtEnd = (x4,y4) );
What color and shape?
What color and shape?
What color and shape?
05 – OpenGL 5/
SetState (LineStyle, DASHED);
SetState (LineColor, RED);
DrawLine ( PtStart = (x1,y1), PtEnd = (x2,y2) );
SetState (LineStyle, DASHED);
SetState (LineColor, BLUE);
DrawLine ( PtStart = (x2,y2), PtEnd = (x3,y3) );
SetState (LineStyle, SOLID);
SetState (LineColor, BLUE);
DrawLine ( PtStart = (x3,y3), PtEnd = (x4,y4) );
What color and shape?
What color and shape?
What color and shape?
05 – OpenGL 7/
05 – OpenGL 8/
05 – OpenGL 10/
05 – OpenGL 11/
DrawLine ( PtStart = (x1,y1), PtEnd = (x2,y2) );
SetState(LineStyle, 12345); DrawLine( PtStart=pt1, PtStart=p2 );
05 – OpenGL 13/
05 – OpenGL 14/
05 – OpenGL 16/
int main( int argc, char** argv ) {
glutInit( &argc, argv ); // Boilerplate initialization
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
#define GLUT_RGB 0 #define GLUT_RGBA GLUT_RGB #define GLUT_INDEX 1 #define GLUT_SINGLE 0 #define GLUT_DOUBLE 2 #define GLUT_ACCUM 4 #define GLUT_ALPHA 8 #define GLUT_DEPTH 16 #define GLUT_STENCIL 32 #if {GLUT_API_VERSION >= 2} #define GLUT_MULTISAMPLE 128 #define GLUT_STEREO 256 #endif #if {GLUT_API_VERSION >= 3} #define GLUT_LUMINANCE 512 #endif
05 – OpenGL 17/
int main( int argc, char** argv ) {
glutInit( &argc, argv ); // Boilerplate initialization
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
glutInitWindowPosition( 50, 50 ); //upper left
glutInitWindowSize( 640, 480 ); // width, height, in pixels
glutCreateWindow( "OpenGL Example" ); // window title
glViewport(
/* lower left corner of the viewport */ 0, 0,
/* width, height of the viewport */ 640, 480 ); //lower left
05 – OpenGL 19/
int main( int argc, char** argv ) {
glutInit( &argc, argv ); // Boilerplate initialization glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH ); glutInitWindowPosition( 50, 50 ); //upper left glutInitWindowSize( 640, 480 ); // width, height, in pixels glutCreateWindow( "OpenGL Example" ); // window title glViewport( /* lower left corner of the viewport / 0, 0, / width, height of the viewport */ 640, 480 ); //lower left glShadeModel( GL_SMOOTH );
glPolygonMode( GL_FRONT, GL_FILL );
setupLighting();
setupCamera(640, 480);
registerCallBacks();
glutMainLoop();
}
Asks OpenGL to render fill the polygons but only in the front-facing side Options are GL_BACK, GL_FRONT_AND_BACK, and GL_POINT, GL_LINE, GL_FILL
05 – OpenGL 20/
int main( int argc, char** argv ) {
glutInit( &argc, argv ); // Boilerplate initialization glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH ); glutInitWindowPosition( 50, 50 ); //upper left glutInitWindowSize( 640, 480 ); // width, height, in pixels glutCreateWindow( "OpenGL Example" ); // window title glViewport( /* lower left corner of the viewport / 0, 0, / width, height of the viewport */ 640, 480 ); //lower left glShadeModel( GL_SMOOTH );
glPolygonMode( GL_FRONT, GL_FILL );
setupLighting();
setupCamera(640, 480);
registerCallBacks();
glutMainLoop();
}
void setupLighting() { glEnable (GL_LIGHTING); glEnable (GL_LIGHT0);
GLfloat whiteColor[] = {0.25f, 0.25f, 0.25f, 1.0f}; glLightfv (GL_LIGHT0, GL_AMBIENT, whiteColor);
//directional (diffuse) light GLfloat whiteFull[] = {1.0f, 1.0f, 1.0f, 1.0f}; GLfloat lightPos[] = {-1.0f, 1.0f, 1.0f, 0.0f}; glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteFull); glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
GLfloat grey[] = {0.1f, 0.1f, 0.1f, 1.0f}; glMaterialfv(GL_FRONT, GL_DIFFUSE, grey); //reflect 10% diffuse glMaterialfv(GL_FRONT, GL_AMBIENT, whiteFull);}//reflect full ambient