jgs SER332 Introduction to Graphics and Game Development Lecture 03: OpenGL Overview Javier Gonzalez-Sanchez [email protected] PERALTA 230U Office Hours: By appointment
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 14 jgs Remove Precompiled Headers § 1. Right click in the project name and select “Properties”. § 2. Select “Not Using Precompiled Headers”
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 39 jgs What Is OpenGL? § Software interface to graphics hardware § Competitors: DirectX, Java2D and Java3D,… § Communicate between CPU and GPU via drivers § A client and server execution model
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 41 jgs OpenGL as a State Machine § Maintain pipeline states: current color, viewing and projection transformation, polygon drawing modes, etc. glColor3f(1.0f, 0.0f, 0.0f); // <- alter current state // Draw a cube //What color is the cube? glColor3f(0.0, 1.0f, 0.0f); // <- alter current state // Draw a sphere. // What color is the sphere? § Hierarchical state maintenance glPushAttrib(), glPushMatrix(), glPopAttrib(), glPopMatrix(),…
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 42 jgs OpenGL Libraries OpenGL core library (GL) #include § OpenGL32 on Windows. GL on most UNIX / LINUX systems (libGL.a) OpenGL Utility Library (GLU) #include § Provides functionality in OpenGL core but avoids having to rewrite code OpenGL Utility Toolkit (GLUT) #include § Provides functionality common to all window systems: Open a window, Get input from mouse and keyboard, Menus, Event-driven § Code is portable but GLUT lacks the functionality of a good toolkit for a specific platform
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 43 jgs OpenGL and Related APIs GLUT GLU GL GLX, AGL or WGL X, Win32, Mac O/S software and/or hardware application program OpenGL Motif widget or similar
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 48 jgs Installation (Windows) § Add glut.h in your include path gl.h and glu.h are included by glut.h § Add glut32.lib in your library path § Add glut32.dll in "windows\system" path
Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 54 jgs Double Buffering Double buffering is necessary for almost all OpenGL applications: § Render into back buffer § Swap buffers when finished rendering a frame: The old back buffer becomes the front buffer that is displayed. The old front buffer becomes the back buffer that is rendered into. § What happens when you do not use double buffering? flickering artifacts, tearing artifacts Commands: § glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE ); § glutSwapBuffers(); //instead of glFlush()
jgs SER332 Introduction to Graphics Javier Gonzalez-Sanchez [email protected] Spring 2018 Disclaimer. These slides can only be used as study material for the class SER332 at ASU. They cannot be distributed or used for another purpose.