www.pudn.com > zfxcengine-0.1.0.zip > ceRenderDevice_D3D9.cpp
#include "Core/ceExceptions.h"
#include "Render/RenderD3D9/ceWindowWin32.h"
#include "Render/RenderD3D9/ceRenderDevice_D3D9.h"
#include "Core/ceMemManager.h"
namespace ZFXCE {
namespace Render {
ceRenderDeviceD3D9::ceRenderDeviceD3D9(void):m_pD3D(NULL),m_pD3DDevice(NULL),m_pDeviceCaps(NULL),
m_pTextureManager(NULL)
{
PUSH_FUNCTION;
m_Window = NULL;
m_pD3DDevice = NULL;
// Direct3D initialisieren
m_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
if(!m_pD3D)
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Objekt erstellen!", CELS_HARDERROR);
}
////////////////////////////////////////////////////////////////////////////////////////
ceRenderDeviceD3D9::~ceRenderDeviceD3D9(void)
{
PUSH_FUNCTION;
Release();
}
////////////////////////////////////////////////////////////////////////////////////////
std::vector ceRenderDeviceD3D9::GetDepthStencilFormat(int iZBuffer, int iStencil)
{
PUSH_FUNCTION;
std::vector fmts;
if (0 != iStencil && 24 != iZBuffer && 15 != iZBuffer)
return fmts;
if (8 == iStencil)
{
fmts.push_back(D3DFMT_D24S8);
fmts.push_back(D3DFMT_D24FS8);
}
if (4 == iStencil)
fmts.push_back(D3DFMT_D24X4S4);
if (1 == iStencil)
fmts.push_back(D3DFMT_D15S1);
if (32 == iZBuffer)
fmts.push_back(D3DFMT_D32);
if (32 == iZBuffer)
{
fmts.push_back(D3DFMT_D32);
fmts.push_back(D3DFMT_D32F_LOCKABLE);
}
if (24 == iZBuffer)
{
fmts.push_back(D3DFMT_D24S8);
fmts.push_back(D3DFMT_D24X8);
fmts.push_back(D3DFMT_D24X4S4);
fmts.push_back(D3DFMT_D24FS8);
}
if (16 == iZBuffer)
{
fmts.push_back(D3DFMT_D16);
fmts.push_back(D3DFMT_D16_LOCKABLE);
}
if (15 == iZBuffer)
fmts.push_back(D3DFMT_D15S1);
return fmts;
}
////////////////////////////////////////////////////////////////////////////////////////
std::vector ceRenderDeviceD3D9::GetBackBufferFormat(int iFmt)
{
PUSH_FUNCTION;
std::vector fmts;
if (32 == iFmt)
{
fmts.push_back(D3DFMT_A8R8G8B8);
fmts.push_back(D3DFMT_X8R8G8B8);
fmts.push_back(D3DFMT_A2R10G10B10);
}
else if (24 == iFmt)
{
fmts.push_back(D3DFMT_R8G8B8);
}
else if (16 == iFmt)
{
fmts.push_back(D3DFMT_A1R5G5B5);
fmts.push_back(D3DFMT_X1R5G5B5);
fmts.push_back(D3DFMT_A4R4G4B4);
fmts.push_back(D3DFMT_R5G6B5);
}
return fmts;
}
////////////////////////////////////////////////////////////////////////////////////////
bool ceRenderDeviceD3D9::TestScreenMode(const ceScreenMode &ScreenMode, ceWindowWin32::SD3DProperty *d3dProp)
{
PUSH_FUNCTION;
unsigned int i,u;
const D3DMULTISAMPLE_TYPE sMultisampleTypes[] =
{
D3DMULTISAMPLE_16_SAMPLES,
D3DMULTISAMPLE_15_SAMPLES,
D3DMULTISAMPLE_14_SAMPLES,
D3DMULTISAMPLE_13_SAMPLES,
D3DMULTISAMPLE_12_SAMPLES,
D3DMULTISAMPLE_11_SAMPLES,
D3DMULTISAMPLE_10_SAMPLES,
D3DMULTISAMPLE_9_SAMPLES,
D3DMULTISAMPLE_8_SAMPLES,
D3DMULTISAMPLE_7_SAMPLES,
D3DMULTISAMPLE_6_SAMPLES,
D3DMULTISAMPLE_5_SAMPLES,
D3DMULTISAMPLE_4_SAMPLES,
D3DMULTISAMPLE_3_SAMPLES,
D3DMULTISAMPLE_2_SAMPLES,
D3DMULTISAMPLE_NONMASKABLE,
D3DMULTISAMPLE_NONE,
};
const UINT sNumMultisampleTypes = sizeof(sMultisampleTypes) / sizeof(sMultisampleTypes[0]);
D3DDISPLAYMODE d3dDisplayMode;
unsigned int uiFSAA;
std::vector BackBufferFmt, DepthStencilFmt;
DepthStencilFmt = GetDepthStencilFormat(ScreenMode.m_uiDepthbuffer, ScreenMode.m_uiStencilBuffer);
BackBufferFmt = GetBackBufferFormat(ScreenMode.m_uiColorBuffer);
D3DFORMAT fmtAdapter;
for (i=0; iGetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3dDisplayMode) ) )
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3DDISPLAYMODE holen!", CELS_HARDERROR);
fmtAdapter = d3dDisplayMode.Format;
}
if (SUCCEEDED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, fmtAdapter, BackBufferFmt[i],
!ScreenMode.m_bFullscreen)))
{
if (SUCCEEDED(m_pD3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, fmtAdapter,
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, DepthStencilFmt[u])))
{
if (SUCCEEDED(m_pD3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, fmtAdapter,
BackBufferFmt[i], DepthStencilFmt[u])))
{
// Nun Multisampling prüfen.
if (16 < ScreenMode.m_uiFSAA)
uiFSAA = 0;
else
uiFSAA = 16 - ScreenMode.m_uiFSAA;
DWORD msQuality;
for( uiFSAA; uiFSAA < sNumMultisampleTypes; uiFSAA++ )
{
if (SUCCEEDED(m_pD3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
BackBufferFmt[i], !ScreenMode.m_bFullscreen, sMultisampleTypes[uiFSAA], &msQuality) &&
SUCCEEDED(m_pD3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
DepthStencilFmt[i], !ScreenMode.m_bFullscreen, sMultisampleTypes[uiFSAA], &msQuality))))
{
d3dProp->fmtAdapter = fmtAdapter;
d3dProp->fmtBackbuffer = BackBufferFmt[i];
d3dProp->fmtDepthStencil = DepthStencilFmt[i];
d3dProp->Multisample = sMultisampleTypes[uiFSAA];
d3dProp->msQuality = msQuality;
return true;
}
}
}
}
}
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::Create(void)
{
PUSH_FUNCTION;
if(!m_Window)
{
CE_EXCEPTION(std::string(__FUNCTION__)+": Keine Fenster! Vorher muss ein Fenster erstellt worden sein!",CELS_ERROR);
return;
}
if (m_pD3DDevice)
CE_EXCEPTION(std::string(__FUNCTION__)+": Direct3D Device wurde bereits erstellt!",CELS_ERROR);
ceWindowProperty WinProp = m_Window->GetWindowProperty();
ceScreenMode ScreeMode = WinProp.m_ScreenMode;
ceWindowWin32::SD3DProperty D3DProp = m_Window->GetD3DProperty();
// Behaviour herausfinden
D3DCAPS9 D3DCaps;
if(FAILED(m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCaps) ) )
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte keine DeviceCaps holen", CELS_HARDERROR);
DWORD dwBehaviourFlags = 0;
if(D3DCaps.VertexProcessingCaps != FALSE)
dwBehaviourFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
else
dwBehaviourFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
// Presentparameters erstellen
D3DPRESENT_PARAMETERS PresentParms;
ZeroMemory(&PresentParms, sizeof(D3DPRESENT_PARAMETERS));
PresentParms.hDeviceWindow = GetForegroundWindow();
PresentParms.BackBufferHeight = ScreeMode.m_uiHeight;
PresentParms.BackBufferWidth = ScreeMode.m_uiWidth;
PresentParms.BackBufferCount = 1;
PresentParms.SwapEffect = D3DSWAPEFFECT_DISCARD;
PresentParms.BackBufferFormat = D3DProp.fmtBackbuffer;
PresentParms.EnableAutoDepthStencil = TRUE;
PresentParms.AutoDepthStencilFormat = D3DProp.fmtDepthStencil;
PresentParms.Windowed = !ScreeMode.m_bFullscreen;
// PresentParms.MultiSampleQuality = D3DProp.msQuality;
PresentParms.MultiSampleType = D3DProp.Multisample;
if (WinProp.m_bVSync)
PresentParms.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
else
PresentParms.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
HRESULT hr = m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetForegroundWindow(),
dwBehaviourFlags, &PresentParms, &m_pD3DDevice);
if(hr != D3D_OK)
{
switch(hr)
{
case D3DERR_DEVICELOST:
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Device erstellen: "+std::string("The device has been lost but cannot be reset at this time. Therefore, rendering is not possible."),
CELS_HARDERROR);
break;
case D3DERR_INVALIDCALL:
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Device erstellen: "+std::string("The method call is invalid. For example, a method's parameter may have an invalid value."),
CELS_HARDERROR);
break;
case D3DERR_NOTAVAILABLE:
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Device erstellen: "+std::string("This device does not support the queried technique."),
CELS_HARDERROR);
break;
case D3DERR_OUTOFVIDEOMEMORY:
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Device erstellen: "+std::string("Direct3D does not have enough display memory to perform the operation."),
CELS_HARDERROR);
break;
default:
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Device erstellen: "+std::string("Unbekannter Fehler!"),
CELS_HARDERROR);
break;
}
}
m_pDeviceCaps = new ceDeviceCapsD3D9(m_pD3DDevice);
m_pTextureManager = new ceTextureManagerD3D9(m_pD3DDevice);
m_pRenderObjectFactory = new ceRenderObjectFactoryD3D9(m_pD3DDevice);
m_pRenderQueue = new ceRenderQueueD3D9(m_pD3DDevice, m_pRenderObjectFactory, m_pTextureManager);
m_ClearColor = D3DCOLOR_RGBA(0, 0, 0, 255);
assert(m_pDeviceCaps != NULL);
assert(m_pTextureManager != NULL);
assert(m_pRenderObjectFactory != NULL);
assert(m_pRenderQueue != NULL);
// wir müssen die Funktion hier aufrufen, da beim ersten Aufruf (CreateNewWindow)
// noch kein D3D Device erstellt ist und SetupAPI() springt dann zurück.
SetupAPI(m_Window->GetWidth(), m_Window->GetHeight() );
/*
D3DDISPLAYMODE DisplayMode;
if( FAILED(m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &DisplayMode) ) )
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3DDISPLAYMODE holen!", CELS_HARDERROR);
HRESULT hr;
if(FAILED(hr = m_pD3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DisplayMode.Format, D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE,D3DFMT_D16) ) )
{
if(hr == D3DERR_NOTAVAILABLE)
CE_EXCEPTION(std::string(__FUNCTION__)+": Brauche mindestens 16Bit DepthBuffer!", CELS_HARDERROR);
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein Format checken", CELS_HARDERROR);
}
D3DCAPS9 D3DCaps;
if(FAILED(m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCaps) ) )
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte keine DeviceCaps holen", CELS_HARDERROR);
UINT BehaviourFlags = 0;
if(D3DCaps.VertexProcessingCaps != FALSE)
BehaviourFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
else
BehaviourFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
D3DPRESENT_PARAMETERS PresentParms;
ZeroMemory(&PresentParms, sizeof(D3DPRESENT_PARAMETERS));
PresentParms.hDeviceWindow = GetForegroundWindow();
PresentParms.BackBufferHeight = m_Window->GetHeight();
PresentParms.BackBufferWidth = m_Window->GetWidth();
PresentParms.BackBufferCount = 1;
PresentParms.SwapEffect = D3DSWAPEFFECT_DISCARD;
PresentParms.BackBufferFormat = DisplayMode.Format;
PresentParms.EnableAutoDepthStencil = TRUE;
PresentParms.AutoDepthStencilFormat = D3DFMT_D16;
PresentParms.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
PresentParms.Windowed = TRUE;
m_pD3DDevice = NULL;
hr = m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetForegroundWindow(),
BehaviourFlags, &PresentParms, &m_pD3DDevice);
if(hr != D3D_OK)
{
switch(hr)
{
case D3DERR_DEVICELOST:
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Device erstellen: "+std::string("The device has been lost but cannot be reset at this time. Therefore, rendering is not possible."),
CELS_HARDERROR);
break;
case D3DERR_INVALIDCALL:
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Device erstellen: "+std::string("The method call is invalid. For example, a method's parameter may have an invalid value."),
CELS_HARDERROR);
break;
case D3DERR_NOTAVAILABLE:
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Device erstellen: "+std::string("This device does not support the queried technique."),
CELS_HARDERROR);
break;
case D3DERR_OUTOFVIDEOMEMORY:
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Device erstellen: "+std::string("Direct3D does not have enough display memory to perform the operation."),
CELS_HARDERROR);
break;
default:
CE_EXCEPTION(std::string(__FUNCTION__)+": Konnte kein D3D Device erstellen: "+std::string("Unbekannter Fehler!"),
CELS_HARDERROR);
break;
}
}
m_pDeviceCaps = new ceDeviceCapsD3D9(m_pD3DDevice);
m_pTextureManager = new ceTextureManagerD3D9(m_pD3DDevice);
m_pRenderObjectFactory = new ceRenderObjectFactoryD3D9(m_pD3DDevice);
m_pRenderQueue = new ceRenderQueueD3D9(m_pD3DDevice, m_pRenderObjectFactory, m_pTextureManager);
m_ClearColor = D3DCOLOR_RGBA(0, 0, 0, 255);
assert(m_pDeviceCaps != NULL);
assert(m_pTextureManager != NULL);
assert(m_pRenderObjectFactory != NULL);
assert(m_pRenderQueue != NULL);
// wir müssen die Funktion hier aufrufen, da beim ersten Aufruf (CreateNewWindow)
// noch kein D3D Device erstellt ist und SetupAPI() springt dann zurück.
SetupAPI(m_Window->GetWidth(), m_Window->GetHeight() );
/**/
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::Release(void)
{
PUSH_FUNCTION;
delete m_pD3DDevice;
m_pDeviceCaps = NULL;
delete m_pTextureManager;
m_pTextureManager = NULL;
delete m_pRenderObjectFactory;
m_pRenderObjectFactory = NULL;
delete m_pRenderQueue;
m_pRenderQueue = NULL;
/*
for(UINT w=0; w < m_vWindows.size(); w++)
{
delete m_vWindows[w];
}
m_vWindows.clear();
*/
delete m_Window;
if (m_pD3DDevice)
{
m_pD3DDevice->Release();
m_pD3DDevice = NULL;
}
m_pD3D->Release();
m_pD3D = NULL;
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::Reset(void)
{
PUSH_FUNCTION;
Release();
Create();
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::AddWindow(ceWindow* Window)
{
PUSH_FUNCTION;
m_Window = (ceWindowWin32*) Window;
//m_vWindows.push_back( (ceWindowWin32*) Window);
}
////////////////////////////////////////////////////////////////////////////////////////
// Suggested behaviour on failure:
// Create a window with 1280x1024,32Bit Colorbuffer, 24Depth Buffer and 6xFSAA
// Window cant be created ==> disable FSAA and try again ==> if fails, lower
// depth buffer to 16 ==> if fails, lower depth buffer to 16 ==> if fails: Exception
ceWindow* ceRenderDeviceD3D9::CreateNewWindow(ceWindowProperty* pWinProp, std::string Title)
{
PUSH_FUNCTION;
if(m_Window != NULL)
delete m_Window;
m_Window = NULL;
ceWindowWin32::SD3DProperty d3dProp;
if (!TestScreenMode(pWinProp->m_ScreenMode, &d3dProp))
{
pWinProp->m_ScreenMode.m_uiColorBuffer = 32;
pWinProp->m_ScreenMode.m_uiDepthbuffer = 24;
if (!TestScreenMode(pWinProp->m_ScreenMode, &d3dProp))
{
pWinProp->m_ScreenMode.m_uiColorBuffer = 16;
pWinProp->m_ScreenMode.m_uiDepthbuffer = 16;
if (!TestScreenMode(pWinProp->m_ScreenMode, &d3dProp))
{
std::cout << "Windowproperty invalid" << std::endl;
return NULL;
}
}
}
m_Window = new ceWindowWin32();
m_Window->Create(pWinProp);
m_Window->SaveD3DProperty(d3dProp);
m_Window->SetTitle(Title);
SetupAPI(m_Window->GetWidth(), m_Window->GetHeight() );
//m_vWindows.push_back(Win);
return m_Window;
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::DeleteWindow(ceWindow* Win)
{
PUSH_FUNCTION;
/*
for(UINT w=0; w < m_vWindows.size(); w++)
{
if(m_vWindows[w] == Win)
{
delete m_vWindows[w];
m_vWindows[w] = NULL;
Win = NULL;
}
}
*/
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::SetClearColor(const ceColorRGBA& Color)
{
PUSH_FUNCTION;
UCHAR r = (UCHAR) (Color.r*255);
UCHAR g = (UCHAR) (Color.g*255);
UCHAR b = (UCHAR) (Color.b*255);
UCHAR a = (UCHAR) (Color.a*255);
m_ClearColor = D3DCOLOR_RGBA(r,g,b,a);
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::ClearBuffers(BOOL bColorBuffer, BOOL bDepthBuffer, BOOL bStencilBuffer)
{
PUSH_FUNCTION;
DWORD Flags = NULL;
if(bColorBuffer)
Flags |= D3DCLEAR_TARGET;
if(bDepthBuffer)
Flags |= D3DCLEAR_ZBUFFER;
if(bStencilBuffer)
Flags |= D3DCLEAR_STENCIL;
m_pD3DDevice->Clear(NULL, NULL, Flags, m_ClearColor, 1.0f, 0);
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::Update(void)
{
PUSH_FUNCTION;
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::SetLookAt(const ceVec3f& vPos, const ceVec3f& vPointTo, const ceVec3f& vWorldUp)
{
PUSH_FUNCTION;
D3DXMatrixLookAtRH(&m_ViewMatrix, (const D3DXVECTOR3*)&vPos, (const D3DXVECTOR3*)&vPointTo, (const D3DXVECTOR3*)&vWorldUp);
m_pD3DDevice->SetTransform(D3DTS_VIEW, &m_ViewMatrix);
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::SetClippingPlanes(ceWindow* Win, FLOAT fNear, FLOAT fFar)
{
PUSH_FUNCTION;
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::SetupAPI(UINT Width, UINT Height)
{
PUSH_FUNCTION;
if(!m_pD3DDevice)
return;
D3DXMatrixPerspectiveFovRH( &m_ProjectionMatrix, D3DXToRadian( 45.0f ), (FLOAT)Width/Height, 2.0f, 4000.0f );
m_pD3DDevice->SetTransform(D3DTS_PROJECTION, &m_ProjectionMatrix);
// D3DXMatrixIdentity(&m_WorldMatrix);
D3DXMatrixIdentity(&m_ViewMatrix);
// adjust culling to D3D
m_pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
m_pD3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
m_pD3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
}
////////////////////////////////////////////////////////////////////////////////////////
ceRenderJob* ceRenderDeviceD3D9::CreateRenderJob(Render::ceWindow* Window, Render::ceViewport& Viewport, INT VertexBufferID, INT IndexBufferID)
{
PUSH_FUNCTION;
ceRenderJobD3D9* job = new ceRenderJobD3D9();
job->m_VertexBuffer = VertexBufferID;
job->m_IndexBuffer = IndexBufferID;
job->m_Win = Window;
job->SetViewport(Viewport);
return (ceRenderJob*) job;
}
////////////////////////////////////////////////////////////////////////////////////////
/* void ceRenderDeviceD3D9::SetState(UINT State, BOOL NewSet)
{
PUSH_FUNCTION;
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::SetStateInfo(UINT State, const FLOAT Value)
{
PUSH_FUNCTION;
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::SetStateInfo(UINT State, const FLOAT* Values)
{
PUSH_FUNCTION;
}*/
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::BeginFrame(void)
{
PUSH_FUNCTION;
m_pD3DDevice->BeginScene();
// m_pD3DDevice->SetTransform(D3DTS_WORLD, &m_WorldMatrix);
m_pD3DDevice->SetTransform(D3DTS_VIEW, &m_ViewMatrix);
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::EndFrame(void)
{
PUSH_FUNCTION;
m_pD3DDevice->EndScene();
m_pD3DDevice->Present(0,0,0,0);
}
////////////////////////////////////////////////////////////////////////////////////////
/* void ceRenderDeviceD3D9::SetTransformation(ceTransform WhichTrans, const ceMatrix* m)
{
PUSH_FUNCTION;
switch(WhichTrans)
{
case CE_RS_PROJECTION_TRANSFORM: memcpy(&m_ProjectionMatrix, m, sizeof(ceMatrix) ); break;
case CE_RS_MODEL_TRANSFORM: CE_EXCEPTION("SetTransformation( CE_RS_MODEL_TRANSFORM, .. ) nicht erlaubt", CELS_ERROR); break;//memcpy(&m_WorldMatrix, m, sizeof(ceMatrix) ); break;
case CE_RS_VIEW_TRANSFORM: memcpy(&m_ViewMatrix, m, sizeof(ceMatrix) ); break;
}
}
////////////////////////////////////////////////////////////////////////////////////////
void ceRenderDeviceD3D9::SetTransformation(ceTransform WhichTrans, const ceMatrix& m)
{
PUSH_FUNCTION;
switch(WhichTrans)
{
case CE_RS_PROJECTION_TRANSFORM: memcpy(&m_ProjectionMatrix, &m, sizeof(ceMatrix) ); break;
case CE_RS_MODEL_TRANSFORM: CE_EXCEPTION("SetTransformation( CE_RS_MODEL_TRANSFORM, .. ) nicht erlaubt", CELS_ERROR); break;//memcpy(&m_WorldMatrix, &m, sizeof(ceMatrix) ); break;
case CE_RS_VIEW_TRANSFORM: memcpy(&m_ViewMatrix, &m, sizeof(ceMatrix) ); break;
}
}*/
} // Namespace Render
} // namespace ZFXCE