Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments.

Slides:



Advertisements
Similar presentations
Computer Graphics - Graphics Programming -
Advertisements

OpenGL Open a Win32 Console Application in Microsoft Visual C++.
OpenGL CMSC340 3D Character Design & Animation. What is OpenGL? A low-level graphics library specification designed for use with the C and C++ provides…
Better Interactive Programs
Graphics Pipeline.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Better Interactive Programs Ed Angel Professor of Computer Science, Electrical and Computer.
InteractionHofstra University1 Graphics Programming Input and Interaction.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 GLUT Callback Functions.
Based on slides created by Edward Angel
CSC461 Lecture 9: GLUT Callbacks Objectives Introduce double buffering for smooth animations Programming event input with GLUT.
Informationsteknologi Tuesday, November 6, 2007Computer Graphics - Class 41 Today’s class Input and interaction.
CS 480/680 Computer Graphics Programming with Open GL Part 8: Working with Callbacks Dr. Frederick C Harris, Jr. Fall 2011.
Using Graphics Libraries Lecture 3 Mon, Sep 1, 2003.
19/4/ :32 Graphics II Syllabus Selection and Picking Session 1.
CSC461 Lecture 11: Interactive Programs Contents and Objectives Picking Writing modes – XOR/Copy Rubberbanding Display list.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
1 Working with Callbacks Yuanfeng Zhou Shandong University.
WORKING WITH CALLBACKS Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Angel: Interactive.
Using OpenGL in Visual C++ Opengl32.dll and glu32.dll should be in the system folder Opengl32.dll and glu32.dll should be in the system folder Opengl32.lib.
Fundamentals of Computer Graphics Part 3 prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.: Interactive.
School of Computer Science University of Seoul. 1. Interaction 2. Input Devices 3. Clients and Servers 4. Display Lists 5. Programming Event-Driven Input.
Input and Interaction Chapter 3. CS 480/680 2Chapter 3 -- Input and Interaction Introduction: Introduction: We now turn to the development of interactive.
1Computer Graphics Input and Interaction Lecture 8 John Shearer Culture Lab – space 2
CAP 4703 Computer Graphic Methods Prof. Roy Levow Lecture 3.
Input and Interaction Lecture No. 4.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
FLTK Help Session By Richard Yu Gu CS 638 -Graphics Fall, 1999.
Lecture 3 OpenGL.
1 Input and Interaction. 2 Input Devices Physical input devices Keyboard devices and pointing devices Logical input devices.
Computer Graphics I, Fall 2010 Input and Interaction.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Ch 2 Graphics Programming page 1 CSC 367 Coordinate Systems (2.1.2) Device coordinates, or screen coordinates (pixels) put limitations on programmers and.
1 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
Computing & Information Sciences Kansas State University Lecture 20 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 21 of 42 William H. Hsu.
CS 480/680 Computer Graphics Programming with Open GL Part 7: Input and Interaction Dr. Frederick C Harris, Jr. Fall 2011.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Better Interactive Programs. 2 Objectives Learn to build more sophisticated interactive programs using ­Picking Select objects from the display Three.
Interactive Computer Graphics CS 418 MP1: Dancing I TA: Zhicheng Yan Sushma S Kini Mary Pietrowicz Slides Taken from: “An Interactive Introduction to OpenGL.
Introduction to OpenGL and GLUT. What’s OpenGL? An Application Programming Interface (API) A low-level graphics programming API – Contains over 250 functions.
1 Input and Interaction. 2 Objectives Introduce the basic input devices ­Physical Devices ­Logical Devices ­Input Modes Event-driven input Introduce double.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Programming in the Simple Raster Graphics Package (SRGP) Chapter 2.
More on GLUT Programming Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September 15, 2003.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Computer Graphics I, Fall 2010 Working with Callbacks.
1 Graphics CSCI 343, Fall 2015 Lecture 6 Viewing, Animation, User Interface.
University of New Mexico
GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Lecture 7 Midterm Review. OpenGL Libraries gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture.
Introduction to Graphics Programming. Graphics API.
Introduction to Graphics Programming. Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Working with Callbacks.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
The Human Visual System vs The Pinhole camera
Better Interactive Programs
Computer Graphics Lecture 33
CSC461 Lecture 8: Input Devices
Introduction to Computer Graphics with WebGL
Advanced Menuing, Introduction to Picking
Better Interactive Programs
Isaac Gang University of Mary Hardin-Baylor
Fundamentals of Computer Graphics Part 3
Input and Interaction Ed Angel
University of New Mexico
Input and Interaction Ed Angel
Input and Interaction Ed Angel Professor Emeritus of Computer Science,
Presentation transcript:

Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments  describe what the function does  document anything you may forget in a week

Indexed Color  Needed for frame buffers with a limited depth  8 bits of color = 2**8 colors = 256 colors  default is dividing bits into rbg assignments  load color map with a pallette of 256 colors  LUT

