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

Creating surfaces


Surfaces are an object representation of image data buffers. They play the main role in the texture management process. Every image you load needs to be placed onto the surface first. After this, you can use this surface to render your image onto the screen, store it into graphical memory, or do some image manipulation.

Getting ready

Every surface consists of a pixel format description and binary data. The surface object structure is shown in the following table:

Field names

Description

flags

This is the bit mask description of surface properties.

format

This is the surface pixel format.

w

This is the surface width in pixels.

h

This is the surface height in pixels.

pitch

This is the length of the surface scanline in bytes. It specifies how many bytes are used to store a single line surface content and it's used mostly in surface blitting operations. The pitch value is always dividable by 4 to optimize surface processing speed.

pixels

This is the pointer...