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

Rendering to texture


Rendering to texture technique is used whenever you need to apply some kind of postprocessing on screen or to produce dynamic textures in reflections.

Over the past few years, OpenGL introduced a number of ways to obtain screen content and transfer it to texture. You could read directly from the frame buffer and store all data in texture with gl.TexSubImage2D function. This approach is a slow process because all rendering must be stalled in order to obtain a copy of the whole frame. For this kind of operation, there was a P buffer introduced sometime in 2000. It presented a more efficient way of transferring larger blocks of pixel data. However, this kind of buffer wasn't available everywhere and what's more, it was hard to use. Later, it was deprecated in OpenGL 3.0 and subsequently removed from OpenGL 3.1. Currently, the standardized way of working with frame buffer is to work with Render Buffer. Render buffer objects have been available since OpenGL 3.0. They use native...