
| Lesson
1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6 Lesson 7 Lesson 8 Lesson 9 Lesson 10 Lesson 11 Lesson 12 Lesson 13 Lesson 14 Lesson 15 Lesson 16 Lesson 17 Lesson 18 Lesson 19 |
Lesson 8 BlendingLike zeLight and zeMaterial; zeBlend, zeFog, and zeStencil are objects that enable corresponding OpenGL attributes. The uses of zeFog and zeStencil will be demonstrated in the advanced applications. The following example shows that without blending the transparency (alpha = 0.5) of the blue triangle have no effect at all. The blending makes you being able to see through the top triangle. Another common use of blending is to produce anti-aliased or smooth lines.
require("register")
render, scene, node, blend, polygon1, polygon2, xyz
= zeGrf.new("render" ,"scene", "node", "blend", "polygon", "polygon", "vertex")
render:add(scene)
scene:set{node = node}
node:add(blend, polygon1, polygon2)
xyz:add(-100, -100, 0)
xyz:add(100, -100, 0)
xyz:add(0, 80, 0)
polygon1:set{vertex = xyz, type = "triangles", color = {1, 0, 0, 1}}
polygon2:set{vertex = xyz, type = "triangles", color = {0, 0, 1, 0.5}}
polygon2:translate(0, 20, 20)
blend:set{enable = false}
render:tofile("blend1.png")
blend:set{enable = true}
render:tofile("blend2.png")
blend1.png and blend2.png |