1 / 18

Introduction to OpenGL

Introduction to OpenGL. What is OpenGL 1/2. A software interface to graphics hardware. Hardware-independent interface. No commands for performing windowing tasks or obtaining user input are included. What is OpenGL 2/2.

wan
Download Presentation

Introduction to OpenGL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to OpenGL CGGM Lab. Tan-Chi Ho 2001

  2. What is OpenGL1/2 • A software interface to graphics hardware. • Hardware-independent interface. • No commands for performing windowing tasks or obtaining user input are included. CGGM Lab. Tan-Chi Ho 2001

  3. What is OpenGL2/2 • Does not provide high-level commands for describing models of three-dimensional objects. CGGM Lab. Tan-Chi Ho 2001

  4. What OpenGL can do • Draw with points, lines, and polygons. • Matrix(View) Transformation • Depth test (Z-Buffer) • Light calculation • Texture mapping • Pixels operation CGGM Lab. Tan-Chi Ho 2001

  5. The Framebuffer1/2 • An OpenGL system can manipulate the following buffers: • Color buffers: • front-left, front-right, back-left, back-right, and any number of auxiliary color buffers. • Depth buffer (Z-Buffer) • Performing Depth test in hidden surface removal. CGGM Lab. Tan-Chi Ho 2001

  6. The Framebuffer2/2 • Stencil buffer • To restrict drawing to certain potions of the screen. • Accumulation buffer • Accumulating a serious of RGBA color data in the color buffers into a final, composite image. CGGM Lab. Tan-Chi Ho 2001

  7. OpenGL Rendering Pipeline1/2 OpenGL Command Buffer OpenGL API Calls Transformation and Lighting Frame Buffer Rasterization CGGM Lab. Tan-Chi Ho 2001

  8. API Hierarchy Application GDI OpenGL Hardware Driver Display Device CGGM Lab. Tan-Chi Ho 2001

  9. OpenGL Rendering Pipeline2/2 Per-Vertex Operations and Primitive Assembly Vertex Data Evaluators Per-Fragment Operations Display List Frame Buffer Rasterization Texture Assembly Pixel Data Pixel Operations CGGM Lab. Tan-Chi Ho 2001

  10. The Simplest Program1/3 #include <GL/glut.h> void GL_display() { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0f, 1.0f, 1.0f); glutSolidCube(1.0); glFlush(); } void GL_reshape(GLsizei w, GLsizei h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-2.0f, 2.0f, -2.0f, 2.0f, -2.0f, 2.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } CGGM Lab. Tan-Chi Ho 2001

  11. The Simplest Program2/3 void main(void) { glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutCreateWindow("Sample"); glutDisplayFunc(GL_display); glutReshapeFunc(GL_reshape); glutMainLoop(); } CGGM Lab. Tan-Chi Ho 2001

  12. The Simplest Program3/3 CGGM Lab. Tan-Chi Ho 2001

  13. OpenGL Utility Toolkit (GLUT) 1/2 • A window system-independent toolkit to hide the complexities of differing window system APIs. • Use the prefix of glut. (ex: glutDisplayFunc()) • Provide following operations: • Initializing and creating window • Handling window and input events • Drawing basic three-dimensional objects • Running the program CGGM Lab. Tan-Chi Ho 2001

  14. OpenGL Utility Toolkit (GLUT) 2/2 • Where can I get GLUT? • Win32: • http://www.xmission.com/~nate/glut.html • Linux: • http://www.mesa3d.org/ CGGM Lab. Tan-Chi Ho 2001

  15. How to Compile1/2 • On Microsoft Visual C++: • Create a new Project with Win32 Console Application • Open Project Settings dialog and add opengl32.lib glu32.lib glut32.lib into Link/Objects/library modules. CGGM Lab. Tan-Chi Ho 2001

  16. How to Compile2/2 • On UNIX: • Needed libraries: • libGL.so, libGLU.so, libglut.a, libX11.a, libX11.so… • Compile command: • gcc [source files] –o [output file] –lglut –lGLU –lGL –lX11 –lm CGGM Lab. Tan-Chi Ho 2001

  17. Reference • Official site of OpenGL • http://www.opengl.org • Further Reading • OpenGL Programming Guide (Red Book) • OpenGL Reference Manual (Blue Book) CGGM Lab. Tan-Chi Ho 2001

  18. Any Question? ? CGGM Lab. Tan-Chi Ho 2001

More Related