Input Devices Introduction to OpenGL - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Input Devices Introduction to OpenGL

Description:

A ball device that can be rotated with the fingers or palm of hand ... Flatbed. Drum. 1/11/2006. TCSS458A Isabelle Bichindaritz. 10. Input Devices. Touch panels ... – PowerPoint PPT presentation

Number of Views:83
Avg rating:3.0/5.0
Slides: 35
Provided by: isabellebi
Category:

less

Transcript and Presenter's Notes

Title: Input Devices Introduction to OpenGL


1
Input DevicesIntroduction to OpenGL
2
Learning Objectives
  • Survey of input devices
  • Introduction to OpenGL
  • First OpenGL program with Java bindings

3
Input Devices
  • Input devices
  • Keyboards, button boxes, dials
  • Mouse devices
  • Trackballs and spaceballs
  • Joysticks
  • Data gloves
  • Digitizers
  • Image scanners
  • Touch panels
  • Light pens
  • Voice systems

4
Input Devices
  • Keyboards, button boxes, dials
  • Standard keyboard
  • Alphanumeric
  • Function keys
  • Button boxset of input dials

5
Input Devices
  • Mouse devices
  • Mechanical mouse
  • One-button
  • Rotating ball
  • Two perpendicular shafts to capture rotation
  • Optical mouse
  • Optical sensor
  • Laser
  • Grid to detect movement
  • Added widgets
  • Buttons
  • Trackball
  • Thumbwheel.

6
Input Devices
  • Trackball
  • A ball device that can be rotated with the
    fingers or palm of hand
  • Spaceball
  • Six degrees of freedom
  • Does not move, detects strain placed on the ball
    by trying to move it.

7
Input Devices
  • Joystick
  • A small, vertical lever mounted on a base
  • Movable joystick measures motion
  • Stationary (isometric) joystick measures strain.
  • Data glove
  • Used to grasp a virtual object
  • Measures hand and finger position
  • 2D or 3D
  • Can also be used as input device to detect
    surface.

8
Input Devices
  • Digitizers
  • Used for drawing, painting, or selecting
    positions
  • Graphics tablet used to input 2D coordinates by
    activating a hand cursor or stylus at given
    positions on a flat surface
  • Used to trace contours, select precise coordinate
    positions
  • Hand held cursor
  • Stylus
  • Electromagnetic
  • Grid of wires
  • Electromagnetic pulses send an electrical signal
    in stylus or cursor
  • Acoustic
  • Sound waves to detect stylus position by
    microphones
  • Can be 3D.
  • Image scanners

9
Input Devices
  • Image scanners
  • Used to store images on a computer
  • Hand held
  • Flatbed
  • Drum.

10
Input Devices
  • Touch panels
  • Select objects by the touch of a finger
  • Optical
  • Line of infrared light-emitting diodes (LED)
    along vertical and horizontal edges
  • Interrupted when panel is touched
  • Electrical
  • Two transparent plates of material, one
    conducting, the other resistive
  • Touch brings the plates to be in contact with one
    another, causing a voltage drop
  • Measure the voltage drop
  • Acoustical.
  • Light pens

11
Input Devices
  • Light pens
  • Pen-shaped device to select screen positions by
    detecting lights coming from points on the CRT
    screen
  • Used to capture position of an object or select
    menu options.

12
Input Devices
  • Voice systems
  • Speech recognition systems to recognize voice
    commands
  • Used to activate menu options or to enter data
  • Uses a dictionary from a particular user
    (learning system).

13
Hard-copy Devices
  • Hard-copy devices
  • Plotters
  • 2D moving pen with stationary paper
  • 1D pen and 1D moving paper
  • Printers
  • Impact devices
  • Inked ribbon
  • Non impact devices
  • Laser, ink-jet, xerographic, electrostatic,
    electrothermal.

14
Graphics Software
  • Graphics software
  • Special purpose
  • For non programmers
  • CAD, CAM, painting, animation
  • General programming packages
  • Library of graphics functions
  • C, C, Java,
  • Picture components (lines, shapes, )
  • Transformations (color, texture, shading,
    rotating, )

15
Coordinate Representation
  • Cartesian coordinates
  • Modeling coordinates (local, master)in the
    reference frame of each object
  • World coordinatesin the scene reference frame
  • Viewing coordinatesview we want of a scene
  • Normalized (device) coordinatesnormalized
    between 1 and 1 or 0 and 1
  • Device coordinates (screen coordinates)

16
Coordinate System
(from Donald Hearn and Pauline Baker)
17
Introduction to OpenGL
  • OpenGL
  • First part of Silicon Graphics graphics
    workstations
  • Became hardware independent in early 1990s
  • Maintained by the OpenGL Architecture Review
    Board
  • Developed for 3D scenes
  • 2D scenes as projections where z-coordinate is 0.

