3D Computer Graphics - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

3D Computer Graphics

Description:

Windows, Linux, Mac, iPhone, Android, PS3, and many more. OpenGL Rendering Pipeline ... glVertex2i(10,0); //Will not draw. GlVertex variations ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 22
Provided by: davidk105
Category:
Tags: computer | graphics | mac

less

Transcript and Presenter's Notes

Title: 3D Computer Graphics


1
  • 3D Computer Graphics
  • OpenGL

David Kabala
2
Why Cool?
3
Computer Graphics
  • Raster Graphics
  • Images are created from pixel data
  • Vector Graphics
  • Images are created from primitives of points,
    lines, curves, and other shapes
  • Final image is computed by processing this
    representation

4
OpenGL
  • OpenGL is a mixture of Vector and Raster graphics
  • Vector graphics
  • polygons, surface normals, colors, etc.
  • Raster graphics
  • textures(images) that are mapped onto surfaces
  • Rasterizing vector graphics into frame buffer
  • Most platforms have an implementation of OpenGL
  • Windows, Linux, Mac, iPhone, Android, PS3, and
    many more

5
OpenGL Rendering Pipeline
Vector Operations
Rasterization
Data
Fragment Operations
Frame Buffer
6
OpenGL Rendering Pipeline
7
OpenGL Rendering Pipeline
  • ATI R600 Pipeline

8
OpenGL Changing with 3.0
  • Many parts of the OpenGL API have been deprecated
    in version 3.0, and removed in version 3.1
  • This includes much of the fixed functionality of
    the pipeline
  • Lighting
  • Programing these portions in the pipeline is the
    path forward

9
OpenGL as a state machine
  • OpenGL is organized for functional programming
    not object-oriented
  • Stays in a persistent state until it receives a
    message that tells it to change
  • Objects are bound
  • Changes are made to the state
  • Color, lighting, line width, etc
  • Immediate draw mode

10
OpenGL API
  • All methods are prefixed with gl
  • e.g. glEnable(GLbool), glVertex2i(GLint,GLint)?
  • All Types are prefixed with GL
  • e.g. GLbool, GLint, GLflaot, GLenum
  • All constants are prefixed with GL_
  • e.g. GL_POINTS, GL_CULL_FACE, GL_QUADS

11
OpenGL defined types
  • Important Types
  • GLshort
  • 16 bit integer
  • GLint
  • 32 bit integer
  • GLfloat
  • 32 bit floating point
  • GLdouble
  • 64 bit floating point
  • GLboolean
  • 8 bit unsigned integer
  • GLenum
  • 32 bit unsigned integer
  • C/C leave the number of bytes of each type up
    to the compiler writer
  • OpenGL has defined types that are the same size
    in all implementations

12
Drawing
  • Primitives are drawn by sending vertex positions
    inside of a glBegin and glEnd block
  • Example

void display(void)? //Setup state to start
drawing //points glBegin(GL_POINTS)
//Draw a point at 10,10
glVertex2i(10,10) glEnd()
13
glBegin/glEnd block
  • OpenGL receives primitive geometry data inside
    a glBegin and glEnd block
  • glBegin(GLenum primitiveType)?
  • primitiveType argument takes a GLenum value of
    the type of primitives to draw

void display(void)? glBegin(GL_POINTS)
glVertex2i(10,10)
glVertex2i(20,10) glVertex2i(0,0)
glEnd() glVertex2i(10,0) //Will not draw
14
GlVertex variations
  • Some sets of OpenGL methods take multiple
    numbers and types of arguments

glVertex2i
Number of arguments
Type of argument
15
Primitives
  • Points
  • Lines
  • Triangles
  • Quadrilaterals
  • Polygons

16
Points
  • send GL_POINTS as parameter to glBegin
  • Every glVertex produces a single point
  • Changing point drawing parameters
  • glPointSize(GLint size)

void display(void)? //Setup state to start
drawing //points glPointSize(5.0)
glBegin(GL_POINTS) //Draw a point at
10,10 glVertex2i(10,10) glEnd()
17
Lines
  • Line Draw Modes
  • GL_LINES
  • GL_LINE_STRIP
  • Changing line width
  • glLineWidth(GLint size)
  • GL_LINE_LOOP

v1
v2
v2
v1
v5
v4
v3
v2
v4
v3
v1
18
Triangles
  • GL_TRIANGLES
  • GL_TRIANGLE_STRIP
  • GL_TRIANGLE_FAN

19
Quads
  • GL_QUADS
  • GL_QUAD_STRIP

20
Polygons
v3
  • GL_POLYGONS
  • Must be convex
  • Must be non-intersecting
  • Separate polygonsmust be in separateglBegin/glEn
    d blocks

v2
v4
v5
v1
v2
v3
v1
v4
v5
v8
v6
v6
21
Next Time
  • Using GLUT (OpenGL Utility) to manage window and
    context creation
  • Transformations using matrix and vector algebra
Write a Comment
User Comments (0)
About PowerShow.com