Aren't textures surfaces??

Started by
5 comments, last by Zipster 16 years, 2 months ago
I would have thought textures are also surfaces because they contain image data. Is this correct or are textures something else? Could someone please clear up the difference between textures and surfaces for me, thanks.
Advertisement
A texture contains one or more surfaces. Because of this relation, they are two different interfaces.

Niko Suni

To expand on that slightly; the reason they contain one or more surfaces is for mip-mapping. Without the distinction between textures and surfaces, you wouldn't be able to have mip-maps.
Also answered 2 days ago [smile]

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Ok, so if I am making a 2d game, I can use either textures or surfaces for my sprites?

The current chapter in my book draws two textures to the screen, but there is also code for a backbuffer surface. Why would a surface be necessary?
In order to use a surface for rendering (to render it to something else), it has to be part of a texture. When you want to render to something, that something can be just a surface (like the backbuffer).

There are also ways to "copy" one surface to another (StretchRect), but that's not really rendering, more of a format-converting-memcpy.
Sirob Yes.» - status: Work-O-Rama.
In the Direct3D paradigm, surfaces are meant to be "raw data" that store the actual bits and bytes of an image, or backbuffer, or whatever other data you would put on a surface. Textures on the other hand are meant to act as an interface and wrapper around surfaces, so that when you have multiple surfaces representing mip-map levels or the like, you can just treat the texture as a black box that handles all the dirty work (dealing with multiple formats, pitches, etc.) for you internally.

Probably the most important difference between the two you should be aware of is that textures can be inputs into shaders, whereas surfaces cannot (again because textures are supposed to act as an interface to the data). In some cases you don't need a texture around the surface, like when you provide a surface for the hardware to use as a depth-stencil buffer or rendertarget. This is because the hardware doesn't need the texture interface, it knows how to work with the surface directly. If you create a "rendertarget texture", then you have the ability to use your rendered output as a shader input in a later pass.

This topic is closed to new replies.

Advertisement