Sign in to follow this  
ed209

Aren't textures surfaces??

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this