OpenGL for NonGraphics Computer Scientists - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

OpenGL for NonGraphics Computer Scientists

Description:

... the 'Red Book' (explains OpenGL) or the 'Blue Book' (reference for commands) ... There are default values for all GL variables. Note about function names: ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 21
Provided by: ben88
Category:

less

Transcript and Presenter's Notes

Title: OpenGL for NonGraphics Computer Scientists


1
OpenGL forNon-Graphics Computer Scientists
  • Benjamin Lok
  • November 14, 2002

2
What am I going to learn?
3
Real Time vs. Non-Real Time
4
Lesson 1
  • Computer Graphics Basics
  • What are images?
  • Computer graphics hardware
  • How do we put things into a computer?

5
Business of Generating Images
  • Images are made up of pixels

6
What is OpenGL?
  • A software interface to graphics hardware
  • A 3D graphics and modeling library
  • Very fast (a standard to be accelerated)
  • Portable
  • Open standard
  • Was SGIs IRIS GL

7
Given 3D data, generate 2D view
8
OpenGL/GLU/GLUT/GLUI
  • OpenGL v1.1 or v1.2 (latest) is the core
    library that is platform independent
  • GLUT v3.6 or v3.7 (beta) is an auxiliary library
    that handles window creation, OS system calls
    (mouse buttons, movement, keyboard, etc),
    callbacks.
  • GLU is an auxiliary library that handles a
    variety of graphics accessory functions
  • GLUI v1.0 or v2.0 (beta)is a GUI manager written
    by Paul Rademacher (rademach_at_cs.unc.edu).

9
ZIP file
  • http//www.cs.uncc.edu/bclok/presentations
  • Download GLUT from opengl.org
  • Download GLUI from www.cs.unc.edu/rademach/glui

10
Headers and Linking
  • OpenGL - main stuff (the only thing that is
    required)
  • include ltGL/gl.hgt
  • Link opengl32.lib (PC), or -lgl (UNIX)
  • opengl.lib is an SGI implementation
  • opengl32.lib is a Microsoft implementation
  • GLU - auxillary functions
  • include ltGL/glu.hgt
  • Link glu32.lib (PC), or -lglu (UNIX)

11
Headers and Libraries
  • GLUT - Window management (requires download of
    library)
  • include ltGL/glut.hgt
  • Link glut32.lib (PC), or -lglut (UNIX)
  • Instead of GLUT, you can use GLX or WGL
  • GLUI - GUI functions (requries downlaod of
    library)
  • include ltGL/glui.hgt
  • Link glui32.lib (PC), or -lglui (UNIX)

12
GLUT
  • GLUT is a Window Manager
  • Makes it easy to create windows
  • Platform Independent
  • Gets you up and running, though it isnt
    extremely customizable
  • Not meant for commercial products
  • Lets compare what you get and you dont get from
    GLUT.

13
Approach to programming in GL
  • Use old code again!
  • If you have any questions, check the Red Book
    (explains OpenGL) or the Blue Book (reference
    for commands)
  • http//www.opengl.org/developers/documentation/spe
    cs.html
  • Use the function glGetError() to check for errors
  • There are default values for all GL variables
  • Note about function names
  • gl means OpenGL (glVertex)
  • glu means GLU (gluPerspective)
  • glut means GLUT (glutCreateWindow)

14
Different Parts of a GL Program
  • In your main(), setup GL and GLUT stuff
  • Callbacks
  • Display
  • Global variables and states
  • State Machine
  • Double Buffering

15
Basic GL Commands
  • glEnable/glDisable
  • GL has many states of operation, and the way you
    change them is through Enabling and Disabling
    them.
  • Ex.
  • glEnable(GL_DEPTH_TEST)
  • glDisable(GL_DEPTH_TEST)
  • glDepthFunc(GL_LESS)

16
Geometry Commands
  • glBegin
  • glVertex
  • glColor
  • glNormal
  • glTexCoord
  • glEnd

17
State Machine
  • OpenGL has several global variables
  • GL_DEPTH_TEST
  • GL_LIGHTING
  • GL_SHADE_MODEL
  • GL_CULL_FACE
  • Color
  • Normal
  • They are the current values till changed

18
State Examples
  • glBegin(GL_TRIANGLES)
  • glColor4f(1.0, 1.0, 1.0, 1.0)
  • glVertex3f(0.0, 0.0, 0.0)
  • glVertex3f(0.0, 1.0, 0.0)
  • glColor4f(1.0, 0.0, 0.0, 1.0)
  • glVertex3f(0.0, 0.0, 1.0)
  • glEnd()

19
Stack
glRotatef(27,.71,.71,0)
glTranslatef(-2,-1,1.2)
glPushMatrix()
glScalef(1.5,1.5,1.5)
glRotatef(45,0,0,1)
glPushMatrix()
glTranslatef(1,0.8,2.4)
20
Stack
  • glTranslatef(0.1, 0.5, 0.5)
  • DrawTorso()
  • glPushMatrix()
  • glTranslatef(0.4, 0.4, 0.8)
  • glRotatef(fArmRotation,0,0,1)
  • DrawUpperArm()
  • glTranslatef(0,0,-1)
  • glRotatef(fLowerArmRotation,0.2,0.2,0.7)
  • glPopMatrix()
Write a Comment
User Comments (0)
About PowerShow.com