Commit bf2d25ae authored by hybrid's avatar hybrid

Added a disableFeature method to the drivers, which can override the support of render features.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1590 dfc29bdd-3216-0410-991c-e03cc46cb475
parent e1ed3d4a
...@@ -112,6 +112,13 @@ namespace video ...@@ -112,6 +112,13 @@ namespace video
\return True if the feature is available, false if not. */ \return True if the feature is available, false if not. */
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const = 0; virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const = 0;
//! Disable a feature of the driver.
/** Can also be used to enable the features again. It is not
possible to enable unsupported features this way, though.
\param feature Feature to disable.
\param flag When true the feature is disabled, otherwise it is enabled. */
virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0;
//! Sets transformation matrices. //! Sets transformation matrices.
/** \param state Transformation type to be set, e.g. view, /** \param state Transformation type to be set, e.g. view,
world, or projection. world, or projection.
......
...@@ -141,8 +141,8 @@ void CD3D8Driver::createMaterialRenderers() ...@@ -141,8 +141,8 @@ void CD3D8Driver::createMaterialRenderers()
//! initialises the Direct3D API //! initialises the Direct3D API
bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd, bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize,
u32 bits, bool fullScreen, bool pureSoftware, HWND hwnd, u32 bits, bool fullScreen, bool pureSoftware,
bool highPrecisionFPU, bool vsync, bool antiAlias) bool highPrecisionFPU, bool vsync, bool antiAlias)
{ {
HRESULT hr; HRESULT hr;
...@@ -381,8 +381,6 @@ bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd ...@@ -381,8 +381,6 @@ bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
} }
//! applications must call this method before performing any rendering. returns false if failed. //! applications must call this method before performing any rendering. returns false if failed.
bool CD3D8Driver::beginScene(bool backBuffer, bool zBuffer, SColor color) bool CD3D8Driver::beginScene(bool backBuffer, bool zBuffer, SColor color)
{ {
...@@ -431,7 +429,6 @@ bool CD3D8Driver::beginScene(bool backBuffer, bool zBuffer, SColor color) ...@@ -431,7 +429,6 @@ bool CD3D8Driver::beginScene(bool backBuffer, bool zBuffer, SColor color)
} }
//! resets the device //! resets the device
bool CD3D8Driver::reset() bool CD3D8Driver::reset()
{ {
...@@ -466,9 +463,8 @@ bool CD3D8Driver::reset() ...@@ -466,9 +463,8 @@ bool CD3D8Driver::reset()
} }
//! applications must call this method after performing any rendering. returns false if failed. //! applications must call this method after performing any rendering. returns false if failed.
bool CD3D8Driver::endScene( void* windowId, core::rect<s32>* sourceRect ) bool CD3D8Driver::endScene(void* windowId, core::rect<s32>* sourceRect)
{ {
CNullDriver::endScene(); CNullDriver::endScene();
...@@ -508,10 +504,12 @@ bool CD3D8Driver::endScene( void* windowId, core::rect<s32>* sourceRect ) ...@@ -508,10 +504,12 @@ bool CD3D8Driver::endScene( void* windowId, core::rect<s32>* sourceRect )
} }
//! queries the features of the driver, returns true if feature is available //! queries the features of the driver, returns true if feature is available
bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
{ {
if (!FeatureEnabled[feature])
return false;
switch (feature) switch (feature)
{ {
case EVDF_RENDER_TO_TARGET: case EVDF_RENDER_TO_TARGET:
...@@ -550,9 +548,9 @@ bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const ...@@ -550,9 +548,9 @@ bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
} }
//! sets transformation //! sets transformation
void CD3D8Driver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) void CD3D8Driver::setTransform(E_TRANSFORMATION_STATE state,
const core::matrix4& mat)
{ {
switch(state) switch(state)
{ {
...@@ -611,7 +609,6 @@ bool CD3D8Driver::setTexture(s32 stage, const video::ITexture* texture) ...@@ -611,7 +609,6 @@ bool CD3D8Driver::setTexture(s32 stage, const video::ITexture* texture)
} }
//! sets a material //! sets a material
void CD3D8Driver::setMaterial(const SMaterial& material) void CD3D8Driver::setMaterial(const SMaterial& material)
{ {
...@@ -628,14 +625,16 @@ void CD3D8Driver::setMaterial(const SMaterial& material) ...@@ -628,14 +625,16 @@ void CD3D8Driver::setMaterial(const SMaterial& material)
//! returns a device dependent texture from a software surface (IImage) //! returns a device dependent texture from a software surface (IImage)
video::ITexture* CD3D8Driver::createDeviceDependentTexture(IImage* surface, const char* name) video::ITexture* CD3D8Driver::createDeviceDependentTexture(IImage* surface,
const char* name)
{ {
return new CD3D8Texture(surface, this, TextureCreationFlags, name); return new CD3D8Texture(surface, this, TextureCreationFlags, name);
} }
//! Enables or disables a texture creation flag. //! Enables or disables a texture creation flag.
void CD3D8Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) void CD3D8Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag,
bool enabled)
{ {
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;
...@@ -646,8 +645,8 @@ void CD3D8Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enab ...@@ -646,8 +645,8 @@ void CD3D8Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enab
//! sets a render target //! sets a render target
bool CD3D8Driver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer, bool CD3D8Driver::setRenderTarget(video::ITexture* texture,
bool clearZBuffer, SColor color) bool clearBackBuffer, bool clearZBuffer, SColor color)
{ {
// check for right driver type // check for right driver type
...@@ -745,14 +744,15 @@ bool CD3D8Driver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer ...@@ -745,14 +744,15 @@ bool CD3D8Driver::setRenderTarget(video::ITexture* texture, bool clearBackBuffer
return ret; return ret;
} }
//! Creates a render target texture. //! Creates a render target texture.
ITexture* CD3D8Driver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name) ITexture* CD3D8Driver::createRenderTargetTexture(
const core::dimension2d<s32>& size, const c8* name)
{ {
return new CD3D8Texture(this, size, name); return new CD3D8Texture(this, size, name);
} }
//! sets a viewport //! sets a viewport
void CD3D8Driver::setViewPort(const core::rect<s32>& area) void CD3D8Driver::setViewPort(const core::rect<s32>& area)
{ {
...@@ -779,7 +779,6 @@ void CD3D8Driver::setViewPort(const core::rect<s32>& area) ...@@ -779,7 +779,6 @@ void CD3D8Driver::setViewPort(const core::rect<s32>& area)
} }
//! gets the area of the current viewport //! gets the area of the current viewport
const core::rect<s32>& CD3D8Driver::getViewPort() const const core::rect<s32>& CD3D8Driver::getViewPort() const
{ {
...@@ -787,11 +786,11 @@ const core::rect<s32>& CD3D8Driver::getViewPort() const ...@@ -787,11 +786,11 @@ const core::rect<s32>& CD3D8Driver::getViewPort() const
} }
//! draws a vertex primitive list //! draws a vertex primitive list
void CD3D8Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, void CD3D8Driver::drawVertexPrimitiveList(const void* vertices,
const void* indexList, u32 primitiveCount, u32 vertexCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType)
{ {
if (!checkPrimitiveCount(primitiveCount)) if (!checkPrimitiveCount(primitiveCount))
return; return;
...@@ -863,9 +862,9 @@ void CD3D8Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, ...@@ -863,9 +862,9 @@ void CD3D8Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
} }
//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
void CD3D8Driver::draw2DImage(const video::ITexture* texture, const core::position2d<s32>& pos, void CD3D8Driver::draw2DImage(const video::ITexture* texture,
const core::position2d<s32>& pos,
const core::rect<s32>& sourceRect, const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect, SColor color, const core::rect<s32>* clipRect, SColor color,
bool useAlphaChannelOfTexture) bool useAlphaChannelOfTexture)
...@@ -1004,10 +1003,12 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture, const core::positi ...@@ -1004,10 +1003,12 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture, const core::positi
} }
void CD3D8Driver::draw2DImage(const video::ITexture* texture,
void CD3D8Driver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect, const core::rect<s32>& sourceRect,
const video::SColor* const colors, bool useAlphaChannelOfTexture) const core::rect<s32>* clipRect,
const video::SColor* const colors,
bool useAlphaChannelOfTexture)
{ {
if(!texture) if(!texture)
return; return;
...@@ -1089,11 +1090,10 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture, const core::rect<s ...@@ -1089,11 +1090,10 @@ void CD3D8Driver::draw2DImage(const video::ITexture* texture, const core::rect<s
} }
//!Draws an 2d rectangle with a gradient. //!Draws an 2d rectangle with a gradient.
void CD3D8Driver::draw2DRectangle(const core::rect<s32>& position, void CD3D8Driver::draw2DRectangle(const core::rect<s32>& position,
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown,
const core::rect<s32>* clip) SColor colorRightDown, const core::rect<s32>* clip)
{ {
core::rect<s32> pos(position); core::rect<s32> pos(position);
......
...@@ -64,7 +64,6 @@ CD3D9Driver::CD3D9Driver(const core::dimension2d<s32>& screenSize, HWND window, ...@@ -64,7 +64,6 @@ CD3D9Driver::CD3D9Driver(const core::dimension2d<s32>& screenSize, HWND window,
} }
//! destructor //! destructor
CD3D9Driver::~CD3D9Driver() CD3D9Driver::~CD3D9Driver()
{ {
...@@ -80,7 +79,6 @@ CD3D9Driver::~CD3D9Driver() ...@@ -80,7 +79,6 @@ CD3D9Driver::~CD3D9Driver()
} }
void CD3D9Driver::createMaterialRenderers() void CD3D9Driver::createMaterialRenderers()
{ {
// create D3D9 material renderers // create D3D9 material renderers
...@@ -150,10 +148,9 @@ void CD3D9Driver::createMaterialRenderers() ...@@ -150,10 +148,9 @@ void CD3D9Driver::createMaterialRenderers()
} }
//! initialises the Direct3D API //! initialises the Direct3D API
bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd, bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize,
u32 bits, bool fullScreen, bool pureSoftware, HWND hwnd, u32 bits, bool fullScreen, bool pureSoftware,
bool highPrecisionFPU, bool vsync, bool antiAlias) bool highPrecisionFPU, bool vsync, bool antiAlias)
{ {
HRESULT hr; HRESULT hr;
...@@ -452,7 +449,6 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd ...@@ -452,7 +449,6 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
} }
//! applications must call this method before performing any rendering. returns false if failed. //! applications must call this method before performing any rendering. returns false if failed.
bool CD3D9Driver::beginScene(bool backBuffer, bool zBuffer, SColor color) bool CD3D9Driver::beginScene(bool backBuffer, bool zBuffer, SColor color)
{ {
...@@ -501,9 +497,8 @@ bool CD3D9Driver::beginScene(bool backBuffer, bool zBuffer, SColor color) ...@@ -501,9 +497,8 @@ bool CD3D9Driver::beginScene(bool backBuffer, bool zBuffer, SColor color)
} }
//! applications must call this method after performing any rendering. returns false if failed. //! applications must call this method after performing any rendering. returns false if failed.
bool CD3D9Driver::endScene( void* windowId, core::rect<s32>* sourceRect ) bool CD3D9Driver::endScene(void* windowId, core::rect<s32>* sourceRect)
{ {
if (DeviceLost) if (DeviceLost)
return false; return false;
...@@ -546,10 +541,12 @@ bool CD3D9Driver::endScene( void* windowId, core::rect<s32>* sourceRect ) ...@@ -546,10 +541,12 @@ bool CD3D9Driver::endScene( void* windowId, core::rect<s32>* sourceRect )
} }
//! queries the features of the driver, returns true if feature is available //! queries the features of the driver, returns true if feature is available
bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
{ {
if (!FeatureEnabled[feature])
return false;
switch (feature) switch (feature)
{ {
case EVDF_MULTITEXTURE: case EVDF_MULTITEXTURE:
...@@ -595,9 +592,9 @@ bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const ...@@ -595,9 +592,9 @@ bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
} }
//! sets transformation //! sets transformation
void CD3D9Driver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) void CD3D9Driver::setTransform(E_TRANSFORMATION_STATE state,
const core::matrix4& mat)
{ {
Transformation3DChanged = true; Transformation3DChanged = true;
...@@ -655,7 +652,6 @@ bool CD3D9Driver::setTexture(s32 stage, const video::ITexture* texture) ...@@ -655,7 +652,6 @@ bool CD3D9Driver::setTexture(s32 stage, const video::ITexture* texture)
} }
//! sets a material //! sets a material
void CD3D9Driver::setMaterial(const SMaterial& material) void CD3D9Driver::setMaterial(const SMaterial& material)
{ {
...@@ -670,17 +666,17 @@ void CD3D9Driver::setMaterial(const SMaterial& material) ...@@ -670,17 +666,17 @@ void CD3D9Driver::setMaterial(const SMaterial& material)
} }
//! returns a device dependent texture from a software surface (IImage) //! returns a device dependent texture from a software surface (IImage)
video::ITexture* CD3D9Driver::createDeviceDependentTexture(IImage* surface, const char* name) video::ITexture* CD3D9Driver::createDeviceDependentTexture(IImage* surface,
const char* name)
{ {
return new CD3D9Texture(surface, this, TextureCreationFlags, name); return new CD3D9Texture(surface, this, TextureCreationFlags, name);
} }
//! Enables or disables a texture creation flag. //! Enables or disables a texture creation flag.
void CD3D9Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) void CD3D9Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag,
bool enabled)
{ {
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;
...@@ -689,11 +685,9 @@ void CD3D9Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enab ...@@ -689,11 +685,9 @@ void CD3D9Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enab
} }
//! sets a render target //! sets a render target
bool CD3D9Driver::setRenderTarget(video::ITexture* texture, bool CD3D9Driver::setRenderTarget(video::ITexture* texture,
bool clearBackBuffer, bool clearZBuffer, bool clearBackBuffer, bool clearZBuffer, SColor color)
SColor color)
{ {
// check for right driver type // check for right driver type
...@@ -780,7 +774,6 @@ bool CD3D9Driver::setRenderTarget(video::ITexture* texture, ...@@ -780,7 +774,6 @@ bool CD3D9Driver::setRenderTarget(video::ITexture* texture,
} }
//! sets a viewport //! sets a viewport
void CD3D9Driver::setViewPort(const core::rect<s32>& area) void CD3D9Driver::setViewPort(const core::rect<s32>& area)
{ {
...@@ -807,7 +800,6 @@ void CD3D9Driver::setViewPort(const core::rect<s32>& area) ...@@ -807,7 +800,6 @@ void CD3D9Driver::setViewPort(const core::rect<s32>& area)
} }
//! gets the area of the current viewport //! gets the area of the current viewport
const core::rect<s32>& CD3D9Driver::getViewPort() const const core::rect<s32>& CD3D9Driver::getViewPort() const
{ {
...@@ -912,9 +904,6 @@ bool CD3D9Driver::updateIndexHardwareBuffer(SHWBufferLink_d3d9 *HWBuffer) ...@@ -912,9 +904,6 @@ bool CD3D9Driver::updateIndexHardwareBuffer(SHWBufferLink_d3d9 *HWBuffer)
if (!HWBuffer->indexBuffer || indexSize * indexCount > HWBuffer->indexBufferSize) if (!HWBuffer->indexBuffer || indexSize * indexCount > HWBuffer->indexBufferSize)
{ {
DWORD flags = 0; DWORD flags = 0;
flags = D3DUSAGE_WRITEONLY; // SIO2: Default to D3DUSAGE_WRITEONLY flags = D3DUSAGE_WRITEONLY; // SIO2: Default to D3DUSAGE_WRITEONLY
...@@ -984,7 +973,6 @@ bool CD3D9Driver::updateHardwareBuffer(SHWBufferLink *HWBuffer) ...@@ -984,7 +973,6 @@ bool CD3D9Driver::updateHardwareBuffer(SHWBufferLink *HWBuffer)
} }
} }
return true; return true;
} }
...@@ -1061,14 +1049,18 @@ void CD3D9Driver::drawHardwareBuffer(SHWBufferLink *_HWBuffer) ...@@ -1061,14 +1049,18 @@ void CD3D9Driver::drawHardwareBuffer(SHWBufferLink *_HWBuffer)
drawVertexPrimitiveList(0, mb->getVertexCount(), 0, mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES, mb->getIndexType()); drawVertexPrimitiveList(0, mb->getVertexCount(), 0, mb->getIndexCount()/3, mb->getVertexType(), scene::EPT_TRIANGLES, mb->getIndexType());
if (HWBuffer->vertexBuffer) pID3DDevice->SetStreamSource(0, 0, 0, 0); if (HWBuffer->vertexBuffer)
if (HWBuffer->indexBuffer) pID3DDevice->SetIndices(0); pID3DDevice->SetStreamSource(0, 0, 0, 0);
if (HWBuffer->indexBuffer)
pID3DDevice->SetIndices(0);
} }
//! draws a vertex primitive list //! draws a vertex primitive list
void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, void CD3D9Driver::drawVertexPrimitiveList(const void* vertices,
const void* indexList, u32 primitiveCount, u32 vertexCount, const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType)
{ {
if (!checkPrimitiveCount(primitiveCount)) if (!checkPrimitiveCount(primitiveCount))
return; return;
...@@ -1136,14 +1128,10 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, ...@@ -1136,14 +1128,10 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
break; break;
case scene::EPT_LINE_STRIP: case scene::EPT_LINE_STRIP:
if(!vertices) if(!vertices)
{
pID3DDevice->DrawIndexedPrimitive(D3DPT_LINESTRIP, 0, 0, vertexCount, 0, primitiveCount); pID3DDevice->DrawIndexedPrimitive(D3DPT_LINESTRIP, 0, 0, vertexCount, 0, primitiveCount);
}
else else
{
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount, pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride); primitiveCount, indexList, indexType, vertices, stride);
}
break; break;
case scene::EPT_LINE_LOOP: case scene::EPT_LINE_LOOP:
if(!vertices) if(!vertices)
...@@ -1168,36 +1156,24 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, ...@@ -1168,36 +1156,24 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
break; break;
case scene::EPT_LINES: case scene::EPT_LINES:
if(!vertices) if(!vertices)
{
pID3DDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, vertexCount, 0, primitiveCount); pID3DDevice->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, vertexCount, 0, primitiveCount);
}
else else
{
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount, pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
primitiveCount, indexList, indexType, vertices, stride); primitiveCount, indexList, indexType, vertices, stride);
}
break; break;
case scene::EPT_TRIANGLE_STRIP: case scene::EPT_TRIANGLE_STRIP:
if(!vertices) if(!vertices)
{
pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, vertexCount, 0, primitiveCount); pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, vertexCount, 0, primitiveCount);
}
else else
{ pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount, primitiveCount,
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount, indexList, indexType, vertices, stride);
primitiveCount, indexList, indexType, vertices, stride);
}
break; break;
case scene::EPT_TRIANGLE_FAN: case scene::EPT_TRIANGLE_FAN:
if(!vertices) if(!vertices)
{
pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLEFAN, 0, 0, vertexCount, 0, primitiveCount); pID3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLEFAN, 0, 0, vertexCount, 0, primitiveCount);
}
else else
{ pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount, primitiveCount,
pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount, indexList, indexType, vertices, stride);
primitiveCount, indexList, indexType, vertices, stride);
}
break; break;
case scene::EPT_TRIANGLES: case scene::EPT_TRIANGLES:
if(!vertices) if(!vertices)
...@@ -1215,9 +1191,12 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount, ...@@ -1215,9 +1191,12 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
} }
void CD3D9Driver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, void CD3D9Driver::draw2DImage(const video::ITexture* texture,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect, const core::rect<s32>& destRect,
const video::SColor* const colors, bool useAlphaChannelOfTexture) const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect,
const video::SColor* const colors,
bool useAlphaChannelOfTexture)
{ {
if(!texture) if(!texture)
return; return;
...@@ -1429,7 +1408,6 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture, ...@@ -1429,7 +1408,6 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture,
} }
//!Draws a 2d rectangle with a gradient. //!Draws a 2d rectangle with a gradient.
void CD3D9Driver::draw2DRectangle(const core::rect<s32>& position, void CD3D9Driver::draw2DRectangle(const core::rect<s32>& position,
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
...@@ -2170,7 +2148,6 @@ void CD3D9Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32 ...@@ -2170,7 +2148,6 @@ void CD3D9Driver::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.
...@@ -2206,7 +2183,6 @@ void CD3D9Driver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftU ...@@ -2206,7 +2183,6 @@ void CD3D9Driver::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.
...@@ -2216,7 +2192,6 @@ u32 CD3D9Driver::getMaximalPrimitiveCount() const ...@@ -2216,7 +2192,6 @@ u32 CD3D9Driver::getMaximalPrimitiveCount() const
} }
//! Sets the fog mode. //! Sets the fog mode.
void CD3D9Driver::setFog(SColor color, bool linearFog, f32 start, void CD3D9Driver::setFog(SColor color, bool linearFog, f32 start,
f32 end, f32 density, bool pixelFog, bool rangeFog) f32 end, f32 density, bool pixelFog, bool rangeFog)
...@@ -2245,7 +2220,6 @@ void CD3D9Driver::setFog(SColor color, bool linearFog, f32 start, ...@@ -2245,7 +2220,6 @@ void CD3D9Driver::setFog(SColor color, bool linearFog, f32 start,
} }
//! Draws a 3d line. //! Draws a 3d line.
void CD3D9Driver::draw3DLine(const core::vector3df& start, void CD3D9Driver::draw3DLine(const core::vector3df& start,
const core::vector3df& end, SColor color) const core::vector3df& end, SColor color)
...@@ -2262,13 +2236,12 @@ void CD3D9Driver::draw3DLine(const core::vector3df& start, ...@@ -2262,13 +2236,12 @@ void CD3D9Driver::draw3DLine(const core::vector3df& start,
} }
//! resets the device //! resets the device
bool CD3D9Driver::reset() bool CD3D9Driver::reset()
{ {
// reset
HRESULT hr;
os::Printer::log("Resetting D3D9 device.", ELL_INFORMATION); os::Printer::log("Resetting D3D9 device.", ELL_INFORMATION);
HRESULT hr;
if (FAILED(hr = pID3DDevice->Reset(&present))) if (FAILED(hr = pID3DDevice->Reset(&present)))
{ {
if (hr == D3DERR_DEVICELOST) if (hr == D3DERR_DEVICELOST)
...@@ -2276,8 +2249,30 @@ bool CD3D9Driver::reset() ...@@ -2276,8 +2249,30 @@ bool CD3D9Driver::reset()
DeviceLost = true; DeviceLost = true;
os::Printer::log("Resetting failed due to device lost.", ELL_WARNING); os::Printer::log("Resetting failed due to device lost.", ELL_WARNING);
} }
else if (hr == D3DERR_DEVICEREMOVED)
{
os::Printer::log("Resetting failed due to device removed.", ELL_WARNING);
}
else if (hr == D3DERR_DRIVERINTERNALERROR)
{
os::Printer::log("Resetting failed due to internal error.", ELL_WARNING);
}
else if (hr == D3DERR_OUTOFVIDEOMEMORY)
{
os::Printer::log("Resetting failed due to out of memory.", ELL_WARNING);
}
else if (hr == D3DERR_DEVICENOTRESET)
{
os::Printer::log("Resetting failed due to not reset.", ELL_WARNING);
}
else if (hr == D3DERR_INVALIDCALL)
{
os::Printer::log("Resetting failed due to invalid call.", ELL_WARNING);
}
else else
os::Printer::log("Resetting failed.", ELL_WARNING); {
os::Printer::log("Resetting failed due to unknown reason.", core::stringc(hr).c_str(), ELL_WARNING);
}
return false; return false;
} }
...@@ -2297,7 +2292,6 @@ bool CD3D9Driver::reset() ...@@ -2297,7 +2292,6 @@ bool CD3D9Driver::reset()
} }
void CD3D9Driver::OnResize(const core::dimension2d<s32>& size) void CD3D9Driver::OnResize(const core::dimension2d<s32>& size)
{ {
if (!pID3DDevice) if (!pID3DDevice)
...@@ -2311,7 +2305,6 @@ void CD3D9Driver::OnResize(const core::dimension2d<s32>& size) ...@@ -2311,7 +2305,6 @@ void CD3D9Driver::OnResize(const core::dimension2d<s32>& size)
} }
//! Returns type of video driver //! Returns type of video driver
E_DRIVER_TYPE CD3D9Driver::getDriverType() const E_DRIVER_TYPE CD3D9Driver::getDriverType() const
{ {
...@@ -2319,7 +2312,6 @@ E_DRIVER_TYPE CD3D9Driver::getDriverType() const ...@@ -2319,7 +2312,6 @@ E_DRIVER_TYPE CD3D9Driver::getDriverType() const
} }
//! Returns the transformation set by setTransform //! Returns the transformation set by setTransform
const core::matrix4& CD3D9Driver::getTransform(E_TRANSFORMATION_STATE state) const const core::matrix4& CD3D9Driver::getTransform(E_TRANSFORMATION_STATE state) const
{ {
...@@ -2327,7 +2319,6 @@ const core::matrix4& CD3D9Driver::getTransform(E_TRANSFORMATION_STATE state) con ...@@ -2327,7 +2319,6 @@ const core::matrix4& CD3D9Driver::getTransform(E_TRANSFORMATION_STATE state) con
} }
//! Sets a vertex shader constant. //! Sets a vertex shader constant.
void CD3D9Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) void CD3D9Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
{ {
...@@ -2335,6 +2326,7 @@ void CD3D9Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s3 ...@@ -2335,6 +2326,7 @@ void CD3D9Driver::setVertexShaderConstant(const f32* data, s32 startRegister, s3
pID3DDevice->SetVertexShaderConstantF(startRegister, data, constantAmount); pID3DDevice->SetVertexShaderConstantF(startRegister, data, constantAmount);
} }
//! Sets a pixel shader constant. //! Sets a pixel shader constant.
void CD3D9Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) void CD3D9Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
{ {
...@@ -2342,6 +2334,7 @@ void CD3D9Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 ...@@ -2342,6 +2334,7 @@ void CD3D9Driver::setPixelShaderConstant(const f32* data, s32 startRegister, s32
pID3DDevice->SetPixelShaderConstantF(startRegister, data, constantAmount); pID3DDevice->SetPixelShaderConstantF(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 CD3D9Driver::setVertexShaderConstant(const c8* name, const f32* floats, int count) bool CD3D9Driver::setVertexShaderConstant(const c8* name, const f32* floats, int count)
{ {
...@@ -2354,6 +2347,7 @@ bool CD3D9Driver::setVertexShaderConstant(const c8* name, const f32* floats, int ...@@ -2354,6 +2347,7 @@ bool CD3D9Driver::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 CD3D9Driver::setPixelShaderConstant(const c8* name, const f32* floats, int count) bool CD3D9Driver::setPixelShaderConstant(const c8* name, const f32* floats, int count)
{ {
...@@ -2366,12 +2360,14 @@ bool CD3D9Driver::setPixelShaderConstant(const c8* name, const f32* floats, int ...@@ -2366,12 +2360,14 @@ bool CD3D9Driver::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* CD3D9Driver::getGPUProgrammingServices() IGPUProgrammingServices* CD3D9Driver::getGPUProgrammingServices()
{ {
return this; return this;
} }
//! Adds a new material renderer to the VideoDriver, using pixel and/or //! Adds a new material renderer to the VideoDriver, using pixel and/or
//! vertex shaders to render geometry. //! vertex shaders to render geometry.
s32 CD3D9Driver::addShaderMaterial(const c8* vertexShaderProgram, s32 CD3D9Driver::addShaderMaterial(const c8* vertexShaderProgram,
...@@ -2399,8 +2395,7 @@ s32 CD3D9Driver::addHighLevelShaderMaterial( ...@@ -2399,8 +2395,7 @@ s32 CD3D9Driver::addHighLevelShaderMaterial(
const c8* pixelShaderEntryPointName, const c8* pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget, E_PIXEL_SHADER_TYPE psCompileTarget,
IShaderConstantSetCallBack* callback, IShaderConstantSetCallBack* callback,
E_MATERIAL_TYPE baseMaterial, E_MATERIAL_TYPE baseMaterial, s32 userData)
s32 userData)
{ {
s32 nr = -1; s32 nr = -1;
...@@ -2527,7 +2522,6 @@ const core::dimension2d<s32>& CD3D9Driver::getCurrentRenderTargetSize() const ...@@ -2527,7 +2522,6 @@ const core::dimension2d<s32>& CD3D9Driver::getCurrentRenderTargetSize() const
} }
// Set/unset a clipping plane. // Set/unset a clipping plane.
bool CD3D9Driver::setClipPlane(u32 index, const core::plane3df& plane, bool enable) bool CD3D9Driver::setClipPlane(u32 index, const core::plane3df& plane, bool enable)
{ {
...@@ -2569,8 +2563,8 @@ namespace video ...@@ -2569,8 +2563,8 @@ namespace video
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
//! creates a video driver //! creates a video driver
IVideoDriver* createDirectX9Driver(const core::dimension2d<s32>& screenSize, HWND window, IVideoDriver* createDirectX9Driver(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)
{ {
......
...@@ -73,6 +73,7 @@ public: ...@@ -73,6 +73,7 @@ public:
IDirect3DSurface9* getRenderTargetSurface(); IDirect3DSurface9* getRenderTargetSurface();
private: private:
friend class CD3D9Driver;
void createRenderTarget(); void createRenderTarget();
......
...@@ -140,6 +140,8 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<s32>& scre ...@@ -140,6 +140,8 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<s32>& scre
// set ExposedData to 0 // set ExposedData to 0
memset(&ExposedData, 0, sizeof(ExposedData)); memset(&ExposedData, 0, sizeof(ExposedData));
for (u32 i=0; i<video::EVDF_COUNT; ++i)
FeatureEnabled[i]=true;
} }
...@@ -220,6 +222,12 @@ bool CNullDriver::endScene( void* windowId, core::rect<s32>* sourceRect ) ...@@ -220,6 +222,12 @@ bool CNullDriver::endScene( void* windowId, core::rect<s32>* sourceRect )
} }
//! Disable a feature of the driver.
void CNullDriver::disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag)
{
FeatureEnabled[feature]=!flag;
}
//! queries the features of the driver, returns true if feature is available //! queries the features of the driver, returns true if feature is available
bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
......
...@@ -48,6 +48,9 @@ namespace video ...@@ -48,6 +48,9 @@ namespace video
virtual bool endScene( void* windowId=0, core::rect<s32>* sourceRect=0 ); virtual bool endScene( void* windowId=0, core::rect<s32>* sourceRect=0 );
//! Disable a feature of the driver.
virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true);
//! queries the features of the driver, returns true if feature is available //! queries the features of the driver, returns true if feature is available
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const;
...@@ -307,7 +310,8 @@ namespace video ...@@ -307,7 +310,8 @@ namespace video
//! Creates a software image from part of another image. //! Creates a software image from part of another image.
virtual IImage* createImage(IImage* imageToCopy, virtual IImage* createImage(IImage* imageToCopy,
const core::position2d<s32>& pos, const core::dimension2d<s32>& size); const core::position2d<s32>& pos,
const core::dimension2d<s32>& size);
//! Draws a mesh buffer //! Draws a mesh buffer
virtual void drawMeshBuffer(const scene::IMeshBuffer* mb); virtual void drawMeshBuffer(const scene::IMeshBuffer* mb);
...@@ -615,6 +619,8 @@ namespace video ...@@ -615,6 +619,8 @@ namespace video
bool AllowZWriteOnTransparent; bool AllowZWriteOnTransparent;
SExposedVideoData ExposedData; SExposedVideoData ExposedData;
bool FeatureEnabled[video::EVDF_COUNT];
}; };
} // end namespace video } // end namespace video
......
...@@ -142,7 +142,7 @@ namespace video ...@@ -142,7 +142,7 @@ namespace video
//! queries the features of the driver, returns true if feature is available //! queries the features of the driver, returns true if feature is available
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
{ {
return COpenGLExtensionHandler::queryFeature(feature); return FeatureEnabled[feature] && COpenGLExtensionHandler::queryFeature(feature);
} }
//! Sets a material. All 3d drawing functions draw geometry now //! Sets a material. All 3d drawing functions draw geometry now
......
...@@ -173,7 +173,7 @@ bool CSoftwareDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const ...@@ -173,7 +173,7 @@ bool CSoftwareDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
switch (feature) switch (feature)
{ {
case EVDF_RENDER_TO_TARGET: case EVDF_RENDER_TO_TARGET:
return true; return FeatureEnabled[feature];
default: default:
return false; return false;
}; };
......
...@@ -276,6 +276,9 @@ void CBurningVideoDriver::setCurrentShader() ...@@ -276,6 +276,9 @@ void CBurningVideoDriver::setCurrentShader()
//! queries the features of the driver, returns true if feature is available //! queries the features of the driver, returns true if feature is available
bool CBurningVideoDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const bool CBurningVideoDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
{ {
if (!FeatureEnabled[feature])
return false;
switch (feature) switch (feature)
{ {
#ifdef SOFTWARE_DRIVER_2_BILINEAR #ifdef SOFTWARE_DRIVER_2_BILINEAR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment