Change the swap effect to DISCARD for windowed applications in d3d drivers.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2025 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2009-01-03 12:44:09 +00:00
parent c3cfdcfa5e
commit 5c64512330
2 changed files with 22 additions and 46 deletions

View File

@ -138,7 +138,6 @@ void CD3D8Driver::createMaterialRenderers()
// add basic 1 texture blending // add basic 1 texture blending
addAndDropMaterialRenderer(new CD3D8MaterialRenderer_ONETEXTURE_BLEND(pID3DDevice, this)); addAndDropMaterialRenderer(new CD3D8MaterialRenderer_ONETEXTURE_BLEND(pID3DDevice, this));
} }
@ -190,8 +189,6 @@ bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize,
os::Printer::log(tmp, ELL_INFORMATION); os::Printer::log(tmp, ELL_INFORMATION);
} }
D3DDISPLAYMODE d3ddm; D3DDISPLAYMODE d3ddm;
hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm); hr = pID3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
if (FAILED(hr)) if (FAILED(hr))
@ -200,10 +197,9 @@ bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize,
return false; return false;
} }
ZeroMemory(&present, sizeof(present)); ZeroMemory(&present, sizeof(present));
present.SwapEffect = D3DSWAPEFFECT_COPY; present.SwapEffect = D3DSWAPEFFECT_DISCARD;
present.Windowed = TRUE; present.Windowed = TRUE;
present.BackBufferFormat = d3ddm.Format; present.BackBufferFormat = d3ddm.Format;
present.EnableAutoDepthStencil = TRUE; present.EnableAutoDepthStencil = TRUE;
@ -649,7 +645,6 @@ void CD3D8Driver::setMaterial(const SMaterial& material)
setTransform((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ), setTransform((E_TRANSFORMATION_STATE) ( ETS_TEXTURE_0 + i ),
material.getTextureMatrix(i)); material.getTextureMatrix(i));
} }
} }
@ -668,7 +663,6 @@ void CD3D8Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag,
if (flag == video::ETCF_CREATE_MIP_MAPS && !queryFeature(EVDF_MIP_MAP)) if (flag == video::ETCF_CREATE_MIP_MAPS && !queryFeature(EVDF_MIP_MAP))
enabled = false; enabled = false;
CNullDriver::setTextureCreationFlag(flag, enabled); CNullDriver::setTextureCreationFlag(flag, enabled);
} }
@ -733,8 +727,7 @@ bool CD3D8Driver::setRenderTarget(video::ITexture* texture,
// store previous target // store previous target
if (!PrevRenderTarget) if (!PrevRenderTarget && (FAILED(pID3DDevice->GetRenderTarget(&PrevRenderTarget))))
if (FAILED(pID3DDevice->GetRenderTarget(&PrevRenderTarget)))
{ {
os::Printer::log("Could not get previous render target.", ELL_ERROR); os::Printer::log("Could not get previous render target.", ELL_ERROR);
return false; return false;
@ -1168,11 +1161,9 @@ void CD3D8Driver::draw2DRectangle(const core::rect<s32>& position,
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0], pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0],
D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex)); D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex));
} }
//! Draws a 2d line. //! Draws a 2d line.
void CD3D8Driver::draw2DLine(const core::position2d<s32>& start, void CD3D8Driver::draw2DLine(const core::position2d<s32>& start,
const core::position2d<s32>& end, const core::position2d<s32>& end,
@ -1211,6 +1202,7 @@ void CD3D8Driver::draw2DLine(const core::position2d<s32>& start,
pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, &vtx[0], sizeof(S3DVertex)); pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, &vtx[0], sizeof(S3DVertex));
} }
//! Draws a pixel //! Draws a pixel
void CD3D8Driver::drawPixel(u32 x, u32 y, const SColor & color) void CD3D8Driver::drawPixel(u32 x, u32 y, const SColor & color)
{ {
@ -1235,7 +1227,6 @@ void CD3D8Driver::drawPixel(u32 x, u32 y, const SColor & color)
} }
//! sets right vertex shader //! sets right vertex shader
void CD3D8Driver::setVertexShader(E_VERTEX_TYPE newType) void CD3D8Driver::setVertexShader(E_VERTEX_TYPE newType)
{ {
@ -1354,7 +1345,6 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
} }
// shademode // shademode
if (resetAllRenderstates || lastmaterial.GouraudShading != material.GouraudShading) if (resetAllRenderstates || lastmaterial.GouraudShading != material.GouraudShading)
{ {
if (material.GouraudShading) if (material.GouraudShading)
@ -1364,7 +1354,6 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
} }
// lighting // lighting
if (resetAllRenderstates || lastmaterial.Lighting != material.Lighting) if (resetAllRenderstates || lastmaterial.Lighting != material.Lighting)
{ {
if (material.Lighting) if (material.Lighting)
@ -1373,9 +1362,7 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE); pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
} }
// zbuffer // zbuffer
if (resetAllRenderstates || lastmaterial.ZBuffer != material.ZBuffer) if (resetAllRenderstates || lastmaterial.ZBuffer != material.ZBuffer)
{ {
switch (material.ZBuffer) switch (material.ZBuffer)
@ -1394,7 +1381,6 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
} }
} }
// zwrite // zwrite
// if (resetAllRenderstates || lastmaterial.ZWriteEnable != material.ZWriteEnable) // if (resetAllRenderstates || lastmaterial.ZWriteEnable != material.ZWriteEnable)
{ {
@ -1405,8 +1391,6 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
} }
// back face culling // back face culling
if (resetAllRenderstates || (lastmaterial.FrontfaceCulling != material.FrontfaceCulling) || (lastmaterial.BackfaceCulling != material.BackfaceCulling)) if (resetAllRenderstates || (lastmaterial.FrontfaceCulling != material.FrontfaceCulling) || (lastmaterial.BackfaceCulling != material.BackfaceCulling))
{ {
// if (material.FrontfaceCulling && material.BackfaceCulling) // if (material.FrontfaceCulling && material.BackfaceCulling)
@ -1504,7 +1488,6 @@ void CD3D8Driver::setBasicRenderStates(const SMaterial& material, const SMateria
} }
//! sets the needed renderstates //! sets the needed renderstates
void CD3D8Driver::setRenderStatesStencilShadowMode(bool zfail) void CD3D8Driver::setRenderStatesStencilShadowMode(bool zfail)
{ {
@ -1588,7 +1571,6 @@ void CD3D8Driver::setRenderStatesStencilShadowMode(bool zfail)
} }
//! sets the needed renderstates //! sets the needed renderstates
void CD3D8Driver::setRenderStatesStencilFillMode(bool alpha) void CD3D8Driver::setRenderStatesStencilFillMode(bool alpha)
{ {
@ -1646,7 +1628,6 @@ void CD3D8Driver::setRenderStatesStencilFillMode(bool alpha)
} }
//! sets the needed renderstates //! sets the needed renderstates
void CD3D8Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel) void CD3D8Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel)
{ {
@ -1784,7 +1765,6 @@ void CD3D8Driver::deleteAllDynamicLights()
} }
//! adds a dynamic light //! adds a dynamic light
void CD3D8Driver::addDynamicLight(const SLight& dl) void CD3D8Driver::addDynamicLight(const SLight& dl)
{ {
@ -1831,7 +1811,6 @@ void CD3D8Driver::addDynamicLight(const SLight& dl)
} }
//! returns the maximal amount of dynamic lights the device can handle //! returns the maximal amount of dynamic lights the device can handle
u32 CD3D8Driver::getMaximalDynamicLightAmount() const u32 CD3D8Driver::getMaximalDynamicLightAmount() const
{ {
@ -1839,7 +1818,6 @@ u32 CD3D8Driver::getMaximalDynamicLightAmount() const
} }
//! Sets the dynamic ambient light color. The default color is //! Sets the dynamic ambient light color. The default color is
//! (0,0,0,0) which means it is dark. //! (0,0,0,0) which means it is dark.
//! \param color: New color of the ambient light. //! \param color: New color of the ambient light.
@ -1854,7 +1832,6 @@ void CD3D8Driver::setAmbientLight(const SColorf& color)
} }
//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8
//! driver, it would return "Direct3D8.1". //! driver, it would return "Direct3D8.1".
const wchar_t* CD3D8Driver::getName() const const wchar_t* CD3D8Driver::getName() const
@ -1863,7 +1840,6 @@ const wchar_t* CD3D8Driver::getName() const
} }
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: Frist, draw all geometry. Then use this method, to draw the shadow //! this: Frist, draw all geometry. Then use this method, to draw the shadow
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
@ -1905,7 +1881,6 @@ void CD3D8Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32
} }
//! Fills the stencil shadow with color. After the shadow volume has been drawn //! Fills the stencil shadow with color. After the shadow volume has been drawn
//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this
//! to draw the color of the shadow. //! to draw the color of the shadow.
@ -1941,7 +1916,6 @@ void CD3D8Driver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftU
} }
//! Returns the maximum amount of primitives (mostly vertices) which //! Returns the maximum amount of primitives (mostly vertices) which
//! the device is able to render with one drawIndexedTriangleList //! the device is able to render with one drawIndexedTriangleList
//! call. //! call.
@ -1978,6 +1952,7 @@ void CD3D8Driver::setFog(SColor color, bool linearFog, f32 start,
pID3DDevice->SetRenderState (D3DRS_RANGEFOGENABLE, rangeFog); pID3DDevice->SetRenderState (D3DRS_RANGEFOGENABLE, rangeFog);
} }
//! Draws a 3d line. //! Draws a 3d line.
void CD3D8Driver::draw3DLine(const core::vector3df& start, void CD3D8Driver::draw3DLine(const core::vector3df& start,
const core::vector3df& end, SColor color) const core::vector3df& end, SColor color)
@ -2003,18 +1978,21 @@ void CD3D8Driver::OnResize(const core::dimension2d<s32>& size)
reset(); reset();
} }
//! Returns type of video driver //! Returns type of video driver
E_DRIVER_TYPE CD3D8Driver::getDriverType() const E_DRIVER_TYPE CD3D8Driver::getDriverType() const
{ {
return EDT_DIRECT3D8; return EDT_DIRECT3D8;
} }
//! Returns the transformation set by setTransform //! Returns the transformation set by setTransform
const core::matrix4& CD3D8Driver::getTransform(E_TRANSFORMATION_STATE state) const const core::matrix4& CD3D8Driver::getTransform(E_TRANSFORMATION_STATE state) const
{ {
return Matrices[state]; return Matrices[state];
} }
//! Sets a vertex shader constant. //! Sets a vertex shader constant.
void CD3D8Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) void CD3D8Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
{ {
@ -2022,6 +2000,7 @@ void CD3D8Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s3
pID3DDevice->SetVertexShaderConstant(startRegister, data, constantAmount); pID3DDevice->SetVertexShaderConstant(startRegister, data, constantAmount);
} }
//! Sets a pixel shader constant. //! Sets a pixel shader constant.
void CD3D8Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) void CD3D8Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
{ {
@ -2029,6 +2008,7 @@ void CD3D8Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32
pID3DDevice->SetPixelShaderConstant(startRegister, data, constantAmount); pID3DDevice->SetPixelShaderConstant(startRegister, data, constantAmount);
} }
//! Sets a constant for the vertex shader based on a name. //! Sets a constant for the vertex shader based on a name.
bool CD3D8Driver::setVertexShaderConstant(const c8* name, const f32* floats, int count) bool CD3D8Driver::setVertexShaderConstant(const c8* name, const f32* floats, int count)
{ {
@ -2036,6 +2016,7 @@ bool CD3D8Driver::setVertexShaderConstant(const c8* name, const f32* floats, int
return false; return false;
} }
//! Sets a constant for the pixel shader based on a name. //! Sets a constant for the pixel shader based on a name.
bool CD3D8Driver::setPixelShaderConstant(const c8* name, const f32* floats, int count) bool CD3D8Driver::setPixelShaderConstant(const c8* name, const f32* floats, int count)
{ {
@ -2043,6 +2024,7 @@ bool CD3D8Driver::setPixelShaderConstant(const c8* name, const f32* floats, int
return false; return false;
} }
//! Returns pointer to the IGPUProgrammingServices interface. //! Returns pointer to the IGPUProgrammingServices interface.
IGPUProgrammingServices* CD3D8Driver::getGPUProgrammingServices() IGPUProgrammingServices* CD3D8Driver::getGPUProgrammingServices()
{ {
@ -2075,7 +2057,6 @@ IVideoDriver* CD3D8Driver::getVideoDriver()
} }
//! Clears the ZBuffer. //! Clears the ZBuffer.
void CD3D8Driver::clearZBuffer() void CD3D8Driver::clearZBuffer()
{ {
@ -2085,6 +2066,7 @@ void CD3D8Driver::clearZBuffer()
os::Printer::log("CD3D8Driver clearZBuffer() failed.", ELL_WARNING); os::Printer::log("CD3D8Driver clearZBuffer() failed.", ELL_WARNING);
} }
//! Returns an image created from the last rendered frame. //! Returns an image created from the last rendered frame.
IImage* CD3D8Driver::createScreenShot() IImage* CD3D8Driver::createScreenShot()
{ {
@ -2176,7 +2158,6 @@ IImage* CD3D8Driver::createScreenShot()
} }
// returns the current size of the screen or rendertarget // returns the current size of the screen or rendertarget
const core::dimension2d<s32>& CD3D8Driver::getCurrentRenderTargetSize() const const core::dimension2d<s32>& CD3D8Driver::getCurrentRenderTargetSize() const
{ {
@ -2187,7 +2168,6 @@ const core::dimension2d<s32>& CD3D8Driver::getCurrentRenderTargetSize() const
} }
// Set/unset a clipping plane. // Set/unset a clipping plane.
bool CD3D8Driver::setClipPlane(u32 index, const core::plane3df& plane, bool enable) bool CD3D8Driver::setClipPlane(u32 index, const core::plane3df& plane, bool enable)
{ {
@ -2228,8 +2208,8 @@ namespace video
#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ #ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
//! creates a video driver //! creates a video driver
IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWND window, IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize,
u32 bits, bool fullscreen, bool stencilbuffer, HWND window, u32 bits, bool fullscreen, bool stencilbuffer,
io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU,
bool vsync, bool antiAlias) bool vsync, bool antiAlias)
{ {
@ -2250,4 +2230,3 @@ IVideoDriver* createDirectX8Driver(const core::dimension2d<s32>& screenSize, HWN
} // end namespace video } // end namespace video
} // end namespace irr } // end namespace irr

View File

@ -130,7 +130,6 @@ void CD3D9Driver::createMaterialRenderers()
MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer);
renderer->drop(); renderer->drop();
// add parallax map renderers // add parallax map renderers
renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp, renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp,
@ -145,10 +144,8 @@ void CD3D9Driver::createMaterialRenderers()
MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer); MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer);
renderer->drop(); renderer->drop();
// add basic 1 texture blending // add basic 1 texture blending
addAndDropMaterialRenderer(new CD3D9MaterialRenderer_ONETEXTURE_BLEND(pID3DDevice, this)); addAndDropMaterialRenderer(new CD3D9MaterialRenderer_ONETEXTURE_BLEND(pID3DDevice, this));
} }
@ -251,7 +248,7 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize,
else else
{ {
present.BackBufferFormat = d3ddm.Format; present.BackBufferFormat = d3ddm.Format;
present.SwapEffect = D3DSWAPEFFECT_COPY; present.SwapEffect = D3DSWAPEFFECT_DISCARD;
present.Windowed = TRUE; present.Windowed = TRUE;
} }
@ -303,9 +300,9 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize,
D3DMULTISAMPLE_NONMASKABLE, &qualityLevels))) D3DMULTISAMPLE_NONMASKABLE, &qualityLevels)))
{ {
// enable non maskable multi sampling // enable non maskable multi sampling
present.SwapEffect = D3DSWAPEFFECT_DISCARD;
present.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE; present.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE;
present.MultiSampleQuality = qualityLevels-1; present.MultiSampleQuality = qualityLevels-1;
present.SwapEffect = D3DSWAPEFFECT_DISCARD;
} }
else else
{ {