Textures and surfaces

Started by
3 comments, last by jollyjeffers 17 years, 7 months ago
Hey guys, Could anyone of you tell me what assigning a texture to a surface mean? Please explain in detail. Thanks
Advertisement

As far as I understand, your question doesn't make sense to me.

In Direct3d there is this base class called surface. Many D3D objects, such as vertex buffers and index buffers, are derived from it. Texture is just a special form of surface. There are lots of operations that you can do with textures, such as assigning them to certain texturestage or nowadays to a shader sampler. You can also use a texture as a rendertarget in order to render the scene into a texture (and perhaps use it later for rendering other things). Textures, as other surfaces, may be locked for reading / writing the data on byte level.

Can you give us an example where the subject was mentioned ?

Cheers
Quote:In Direct3d there is this base class called surface. Many D3D objects, such as vertex buffers and index buffers, are derived from it.


You mean resource. As in IDirect3DResource9.
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!
Ah. :) That's interesting. Before I was thinking that surfaces were some kind of formated memory space just for storing graphics, ie: textures, backbuffers, a group of textures/sprites,etc. I didn't realize it was a base class. :D
Textures are collections of surfaces. Look up IDirect3DTexture9::GetSurfaceLevel() - each of the mip-map levels is an IDirect3DSurface9.

Quote:You can also use a texture as a rendertarget in order to render the scene into a texture (and perhaps use it later for rendering other things)
I understand what you're saying, but just to be pedantic this isn't quite right [smile]

A render-target is actually a surface - look up IDirect3DDevice9::CreateRenderTarget() and see that it actually creates/returns a IDirect3DSurface9. Same with SetRenderTarget() calls - they take a surface not a texture.

For RtT effects you're going to use the aforementioned GetSurfaceLevel() to retrieve one of the surfaces making up a texture then use it to connect rendering with the contents of the texture. Surfaces can't be bound as texturing/shading inputs but textures can, thus it'd be reasonably accurate to describe the process as a form of casting like you get in most programming languages [smile]

Quote:surfaces were some kind of formated memory space just for storing graphics
They are! One of the big things in the early days of DirectDraw (which is where the concept of 'surface' originated afaict) was that surfaces represented a contigous block of memory that could be used to store pixels. Its a bit before my time, but as I understand it this wasn't always the case when doing Mode13/DOS level graphics. Having the API provide (even if its just an abstraction) a continuous block of memory to use was very useful...

I don't think it's accurate to consider IDirect3DSurface9 as a base class though. Via composition (correct OOP term?) it is used to construct more complex types but it is, in its own right, a valid type that can be used on its own. IDirect3DResource9 and IDirect3DBaseTexture9 are probably better examples of base classes [smile]

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

This topic is closed to new replies.

Advertisement