Interactive Computer Graphics CS 418 MP1: Dancing I TA: Zhicheng Yan Sushma S Kini Mary Pietrowicz Slides Taken from: “An Interactive Introduction to OpenGL.

Slides:



Advertisements
Similar presentations
Programming with OpenGL - Getting started - Hanyang University Han Jae-Hyek.
Advertisements

Computer Graphics - Graphics Programming -
Department of nskinfo i-education
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…
Line and Curve Drawing Algorithms. Line Drawing x0x0 y0y0 x end y end.
Chapter 2: Graphics Programming
Computer Graphics CSCE 441
#include int line_width = 1; void Display( void ) { glEnable( GL_LINE_STIPPLE ); glClearColor (0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT);
CS 4731 Lecture 2: Intro to 2D, 3D, OpenGL and GLUT (Part I) Emmanuel Agu.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Transformations I Week.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
InteractionHofstra University1 Graphics Programming Input and Interaction.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner OpenGL, GLUT, Transformations.
CENG477 Introduction to Computer Graphics Introduction to OpenGL, GLUT and GLUI.
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.
Computer Graphics CS 385 February 7, Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining.
Introduction to OpenGL Jian Huang This set of slides are extracted from the Interactive OpenGL Programming course given by Dave Shreine, Ed Angel and Vicki.
Chapter 03: Graphics Primitives Course web page: Chapter #3.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 Computer Graphics Dr. Amy Zhang Assistant Professor of Computer Science United International College.
1 GLUT Callback functions Event-driven: Programs that use windows  Input/Output  Wait until an event happens and then execute some pre-defined functions.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
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.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner GLUT, Transformations.
School of Computer Science University of Seoul. 1. Interaction 2. Input Devices 3. Clients and Servers 4. Display Lists 5. Programming Event-Driven Input.
1Computer Graphics Input and Interaction Lecture 8 John Shearer Culture Lab – space 2
Lecture 3 OpenGL.
Computer Graphics I, Fall 2010 Input and Interaction.
 “OpenGL (Open Graphics Library) is a standard specification defining a cross- language cross-platform API for writing applications that produce 2D 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.
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
CS 480/680 Computer Graphics Programming with Open GL Part 7: Input and Interaction Dr. Frederick C Harris, Jr. Fall 2011.
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 4 of 41 William H. Hsu Department of Computing.
Introduction to OpenGL and GLUT. What’s OpenGL? An Application Programming Interface (API) A low-level graphics programming API – Contains over 250 functions.
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.
1 Input and Interaction. 2 Objectives Introduce the basic input devices ­Physical Devices ­Logical Devices ­Input Modes Event-driven input Introduce double.
University of New Mexico
Computing & Information Sciences Kansas State University CG Basics 3 of 8: OpenGL Primer 1 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction.
NoufNaief.net TA: Nouf Al-harbi.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor.
GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner OpenGL/GLUT Intro Week.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CSCE 441: Computer Graphics
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
12/22/ :38 1 Comp 175C - Computer Graphics Dan Hebert Computer Graphics Comp 175 Chapter 3 Instructor: Dan Hebert.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
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.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
INTRODUCTION TO OPENGL
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics Lecture 33
CSC461 Lecture 8: Input Devices
The User Interface Lecture 2 Mon, Aug 27, 2007.
גרפיקה ממוחשבת: מבוא ל-OpenGL
Rendering Pipeline, OpenGL/GLUT
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Isaac Gang University of Mary Hardin-Baylor
Input and Interaction Ed Angel
University of New Mexico
Computer Graphics Practical Lesson 1-
Input and Interaction Ed Angel
Input and Interaction Ed Angel Professor Emeritus of Computer Science,
Presentation transcript:

Interactive Computer Graphics CS 418 MP1: Dancing I TA: Zhicheng Yan Sushma S Kini Mary Pietrowicz Slides Taken from: “An Interactive Introduction to OpenGL Programming” Dave Shreiner, Ed Angel, Vicki Shreiner

Agenda  MP1 Submission  A little more OpenGL  Applications Structure  Callback functions  Double Buffering (required)  Animation Techniques  MP Q&A

MP1 : Mesh Rendering  Due on 12:30pm CST 10 Feb  Compass is sometimes not very stable. Try to submit earlier  Check the Piazza post MP1 submission instructions  We want a zip file named cs418_mp1_{netid}.zip: ▪ Source code folder ▪ Screen shot folder ▪ README with compilation instructions and link to mandatory video demo  Depth Test : “glEnable(GL_DEPTH_TEST);”  Demo:

4 GLUT Basics  Application Structure  Configure and open window  Initialize OpenGL state  Register input callback functions ▪ render/display ▪ resize ▪ input: keyboard, mouse, etc.  Enter event processing loop

5 Sample Program void main( int argc, char** argv ) { int mode = GLUT_RGB|GLUT_DOUBLE; glutInitDisplayMode( mode ); glutCreateWindow( argv[0] ); init(); glutDisplayFunc( display ); glutReshapeFunc( resize ); glutKeyboardFunc( key ); glutIdleFunc( idle ); glutMainLoop(); }

6 OpenGL Initialization  Set up whatever state you’re going to use.  In our MP1 Case only this: void init( void ) { glClearColor( 0.0, 0.0, 0.0, 1.0 ); }

7 GLUT Callback Functions  Routine to call when something happens  window resize or redraw  user input  animation  “Register” callbacks with GLUT glutDisplayFunc( display ); glutIdleFunc( idle ); glutKeyboardFunc( keyboard );

8 Rendering Callback  Do all of your drawing here glutDisplayFunc( display ); void display( void ) { glClear( GL_COLOR_BUFFER_BIT ); glBegin( GL_TRIANGLE_STRIP ); glVertex3fv( v[0] ); glVertex3fv( v[1] ); glVertex3fv( v[2] ); glVertex3fv( v[3] ); glEnd(); glutSwapBuffers(); }

9 Idle Callbacks  Use for animation and continuous update glutIdleFunc( idle ); void idle( void ) { glutPostRedisplay(); }

10 User Input Callbacks  Process user input glutKeyboardFunc( keyboard ); void keyboard( char key, int x, int y ) { switch( key ) { case ‘q’ : case ‘Q’ : exit( EXIT_SUCCESS ); break; case ‘r’ : case ‘R’ : rotate = GL_TRUE; break; }

11 Double Buffering Front Buffer Back Buffer Display

12 Animation Using Double Buffering  Request a double buffered color buffer glutInitDisplayMode(GLUT_RGB |GLUT_DOUBLE);  Clear color buffer glClear( GL_COLOR_BUFFER_BIT );  Render scene  Request swap of front and back buffers glutSwapBuffers(); Interesting Example  Repeat steps for animation

Sine Waves-Simple Animation  2 ways to generate sine waves in software:  y = sin(x) ▪ Ex. glVertex2f(sin(x), cos(y)); ▪ Don’t change every point with the same function otherwise the animation would be uniform.  Look Up Table

Lookup Table  generate an array of the sine values and store them in memory. ▪ use the symmetry properties of the sine wave to minimize the memory storage Example: Obtain y=sin(x) in one degree steps: For x Є (0,90), we can create the array: float sine[91], pi= ; for (int i=0;i<=90;i++) sine[i] = sin(pi/180 * i); Then, if we wanted the sine of 45 degrees, we simply write y = sine[45];

Lookup Table (cont.) Example (cont.): Obtain the other 3/4's of the circle: we can use the symmetry of sine wave. Each quadrant is obtained as follows: y = sine[ x]; /* 90 <= x <= 180 */ y = -sine[x - 180]; /* 180 <= x <= 270 */ y = -sine[360 - x]; /* 270 <= x <= 360 */

Q&A