Download presentation
Presentation is loading. Please wait.
Published bySilvester Washington Modified over 9 years ago
1
Color spaces. Draw Buffers Color models
2
Mathmatical Protocols for defining colors with numbers RGB Red, Green, Blue HSV Hue, Saturation, Value(Brightness) CYMK Cyan, Yellow, Magenta, Black
3
RGB Red Green Blue Additive Color Mixing Used for many types of monitors and projectors Cathode ray, LCD, DLP, and others
4
CYMK Cyan Yellow Magenta Black Subtractive color mixing Used in printing to describe the inks to use
5
HSV == HSB Hue Range of 0° to 360° Denotes location in light spectrum Saturation Intensity of a color, 0.0 to 1.0 Value/Brightness Lightness or darkness of a color, 0.0 to 1.0
6
Buffers Many types of buffers – Holds data that is stored for each pixel – All buffers for the same window have the same dimensions – Buffers may hold different types/amount of data per pixel Buffer types – Color, depth, alpha, stencil, accumulation
7
Frame Buffer Comprises all of the buffers used to store data per pixel/fragment ColorDepthAlpha AccumulationStencil Frame Buffer
8
Depth Buffer Additional component of the frame buffer Holds the depth value of each fragment Needs to be cleared like color buffer Depth Buffer (drawn as greyscale) Color Buffer
9
Setting up Depth Test OpenGL disables depth test by default glEnable(GL_DEPTH_TEST); We have an additional part of the frame buffer that needs clearing glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); We need a drawing context that has a depth buffer glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH);
10
Depth Test Example void display(void) { glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Setup state to start drawing glBegin(GL_TRIANGLES); glVertex3i(-100, 100, 1); glVertex3i(0, 100, 1); glVertex3i(-50, 50, 1); glVertex3i(50, 50, 3); glVertex3i(100, 100, 3); glVertex3i(75, 20, 3); glEnd(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH); glutCreateWindow("Depth Example"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; } Display code GLUT initialization
11
Multiple Frame Buffers More than one frame buffer can be defined – Useful for drawing to a different buffer than the one being displayed Uses – Double Buffering – Drawing for stereoscopic displays ColorDepthAlpha Accumulat ion Stencil Front Frame Buffer ColorDepthAlpha Accumulat ion Stencil Back Frame Buffer
12
Double Buffering Front frame buffer is displayed Not drawn to Back frame buffer is actively drawn to When finished drawing, switch buffers Front BufferBack Buffer
13
Setting up Double Buffer glFlush() is not needed when double buffering GLUT needs to initialize the display mode to be double buffered glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); Use GLUT to swap buffers after drawing is completed glutSwapBuffers();
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.