COMPE 473 Recitation - PowerPoint PPT Presentation

1 / 47
About This Presentation
Title:

COMPE 473 Recitation

Description:

A hardware and operating system independent graphics API specification. Many vendors provide implementations of this ... http://fly.cc.fer.hr/~unreal/theredbook ... – PowerPoint PPT presentation

Number of Views:75
Avg rating:3.0/5.0
Slides: 48
Provided by: murat2
Category:

less

Transcript and Presenter's Notes

Title: COMPE 473 Recitation


1
COMPE 473 Recitation 2
  • OPENGL recitation 2

2
Introduction
  • OpenGL
  • A hardware and operating system independent
    graphics API specification.
  • Many vendors provide implementations of this
    specification for a variety of hardware
    platforms.
  • Bindings exist primarily for the C, Fortran and
    Ada programming languages.

3
Introduction
  • OpenGL has been designed using a client/server
    paradigm, allowing the client application and the
    graphics server controlling the display hardware
    to exist on the same or separate machines. The
    network is transparent to the application.

4
Introduction
  • OpenGL is window system independent, and
    therefore contains no windowing operations or
    mechanisms for user input. Also, OpenGL does not
    provide direct support for complex geometrical
    shapes, such as cubes or spheres.

5
Introduction
  • Some features of OpenGL include the following

6
Introduction
  • Also the following three libraries are available
    with OpenGL
  • The OpenGL Utility Library (GLU), which contains
    several routines that use lower-level OpenGL
    commands to perform such tasks as setting up
    matrices for specific viewing orientations and
    projections, performing tessellation, and
    rendering surfaces.

7
Introduction
  • The OpenGL Extension to the X Window System (GLX)
    provides a means of creating an OpenGL context
    and associating it with an X Window System
    window.
  • The OpenGL Programming Guide Auxiliary Library
    provides routines for initializing and opening
    windows, handling X events and dealing with
    common complex shapes, such as cubes, spheres,
    and cylinders.

8
Introduction
  • OpenGL is defined and released by the OpenGL
    Architecture Review Board (ARB). The ARB consists
    of representatives from industry, including DEC,
    ES, H-P, IBM, Intel, Intergraph, Microsoft, SGI,
    and Sun. The ARB oversees the administration of
    the OpenGL Specification and Conformance Test
    Suite.

9
OpenGL Pipeline
10
OpenGL Command Format

11
Vertices and Primitives
  • Most objects (with the exception of pixel
    rectangles and bitmaps), use glBegin/glEnd
    primitives. Each glBegin/glEnd primitive contains
    a series of vertex data, and may optionally
    contain normals , texture coordinates, colors,
    edge flags, and material properties.

12
Vertices and Primitives
  • glBegin(GL_XXX)
  • glVertex3f(0.0f,3.0f,1.0f)
  • glVertex3f(1.0f,3.0f,1.0f)
  • glEnd()
  • Then GL_XXX gt

13
Vertices and Primitives
  • There are ten primitive types, as follows
  • Points, GL_POINTS
  • individual points

14
Vertices and Primitives
  • Lines, GL_LINES
  • pairs of vertices interpreted as individual line
    segments

15
Vertices and Primitives
  • Line Strip, GL_LINE_STRIP
  • series of connected line segments

16
Vertices and Primitives
  • Line Loop, GL_LINE_LOOP
  • Line strip with a segment added between last and
    first vertices

17
Vertices and Primitives
  • Polygon , GL_POLYGON
  • boundary of a simple, convex polygon

18
Vertices and Primitives
  • triangles , GL_TRIANGLES
  • triples of vertices interpreted as triangles

19
Vertices and Primitives
  • Triangle Strip , GL_TRIANGLE_STRIP
  • linked strip of triangles

20
Vertices and Primitives
  • Triangle Fan , GL_TRIANGLE_FAN
  • linked fan of triangles

21
Vertices and Primitives
  • Quads , GL_QUADS
  • quadruples of vertices interpreted as four-sided
    polygons

22
Vertices and Primitives
  • Quad Strip , GL_QUAD_STRIP
  • linked strip of quadrilaterals

23
Vertices and Primitives
  • Vertices may be specified in 2D, 3D, or 4D.
  • 2D coordinates are promoted to 3D by assigning a
    Z value of zero.
  • 4D homogeneous coordinates are reduced to 3D by
    dividing x, y, and z by the w coordinate (if
    non-zero).

24
Vertices and Primitives
  • Between glBegin/ glEnd, those opengl commands are
    allowed
  • glVertex() set vertex coordinates
  • glColor() set current color
  • glIndex() set current color index
  • glNormal() set normal vector coordinates
  • glTexCoord() set texture coordinates

