Public Member Functions

xl7::direct3d::RenderDevice Class Reference

#include <RenderDevice.h>

List of all members.

Public Member Functions

IDirect3DDevice9 * GetInterface ()
const IDirect3DDevice9 * GetInterface () const
const D3DADAPTER_IDENTIFIER9 & GetAdapterIdentifier () const
const D3DPRESENT_PARAMETERS & GetParams () const
const D3DCAPS9 & GetCaps () const
bool GetShaderSupport () const
StateMachineGetStateMachine () const
D3DFORMAT GetBackBufferFormat () const
D3DFORMAT GetDepthStencilFormat () const
const SIZE & GetBackBufferSize () const
const SIZE & GetWindowSize () const
float GetBackBufferAspect () const
float GetWindowAspect () const
bool IsDeviceLost () const
bool IsSceneOn () const
IDirect3DSurface9 * GetStandardBackBufferSurface ()
IDirect3DSurface9 * GetStandardZBufferSurface ()
textures::TextureManagerGetTextureManager ()
surfaces::SurfaceManagerGetSurfaceManager ()
meshes::MeshManagerGetMeshManager ()
models::ModelManagerGetModelManager ()
shader::ShaderManagerGetShaderManager ()
fonts::FontGetSystemFont ()
const D3DCOLOR & GetClearColor () const
float GetClearZValue () const
unsigned long GetClearStencilValue () const
void SetClearColor (const D3DCOLOR &color)
void SetClearZValue (float z_value)
void SetClearStencilValue (unsigned long stencil_value)
void SimulateLostDevice ()
bool CaptureCurrentState ()
bool ResetCurrentState ()
const ml7::Matrix4x4GetWorldTransform () const
const ml7::Matrix4x4GetViewTransform () const
const ml7::Matrix4x4GetProjectionTransform () const
const D3DVIEWPORT9 & GetViewport () const
IDirect3DSurface9 * GetColorRenderTarget () const
IDirect3DSurface9 * GetColorRenderTarget (unsigned index) const
IDirect3DSurface9 * GetDepthStencilTarget () const
unsigned long GetFVF () const
unsigned long GetRenderState (D3DRENDERSTATETYPE rst) const
unsigned long GetTextureState (unsigned stage, D3DTEXTURESTAGESTATETYPE tss) const
unsigned long GetSamplerState (unsigned stage, D3DSAMPLERSTATETYPE ss) const
float GetRenderStateF (D3DRENDERSTATETYPE rst) const
float GetTextureStateF (unsigned stage, D3DTEXTURESTAGESTATETYPE tss) const
float GetSamplerStateF (unsigned stage, D3DSAMPLERSTATETYPE ss) const
IDirect3DBaseTexture9 * GetTexture (unsigned stage) const
const D3DMATERIAL9 & GetMaterial () const
IDirect3DVertexBuffer9 * GetVertices () const
IDirect3DVertexBuffer9 * GetVertices (unsigned index) const
IDirect3DIndexBuffer9 * GetIndices () const
IDirect3DVertexShader9 * GetVertexShader () const
IDirect3DPixelShader9 * GetPixelShader () const
IDirect3DVertexDeclaration9 * GetVertexDeclaration () const
bool SetWorldTransform (const ml7::Matrix4x4 &world)
bool SetViewTransform (const ml7::Matrix4x4 &view)
bool SetProjectionTransform (const ml7::Matrix4x4 &projection)
bool SetViewport (const D3DVIEWPORT9 &viewport)
bool SetColorRenderTarget (IDirect3DSurface9 *color_render_target)
bool SetColorRenderTarget (unsigned index, IDirect3DSurface9 *color_render_target)
bool SetDepthStencilTarget (IDirect3DSurface9 *depth_stencil_target)
bool SetFVF (unsigned long fvf)
bool SetRenderState (D3DRENDERSTATETYPE rst, unsigned long value)
bool SetTextureState (unsigned stage, D3DTEXTURESTAGESTATETYPE tss, unsigned long value)
bool SetSamplerState (unsigned stage, D3DSAMPLERSTATETYPE ss, unsigned long value)
bool SetRenderStateF (D3DRENDERSTATETYPE rst, float value)
bool SetTextureStateF (unsigned stage, D3DTEXTURESTAGESTATETYPE tss, float value)
bool SetSamplerStateF (unsigned stage, D3DSAMPLERSTATETYPE ss, float value)
bool SetTexture (unsigned stage, IDirect3DBaseTexture9 *texture)
bool SetMaterial (const D3DMATERIAL9 &material)
bool SetVertices (IDirect3DVertexBuffer9 *vertices, unsigned stride)
bool SetVertices (unsigned index, IDirect3DVertexBuffer9 *vertices, unsigned stride)
bool SetIndices (IDirect3DIndexBuffer9 *indices)
bool SetVertexShader (IDirect3DVertexShader9 *vertex_shader)
bool SetPixelShader (IDirect3DPixelShader9 *pixel_shader)
bool SetVertexDeclaration (IDirect3DVertexDeclaration9 *vertex_decl)
bool CaptureWindowSize ()
bool BeginScene ()
bool EndScene ()
bool Present ()
bool Clear ()
bool ClearBuffers (D3DCOLOR clear_color, float clear_z_value, unsigned long clear_stencil_value)
bool ClearRenderTarget (D3DCOLOR clear_color)
bool ClearDepthStencil (float clear_z_value, unsigned long clear_stencil_value)
errorcodes::ErrorCode CheckDeviceLost ()
unsigned GetPower2TextureSize (unsigned x) const
bool AdjustTextureSize (unsigned &width, unsigned &height) const
bool TransformWorld2Pixel (const ml7::Vector3 &in_world, ml7::Vector2 *out_pixel) const
bool TransformPixel2World (const ml7::Vector2 &in_pixel, ml7::Vector3 *out_near, ml7::Vector3 *out_far) const
void LogAdapterIdentifier () const

