Lecture 5 Rendering 3D graphical primitives 3D Rendering Example: 3D Rendering Pipeline 3D Rendering Pipeline Rendering How to render in different modes to get either a solid or an outlined object? OpenGL allows both sides of an object to be rendered in a different mode.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
3D graphical primitives
glPolygonMode( GL_FRONT, GL_FILL ); // Front filled
glPolygonMode( GL_BACK, GL_LINE ); // Back Outlined
glColor3f( 1.0, 0.0, 0.0 );
glBegin( GL_QUAD );
// Square drawn counter clockwise
glVertex2d( -1.0, -1.0 );
glVertex2d( 1.0, -1.0 );
glVertex2d( 1.0, 1.0 );
glVertex2d( -1.0, 1.0 );
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
// return the drawing mode
glEnable( GL_CULL_FACE ).
How does OpenGL know what objects are in front of other objects?
Assume, two objects are rendered. Object 1 is behind object 2 and object 2 is partially obscuring object 1. The display function would draw the object 1 first and then object 2.
What if the camera rotated 180 degrees behind object 1? Now the tables are turned, and object 1 is in front with the respects to the camera. If the objects are drawn in the same order, object 2 will always look like it is in front of object 1 no matter what the camera location is.
To enable this powerful feature:
call to glClear should also contain GL_DEPTH_BUFFER_BIT along with any other buffer bit you wish to clear.
glClear( GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glutInitDisplayMode(GLUT_DEPTH | … );
int rings );
int rings );
// Clear pixels in buffer
glClear( GL_COLOR_BUFFER_BIT );
glColor3f( 1.0, 1.0, 0.0 );
glutSolidTeapot( 0.5 );
glFlush(); // Draw to the screen