opengl tutorial cisc 640 440 computer graphics l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
OpenGL Tutorial CISC 640/440 Computer Graphics PowerPoint Presentation
Download Presentation
OpenGL Tutorial CISC 640/440 Computer Graphics

Loading in 2 Seconds...

play fullscreen
1 / 15

OpenGL Tutorial CISC 640/440 Computer Graphics - PowerPoint PPT Presentation


  • 270 Views
  • Uploaded on

OpenGL Tutorial CISC 640/440 Computer Graphics. TA: Qi Li/Mani Thomas qili@cis.udel.edu / manivt@cis.udel.edu. OpenGL: What is It?. GL ( G raphics L ibrary): Library of 2-D, 3-D drawing primitives and operations API for 3-D hardware acceleration

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'OpenGL Tutorial CISC 640/440 Computer Graphics' - salena


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
opengl tutorial cisc 640 440 computer graphics

OpenGL Tutorial CISC 640/440 Computer Graphics

TA: Qi Li/Mani Thomas

qili@cis.udel.edu/manivt@cis.udel.edu

CISC640/440 OpenGL Tutorial

opengl what is it
OpenGL: What is It?
  • GL (Graphics Library): Library of 2-D, 3-D drawing primitives and operations
    • API for 3-D hardware acceleration
  • GLU (GL Utilities): Miscellaneous functions dealing with camera set-up and higher-level shape descriptions
  • GLUT (GL Utility Toolkit): Window-system independent toolkit with numerous utility functions, mostly dealing with user interface

CISC640/440 OpenGL Tutorial

opengl geometric primitives

GL_LINES

GL_POLYGON

GL_LINE_STRIP

GL_LINE_LOOP

GL_POINTS

GL_TRIANGLES

GL_QUADS

GL_TRIANGLE_FAN

GL_TRIANGLE_STRIP

GL_QUAD_STRIP

OpenGL Geometric Primitives

CISC640/440 OpenGL Tutorial

specifying geometric primitives
Specifying Geometric Primitives
  • Primitives are specified using

glBegin(primType);

...

glEnd();

    • primType determines how vertices are combined
  • GLfloat red, green, blue;
  • GLfloat x, y;
  • glBegin(primType);
  • for (i = 0; i < nVerts; i++) {
  • glColor3f(red, green, blue);
  • glVertex2f(x, y);
  • ... // change coord. values
  • }
  • glEnd();
opengl vertex color command formats
OpenGL Vertex/Color Command Formats

glVertex3fv( v )

glColor3fv( v )

Data Type

Vector

Number of

components

b - byte

ub - unsigned byte

s - short

us - unsigned short

i - int

ui - unsigned int

f - float

d - double

omit “v” for

scalar form–

e.g.,

glVertex2f(x, y)

glColor3f(r, g, b)

2 - (x,y)

3 - (x,y,z),

(r,g,b)

4 - (x,y,z,w),

(r,g,b,a)

opengl 3 d coordinates
OpenGL 3-D coordinates
  • Right-handed system
  • From point of view of camera looking out into scene:
    • +X right, -X left
    • +Y up, -Y down
    • +Zbehind camera, -Z in front
  • Positive rotations are counterclockwise around axis of rotation

CISC640/440 OpenGL Tutorial

transformations in opengl
Transformations in OpenGl
  • Modeling transformation
  • Viewing transformation
  • Projection transformation

CISC640/440 OpenGL Tutorial

modeling transformation
Modeling Transformation
  • Refer to the transformation of models (i.e., the scenes, or objects)
  • Generally,
    • glMultMatrixf(M_i)
  • Some simple transformations
    • Translation: glTranslate(x,y,z)
    • Scale: glScale(sx,sy,sz)
    • Rotation: glRotate(theta, x,y,z)
      • x,y,z are components of vector defining axis of rotation
      • Angle in degrees; direction is counterclockwise

CISC640/440 OpenGL Tutorial

viewing transformation
Viewing Transformation
  • Refer to the transformation on the camera
  • Using glTranslate*() and glRotate*()
  • Using gluLookAt()
    • gluLookAt (eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ)
      • eye= (eyeX, eyeY, eyeZ)T: Desired camera position
      • center = (centerX, centerY, centerZ)T: Where camera is looking
      • up = (upX, upY, upZ)T: Camera’s “up” vector

CISC640/440 OpenGL Tutorial

viewing transformation10
Viewing Transformation

from Woo et al

CISC640/440 OpenGL Tutorial

projection transformation
Projection Transformation
  • Refer to the transformation from scene to image
  • Orthographic projection
    • glOrtho (left, right, bottom, top, near, far)

from Hill

CISC640/440 OpenGL Tutorial

projection transformation12
Projection Transformation
  • Refer to the transformation from scene to image
  • Orthographic projection
    • glOrtho (left, right, bottom, top, near, far)
  • Perspective projection
    • glFrustum (left, right, bottom, top, near, far)

CISC640/440 OpenGL Tutorial

projection transformation13
Projection Transformation
  • Refer to the transformation from scene to image
  • Orthographic projection
    • glOrtho (left, right, bottom, top, near, far)
  • Perspective projection
    • glFrustum (left, right, bottom, top, near, far)

CISC640/440 OpenGL Tutorial

notes on opengl transformations
Notes on openGl transformations
  • Before applying modeling or viewing transformations, need to set glMatrixMode(GL_MODELVIEW)
  • Before applying projection transformations, need to set glMatrixMode(GL_Projection)
  • Replacement by either following commands glLoadIdentity(); glLoadMatrix(M);
  • Multiple transformations (either in modeling or viewing) are applied in reverse order

CISC640/440 OpenGL Tutorial

notes on opengl transformations15
Notes on openGl transformations
  • Before applying modeling or viewing transformations, need to set glMatrixMode(GL_MODELVIEW)
  • Before applying projection transformations, need to set glMatrixMode(GL_Projection)
  • Replacement by either following commands glLoadIdentity(); glLoadMatrix(M);
  • Multiple transformations (either in modeling or viewing) are applied in reverse order

CISC640/440 OpenGL Tutorial