My Project
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
CD3DApplication Class Reference

A base class for creating D3D device based application. More...

#include <d3dapp.h>

Inheritance diagram for CD3DApplication:
ParaEngine::CParaEngineApp

Public Member Functions

virtual void Pause (bool bPause)
 
virtual bool IsPaused ()
 
HRESULT PresentScene ()
 force present the scene. More...
 
void EnablePassiveRendering (bool bEnable)
 
bool IsPassiveRenderingEnabled ()
 
void Enable3DRendering (bool bEnable)
 disable 3D rendering, do not present the scene. More...
 
bool Is3DRenderingEnabled ()
 whether 3D rendering is enabled, do not present the scene. More...
 
void SetRefreshTimer (float fTimeInterval, int nFrameRateControl=0)
 Set the frame rate timer interval. More...
 
float GetRefreshTimer () const
 get the refresh timer.
 
virtual HRESULT Create ()
 
virtual HRESULT CreateFromD3D9Device (IDirect3DDevice9 *pD3dDevice, IDirect3DSwapChain9 *apSwapChain)
 
virtual int Run (HINSTANCE hInstance)
 
ParaEngine::PEAppState GetAppState ()
 
void SetAppState (ParaEngine::PEAppState state)
 
bool IsExternalD3DDevice ()
 whether the d3d device is managed externally
 

Protected Member Functions

HRESULT DisplayErrorMsg (HRESULT hr, DWORD dwType)
 
bool FindBestWindowedMode (bool bRequireHAL, bool bRequireREF)
 
bool FindBestFullscreenMode (bool bRequireHAL, bool bRequireREF)
 
HRESULT LaunchReadme ()
 
HRESULT ChooseInitialD3DSettings ()
 
HRESULT Initialize3DEnvironment ()
 
HRESULT HandlePossibleSizeChange (bool bUpdateSizeOnly=false)
 this function is called whenever the main window size changes. More...
 
HRESULT Reset3DEnvironment ()
 
HRESULT ToggleFullscreen ()
 
HRESULT ForceWindowed ()
 
HRESULT UserSelectNewDevice ()
 
void Cleanup3DEnvironment ()
 
HRESULT Render3DEnvironment (bool bForceRender=false)
 frame move and render More...
 
virtual void BuildPresentParamsFromSettings ()
 
virtual HRESULT AdjustWindowForChange ()
 
virtual void UpdateStats ()
 
virtual HRESULT ConfirmDevice (D3DCAPS9 *, DWORD, D3DFORMAT, D3DFORMAT)
 
virtual HRESULT OneTimeSceneInit ()
 
virtual HRESULT InitDeviceObjects ()
 
virtual HRESULT RestoreDeviceObjects ()
 
virtual HRESULT FrameMove ()
 
virtual HRESULT Render ()
 
virtual HRESULT InvalidateDeviceObjects ()
 
virtual HRESULT DeleteDeviceObjects ()
 
virtual HRESULT FinalCleanup ()
 
virtual bool UpdateViewPort ()
 update view port by backbuffer size. More...
 
virtual HRESULT DoWork ()
 this function is called per frame, in most cases, it will render the 3d scene and frame move. More...
 

Static Protected Member Functions

static bool ConfirmDeviceHelper (D3DCAPS9 *pCaps, VertexProcessingType vertexProcessingType, D3DFORMAT adapterFormat, D3DFORMAT backBufferFormat)
 

Protected Attributes

CD3DEnumeration m_d3dEnumeration
 
CD3DSettings m_d3dSettings
 
bool m_bWindowed
 
bool m_bActive
 
bool m_bDeviceLost
 
bool m_bMinimized
 
bool m_bMaximized
 
bool m_bIgnoreSizeChange
 
bool m_bDeviceObjectsInited
 
bool m_bDeviceObjectsRestored
 
bool m_bFrameMoving
 
bool m_bSingleStep
 
bool m_bDisableD3D
 if this is true, the directX is not needed to run the application. More...
 
bool m_bPassiveRendering
 passive rendering, it will not render the scene, but simulation and time remains the same. Default is false
 
bool m_bEnable3DRendering
 whether to render 3d scene and present to screen.
 
D3DPRESENT_PARAMETERS m_d3dpp
 
