Commit d352d8cf authored by cutealien's avatar cutealien

Fix compiling of DirectX 8.

NOTE: This is likely the last change to DX8 in trunk, as it's going to be removed now. Just wanted to get it working again before removing.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5044 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 15f4951a
...@@ -722,7 +722,7 @@ void CD3D8Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, ...@@ -722,7 +722,7 @@ void CD3D8Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag,
//! sets a render target //! sets a render target
bool CD3D8Driver::setRenderTarget(video::ITexture* texture, bool CD3D8Driver::setRenderTarget(video::ITexture* texture,
bool clearBackBuffer, bool clearZBuffer, SColor color) bool clearBackBuffer, bool clearZBuffer, SColor color, video::ITexture* depthStencil)
{ {
// check for right driver type // check for right driver type
......
...@@ -61,7 +61,7 @@ namespace video ...@@ -61,7 +61,7 @@ namespace video
//! sets a render target //! sets a render target
virtual bool setRenderTarget(video::ITexture* texture, virtual bool setRenderTarget(video::ITexture* texture,
bool clearBackBuffer=true, bool clearZBuffer=true, bool clearBackBuffer=true, bool clearZBuffer=true,
SColor color=video::SColor(0,0,0,0)) _IRR_OVERRIDE_; SColor color=video::SColor(0,0,0,0), video::ITexture* depthStencil=0) _IRR_OVERRIDE_;
//! sets a viewport //! sets a viewport
virtual void setViewPort(const core::rect<s32>& area) _IRR_OVERRIDE_; virtual void setViewPort(const core::rect<s32>& area) _IRR_OVERRIDE_;
......
...@@ -32,9 +32,7 @@ namespace video ...@@ -32,9 +32,7 @@ namespace video
//! rendertarget constructor //! rendertarget constructor
CD3D8Texture::CD3D8Texture(CD3D8Driver* driver, const core::dimension2d<u32>& size, const io::path& name) CD3D8Texture::CD3D8Texture(CD3D8Driver* driver, const core::dimension2d<u32>& size, const io::path& name)
: ITexture(name), Texture(0), RTTSurface(0), Driver(driver), : ITexture(name), Texture(0), RTTSurface(0), Driver(driver)
TextureSize(size), ImageSize(size), Pitch(0),
HasMipMaps(false), IsRenderTarget(true)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CD3D8Texture"); setDebugName("CD3D8Texture");
...@@ -44,6 +42,11 @@ CD3D8Texture::CD3D8Texture(CD3D8Driver* driver, const core::dimension2d<u32>& si ...@@ -44,6 +42,11 @@ CD3D8Texture::CD3D8Texture(CD3D8Driver* driver, const core::dimension2d<u32>& si
if (Device) if (Device)
Device->AddRef(); Device->AddRef();
DriverType = EDT_DIRECT3D8;
OriginalSize = size;
Size = size;
IsRenderTarget = true;
createRenderTarget(); createRenderTarget();
} }
...@@ -51,14 +54,13 @@ CD3D8Texture::CD3D8Texture(CD3D8Driver* driver, const core::dimension2d<u32>& si ...@@ -51,14 +54,13 @@ CD3D8Texture::CD3D8Texture(CD3D8Driver* driver, const core::dimension2d<u32>& si
//! constructor //! constructor
CD3D8Texture::CD3D8Texture(IImage* image, CD3D8Driver* driver, CD3D8Texture::CD3D8Texture(IImage* image, CD3D8Driver* driver,
u32 flags, const io::path& name, void* mipmapData) u32 flags, const io::path& name, void* mipmapData)
: ITexture(name), Texture(0), RTTSurface(0), Driver(driver), : ITexture(name), Texture(0), RTTSurface(0), Driver(driver)
TextureSize(0,0), ImageSize(0,0), Pitch(0),
HasMipMaps(false), IsRenderTarget(false)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CD3D8Texture"); setDebugName("CD3D8Texture");
#endif #endif
DriverType = EDT_DIRECT3D8;
HasMipMaps = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); HasMipMaps = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
Device=driver->getExposedVideoData().D3D8.D3DDev8; Device=driver->getExposedVideoData().D3D8.D3DDev8;
...@@ -106,9 +108,9 @@ CD3D8Texture::~CD3D8Texture() ...@@ -106,9 +108,9 @@ CD3D8Texture::~CD3D8Texture()
//! creates the hardware texture //! creates the hardware texture
bool CD3D8Texture::createTexture(u32 flags, video::IImage* image) bool CD3D8Texture::createTexture(u32 flags, video::IImage* image)
{ {
ImageSize = image->getDimension(); OriginalSize = image->getDimension();
core::dimension2d<u32> optSize = ImageSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT), !Driver->queryFeature(EVDF_TEXTURE_NSQUARE), true, Driver->Caps.MaxTextureWidth); core::dimension2d<u32> optSize = OriginalSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT), !Driver->queryFeature(EVDF_TEXTURE_NSQUARE), true, Driver->Caps.MaxTextureWidth);
D3DFORMAT format = D3DFMT_A1R5G5B5; D3DFORMAT format = D3DFMT_A1R5G5B5;
switch(getTextureFormatFromFlags(flags)) switch(getTextureFormatFromFlags(flags))
...@@ -187,8 +189,8 @@ bool CD3D8Texture::copyTexture(video::IImage* image) ...@@ -187,8 +189,8 @@ bool CD3D8Texture::copyTexture(video::IImage* image)
D3DSURFACE_DESC desc; D3DSURFACE_DESC desc;
Texture->GetLevelDesc(0, &desc); Texture->GetLevelDesc(0, &desc);
TextureSize.Width = desc.Width; Size.Width = desc.Width;
TextureSize.Height = desc.Height; Size.Height = desc.Height;
D3DLOCKED_RECT rect; D3DLOCKED_RECT rect;
HRESULT hr = Texture->LockRect(0, &rect, 0, 0); HRESULT hr = Texture->LockRect(0, &rect, 0, 0);
...@@ -199,7 +201,7 @@ bool CD3D8Texture::copyTexture(video::IImage* image) ...@@ -199,7 +201,7 @@ bool CD3D8Texture::copyTexture(video::IImage* image)
} }
Pitch = rect.Pitch; Pitch = rect.Pitch;
image->copyToScaling(rect.pBits, TextureSize.Width, TextureSize.Height, ColorFormat, Pitch); image->copyToScaling(rect.pBits, Size.Width, Size.Height, ColorFormat, Pitch);
hr = Texture->UnlockRect(0); hr = Texture->UnlockRect(0);
if (FAILED(hr)) if (FAILED(hr))
...@@ -283,42 +285,6 @@ void CD3D8Texture::unlock() ...@@ -283,42 +285,6 @@ void CD3D8Texture::unlock()
RTTSurface->UnlockRect(); RTTSurface->UnlockRect();
} }
//! Returns original size of the texture.
const core::dimension2d<u32>& CD3D8Texture::getOriginalSize() const
{
return ImageSize;
}
//! Returns (=size) of the texture.
const core::dimension2d<u32>& CD3D8Texture::getSize() const
{
return TextureSize;
}
//! returns driver type of texture (=the driver, who created the texture)
E_DRIVER_TYPE CD3D8Texture::getDriverType() const
{
return EDT_DIRECT3D8;
}
//! returns color format of texture
ECOLOR_FORMAT CD3D8Texture::getColorFormat() const
{
return ColorFormat;
}
//! returns pitch of texture (in bytes)
u32 CD3D8Texture::getPitch() const
{
return Pitch;
}
//! returns the DIRECT3D8 Texture //! returns the DIRECT3D8 Texture
IDirect3DTexture8* CD3D8Texture::getDX8Texture() const IDirect3DTexture8* CD3D8Texture::getDX8Texture() const
{ {
...@@ -434,16 +400,16 @@ ECOLOR_FORMAT CD3D8Texture::getColorFormatFromD3DFormat(D3DFORMAT format) ...@@ -434,16 +400,16 @@ ECOLOR_FORMAT CD3D8Texture::getColorFormatFromD3DFormat(D3DFORMAT format)
{ {
case D3DFMT_X1R5G5B5: case D3DFMT_X1R5G5B5:
case D3DFMT_A1R5G5B5: case D3DFMT_A1R5G5B5:
Pitch = TextureSize.Width * 2; Pitch = Size.Width * 2;
return ECF_A1R5G5B5; return ECF_A1R5G5B5;
break; break;
case D3DFMT_A8R8G8B8: case D3DFMT_A8R8G8B8:
case D3DFMT_X8R8G8B8: case D3DFMT_X8R8G8B8:
Pitch = TextureSize.Width * 4; Pitch = Size.Width * 4;
return ECF_A8R8G8B8; return ECF_A8R8G8B8;
break; break;
case D3DFMT_R5G6B5: case D3DFMT_R5G6B5:
Pitch = TextureSize.Width * 2; Pitch = Size.Width * 2;
return ECF_R5G6B5; return ECF_R5G6B5;
break; break;
default: default:
...@@ -547,7 +513,7 @@ void CD3D8Texture::copy32BitMipMap(char* src, char* tgt, ...@@ -547,7 +513,7 @@ void CD3D8Texture::copy32BitMipMap(char* src, char* tgt,
void CD3D8Texture::createRenderTarget() void CD3D8Texture::createRenderTarget()
{ {
TextureSize = TextureSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT), !Driver->queryFeature(EVDF_TEXTURE_NSQUARE), true, Driver->Caps.MaxTextureWidth); Size = Size.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT), !Driver->queryFeature(EVDF_TEXTURE_NSQUARE), true, Driver->Caps.MaxTextureWidth);
// get backbuffer format to create the render target in the // get backbuffer format to create the render target in the
// same format // same format
...@@ -577,8 +543,8 @@ void CD3D8Texture::createRenderTarget() ...@@ -577,8 +543,8 @@ void CD3D8Texture::createRenderTarget()
HRESULT hr; HRESULT hr;
hr = Device->CreateTexture( hr = Device->CreateTexture(
TextureSize.Width, Size.Width,
TextureSize.Height, Size.Height,
1, // mip map level count, we don't want mipmaps here 1, // mip map level count, we don't want mipmaps here
D3DUSAGE_RENDERTARGET, D3DUSAGE_RENDERTARGET,
d3DFormat, d3DFormat,
...@@ -599,7 +565,7 @@ void CD3D8Texture::regenerateMipMapLevels(void* mipmapData) ...@@ -599,7 +565,7 @@ void CD3D8Texture::regenerateMipMapLevels(void* mipmapData)
{ {
if (mipmapData) if (mipmapData)
{ {
core::dimension2du size = TextureSize; core::dimension2du size = Size;
u32 level=0; u32 level=0;
do do
{ {
...@@ -627,8 +593,8 @@ void CD3D8Texture::regenerateMipMapLevels(void* mipmapData) ...@@ -627,8 +593,8 @@ void CD3D8Texture::regenerateMipMapLevels(void* mipmapData)
return; return;
} }
memcpy(miplr.pBits, mipmapData, size.getArea()*getPitch()/TextureSize.Width); memcpy(miplr.pBits, mipmapData, size.getArea()*getPitch()/Size.Width);
mipmapData = (u8*)mipmapData+size.getArea()*getPitch()/TextureSize.Width; mipmapData = (u8*)mipmapData+size.getArea()*getPitch()/Size.Width;
// unlock // unlock
mipSurface->UnlockRect(); mipSurface->UnlockRect();
// release // release
...@@ -650,14 +616,6 @@ void CD3D8Texture::regenerateMipMapLevels(void* mipmapData) ...@@ -650,14 +616,6 @@ void CD3D8Texture::regenerateMipMapLevels(void* mipmapData)
} }
} }
//! returns if it is a render target
bool CD3D8Texture::isRenderTarget() const
{
return IsRenderTarget;
}
//! Returns pointer to the render target surface //! Returns pointer to the render target surface
IDirect3DSurface8* CD3D8Texture::getRenderTargetSurface() IDirect3DSurface8* CD3D8Texture::getRenderTargetSurface()
{ {
......
...@@ -43,21 +43,6 @@ public: ...@@ -43,21 +43,6 @@ public:
//! unlock function //! unlock function
virtual void unlock() _IRR_OVERRIDE_; virtual void unlock() _IRR_OVERRIDE_;
//! Returns original size of the texture.
virtual const core::dimension2d<u32>& getOriginalSize() const _IRR_OVERRIDE_;
//! Returns (=size) of the texture.
virtual const core::dimension2d<u32>& getSize() const _IRR_OVERRIDE_;
//! returns driver type of texture (=the driver, who created the texture)
virtual E_DRIVER_TYPE getDriverType() const _IRR_OVERRIDE_;
//! returns color format of texture
virtual ECOLOR_FORMAT getColorFormat() const _IRR_OVERRIDE_;
//! returns pitch of texture (in bytes)
virtual u32 getPitch() const _IRR_OVERRIDE_;
//! returns the DIRECT3D8 Texture //! returns the DIRECT3D8 Texture
IDirect3DTexture8* getDX8Texture() const; IDirect3DTexture8* getDX8Texture() const;
...@@ -68,9 +53,6 @@ public: ...@@ -68,9 +53,6 @@ public:
//! modifying the texture //! modifying the texture
virtual void regenerateMipMapLevels(void* mipmapData=0) _IRR_OVERRIDE_; virtual void regenerateMipMapLevels(void* mipmapData=0) _IRR_OVERRIDE_;
//! returns if it is a render target
virtual bool isRenderTarget() const _IRR_OVERRIDE_;
//! Returns pointer to the render target surface //! Returns pointer to the render target surface
IDirect3DSurface8* getRenderTargetSurface(); IDirect3DSurface8* getRenderTargetSurface();
...@@ -105,14 +87,7 @@ private: ...@@ -105,14 +87,7 @@ private:
IDirect3DTexture8* Texture; IDirect3DTexture8* Texture;
IDirect3DSurface8* RTTSurface; IDirect3DSurface8* RTTSurface;
CD3D8Driver* Driver; CD3D8Driver* Driver;
core::dimension2d<u32> TextureSize;
core::dimension2d<u32> ImageSize;
s32 Pitch;
u32 MipLevelLocked; u32 MipLevelLocked;
ECOLOR_FORMAT ColorFormat;
bool HasMipMaps;
bool IsRenderTarget;
}; };
......
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