Book Image

Lua Game Development Cookbook

By : Mario Kasuba, Mário Kašuba
Book Image

Lua Game Development Cookbook

By: Mario Kasuba, Mário Kašuba

Overview of this book

Table of Contents (16 chapters)
Lua Game Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Setting up blending


OpenGL allows you to change the way textures are drawn. This process is called blending and it's often used when combining multiple textures. However, blending can also be applied to texture rendering on screen. OpenGL uses a so-called "blending function" to define the mathematical function that calculates the final color value. For example, the GL_FUNC_ADD blending function defines additive blending, which is used when mixing colored lights in a scene.

This function uses two values:

  • The source value is usually a color or alpha channel value of the texture you are currently using. The source value is also called a fragment.

  • The destination value is a color or alpha channel value that's on the destination surface or the screen.

You can't directly put values into the blending function. What you are allowed to do is to use one of the predefined functions to be used for the source value or the destination value.

Note that the blending function is also used with the modern rendering...