Qt my favorite gtk michael tao csc418 computer

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ao CSC418: Computer Graphics Tutorial 1 September 20, 2012 5 / 31 GLUT Set of of slots for various functionalities What What What What to to to to render? do when window reshaped? do when key pressed? do when mouse pressed? Called Callback Registration Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 6 / 31 GLUT Functional slots defined by Callback Registration int main ( int argc , char * argv ) { glutInit (& argc , argv ) ; g l u t I n i t D i s p l a y M o d e ( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA ) ; g l u t I n i t W i n d o w P o s i t i o n (100 ,100) ; g l u t I n i t W i n d o w S i z e (320 ,320) ; g l u t C r e a t e W i nd o w ( " Window " ) ; g lu tD is p la yF un c ( render Function ) ; g l u t K e y b o a r d F u n c t i o n ( k e y b o a r d F u n c t i on ) ; g lu tR es h ap eF un c ( reshapeFunc ) ; glutMainLoop () ; } Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 7 / 31 GLUT: Callback Function Examples void k e y b o a r d F u n c ti o n ( u n s i g n e d char key , int x , int y ) { if ( key == ’p ’) { printf ( " Mouse position : % d % d " ,x , y ) ; } } void rende rFunctio n () { glClear ( G L _ C O L O R _ B UF F E R _ B I T | G L _D EP TH _ BU FF ER ) ; glClearColor (0 ,0 ,0 ,1) ; drawStuff () ; g lu tS wa p Bu ff er s () ; } Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 8 / 31 GLUT: Use Sparingly Designed for rapid prototyping of small applications Lacks a v...
View Full Document

This document was uploaded on 02/12/2014.

Ask a homework question - tutors are online