Introduction to OpenGL - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Introduction to OpenGL

Description:

Hidden Surface Removal (Z-Buffer) Lighting (Phong model) Gouraud Shading ... Provide some basic utilities based on the OpenGL library (camera model, NURBS... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 24
Provided by: key8
Category:

less

Transcript and Presenter's Notes

Title: Introduction to OpenGL


1
Introduction to OpenGL
2
What is a Graphics API
  • A software interface for graphics hardware.
  • Provide the low-level functions to access
    graphics hardware directly.
  • OpenGL / Direct3D
  • (Direct3D also provides high-level functions.)

3
API Hierarchy
Applications
GDI
OpenGL
Hardware Driver

Display Device
4
What is OpenGL1/2
  • Industry standard.
  • Hardware independent.
  • Window system independent.

5
What is OpenGL2/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
What OpenGL provides
  • Draw with points, lines, and polygons.
  • Matrix Operations (Transformations)
  • Hidden Surface Removal (Z-Buffer)
  • Lighting (Phong model)
  • Gouraud Shading
  • Texture mapping
  • Pixels operations

7
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
  • Will be discussed later.

8
Rendering Pipeline1/2
OpenGL Command Buffer
OpenGL API Calls
Transformation and Lighting
Rasterization
Frame Buffer
9
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
10
OpenGL Relative Libraries1/2
  • OpenGL Library
  • The basic library to access the graphics
    hardware.
  • GLU
  • Provide some basic utilities based on the OpenGL
    library (camera model, NURBS).
  • 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
OpenGL Relative Libraries2/2
  • GL, GLU, WGL libraries are already contained
    within the OS later than Win95SE.
  • For Linux, FreeBSD systems, download the mesa
    library, which is fully compatible with OpenGL.

12
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

13
OpenGL Utility Toolkit (GLUT) 2/3
  • Where to get GLUT?
  • Win32
  • http//www.xmission.com/nate/glut.html
  • Linux
  • http//www.mesa3d.org/

14
OpenGL Utility Toolkit (GLUT) 3/3
  • On Microsoft Visual C 6
  • Put glut.h into ltMSVCgt/include/GL/
  • Put glut.lib into ltMSVCgt/lib/
  • Put glut32.dll into ltwindowgt/System32/
  • On Microsoft Visual C .NET
  • Put glut.h into ltMSVCgt/platformSDK/include/GL/
  • Put glut.lib into ltMSVCgt/platformSDK/lib/
  • Put glut32.dll into ltwindowgt/System32/

15
How to Compile1/3
  • 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.

16
How to Compile2/3
  • On Microsoft Visual C .NET
  • New a Win32 Project
  • Add opengl32.lib glu32.lib glut32.lib into
    link/library dependence.
  • Writing your OpenGL code.
  • Compile it.

17
How to Compile3/3
  • 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
The Simplest Program1/3
  • include ltGL/glut.hgt
  • 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
The Simplest Program2/3
  • void main(void)
  • glutInitDisplayMode(GLUT_SINGLE GLUT_RGB)
  • glutCreateWindow("Sample")
  • glutDisplayFunc(GL_display)
  • glutReshapeFunc(GL_reshape)
  • glutMainLoop()

20
The Simplest Program3/3
21
Reference1/2
  • Official site of OpenGL
  • http//www.opengl.org
  • Useful Sites
  • NeHes OpenGL Tutorials
  • The Developers Gallery
  • NVidias developer web

22
Reference2/2
  • Further Reading
  • OpenGL Programming Guide (Red Book)
  • OpenGL Reference Manual (Blue Book)

23
Any Question
  • ?
Write a Comment
User Comments (0)
About PowerShow.com