Game Development Reference
In-Depth Information
Textures
Textures store the image data we need to display on the screen. They represent a 2D
array of pixels in memory that can be used for many different purposes, as you will
see in this topic.
Note
The pixels inside a texture are referred to as texels . We use this distinction be-
cause through filtering, scaling, and other transformations, we may lose the 1:1
mapping between a texel in the image and a pixel in the output frame buffer.
Textures also take up much of the memory available to a game, making it important
that you apply techniques to reduce their size as much as possible when working on
memory limited devices such as tablets or phones. Textures are generally stored on
the GPU in special memory designed for quick access; however, on some platforms
that memory is shared with the system memory, reducing the amount of space you
have even further.
Note
GPU refers to Graphics Processing Unit . This is a piece of acceleration hard-
ware that is designed to handle the mathematics required to create our game im-
ages at the rates required for an interactive game. The focus on rendering allows
the hardware to be specialised and perform better than a CPU for rendering tasks.
Textures are static; however, by using a texture as a sprite sheet you can add anim-
ation to your game and reduce the number of files you need to load. Textures them-
selves do not define anything but the format of the pixel in memory, the width, and
the height, leaving the interpretation and use up to you. We won't go into detail about
these techniques, but there is plenty of information available online if you want to add
animations to your game.
Now let's look at the different formats that we can use, and load them in ready for ren-
dering later on.
Search WWH ::




Custom Search