HWND m_hWnd
 
HWND m_hWndFocus
 
HMENU m_hMenu
 
LPDIRECT3D9 m_pD3D
 
LPDIRECT3DDEVICE9 m_pd3dDevice
 
IDirect3DSwapChain9 * m_pd3dSwapChain
 
D3DCAPS9 m_d3dCaps
 
D3DSURFACE_DESC m_d3dsdBackBuffer
 
DWORD m_dwCreateFlags
 
DWORD m_dwWindowStyle
 
RECT m_rcWindowBounds
 
RECT m_rcWindowClient
 
int m_nClientWidth
 
int m_nClientHeight
 
double m_fTime
 
double m_fElapsedTime
 
FLOAT m_fFPS
 
TCHAR m_strDeviceStats [90]
 
TCHAR m_strFrameStats [90]
 
float m_fRefreshTimerInterval
 
int m_nFrameRateControl
 
TCHAR * m_strWindowTitle
 
DWORD m_dwCreationWidth
 
DWORD m_dwCreationHeight
 
bool m_bShowCursorWhenFullscreen
 
bool m_bClipCursorWhenFullscreen
 
bool m_bStartFullscreen
 
bool m_bCreateMultithreadDevice
 
bool m_bAllowDialogBoxMode
 
bool m_bIsExternalWindow
 whether the main rendering window is an externally provided window or not. More...
 
bool m_bIsExternalD3DDevice
 
ParaEngine::PEAppState m_nAppState
 application state
 

Detailed Description

A base class for creating D3D device based application.

Member Function Documentation

§ DoWork()

HRESULT CD3DApplication::DoWork ( )
protectedvirtual

this function is called per frame, in most cases, it will render the 3d scene and frame move.

call this as often as one like internally it will use a timer to best fit the interval.

Reimplemented in ParaEngine::CParaEngineApp, ParaEngine::CParaEngineApp, and ParaEngine::CParaEngineApp.

§ Enable3DRendering()

void CD3DApplication::Enable3DRendering ( bool  bEnable)
inline

disable 3D rendering, do not present the scene.

This is usually called before and after we show a standard win32 window during full screen mode, such as displaying a flash window

Parameters
bEnabletrue to enable.

§ HandlePossibleSizeChange()

HRESULT CD3DApplication::HandlePossibleSizeChange ( bool  bUpdateSizeOnly = false)
protected

this function is called whenever the main window size changes.

It may need to adjust/strech the d3d devices and coordinate systems.

Parameters
bUpdateSizeOnlyif true, we will only update the d3d device.

§ Is3DRenderingEnabled()

bool CD3DApplication::Is3DRenderingEnabled ( )
inline

whether 3D rendering is enabled, do not present the scene.

This is usually called before and after we show a standard win32 window during full screen mode, such as displaying a flash window

§ PresentScene()

HRESULT CD3DApplication::PresentScene ( )

force present the scene.

§ Render3DEnvironment()

HRESULT CD3DApplication::Render3DEnvironment ( bool  bForceRender = false)
protected

frame move and render

Parameters
bForceRenderif true, it will force frame move and render the scene. if not, it will internally use a frame rate controller that maintain the frame rate at 30 fps, no matter who often this function is called.

§ SetRefreshTimer()

void CD3DApplication::SetRefreshTimer ( float  fTimeInterval,
int  nFrameRateControl = 0 
)

Set the frame rate timer interval.

Parameters
fTimeIntervalvalue in seconds. such as 0.033f or 0.01667f Passing a value <= 0 to render in idle time.
nFrameRateControl0 for real time, 1 for ideal frame rate at 30 FPS no matter whatever time interval is set.

§ UpdateViewPort()

bool CD3DApplication::UpdateViewPort ( )
protectedvirtual

update view port by backbuffer size.

Member Data Documentation

§ m_bDisableD3D

bool CD3DApplication::m_bDisableD3D
protected

if this is true, the directX is not needed to run the application.

this is useful for server mode application. by default, it is false.

§ m_bIsExternalWindow

bool CD3DApplication::m_bIsExternalWindow
protected

whether the main rendering window is an externally provided window or not.

This will be true if SetMainWindow() is called.


The documentation for this class was generated from the following files: