Download presentation
Presentation is loading. Please wait.
Published byHector Goodwin Modified over 9 years ago
1
CS 4363/6353 OPENGL BACKGROUND
2
WHY IS THIS CLASS SO HARD TO TEACH? (I’LL STOP WHINING SOON) Hardware (GPUs) double in processing power ever 6 months! The “graphics pipeline” has been *drastically* changing Core profile Compatibility profile (for backwards compatibility) More of the pipeline is available: Good for developers (beautiful graphics) Hard for teachers (more difficult to get a “Hello, World!” going) Requires students to understand more simply to begin Need scaffolding
3
WHAT IS OPENGL? “Open” (source) Graphics Language Developed by Silicon Graphics, Inc. (SGI) Not a language, but an API (Application Programming Interface) Include the “new” GLSL (Shading Language) – a C-like language for rendering Intended to run on hardware Cross-platform (MacOS, Windows, Linux using Mesa3D) Was “owned” by an industry board (the ARB – Architecture Review Board) and now the Khronos group OpenGL != GPGPU Mesa is an open-source software implementation
4
VERSIONS V1 – Fixed function pipeline 1992 – 1.0 1997 – 1.1 1998 - 1.2 2001 – 1.3 2002 – 1.4 2003 – 1.5 V2 – Programmable pipeline 2004 – 2.0 2006 - 2. V3* – Programmable buffers 2008 – 3.0 2009 – 3.1 2009 – 3.2 2010 – 3.3 V4 - ?? 2010 – 4.0 2011 (Aug) – 4.2 * No longer backwards compatible
5
STATE MACHINE OpenGL is a state machine that uses a client/server model Our (C/C++) program is the client The hardware (GPU driver) is the server Client sends commands to the server This is what GLEW does – asks the driver for pointers to all the gl functions!
6
HELPER LIBRARIES YOU MIGHT USE GL – The Graphics Library (opengl32.lib and DLL) GLUT – OpenGL “Utility Toolkit” for system-independent windows, which also accepts user input (mouse). Others are: SDL GLX WGL We’ll use “FreeGLUT” GLEW – The GL “Extension Wrangler” for determining which vendor extensions are available and loading them (later
7
GL CONVENTIONS Functions can begin with gl or glut Data types usually begin with GL GLboolean -1 bit GLbyte – 8 bits GLubyte – 8 bits (unsigned) GLchar – 8 bits GLshort - 16 bits GLushort – 16 bits unsigned GLint – 32 bits GLuint – 32 bits unsigned Enumerants start with GL_ GL_TRIANGLES GLsizei – 32 bits GLenum – 32 bits GLfloat – 32 bits GLdouble – 64 bits GLint64 – 64 bits GLintptr – native pointer
8
OPENGL ERRORS Hard to debug! Use the built-in method to determine which error occurred: GL_INVALID_ENUM GL_INVALID_VALUE GL_INVALID_OPERATION GL_OUT_OF_MEMORY GL_NO_ERROR if (glGetError() == GL_INVALID_OPERATION) {...} Note: invalid function calls are quietly disregarded!
9
IDENTIFYING THE VERSION Can query for the vendor and version number of the rendering engine: const GLubyte* glGetString(GLenum name);
10
HINTS… Sometimes, you need speed at the sacrifice of quality. glHint (GLenum target, GLenum mode) Sometimes, you need speed at the sacrifice of quality. glHint (GL_POLYGON_SMOOTH, GL_FASTEST);
11
ARE YOU AN ENABLER? (MORE OF THE STATE MACHINE) In OpenGL, we are always turning features on and off with glEnable and glDisable By default, everything is disabled! Example: glEnable (GL_DEPTH_TEST);. glDisable (GL_DEPTH_TEST); Note: you can always determine if something is on with GLboolean glIsEnabled(GLenum);
12
COLOR THEORY All colors in OpenGL are comprised of three primary colors Red Green Blue Have two separate ranges 0-255 0.0-1.0 Examples: Red = {255, 0, 0} Green = {0, 255, 0} Blue = {0, 0, 255}
13
LIGHTING Lighting is complex! We have to make approximations to real-world lighting For now, understand OpenGL supports the idea of: Camera (View) – using a matrix Light sources – using an array Normals of a triangle We use math to calculate light
14
THE GRAPHICS PIPELINE (AKA - THE BIG PICTURE) Vertex Processing Clipping/Assembly Rasterization Fragment Processing 4 major phases, though several sub-phases
15
THE GRAPHICS PIPELINE (AKA - THE BIG PICTURE) Vertex Processing Clipping/Assembly Rasterization Fragment Processing Vertex Processing Transform vertices using math Light a vertex Determine the color of a vertex We write vertex shaders to do this!
16
THE GRAPHICS PIPELINE (AKA - THE BIG PICTURE) Vertex Processing Clipping/Assembly Rasterization Fragment Processing Clipping and Primitive Assembly Assemble vertices into triangles Clip triangles if they straddle viewport We have no (programmable) control over this
17
THE GRAPHICS PIPELINE (AKA - THE BIG PICTURE) Vertex Processing Clipping/Assembly Rasterization Fragment Processing Rasterization “Scanline” converting Output is a set of “uncolored” fragments Not programmable
18
THE GRAPHICS PIPELINE (AKA - THE BIG PICTURE) Vertex Processing Clipping/Assembly Rasterization Fragment Processing Works on a pixel/fragment basis Determining the color of each pixel We write pixel shaders for this Lighting Materials Color information
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.