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

Drawing a simple window


Drawing a window usually means drawing a rectangular region filled with information. This recipe will show you how to do this efficiently with new capabilities that OpenGL can offer, such as vertex buffers and shaders.

You could be tempted to put the window corner coordinates into the vertex buffer, which is fine for static windows. However, soon you would realize that it is harder to manipulate a window. To move your window, you'd need to change the window coordinates, which would mean changing the content of the vertex buffer. As you already know, moving data from CPU to GPU is a slow process and it basically halts the GPU processing for a while. A better solution to this would be putting static unit-sized window coordinates and transforming it with a model-view matrix. Matrices can be updated by using uniform variables as they tend to be much faster than doing buffer updates. This gives you an incredible amount of power for drawing a window because you can use those...