The Nebula Device 3: Direct3D9::D3D9Texture Class Reference

The Nebula Device 3

Direct3D9::D3D9Texture Class Reference

#include <d3d9texture.h>

Inheritance diagram for Direct3D9::D3D9Texture:

Base::TextureBase Base::ResourceBase Resources::Resource Core::RefCounted CoreGraphics::Texture

Detailed Description

D3D9/Xbox360 implementation of Texture class

FIXME: need to handle DeviceLost through RenderDevice event handler (Win32 only)

(C) 2007 Radon Labs GmbH

Public Types

enum  Type
 texture types
enum  CubeFace
 cube map face
enum  Usage
 resource usage flags
enum  State
 resource states (DO NOT CHANGE ORDER!)

Public Member Functions

 D3D9Texture ()
 constructor
virtual ~D3D9Texture ()
 destructor
virtual void Unload ()
 unload the resource, or cancel the pending load
bool Map (IndexT mipLevel, MapType mapType, MapInfo &outMapInfo)
 map a texture mip level for CPU access
void Unmap (IndexT mipLevel)
 unmap texture after CPU access
bool MapCubeFace (CubeFace face, IndexT mipLevel, MapType mapType, MapInfo &outMapInfo)
 map a cube map face for CPU access
void UnmapCubeFace (CubeFace face, IndexT mipLevel)
 unmap cube map face after CPU access
IDirect3DBaseTexture9 * GetD3D9BaseTexture () const
 get d3d9 base texture pointer
IDirect3DTexture9 * GetD3D9Texture () const
 get d3d9 texture pointer
IDirect3DCubeTexture9 * GetD3D9CubeTexture () const
 get d3d9 cube texture pointer
IDirect3DVolumeTexture9 * GetD3D9VolumeTexture () const
 get d3d9 volume texture pointer
void SetupFromD3D9Texture (IDirect3DTexture9 *ptr, const bool setLoaded=true)
 setup from a IDirect3DTexture9
void SetupFromD3D9CubeTexture (IDirect3DCubeTexture9 *ptr, const bool setLoaded=true)
 setup from a IDirect3DCubeTexture
void SetupFromD3D9VolumeTexture (IDirect3DVolumeTexture9 *ptr, const bool setLoaded=true)
 setup from a IDirect3DVolumeTexture
Type GetType () const
 get texture type
SizeT GetWidth () const
 get width of texture
SizeT GetHeight () const
 get height of texture (if 2d or 3d texture)
SizeT GetDepth () const
 get depth of texture (if 3d texture)
SizeT GetNumMipLevels () const
 get number of mip levels
SizeT GetSkippedMips () const
 get number of currently skipped mip levels
void SetSkippedMips (SizeT m)
 set number of currently skipped mip levels
CoreGraphics::PixelFormat::Code GetPixelFormat () const
 get pixel format of the texture
bool Map (IndexT mipLevel, Access accessMode, MapInfo &outMapInfo)
 map the a texture mip level for CPU access
bool MapCubeFace (CubeFace face, IndexT mipLevel, Access accessMode, MapInfo &outMapInfo)
 map a cube map face for CPU access
void SetUsage (Usage usage)
 set resource usage type
Usage GetUsage () const
 get resource usage type
void SetAccess (Access access)
 set resource cpu access type
Access GetAccess () const
 get cpu access type
void SetAsyncEnabled (bool b)
 request synchronous/asynchronous resource loading
bool IsAsyncEnabled () const
 return true if asynchronous resource loading is enabled
void Lock ()
 set locked to true
void Unlock ()
 set locked to false
bool IsLocked () const
 returns true if resource will be used as source for copy process soon
void SetResourceId (const ResourceId &id)
 set the resource identifier
const ResourceIdGetResourceId () const
 get the resource identifier
void SetLoader (const Ptr< ResourceLoader > &loader)
 set optional resource loader
const Ptr< ResourceLoader > & GetLoader () const
 get optional resource loader
void SetSaver (const Ptr< ResourceSaver > &saver)
 set optional resource saver
const Ptr< ResourceSaver > & GetSaver () const
 get optional resource saver
SizeT GetUseCount () const
 get current use count
virtual State Load ()
 load the resource
void SetState (State s)
 set current state (usually only called during Load()!)
State GetState () const
 get current state
bool IsLoaded () const
 return true if current state is Loaded
bool IsPending () const
 return true if current state is Pending
bool LoadFailed () const
 return true if current state is Failed
virtual bool Save ()
 save the resource
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Static Public Member Functions

static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

Protected Member Functions

void SetType (Type t)
 set texture type
void SetWidth (SizeT w)
 set texture width
void SetHeight (SizeT h)
 set texture height
void SetDepth (SizeT d)
 set texture depth
void SetNumMipLevels (SizeT n)
 set number of mip levels
void SetPixelFormat (CoreGraphics::PixelFormat::Code f)
 set pixel format
void IncrUseCount ()
 increment use count
void DecrUseCount ()
 decrement use count

Member Function Documentation

void Direct3D9::D3D9Texture::SetupFromD3D9Texture ( IDirect3DTexture9 *  tex2D,
const bool  setLoaded = true 
)

setup from a IDirect3DTexture9

Helper method to setup the texture object from a D3D9 2D texture.

void Direct3D9::D3D9Texture::SetupFromD3D9CubeTexture ( IDirect3DCubeTexture9 *  texCube,
const bool  setLoaded = true 
)

setup from a IDirect3DCubeTexture

Helper method to setup the texture object from a D3D9 cube texture.

void Direct3D9::D3D9Texture::SetupFromD3D9VolumeTexture ( IDirect3DVolumeTexture9 *  texVolume,
const bool  setLoaded = true 
)

setup from a IDirect3DVolumeTexture

Helper method to setup the texture object from a D3D9 volume texture.

Resource::State Resources::Resource::Load (  )  [virtual, inherited]

load the resource

This loads the resource through the attached resource loader. Depending on the resource loader, the resource may happen synchronously or asynchronously. If the resource is loaded asynchronously, the IsPending() method will return true as long as the load is in progress, and IsLoaded() will become true when the loading process has finished. If the load has failed, IsPending() will switch to false and IsLoaded() will not be true.

bool Resources::Resource::Save (  )  [virtual, inherited]

save the resource

This will save the resource. A resource saver must be attached to the resource and the resource must be loaded for the method to succeed. Saving will always be performed synchronously.

int Core::RefCounted::GetRefCount (  )  const [inline, inherited]

get the current refcount

Return the current refcount of the object.

void Core::RefCounted::AddRef (  )  [inline, inherited]

increment refcount by one

Increment the refcount of the object.

void Core::RefCounted::Release (  )  [inline, inherited]

decrement refcount and destroy object if refcount is zero

Decrement the refcount and destroy object if refcount is zero.

const Util::String & Core::RefCounted::GetClassName (  )  const [inline, inherited]

get the class name

Get the class name of the object.

Util::FourCC Core::RefCounted::GetClassFourCC (  )  const [inline, inherited]

get the class FourCC code

Get the class FourCC of the object.

void Core::RefCounted::DumpRefCountingLeaks (  )  [static, inherited]

dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

This method should be called as the very last before an application exits.