lab2 - Window opening and Rendering Computer Graphics Lab...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Window opening and Rendering Computer Graphics Lab – 01 Contents • GLUT library – Creating a new window – Defining the window‟s drawing callback function – Starting the glut main loop • OpenGL library – Selecting window‟s background color – Clearing the window – Rendering vertices and lines – Color selection in RGB – Changing point size and line width – Making sure everything is drawn – Defining World Coordinates – Rectangles • Pixel representation • Exercise Including required libraries • GL Libraries #include <GL/gl.h> #include<GL/glu.h> #include<GL/glut.h> (we will need this one mainly) Creating window void glutInitWindowSize( int width,int height ); width – Width in pixels height – Height in pixels void glutInitWindowPosition( int x, int y ); x – Window X location in pixels y – Window Y location in pixels ( 0, 0 ) (x, y) x y Application Window Screen Window Position Window size Creating window (cont) void glutInitDisplayMode( GLUT_MODE1 | GLUT_MODE2 | … ) int window_id = glutCreateWindow( char *name ); void glutDisplayFunc (void (* drawingCBfunc) (void)); Example void drawingCB(); void main() { int window_id; // set window’s size and position glutInitWindowSize( 640, 480 ); glutInitWindowPosition( 0, 0 ); // set window’s parameters glutInitDisplayMode( GLUT_RGB ); // create the window and store it’s name in a variable window_id = glutCreateWindow( “myWin” ); // define the window’s display callback function glutDisplayFunc (drawingCB); // start the GLUT’s main loop glutMainLoop(); }...
View Full Document

Page1 / 21

lab2 - Window opening and Rendering Computer Graphics Lab...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online