SlideServe
Menu
Préférences
© SlideServe · v2026

Lecture 2

dian avatar
26 diapositives · 464 Views · Sep 12, 2014

Lecture 2. Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure. Lecture 2. OpenGL Libraries and Compilation GLUT Window initialization commands Color Drawing 2-D Primitives. OpenGL Libraries.

Lecture 2 - slide 1
01 / 26Lecture 2
1 / 17

Télécharger la présentation

Lecture 2
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  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. Polygon

  17. Polygon

  18. Polygon

  19. Polygon

  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