Detailed Description

Class to encapsulate the Direct3D device.


Member Function Documentation

bool xl7::direct3d::RenderDevice::AdjustTextureSize ( unsigned &  width,
unsigned &  height 
) const

Eventually adjusts the given texture width and height, if the given values are not valid with regard to the power of 2 or squared sizes (if required). The function returns true, if the given values are valid or the values could be adjusted to fit the device's requirements (power of 2, squared, etc.). The function returns false, if there are no valid values greater or equal to the given values. In the latter case, you should reduce the values by yourself and retry to adjust them by calling this function again. Attention: The given values may be changed, although the function returns false and thus the resulting values would not be valid.

bool xl7::direct3d::RenderDevice::BeginScene (  ) 

Begins a scene.

bool xl7::direct3d::RenderDevice::CaptureCurrentState (  ) 

Captures the current state from the hardware.

bool xl7::direct3d::RenderDevice::CaptureWindowSize (  ) 

Captures and caches the size of the display window.

errorcodes::ErrorCode xl7::direct3d::RenderDevice::CheckDeviceLost (  ) 

Tests the current cooperative-level status of the Direct3D device. If the device is lost, all Resources will be forced to resign memory. If the device was lost earlier, the device and all resources are checked whether they can be reaquired. If so, they will be. In case of any error code != 0 the application should pause and periodically call this function again.

bool xl7::direct3d::RenderDevice::Clear (  ) 

Clears the buffers (render-target and depth-stencil) with the specified default values.

bool xl7::direct3d::RenderDevice::ClearBuffers ( D3DCOLOR  clear_color,
float  clear_z_value,
unsigned long  clear_stencil_value 
)

Clears the buffers (render-target and depth-stencil) with the given values.

bool xl7::direct3d::RenderDevice::ClearDepthStencil ( float  clear_z_value,
unsigned long  clear_stencil_value 
)

Clears the depth-stencil buffer with the given values.

bool xl7::direct3d::RenderDevice::ClearRenderTarget ( D3DCOLOR  clear_color  ) 

Clears the render-target buffer with the given value.

bool xl7::direct3d::RenderDevice::EndScene (  ) 

Ends a scene that was begun by calling BeginScene.

const D3DADAPTER_IDENTIFIER9& xl7::direct3d::RenderDevice::GetAdapterIdentifier (  )  const [inline]

Returns the structure containing information identifying the adapter.

float xl7::direct3d::RenderDevice::GetBackBufferAspect (  )  const [inline]

Returns the aspect (width/height) of the back buffer.

D3DFORMAT xl7::direct3d::RenderDevice::GetBackBufferFormat (  )  const [inline]

Returns the format of the (standard) back buffer.

const SIZE& xl7::direct3d::RenderDevice::GetBackBufferSize (  )  const [inline]