25
Vertices and Primitives
  • glMultiTexCoord() set texture coordinates for
    multitexturing
  • glEdgeFlag() control drawing of edges
  • glMaterial() set material properties
  • glArrayElement() Extract array element data
  • glCallList(), glCallLists() execute display list

26
Point Details
  • To control the size of a rendered point use
  • glPointSize(Glfloat size)
  • Sets the width of pixels for rendered points,
    size has to be greater than 0.0
  • Default is 1.0

27
Line Details
  • To control the width of a rendered line use
  • glLineWidth(Glfloat width)
  • Sets the width in pixels for rendered lines, size
    has to be greater than 0.0
  • Default is 1.0

28
Line Details
  • To make dotted or dashed lines, use
  • glLineStipple(Glint factor, Glshort pattern)
  • to define the stipple pattern, and you need to
    enable stippling by glEnable(GL_LINE_STIPPLE)
  • Pattern 16 bit series of 1s and 0s.1 indicates
    drawing occurs, 0 indicates no drawing occurs
    pixel by pixel.

29
Line Details
  • Pattern 16 bit series of 1s and 0s. 1 indicates
    drawing occurs, 0 indicates no drawing occurs on
    a pixel by pixel basis, beginning with the
    low-order bit of the pattern.
  • Factor multiplies each sub series of 1s and 0s.
    It has to be between 1 and 256.

30
Line Details
  • glLineStipple(1,0x3F07) gt
  • 0011 1111 0000 0111 means
  • A line would be drawn with 3 pixels on, then 5
    pixels off , 6 pixels on, and 2 pixels off.

31
Polygon Details
  • By default both front and back faces of polygons
    are drawn in the same way. To change this use
  • glPolygonMode(Glenum face, Glenum mode)
  • face may be GL_FRONT,GL_BACK,GL_FRONT_AND_BACK
  • Mode may be GL_POINT,GL_LINE or GL_FILL

32
Polygon Details
  • For Polygon Stipple refer to the OPENGL
    Programming Guide pg 59-62
  • glPolygonStipple(const Glubyte mask)
  • glEnable(GL_POLYGON_STIPPLE)
  • glDisable (GL_POLYGON_STIPPLE)

33
Polygon Details
  • For Polygon Stipple refer to the OPENGL
    Programming Guide
  • glPolygonStipple(const Glubyte mask)
  • glEnable(GL_POLYGON_STIPPLE)
  • glDisable (GL_POLYGON_STIPPLE)

34
Sub Windows and TodayS Func.s
  • int glutCreateSubWindow(int win, int x, int y,
    int width, int height)
  • void glutSolidSphere(GLdouble radius, GLint
    slices, GLint stacks)
  • void glutSolidCube(GLdouble size)
  • void glRasterPos2f( GLfloat x,GLfloat y )
  • void glutBitmapCharacter(void font, int
    character)

35
NEXT TIME WE WILL SEEWhat about Viewing
  • We know how to draw primitive shapes, but we need
    to define our coordinate system, and viewing
    system to render those shapes as an image on a
    monitor.
  • For this recitation we will mention basics of
    projections. In the next recitation we will see
    vertex arrays, and mention details of viewing
    including transformations.

36
Camera Analogy
  • Viewing Position the viewing volume in the world
  • Modeling Position the models in the world
  • Projection Determine the shape of viewing volume
  • Viewport Determine sizes of the final image on
    the screen window.

37
Model-View and Projection Matrices
38
Model-View and Projection Matrices
39
Projection Transformation
  • Most important ones are
  • Orthogonal Projection
  • Perspective Projection

40
Orthogonal Projection
  • .

41
Orthogonal Projection
42
Perspective Projection
  • .

43
Perspective Projection
44
Perspective Projection
45
Modeling and Viewing Transformations
  • Modeling
  • glRotate
  • glTranslate
  • glScale
  • Viewing
  • Modeling transformations gluLookAt

46
View-port Transformation
47
Reference
  • http//www.opengl.org/documentation/spec.html
  • OpenGL Programming Guide http//www.parallab.uib.n
    o/SGI_bookshelves/SGI_Developer/books/OpenGL_PG/sg
    i_html/
  • http//fly.cc.fer.hr/unreal/theredbook/
  • http//www.cs.wpi.edu/matt/courses/cs563/talks/Op
    enGL_Presentation/OpenGL_Presentation.html
  • Lecture notes of Thilo Kielmann
Write a Comment
User Comments (0)
About PowerShow.com