Introduction to OpenGL Keng Shih-Ling 2003 Spring.
-
Upload
ethel-mills -
Category
Documents
-
view
245 -
download
0
Transcript of Introduction to OpenGL Keng Shih-Ling 2003 Spring.
![Page 2: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/2.jpg)
ExampleOpenGL example
![Page 3: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/3.jpg)
OpenGL is a Graphics API
A software interface for graphics hardware.Provide the low-level functions to access graphics hardware directly.OpenGL / Direct3DOpenGL functions use the prefix gl.
![Page 4: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/4.jpg)
OpenGL is a Graphics API
Application
GDI
Display Device
OpenGL
Hardware Driver
…
![Page 5: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/5.jpg)
OpenGL library
Microsoft’s implementation– From Win95 OSR2, Microsoft Windows
ship with OpenGL32.DLL.– For old Win95 users, you still can
download OPENGL95.EXE via Microsoft website.
– Header files and import library files are already included in Win32 Platform SDK.
![Page 6: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/6.jpg)
OpenGL library
Microsoft’s OpenGL32.DLL applies a hardware accelerated driver registered in Registry.
– HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers
– You can search it by using REGEDIT.EXE
![Page 7: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/7.jpg)
API Hierarchy
![Page 8: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/8.jpg)
OpenGL Utility Library
The OpenGL Utility Library(GLU) provides many of the modeling features, such as quadric surfaces and NURBS curves and surfaces. GLU is a standard part of every OpenGL implementationGLU routines use the prefix glu.– gluLookAt( … );– …
![Page 9: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/9.jpg)
Windows system related helper library
For every window system, there is a library that extends the functionality of that window system to support OpenGL rendering. – X Window System -> GLX – Microsoft Windows -> WGL– IBM OS/2 -> PGL
![Page 10: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/10.jpg)
OpenGL Utility Toolkit
The OpenGL Utility Toolkit (GLUT) is a window system-independent toolkit, written by Mark Kilgard, to hide the complexities of differing window system APIs. GLUT routines use the prefix glut.– glutPostRedisplay();– …
![Page 11: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/11.jpg)
OpenGL Utility Toolkit
You can download this toolkit in the following website– Win32
• http://www.xmission.com/~nate/glut.html
– Linux• http://www.mesa3d.org
We focus on this toolkit
![Page 12: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/12.jpg)
Basic Setup (GLUT)
On Microsoft Visual C++ 6:– Put glut.h into <MSVC>/include/GL/– Put glut.lib into <MSVC>/lib/– Put glut32.dll into <window>/System32/
On Microsoft Visual C++ .NET:– Put glut.h into
<MSVC>/platformSDK/include/GL/– Put glut.lib into <MSVC>/platformSDK/lib/– Put glut32.dll into <window>/System32
![Page 13: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/13.jpg)
How to Compile (VC6.0)
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.
![Page 14: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/14.jpg)
How to Compile (.NET)
On Microsoft Visual C++ .NET:– 建立Win32專案– 在應用程式設定,選擇主控台應用程式– 開啟專案屬性,在連結器 /輸入 /其他相依性中輸入 opengl32.lib glu32.lib glut32.lib 。
– Writing your OpenGL code.– Compile it.
![Page 15: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/15.jpg)
How to Compile (.NET)
![Page 16: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/16.jpg)
The Simplest Program#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();
}
![Page 17: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/17.jpg)
The Simplest Program
void main(void){
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);glutCreateWindow("Sample");glutDisplayFunc(GL_display);glutReshapeFunc(GL_reshape);glutMainLoop();
}
![Page 18: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/18.jpg)
The Simplest Program
![Page 19: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/19.jpg)
Reference
Official site of OpenGL– http://www.opengl.org
Useful Sites– NeHe’s OpenGL Tutorials– The Developer’s Gallery
![Page 20: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/20.jpg)
Reference
Further Reading– OpenGL Programming Guide (Red
Book)– OpenGL Reference Manual (Blue
Book)– OpenGL Super Bible (中文版 )
![Page 21: Introduction to OpenGL Keng Shih-Ling 2003 Spring.](https://reader035.fdocuments.net/reader035/viewer/2022081512/56649d9f5503460f94a89f04/html5/thumbnails/21.jpg)
Any Question?
?