Viewing  Camera and objects are specified independently.  For a 2D world - define viewing or clipping rectangle.  Objects inside will be seen.  Objects outside will not be seen.  For a 3D world - define a viewing volume.  Orthographic projection.

Matrix Modes  Pipeline graphics dependent on concatenating a number of transformation matrices. Vertices Transformer Clipper Projector Rasterizer Pixels  Matrices  model-view  projection

Clients and Servers  Graphics server  Workstation with raster display, keyboard, and pointing device  Provides input and output services for network  Client  OpenGL application programs

Display Lists  From display processor  A special purpose computer  Host computer sent instructions to the display processor  Instructions stored in display memory as a display file or a display list  Immediate mode  Program defines a primitive  Primitive sent to server for display  No memory of primitive exists

Display Lists  Retained mode graphics  Define object once  Put description in a display list  Display list stored on the server  Redisplayed by a single function call  Advantage  Reduced network traffic  Disadvantage  Memory required on the server  Creating the display list has overhead

Display Lists  Creation of a display list - use glNewList, glEndList to encapsulate the list.  Each list has an int identifier which can be invoked with the command glCallList(identifier);  Save attributes with the matrix and attribute stacks (remember from 202: push onto a stack and pop off of a stack).

Interaction  According to Webster’s  To act upon each other  Two way communication  GLUT toolkit for windowing  GLUT recognizes only a small subset of the events recognized by X

Input  Input devices  Logical devices  From the perspective of the application program  Physical devices  Hardware and how it works

Input Modes  Mode defined by the relationship between the trigger and the measuring process.  Trigger (physical input that user signals computer).  Measure (what is returned to the program).  Request mode.  Measure returned when triggered. Trigger measure requestprogram. Process triggerprocess measure.

Input Modes  Sample mode  Measure returned when triggered Measure sampleprogram Process measure  Event mode  Device triggered  Event generated  Device measure placed on the event queue  Event type tied to function called CALLBACK

Input Modes Trigger measure event await program. Process trigger process measure queue event.  Event mode.  Device triggered.  Event generated.  Device measure placed on the event queue.  CALLBACK registered with the windowing system. Event type tied to function called a callback.

Using the Pointing Device Mouse Triggered Events  Move event  Move the mouse with the buttons depressed  Passive move event  Move the mouse without pressing a button  Mouse event  When one of the buttons is either released or pressed

Specify the Mouse Callback Function  In main()  With glutMouseFunc(mouse_callback_func)  void mouse_callback_func(int button, int state, int x, int, y)  The callback function specifies what actions are related to the specified event

Window Event  Generated when the window is resized  Redraw all the objects in the window  How to handle the aspect ratio  Do we change the sizes or attributes of the new primitives if the size of the new window is different from that of the old

Keyboard Events  Generated when the mouse is in the window and one of the keys is depressed  Returns the ascii code for the key and the x and y coordinates of the mouse  void keyboard(unsigned char key, int x, imt y)

Display Callback  Invoked when GLUT determines the window should be redisplayed  Upon opening it initially

Idle Function  Idle callback invoked when there are no other events.  Generates graphical primitives through a display function while nothing else is happening.  Event processing happens between calls to the idle function.  Do not spend too much time in the idle function.  Idle does not actually rerender the frame.  To rerender call glutPostRedisplay(); from within the idle callback.

Menus  GLUT provides popup menus  glutCreateMenu(menu_callback_name);  Menu_callback_name is the name of the function. The argument to that function is the identifier passed to the callback when the entry is selected

Adding a Menu glutCreateMenu(menu_callback_name);glutAddMenuEntry("quit",1);glutAttachMenu(GLUT_RIGHT_BUTTON);

Adding a menu callback menu_callback_name(int id) { if (id ==. if (id ==...}

Animation  Double buffering eliminates flicker.

Callback Advice From the Creator of GLUT, Mark Kilgard  Don’t change state that will affect the way a window will be drawn a display callback.  If you need to redisplay a window, instead of rendering in whatever callback you happen to be in, call glutPostRedisplay.  If you use an idle callback to control animation, use a visibility callback to determine when the window is fully obscured or iconified.

More Callback Advice  The backspace, Esc, and Del keys generate ASCII characters, so detect key presses for these keys using the glutKeyboardFunc callback.

Design of Interactive Programs  A smooth display (no flicker or artifacts of the refresh process)  A variety of interactive devices on the display  A variety of methods for entering and displaying information  An easy to use interface that does not require substantial effort to learn  Feedback to the user  Tolerance for user errors  A design incorporation for consideration of both the visual and motor properties of the human

Limitations of Geometric Rendering  Designing widgets  example of popup menu  refreshing the display where the menu was  no primitives but uses scan line image data  operations described in terms of the frame buffer or in terms of bit-block transfer operation

Limitations of Geometric Rendering  Rubberbanding  a technique for displaying line segments in a changing manner.  Endpoint is selected  Before second endpoint is selected a line segment is drawn automatically to where the present position of the mouse is  As the mouse moves the old segment must be erased and a new one drawn.

Homework  Read chapter 4  Program 2 due 02/01/05