Managing Multiple Windows with OpenGL and GLUT

Slides:



Advertisements
Similar presentations
OpenGL Open a Win32 Console Application in Microsoft Visual C++.
Advertisements

OpenGL CMSC340 3D Character Design & Animation. What is OpenGL? A low-level graphics library specification designed for use with the C and C++ provides…
OPEN GL. Install GLUT Download package di sini Dari devcpp, buka Tools->PackageManager-
Computer Graphics CSCE 441
Pemrograman OpenGL Dasar
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 Basics Donghui Han. Assignment Grading Visual Studio Glut Files of four types needed: – Source code:.cpp,.h – Executable file:.exe (build in release.
OpenGL (I). What is OpenGL (OGL)? OGL is a 3D graphics & modeling library Can also use it to draw 2D objects.
InteractionHofstra University1 Graphics Programming Input and Interaction.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner OpenGL, GLUT, Transformations.
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.
Write a Simple Program with OpenGL & GLUT. Books and Web Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible.
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.
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.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner GLUT, Transformations.
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
1Computer Graphics Input and Interaction Lecture 8 John Shearer Culture Lab – space 2
Lecture 3 OpenGL.
Computer Graphics I, Fall 2010 Input and Interaction.
Write a Simple Program with OpenGL & GLUT. Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible
 “OpenGL (Open Graphics Library) is a standard specification defining a cross- language cross-platform API for writing applications that produce 2D and.
Managing Multiple Windows with OpenGL and GLUT
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.
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.
Intro to OpenGL (Version 2) Geb Thomas. Setting Up GLUT You will need GLUT for opening windows We can use the version made by Nate Robins: –
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.
University of New Mexico
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net TA: Nouf Al-harbi.
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.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Working with Callbacks.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
July FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.
INTRODUCTION TO OPENGL
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Computer Graphics -practical- Lecture 6. (visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft.
Basic Program with OpenGL and GLUT
Review GLUT Callback Functions
Working with Callbacks
Introduction to the Mouse
Windows Programming Lecture 09.
Computer Graphics Lecture 33
CS5500 Computer Graphics March 2, 2006.
CSC461 Lecture 8: Input Devices
The User Interface Lecture 2 Mon, Aug 27, 2007.
Working with Callbacks
Rendering Pipeline, OpenGL/GLUT
Coordinate Systems and Transforming the Coordinates
Introduction to OpenGL
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
Basic OpenGL programming, Geometric objects & User Interaction
OpenGL, GLUT, Transformations I Week 2, Wed Jan 16
Input and Interaction Ed Angel Professor Emeritus of Computer Science,
Presentation transcript:

Managing Multiple Windows with OpenGL and GLUT A mini-tutorial

The OpenGL Utility Toolkit (GLUT) Programming Interface Based upon: The OpenGL Utility Toolkit (GLUT) Programming Interface API Version 3 Mark J. Kilgard Copyright 1996

Two (or more) OpenGL/GLUT Windows State OpenGL State Callbacks Display Func. Mouse Func. Reshape Func. Keyboard Func. Etc. Frame Buffer Callbacks Display Func. Mouse Func. Reshape Func. Keyboard Func. Etc. Idle Function Shared

Steps for Creating Multiple Windows Initialize drawing context and frame buffer using glutInit(), glutInitDisplayMode(), and glutInitWindowSize(). Create first window Register callbacks for first window Create second window Position the second window Register callbacks for second window Register (shared) idle callback Enter the main loop Note: Callbacks can be shared between windows, if desired

Creating a Window Creates a window data structure and returns a small int glutCreateWindow(char *name); Unique identifier of the window created Name of the window Appears at top in window decoration Creates a window data structure and returns a small integer identifier. Window is not displayed until the main loop is entered Window becomes the current window. The current window Can be set or obtained using glutSetWindow() and glutGetWindow().

Behavior of Callback Functions Keyboard and mouse events are routed by the event loop to the callbacks registered for the window in which the cursor is located. Display events are generated for each window separately when the O/S determines that the window must be redisplayed. Display events can be user generated using glutPostRedisplay(). These events are routed to the display callback for the current window. The shared idle() function is executed whenever no events are present in the event queue.

Example Using Two Windows glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB |GLUT_DEPTH); glutInitWindowSize(500, 500); // create the first window window1 = glutCreateWindow("First Window - Perspective View"); // register callbacks for first window, which is now current glutReshapeFunc(window1_reshape); glutDisplayFunc(window1_display); glutMouseFunc(window1_mouse); //create the second window window2 = glutCreateWindow("Second Window - Top/Down View"); //define a window position for second window glutPositionWindow(520,20); // register callbacks for second window, which is now current glutReshapeFunc(window2_reshape); glutDisplayFunc(window2_display); glutMouseFunc(window1_mouse); //note we share the mouse function glutIdleFunc(spinCube); //idle function is not associated with a window glutMainLoop();

Resulting Display from Two Windows Code

Generating Subwindows Main Window Subwindow1 Subwindow2

Subwindows Are equivalent to any other window except that their coordinates are defined in terms of a parent window Therefore, have their own OpenGL state and callback functions Are not automatically resized when their parent window is resized Can be nested arbitrarily deeply

Creating a Subwindow Parent window identifier Location wrt parent window int glutCreateSubWindow(int win, int x, int y, int width, int height); Unique identifier of the window created Initial size of subwindow Creates a subwindow data structure and returns a small integer identifier. Subwindow is not displayed until the main loop is entered Subwindow becomes the current window. The current window Can be set or obtained using glutSetWindow() and glutGetWindow().