Returns the size of the (standard) back buffer (in pixels).

const D3DCAPS9& xl7::direct3d::RenderDevice::GetCaps (  )  const [inline]

Returns the capabilities of the hardware.

const D3DCOLOR& xl7::direct3d::RenderDevice::GetClearColor (  )  const [inline]

Returns the ARGB color to clear the color buffer with.

unsigned long xl7::direct3d::RenderDevice::GetClearStencilValue (  )  const [inline]

Returns the value to clear the stencil buffer with (ranges from 0 to 2^(n-1) where n is the bit depth of the stencil buffer).

float xl7::direct3d::RenderDevice::GetClearZValue (  )  const [inline]

Returns the z value to clear the depth buffer with (ranges from 0 to 1).

IDirect3DSurface9 * xl7::direct3d::RenderDevice::GetColorRenderTarget ( unsigned  index  )  const

Returns the current color render target.

IDirect3DSurface9 * xl7::direct3d::RenderDevice::GetColorRenderTarget (  )  const

Returns the current color render target.

D3DFORMAT xl7::direct3d::RenderDevice::GetDepthStencilFormat (  )  const [inline]

Returns the format of the (standard) depth-stencil surface.

IDirect3DSurface9 * xl7::direct3d::RenderDevice::GetDepthStencilTarget (  )  const

Returns the current depth render target.

unsigned long xl7::direct3d::RenderDevice::GetFVF (  )  const

Returns the current flexible vertex format.

IDirect3DIndexBuffer9 * xl7::direct3d::RenderDevice::GetIndices (  )  const

Returns the current index buffer.

const IDirect3DDevice9* xl7::direct3d::RenderDevice::GetInterface (  )  const [inline]

Returns the Direct3D device interface.

IDirect3DDevice9* xl7::direct3d::RenderDevice::GetInterface (  )  [inline]

Returns the Direct3D device interface.

const D3DMATERIAL9 & xl7::direct3d::RenderDevice::GetMaterial (  )  const

Returns the current material.

meshes::MeshManager& xl7::direct3d::RenderDevice::GetMeshManager (  )  [inline]

Returns the mesh manager.

models::ModelManager& xl7::direct3d::RenderDevice::GetModelManager (  )  [inline]

Returns the model manager.

const D3DPRESENT_PARAMETERS& xl7::direct3d::RenderDevice::GetParams (  )  const [inline]

Returns the presentation parameters.

IDirect3DPixelShader9 * xl7::direct3d::RenderDevice::GetPixelShader (  )  const

Returns the current pixel shader.

unsigned xl7::direct3d::RenderDevice::GetPower2TextureSize ( unsigned  x  )  const

Returns the lowest power of 2 value that is equal to or greater than the given value. Use this function to determine texture sizes that are compatible with older graphics cards.

const ml7::Matrix4x4 & xl7::direct3d::RenderDevice::GetProjectionTransform (  )  const

Returns the current projection transform matrix.

unsigned long xl7::direct3d::RenderDevice::GetRenderState ( D3DRENDERSTATETYPE  rst  )  const

Returns the current value of a given render state.

float xl7::direct3d::RenderDevice::GetRenderStateF ( D3DRENDERSTATETYPE  rst  )  const

Returns the current (float) value of a given render state.

unsigned long xl7::direct3d::RenderDevice::GetSamplerState ( unsigned  stage,
D3DSAMPLERSTATETYPE  ss 
) const

Returns the current value of a given sampler state.

float xl7::direct3d::RenderDevice::GetSamplerStateF ( unsigned  stage,
D3DSAMPLERSTATETYPE  ss 
) const

Returns the current (float) value of a given sampler state.

shader::ShaderManager& xl7::direct3d::RenderDevice::GetShaderManager (  )  [inline]

Returns the shader manager.

bool xl7::direct3d::RenderDevice::GetShaderSupport (  )  const [inline]

Returns the flag specifying whether the hardware supports the use of shaders.

IDirect3DSurface9* xl7::direct3d::RenderDevice::GetStandardBackBufferSurface (  )  [inline]

Returns the (standard) back buffer surface.

IDirect3DSurface9* xl7::direct3d::RenderDevice::GetStandardZBufferSurface (  )  [inline]

Returns the (standard) z-buffer surface.

StateMachine* xl7::direct3d::RenderDevice::GetStateMachine (  )  const [inline]

Returns the state machine managing the current state of the device.