18
Important Concepts
  • Three dimensional concepts
  • Light-material interactions
  • Transformations
  • Modeling
  • Interaction
  • Rendering Algorithms
  • ... and others

19
OpenGL
  • Graphics rendering API (Application Programmers
    Interface)
  • Generation of high-quality color images composed
    of geometric and image primitives
  • Window system independent
  • Operating system independent
  • Close to the hardware
  • Algorithms and implementation are important

20
Pipeline Model
  • Close to hardware
  • Easy to program
  • Direct implementation of synthetic camera
  • Image formation by computer is analogous to image
    formation by camera (or human)
  • Specify viewer, objects, lights
  • Let hardware/software form image (via projection)

21
OpenGL Geometric Pipeline
State
ApplicationProgram
ModelView Transformation
Frame Buffer
Rasterization
Projection
Pixels
Vertices
22
OpenGL as a Renderer
  • Two operations (basically) in OpenGL
  • Draw something
  • Change the state of what or how OpenGL draws
  • Geometric primitives
  • Various kinds of points, lines, and polygons
  • Image Primitives
  • Images and bitmaps
  • Separate pipeline for images and geometry
  • Linked through texture mapping
  • Rendering depends on the state of
  • Colors, materials, light sources, etc.

23
OpenGL Architecture
Upper pipeline is for geometric, vector-based
primitives.
Lower pipeline is for pixel-based,
image primitives.
24
OpenGL and the Windowing System
  • OpenGL is concerned only with rendering
  • It is window system independent
  • No input functions
  • OpenGL must interact with the underlying OS and
    windowing system
  • Need minimal interface which may be system
    dependent
  • Done through additional libraries AGL, GLX, WGL

25
GLU and GLUT
  • GLU (OpenGL Utility Library)
  • Part of OpenGL
  • Provides NURBS (splines), etc.
  • GLUT (OpenGL Utility Toolkit)
  • A portable windowing API
  • Not officially part of OpenGL
  • Extremely useful for helping to create images
    quickly without worrying about the underlying
    windowing system being used

26
OpenGL and Related APIs
application program
OpenGL Motif widget or similar
GLUT
GLX, AGLor WGL
GLU
GL
X, Win32, Mac O/S
software and/or hardware
27
OpenGL Geometric Primitives
  • All geometric primitives are specified by vertices

28
OpenGL Command Formats
glVertex3fv( v )
Number of components
Data Type
Vector
b - byte ub - unsigned byte s - short us -
unsigned short i - int ui - unsigned int f -
float d - double
omit v for scalar form glVertex2f( x, y )
2 - (x,y) 3 - (x,y,z) 4 - (x,y,z,w)
29
Specifying Geometric Primitives
  • Primitives are specified using
  • glBegin( primType )
  • glEnd()
  • primType determines how vertices are combined

GLfloat red, green, blue Glfloat
coords3 glBegin( primType ) for ( i 0 i lt
nVerts i ) glColor3f( red, green, blue
) glVertex3fv( coords ) glEnd()
30
Display Window
(from Donald Hearn and Pauline Baker)
31
Sample Programs
  • include ltGL/glut.hgt // (or others,
    depending on the system in use)
  • void init (void)
  • glClearColor (1.0, 1.0, 1.0, 0.0) // Set
    display-window color to white.
  • glMatrixMode (GL_PROJECTION) // Set
    projection parameters.
  • gluOrtho2D (0.0, 200.0, 0.0, 150.0)

32
Sample Programs
  • void lineSegment (void)
  • glClear (GL_COLOR_BUFFER_BIT) // Clear
    display window.
  • glColor3f (0.0, 0.0, 1.0) // Set line
    segment color to red.
  • glBegin (GL_LINES)
  • glVertex2i (180, 15) // Specify
    line-segment geometry.
  • glVertex2i (10, 145)
  • glEnd ( )
  • glFlush ( ) // Process all OpenGL
    routines as quickly as possible.

33
Sample Programs
  • void main (int argc, char argv)
  • glutInit (argc, argv)
    // Initialize GLUT.
  • glutInitDisplayMode (GLUT_SINGLE GLUT_RGB)
    // Set display mode.
  • glutInitWindowPosition (50, 100) // Set
    top-left display-window position.
  • glutInitWindowSize (400, 300) // Set
    display-window width and height.
  • glutCreateWindow ("An Example OpenGL
    Program") // Create display window.
  • init ( ) //
    Execute initialization procedure.
  • glutDisplayFunc (lineSegment) // Send
    graphics to display window.
  • glutMainLoop ( ) //
    Display everything and wait.

34
Output
Write a Comment
User Comments (0)
About PowerShow.com