Presentation is loading. Please wait.

Presentation is loading. Please wait.

CGGM Lab. Tan-Chi Ho 20021 Introduction to OpenGL.

Similar presentations


Presentation on theme: "CGGM Lab. Tan-Chi Ho 20021 Introduction to OpenGL."— Presentation transcript:

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

2 CGGM Lab. Tan-Chi Ho 20022 Graphics API A software interface for graphics hardware. Provide the low-level functions to access graphics hardware directly. OpenGL / Direct3D

3 CGGM Lab. Tan-Chi Ho 20023 API Hierarchy Application GDI Display Device OpenGL Hardware Driver …

4 CGGM Lab. Tan-Chi Ho 20024 What is OpenGL 1/2 Industry standard. Hardware independent. OS independent.

5 CGGM Lab. Tan-Chi Ho 20025 What is OpenGL 2/2 No commands for performing windowing tasks or obtaining user input are included. No high-level commands for describing models of 3D objects are provided.

6 CGGM Lab. Tan-Chi Ho 20026 What OpenGL provides Draw with points, lines, and polygons. Matrix(View) Transformation Hidden Surface Removal (Z-Buffer) Light effects Gouraud Shading Texture mapping Pixels operation

7 CGGM Lab. Tan-Chi Ho 20027 The Buffers A buffer is a memory area in the graphics hardware for some special purposes. An OpenGL system can manipulate the four buffers: Color buffers Depth buffer (Z-Buffer) Stencil buffer Accumulation buffer

8 CGGM Lab. Tan-Chi Ho 20028 OpenGL Rendering Pipeline 1/2 OpenGL API Calls OpenGL Command Buffer Transformation and Lighting RasterizationFrame Buffer

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

10 CGGM Lab. Tan-Chi Ho 200210 OpenGL Libraries OpenGL Library The basic library to access the graphics hardware. GLU Provide some useful utilities based on the OpenGL library. GLX / WGL / AGL OS dependent libraries to bind the OpenGL library with specific window system. GLX for X-window, WGL for win32, AGL for Apple.

11 CGGM Lab. Tan-Chi Ho 200211 OpenGL Utility Toolkit (GLUT) 1/3 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

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

13 CGGM Lab. Tan-Chi Ho 200213 OpenGL Utility Toolkit (GLUT) 3/3 On Microsoft Visual C++ 6: Put glut.h into /include/GL/ Put glut.lib into /lib/ Put glut32.dll into /System32/ On Microsoft Visual C++.NET: Put glut.h into /platformSDK/include/GL/ Put glut.lib into /platformSDK/lib/ Put glut32.dll into /System32/

14 CGGM Lab. Tan-Chi Ho 200214 How to Compile 1/4 On Microsoft Visual C++ 6: 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. Writing your OpenGL code. Compile it.

15 CGGM Lab. Tan-Chi Ho 200215 How to Compile 2/4 On Microsoft Visual C++.NET: 建立 Win32 專案 在應用程式設定,選擇主控台應用程式 開啟專案屬性,在連結器 / 輸入 / 其他相依性 中輸入 opengl32.lib glu32.lib glut32.lib 。 Writing your OpenGL code. Compile it.

16 CGGM Lab. Tan-Chi Ho 200216 How to Compile 3/4

17 CGGM Lab. Tan-Chi Ho 200217 How to Compile 4/4 On UNIX: Needed libraries: libGL.so, libGLU.so, libglut.a, libX11.a, libX11.so … Compile command: gcc [OpenGL code files] – o [output file] – lglut – lGLU – lGL – lX11 – lm

18 CGGM Lab. Tan-Chi Ho 200218 The Simplest Program 1/3 #include 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(); }

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

20 CGGM Lab. Tan-Chi Ho 200220 The Simplest Program 3/3

21 CGGM Lab. Tan-Chi Ho 200221 Reference 1/2 Official site of OpenGL http://www.opengl.org Useful Sites NeHe ’ s OpenGL Tutorials NeHe ’ s OpenGL Tutorials The Developer ’ s Gallery The Developer ’ s Gallery

22 CGGM Lab. Tan-Chi Ho 200222 Reference 2/2 Further Reading OpenGL Programming Guide (Red Book) OpenGL Reference Manual (Blue Book) OpenGL Super Bible ( 中文版 ?)

23 CGGM Lab. Tan-Chi Ho 200223 Any Question? ?


Download ppt "CGGM Lab. Tan-Chi Ho 20021 Introduction to OpenGL."

Similar presentations


Ads by Google