surfaces::SurfaceManager& xl7::direct3d::RenderDevice::GetSurfaceManager (  )  [inline]

Returns the surface (render target) manager.

fonts::Font& xl7::direct3d::RenderDevice::GetSystemFont (  )  [inline]

Returns the system font for debug text etc.

IDirect3DBaseTexture9 * xl7::direct3d::RenderDevice::GetTexture ( unsigned  stage  )  const

Returns the current texture of a given stage.

textures::TextureManager& xl7::direct3d::RenderDevice::GetTextureManager (  )  [inline]

Returns the texture manager.

unsigned long xl7::direct3d::RenderDevice::GetTextureState ( unsigned  stage,
D3DTEXTURESTAGESTATETYPE  tss 
) const

Returns the current value of a given texture stage state.

float xl7::direct3d::RenderDevice::GetTextureStateF ( unsigned  stage,
D3DTEXTURESTAGESTATETYPE  tss 
) const

Returns the current (float) value of a given texture stage state.

IDirect3DVertexDeclaration9 * xl7::direct3d::RenderDevice::GetVertexDeclaration (  )  const

Returns the current vertex declaration.

IDirect3DVertexShader9 * xl7::direct3d::RenderDevice::GetVertexShader (  )  const

Returns the current vertex shader.

IDirect3DVertexBuffer9 * xl7::direct3d::RenderDevice::GetVertices (  )  const

Returns the current vertex buffer.

IDirect3DVertexBuffer9 * xl7::direct3d::RenderDevice::GetVertices ( unsigned  index  )  const

Returns the current vertex buffer.

const D3DVIEWPORT9 & xl7::direct3d::RenderDevice::GetViewport (  )  const

Returns the current viewport.

const ml7::Matrix4x4 & xl7::direct3d::RenderDevice::GetViewTransform (  )  const

Returns the current view transform matrix.

float xl7::direct3d::RenderDevice::GetWindowAspect (  )  const [inline]

Returns the aspect (width/height) of the display window.

const SIZE& xl7::direct3d::RenderDevice::GetWindowSize (  )  const [inline]

Returns the size of the display window (in pixels).

const ml7::Matrix4x4 & xl7::direct3d::RenderDevice::GetWorldTransform (  )  const

Returns the current world transform matrix.

bool xl7::direct3d::RenderDevice::IsDeviceLost (  )  const [inline]

Returns the flag specifying if the device was lost due to a task switch or something.

bool xl7::direct3d::RenderDevice::IsSceneOn (  )  const [inline]

Returns the flag specifying if the function BeginScene has been called without a following call to EndScene.

void xl7::direct3d::RenderDevice::LogAdapterIdentifier (  )  const

Logs some stuff of the adapter identifier to the standard logger.

bool xl7::direct3d::RenderDevice::Present (  ) 

Presents the contents of the back buffer.

bool xl7::direct3d::RenderDevice::ResetCurrentState (  ) 

Resets the current state to initial values and writes it to the hardware.

void xl7::direct3d::RenderDevice::SetClearColor ( const D3DCOLOR &  color  )  [inline]

Sets the ARGB color to clear the color buffer with.

void xl7::direct3d::RenderDevice::SetClearStencilValue ( unsigned long  stencil_value  )  [inline]

Sets the value to clear the stencil buffer with (ranges from 0 to 2^(n-1) where n is the bit depth of the stencil buffer).

void xl7::direct3d::RenderDevice::SetClearZValue ( float  z_value  )  [inline]

Sets the z value to clear the depth buffer with (ranges from 0 to 1).

bool xl7::direct3d::RenderDevice::SetColorRenderTarget ( IDirect3DSurface9 *  color_render_target  ) 

Sets the current color render target.

bool xl7::direct3d::RenderDevice::SetColorRenderTarget ( unsigned  index,
IDirect3DSurface9 *  color_render_target 
)

Sets the current color render target.

bool xl7::direct3d::RenderDevice::SetDepthStencilTarget ( IDirect3DSurface9 *  depth_stencil_target  ) 

Sets the current depth render target.

bool xl7::direct3d::RenderDevice::SetFVF ( unsigned long  fvf  ) 

Sets the current flexible vertex format.

bool xl7::direct3d::RenderDevice::SetIndices ( IDirect3DIndexBuffer9 *  indices  ) 

Sets the current index buffer.

