Presentation is loading. Please wait.

Presentation is loading. Please wait.

OpenGL Background CS 4722.

Similar presentations


Presentation on theme: "OpenGL Background CS 4722."— Presentation transcript:

1 OpenGL Background CS 4722

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 * No longer backwards compatible V1 – Fixed function pipeline
1992 – 1.0 1997 – 1.1 2001 – 1.3 2002 – 1.4 2003 – 1.5 V2 – Programmable pipeline 2004 – 2.0 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 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) 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 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 4 major phases, though several sub-phases Clipping/Assembly Rasterization Fragment Processing

15 the Graphics Pipeline (AKA - the Big Picture)
Vertex Processing Vertex Processing Transform vertices using math Light a vertex Determine the color of a vertex We write vertex shaders to do this! Clipping/Assembly Rasterization Fragment Processing

16 the Graphics Pipeline (AKA - the Big Picture)
Vertex Processing Clipping and Primitive Assembly Assemble vertices into triangles Clip triangles if they straddle viewport We have no (programmable) control over this Clipping/Assembly Rasterization Fragment Processing

17 the Graphics Pipeline (AKA - the Big Picture)
Vertex Processing Rasterization “Scanline” converting Output is a set of “uncolored” fragments Not programmable Clipping/Assembly Rasterization Fragment Processing

18 the Graphics Pipeline (AKA - the Big Picture)
Vertex Processing Fragment Processing Works on a pixel/fragment basis Determining the color of each pixel We write pixel shaders for this Lighting Materials Color information Clipping/Assembly Rasterization Fragment Processing


Download ppt "OpenGL Background CS 4722."

Similar presentations


Ads by Google