Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure.

Similar presentations


Presentation on theme: "Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure."— Presentation transcript:

1 Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure

2 Lecture 2 OpenGL Libraries and Compilation GLUT Window initialization commands Color Drawing 2-D Primitives

3 OpenGL Libraries GLUT(OpenGL Utility Toolkit): Implements a simple windowing API for OpenGL. GLU(OpenGL Utility Library): Set of functions to create textures from base images, drawing quadratic surfaces, etc. More Details about libraries: http://www.opengl.org/resources/libraries/

4 Compilation Overview: Compiling Linking Running In Microsoft Visual Studio C++ http://csf11.acs.uwosh.edu/cs371/visualstudio/ In MinGW C http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/

5 GLUT Window Initialization What is Buffer? Clearing the Window glClearColor(R, G, B, A) glClearColor(GL_COLOR_BUFFER_BIT) glClearDepth() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

6 GLUT Window Initialization glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) Vs. glClear(GL_COLOR_BUFFER_BIT) glClear(GL_DEPTH_BUFFER_BIT)

7 OpenGL Buffers

8 Color glColor3f(R, G, B) glColor3f(0.0, 0.0, 0.0) : Black glColor3f(1.0, 0.0, 0.0) : Red glColor3f(0.0, 1.0, 0.0) : Green glColor3f(0.0, 0.0, 1.0) : Blue

9 Forcing Completion of Drawing void glFlush(void) void glFinish(void)

10 Structure of an OpenGL code Sample Code Reshape Function void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h); }

11 Point (Vertex) Mathematical Representation OpenGL representation Homogeneous Coordinate System (Optional)

12 Line Mathematical Line Line Segment: Used in OpenGL

13 Polygon Mathematical Definitions. Convex Polygon (Used in OpenGL) What is the simplest Polygon?

14 Polygon Invalid Polygons in OpenGL

15 Polygon

16

17

18

19

20 Specifying Vertices OpenGL command: void glVertex{234}{sifd}[v](TYPEcoords); Example: glVertex2s(2, 3); glVertex3d(0.0, 0.0, 3.1415926535898); glVertex4f(2.3, 1.0, -2.2, 2.0); GLdouble dvect[3] = {5.0, 9.0, 1992.0}; glVertex3dv(dvect);

21 Specifying Lines, Polygons Specifying a set of vertices glBegin(GLenum_mode); glVertex2f(0.0, 0.0); glVertex2f(0.0, 3.0); glVertex2f(4.0, 3.0); glVertex2f(6.0, 1.5); glVertex2f(4.0, 0.0); glEnd();

22 Specifying Lines, Polygons

23 glBegin(parameters)

24 Stippled Lines Definition Command: glLineStipple(GLint factor, GLushort pattern) glEnable(GL_LINE_STIPPLE)

25 QUESTIONS?

26 Next Session Interactive Programming with GLUT Callback Registration Keyboard, Mouse Callbacks Animation Double Buffering


Download ppt "Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure."

Similar presentations


Ads by Google