bool xl7::direct3d::RenderDevice::SetMaterial ( const D3DMATERIAL9 &  material  ) 

Sets the current material.

bool xl7::direct3d::RenderDevice::SetPixelShader ( IDirect3DPixelShader9 *  pixel_shader  ) 

Sets the current pixel shader.

bool xl7::direct3d::RenderDevice::SetProjectionTransform ( const ml7::Matrix4x4 projection  ) 

Sets the current projection transform matrix.

bool xl7::direct3d::RenderDevice::SetRenderState ( D3DRENDERSTATETYPE  rst,
unsigned long  value 
)

Sets the current value of a given render state.

bool xl7::direct3d::RenderDevice::SetRenderStateF ( D3DRENDERSTATETYPE  rst,
float  value 
)

Sets the current (float) value of a given render state.

bool xl7::direct3d::RenderDevice::SetSamplerState ( unsigned  stage,
D3DSAMPLERSTATETYPE  ss,
unsigned long  value 
)

Sets the current value of a given sampler state.

bool xl7::direct3d::RenderDevice::SetSamplerStateF ( unsigned  stage,
D3DSAMPLERSTATETYPE  ss,
float  value 
)

Sets the current (float) value of a given sampler state.

bool xl7::direct3d::RenderDevice::SetTexture ( unsigned  stage,
IDirect3DBaseTexture9 *  texture 
)

Sets the current texture of a given stage.

bool xl7::direct3d::RenderDevice::SetTextureState ( unsigned  stage,
D3DTEXTURESTAGESTATETYPE  tss,
unsigned long  value 
)

Sets the current value of a given texture stage state.

bool xl7::direct3d::RenderDevice::SetTextureStateF ( unsigned  stage,
D3DTEXTURESTAGESTATETYPE  tss,
float  value 
)

Sets the current (float) value of a given texture stage state.

bool xl7::direct3d::RenderDevice::SetVertexDeclaration ( IDirect3DVertexDeclaration9 *  vertex_decl  ) 

Sets the current vertex declaration.

bool xl7::direct3d::RenderDevice::SetVertexShader ( IDirect3DVertexShader9 *  vertex_shader  ) 

Sets the current vertex shader.

bool xl7::direct3d::RenderDevice::SetVertices ( unsigned  index,
IDirect3DVertexBuffer9 *  vertices,
unsigned  stride 
)

Sets the current vertex buffer.

bool xl7::direct3d::RenderDevice::SetVertices ( IDirect3DVertexBuffer9 *  vertices,
unsigned  stride 
)

Sets the current vertex buffer.

bool xl7::direct3d::RenderDevice::SetViewport ( const D3DVIEWPORT9 &  viewport  ) 

Sets the current viewport.

bool xl7::direct3d::RenderDevice::SetViewTransform ( const ml7::Matrix4x4 view  ) 

Sets the current view transform matrix.

bool xl7::direct3d::RenderDevice::SetWorldTransform ( const ml7::Matrix4x4 world  ) 

Sets the current world transform matrix.

void xl7::direct3d::RenderDevice::SimulateLostDevice (  )  [inline]

Sets the flag specifying whether to simulate the case of a lost device.

bool xl7::direct3d::RenderDevice::TransformPixel2World ( const ml7::Vector2 in_pixel,
ml7::Vector3 out_near,
ml7::Vector3 out_far 
) const

Transforms the given 2d-pixel-position in viewport-space into the corresponding line segment indicating the possible 3d-positions in world-space. Therefore, the currently set view and projection matrices are used to transform the input vector. If the 2d-input-vector is located inside the currently set viewport bounds, the function returns true, else otherwise. To transform a 2d-pixel-position into object-space, you have to transform the resulting (possible) 3d-position(s) in world-space into object-space coordinates later, by yourself.

bool xl7::direct3d::RenderDevice::TransformWorld2Pixel ( const ml7::Vector3 in_world,
ml7::Vector2 out_pixel 
) const

Transforms the given 3d-position in world-space into the corresponding 2d-pixel-position in viewport-space. Therefore, the currently set view and projection matrices are used to transform the input vector. The resulting 2d-vector then gets checked against the currently set viewport bounds. If the 3d-vector is located inside the view frustum (and thus the 2d-vector is located inside the viewport bounds), the function returns true, else otherwise. To transform a 3d-position in object-space into 2d-viewport-space, you have to transform it into world-space coordinates first, by yourself.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines