GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window.

Slides:



Advertisements
Similar presentations
Department of nskinfo i-education
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…
Pemrograman OpenGL Dasar
#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.
Chapter 3: Input and Interaction Instructor: Shih-Shinh Huang 1.
OpenGL (I). What is OpenGL (OGL)? OGL is a 3D graphics & modeling library Can also use it to draw 2D objects.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
30/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 1: Introduction.
CENG477 Introduction to Computer Graphics Introduction to OpenGL, GLUT and GLUI.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 3: Introduction.
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.
Introduction to OpenGL TA: Mani Thomas CISC 440/640
Using Graphics Libraries Lecture 3 Mon, Sep 1, 2003.
Computer Graphics Bing-Yu Chen National Taiwan University.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
COMPUTER GRAPHICS Hochiminh city University of Technology Faculty of Computer Science and Engineering CHAPTER 03: Input & Interaction.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Chapter 3: Input and Interaction.
More on Drawing in OpenGL: Examples CSC 2141 Introduction to Computer Graphics.
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.
1Computer Graphics Input and Interaction Lecture 8 John Shearer Culture Lab – space 2
Lecture 3 OpenGL.
Computer Graphics I, Fall 2010 Input and Interaction.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
 “OpenGL (Open Graphics Library) is a standard specification defining a cross- language cross-platform API for writing applications that produce 2D and.
CS 480/680 Computer Graphics Programming with Open GL Part 7: Input and Interaction Dr. Frederick C Harris, Jr. Fall 2011.
Interactive Computer Graphics CS 418 MP1: Dancing I TA: Zhicheng Yan Sushma S Kini Mary Pietrowicz Slides Taken from: “An Interactive Introduction to OpenGL.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
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.
Input and Interaction Yuanfeng Zhou Shandong University Software College 1.
University of New Mexico
Input and Interaction Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor.
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
12/22/ :38 1 Comp 175C - Computer Graphics Dan Hebert Computer Graphics Comp 175 Chapter 3 Instructor: Dan Hebert.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Input and Interaction Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
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.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
INTRODUCTION TO OPENGL
CS 480/680 Computer Graphics Programming with Open GL Part 2: Complete Programs Dr. Frederick C Harris, Jr. Fall 2011.
Review GLUT Callback Functions
Computer Graphics Lecture 33
CS5500 Computer Graphics March 2, 2006.
CSC461 Lecture 8: Input Devices
Programming with OpenGL Part 2: Complete Programs
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
גרפיקה ממוחשבת: מבוא ל-OpenGL
Input and Interactions
Isaac Gang University of Mary Hardin-Baylor
Input and Interaction Ed Angel
University of New Mexico
Input and Interaction Ed Angel
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Basic OpenGL programming, Geometric objects & User Interaction
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Input and Interaction Ed Angel Professor Emeritus of Computer Science,
Presentation transcript:

GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window (the rendering context) RGB color Single buffering Properties logically ORed together glutWindowSize in pixels glutWindowPosition from top-left corner of display glutCreateWindow create window with title “simple” glutDisplayFunc display callback glutMainLoop enter infinite event loop 2

main.c (in book) #include int main(int argc, char** argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(0,0); glutCreateWindow("simple"); glutDisplayFunc(mydisplay); init(); glutMainLoop(); } Angel: Interactive Computer Graphics 5E © Addison-Wesley includes gl.h define window properties set OpenGL state enter event loop display callback

Event Types Window: resize, expose, iconify Mouse: click one or more buttons Motion: move mouse Keyboard: press or release a key Idle: nonevent Define what should be done if no other event is in queue Angel: Interactive Computer Graphics 5E © Addison-Wesley

Callbacks Programming interface for event-driven input Define a callback function for each type of event the graphics system recognizes This user-supplied function is executed when the event occurs GLUT example: glutMouseFunc(mymouse) Angel: Interactive Computer Graphics 5E © Addison-Wesley mouse callback function

GLUT callbacks GLUT recognizes a subset of the events recognized by any particular window system (Windows, X, Macintosh) glutDisplayFunc glutMouseFunc glutReshapeFunc glutKeyboardFunc glutIdleFunc glutMotionFunc, glutPassiveMotionFunc Angel: Interactive Computer Graphics 5E © Addison-Wesley

GLUT Event Loop Recall that the last line in main.c for a program using GLUT must be glutMainLoop(); which puts the program in an infinite event loop In each pass through the event loop, GLUT looks at the events in the queue for each event in the queue, GLUT executes the appropriate callback function if one is defined if no callback is defined for the event, the event is ignored Angel: Interactive Computer Graphics 5E © Addison-Wesley

The display callback The display callback is executed whenever GLUT determines that the window should be refreshed, for example When the window is first opened When the window is reshaped When a window is exposed When the user program decides it wants to change the display In main.c glutDisplayFunc(mydisplay) identifies the function to be executed Every GLUT program must have a display callback Angel: Interactive Computer Graphics 5E © Addison-Wesley

Double Buffering Instead of one color buffer, we use two Front Buffer: one that is displayed but not written to Back Buffer: one that is written to but not displayed Program then requests a double buffer in main.c glutInitDisplayMode(GL_RGB | GL_DOUBLE) At the end of the display callback buffers are swapped 9 void mydisplay() { glClear(GL_COLOR_BUFFER_BIT|….). /* draw graphics here */. glutSwapBuffers() }

Using the idle callback The idle callback is executed whenever there are no events in the event queue glutIdleFunc(myidle) Useful for animations 10 void myidle() { /* change something */ t += dt glutPostRedisplay(); } Void mydisplay() { glClear(); /* draw something that depends on t */ glutSwapBuffers(); }

Using globals The form of all GLUT callbacks is fixed void mydisplay() void mymouse(GLint button, GLint state, GLint x, GLint y) Must use globals to pass information to callbacks 11 float t; /*global */ void mydisplay() { /* draw something that depends on t }