A foo f foo a barptr g int a foo

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: gt; g () ; int a = Foo :: g () ; Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 12 / 31 C++: References and const Pointers Similar to what you see in most other languages so far Pass by value / pass by reference Except we explicitly declare when to do what const provides security over modification Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 13 / 31 C++: References and const int f ( Foo & foo ) { return foo . a = 3; } int g ( const Foo & foo ) { h ( a ) ; // h has to be h ( const Foo &) return foo . a ; } const x = 0; const Foo ; const * const Foo = & foo ; Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 14 / 31 C++: Templates Allow for generic typing of functions/classes Resolved at compilation template < typename T> T mymax ( const T & a , const T & b ) { return (a > b ) ? a : b ; } int a = mymax (3 ,4) ; float b = mymax (1.0 f ,2.0 f ) ; double c = mymax (1.0 ,2.0) ; std :: string str = mymax ( std :: string ( " foo " ) , std :: string ( " bar " ) ) ; Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 15 / 31 OpenGL OpenGL is how we draw things on the screen Push vertex information to graphics card Vertex positions Colors Normals Get pretty pictures Two main pipelines Fixed Pipeline Programmable Pipeline Shader Programs Rapidly Changing! Michae...
View Full Document

Ask a homework question - tutors are online