• Advertisement
Sign in to follow this  

Aren't textures surfaces??

This topic is 3676 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
A texture contains one or more surfaces. Because of this relation, they are two different interfaces.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement