Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics Practical Lesson 1-

Similar presentations


Presentation on theme: "Computer Graphics Practical Lesson 1-"— Presentation transcript:

1 Computer Graphics Practical Lesson 1-
Introduction to OpenGL Ayal Stein

2 Contact Info Teaching Assistance: Ayal Stein Phone number: Course Site: Room -102/37 Office Hours: ????

3 OpenGL OpenGL (Open Graphics Library) is cross-platform library to produce 2d and 3d graphics. It was developed during the 80’s until the early 90’s

4 Installing OpenGL Open the page “Files and Links” in the course site.
Under section “Direct Download” – download the zip file from link “GLUT Binaries” Extract zip file into your code folder.

5 Installing OpenGL(cont’)
The include directive #include <gl/glut.h> in our sample code is used when OpenGl is installed on system. To easily start working, you can replace the include directive to #include “glut.h” and copy glut files into project page: glut32.dll , glut32.lib , glut.h

6 OpenGL events OpenGL is windows based application.
The flow of the program is based on events. We define functions to handle events.

7 Initialize Functions glutInit – GL defined function initialize the GL environment. glutCreateWindow – open the window glutInitDisplayMode – definitions like transparency and depth test. glutMainLoop –GUI main loop.

8 Events Functions Init function – function that opens the GL window and define events. glutDisplayFunc and glutIdleFunc – Draw function for window. glutReshapeFunc - Event for window resize.

9 Events Functions(cont’)
glutMouseFunc – event for mouse click glutMotionFunc – event for mouse movements. glutKeyboardFunc – events for keyboard.

10 Drawing Basic Shapes Drawing 2 points:
glBegin() - declare the shape type. glEnd() – end of drawing. Drawing 2 points: glBegin(GL_POINTS); glVertex3f(0.2f,0.8f,0.0f); glVertex3f(0.8f,0.2f,0.0f); glEnd();

11 Drawing Basic Shapes Basic types of shapes:
GL_POINTS – draw isolated points GL_LINES – draw lines GL_TRIANGLES – triangles GL_QUADS – squares. And many more….

12 Design Pattern – State machine
When working with GUI, we have state. In the first example, the first state draws a triangle. The second stage is drawing a square.

13 State Machine Example – MP3 Player

14 Design Pattern – State machine
By mouse click, we switch to next state. There is a base class for state with virtual functions defined in it. Each state is represented by its own class. Each successor define its own functions.

15 First Assignment Expand the first example to draw a sixth shape.
Draw a new shape in a new color. This is a warm up mission should not take you more than an hour. Submission is on next lesson.


Download ppt "Computer Graphics Practical Lesson 1-"

Similar presentations


Ads by Google