Download presentation
Presentation is loading. Please wait.
1
Computer Graphics Practical Lesson 7
Display Lists, blending and anti alias
2
OFF files OFF files are standard format to represent 3D model.
Starts with number of points, then number of polygons ( usually triangles ). List of points. List of polygons – number of points of polygon and list of points index. Easy to write OFF file reader and draw these models.
3
What is display list? Each command we give in OpenGL is compiled into the data format of the graphic device. Display list - save a sequence of commands that are compiled on startup and run them as many times as we want, so we save the compile time. Not too efficient, hardly being used today. We will see more effective methods on next practical session.
4
Create a display list To create a display list: glNewList(list_index, GL_COMPILE); …… write list’s command. glEndList(); List index is int value that is index of value Second parameter is working mode. There are 2 options: compile only(GL_COMPILE) or compile and run immediately(GL_COMPILE_AND_EXECUTE) NODE: Only OpenGL commands are stored in display list.
5
Deleting a list To delete a list: glDeleteList(list_index)
Where list_index is the id of the list.
6
Running a display list To run a display list: glCallList(list_index)
The parameter is the id of the list. In OpenGL we can create nested lists calls.
7
Managing Display lists
When we assign ourselves the id’s of each lists, it can cause problems. We may overrun previous lists for example. OpenGl can assign lists’ id’s, so we won’t overrun existing lists: int glGenLists(int range) Where range is the number of list we want to assign. After that we need to call glNewList for each list separately.
8
Blending When transparent objects are drawn with other objects behind them, we need to mix between their colors. Until now, it was done automatically using alpha values of objects colors. Blending allow us to define how the colors of objects will be mixed.
9
Defining Blending (cont’)
flBlendFunc(Glenum sfactor, Glenum dfactor). This function set the ratio between source and destination objects colors. There are many values for this enum, for example: GL_ZERO ( object color is disabled ) GL_ONE (Fully use of color) If source and destination values are set with GL_ONE, both objects color will have the same weight.
10
Defining Blending(cont’)
The order of drawing objects affects the final results since the first object that was drawn receives the factor of destination, so if the order is changed, it will receive the destination factor.
11
Blending transparent and opaque objects
When we use the depth buffer, each time we render an object, we check in depth buffer if an object has been drawn closer to the camera. If not, we render the object and update the depth buffer. If we have transparent object like windshield close to the eye, it will prevent the drawing of any object behind him.
12
Blending transparent and opaque objects(cont’)
To solve this problem, we need to prevent writing to depth buffer for transparent objects. Void glDepthMask(bool) This function enable or disable the writing to depth buffer. When we draw transparent objects, we disable the writing.
13
Antialiasing When objects and lines are drawn, the borders are coarse. To receive an image with higher quality the boarders are blurred. Each boarder point color is calculated as weighted average of adjunct pixels depend on covered space by line and selected policy.
14
Antialiasing parameters
To enable antialiasing on lines: glEnable(GL_LINE_SMOOTH) To set quality of antialiasing: void glHint(Glenum target, Glenum hint). Target can be GL_LINE_SMOOTH_HINT, GL_POINT_SMOOTH_HINT and GP_POLYGON_SMOOTH_HINT. Hint can be GL_NICEST( per pixel ) or GL_FASTEST( per vertex)
15
Antialiasing Example Click on ‘R’ rotates the lines
Click on ‘E’ sets antialias on. Click on ‘D’ sets antialias off.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.