Drawing Figures contd' - PowerPoint PPT Presentation

Loading...

PPT – Drawing Figures contd' PowerPoint presentation | free to view - id: 17b7ad-ZDc1Z



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Drawing Figures contd'

Description:

To ensure that the plot covers a reasonably large part of the ... draws a rectangle whose diagonally opposite vertex coordinates are supplied as arguments. ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 11
Provided by: cis86
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Drawing Figures contd'


1
Drawing Figures (contd.)
  • (elementary OpenGL programming)
  • www.cis.syr.edu/mohan/gra3.ppt

2
Plotting a function
  • To ensure that the plot covers a reasonably large
    part of the screen, it is necessary to scale and
    shift the coordinate system from (x,f(x) to
    (AxB, Cf(x)D), choosing the coefficients so
    that AxB ranges from 0 to screenWidth and
    Cf(x)D ranges from 0 to screenHeight. (Example
    Figure 2.16)

3
Drawing Lines
  • Set line color using glColor3f, and line width
    using glLineWidth.
  • Enclose a list of vertices between glBegin
    (GL_LINES/LINE_STRIP/LINE_LOOP/POLYGON)glEnd().
  • Vertices can be stored in a file and read by the
    OpenGL program (e.g., fig.2.22, with file
    dino.dat), or in an array (fig.2.27, 2.28).

4
Parameterized Figures
  • Families of objects can be drawn, distinguished
    by parameter values, e.g., houses parameterized
    by peak position, width and height (Fig. 2.25)

5
moveto() and lineto()
  • Manipulate a hypothetical pen at current position
    (cp)
  • cp is modified by moveto() and lineto() the
    latter also draws a line from the previous cp to
    the new one.

6
Drawing aligned rectangles
  • glRecti(,,,) draws a rectangle whose diagonally
    opposite vertex coordinates are supplied as
    arguments.
  • Exercise generate a checkerboard
  • Aspect ratio width/height

7
Other Primitives in OpenGL
  • GL_TRIANGLES
  • GL_TRIANGLE_STRIP
  • GL_TRIANGLE_FAN
  • GL_QUADS
  • GL_QUAD_STRIP

8
Mouse Interaction(1)
  • glutMouseFunc(f) registers f with the event that
    occurs with button press/release f must be
    designed to take four arguments
  • GLUT_LEFT/MIDDLE/RIGHT_BUTTON
  • GLUT_UP/DOWN
  • x (int)
  • y (int)
  • E.g., specifying rectangles/polylines, fig.2.38,
    2.40

9
Mouse Interaction(2)
  • glutMotionFunc(f) registers f with the event that
    occurs when the mouse is moved while a button is
    pressed f must be defined to take x and y
    coordinates as parameters
  • Example useful in freehand drawing with a fat
    brush, p.66

10
Keyboard Interaction
  • glutKeyboardFunc(f) registers f with keyboard key
    press event f must be defined to take three
    parameters key id, mouseX and mouseY
    coordinates.
  • E.g., fig.2.41
  • The y coordinates must be flipped (subtracted
    from screenHeight) in some of these routines.
About PowerShow.com