Commit e12ef3a4 authored by nadro's avatar nadro

- Changes for D3D9 texture code (at now it looks like OpenGL texture code)....

- Changes for D3D9 texture code (at now it looks like OpenGL texture code). Those changes was required for upcoming cubemaps support.
- Minor improvements in COGLCoreTexture.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5237 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 1aba16d8
......@@ -603,9 +603,7 @@ bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
case EVDF_MIP_MAP:
return (Caps.TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0;
case EVDF_MIP_MAP_AUTO_UPDATE:
// always return false because a lot of drivers claim they do
// this but actually don't do this at all.
return false; //(Caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP) != 0;
return (Caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP) != 0;
case EVDF_STENCIL_BUFFER:
return Params.Stencilbuffer && Caps.StencilCaps;
case EVDF_VERTEX_SHADER_1_1:
......@@ -744,24 +742,19 @@ void CD3D9Driver::setMaterial(const SMaterial& material)
ITexture* CD3D9Driver::createDeviceDependentTexture(const io::path& name, IImage* image)
{
CD3D9Texture* texture = new CD3D9Texture(image, this, TextureCreationFlags, name);
core::array<IImage*> imageArray(1);
imageArray.push_back(image);
CD3D9Texture* texture = new CD3D9Texture(name, imageArray, ETT_2D, this);
return texture;
}
/*ITexture* CD3D9Driver::createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image)
ITexture* CD3D9Driver::createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image)
{
CD3D9Texture* texture = new CD3D9Texture(name, image, ETT_CUBEMAP, this);
}*/
//! Enables or disables a texture creation flag.
void CD3D9Driver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag,
bool enabled)
{
if (flag == video::ETCF_CREATE_MIP_MAPS && !queryFeature(EVDF_MIP_MAP))
enabled = false;
CNullDriver::setTextureCreationFlag(flag, enabled);
return texture;
}
bool CD3D9Driver::setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil)
......@@ -2880,7 +2873,7 @@ bool CD3D9Driver::reset()
for (i=0; i<Textures.size(); ++i)
{
if (Textures[i].Surface->isRenderTarget())
((CD3D9Texture*)(Textures[i].Surface))->createRenderTarget();
((CD3D9Texture*)(Textures[i].Surface))->generateRenderTarget();
}
for (i = 0; i<RenderTargets.size(); ++i)
{
......
......@@ -213,9 +213,6 @@ namespace video
//! call.
virtual u32 getMaximalPrimitiveCount() const _IRR_OVERRIDE_;
//! Enables or disables a texture creation flag.
virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) _IRR_OVERRIDE_;
//! Sets the fog mode.
virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start,
f32 end, f32 density, bool pixelFog, bool rangeFog) _IRR_OVERRIDE_;
......@@ -348,7 +345,7 @@ namespace video
virtual ITexture* createDeviceDependentTexture(const io::path& name, IImage* image) _IRR_OVERRIDE_;
/*virtual ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image) _IRR_OVERRIDE_;*/
virtual ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image) _IRR_OVERRIDE_;
//! returns the current size of the screen or rendertarget
virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const _IRR_OVERRIDE_;
......
This diff is collapsed.
......@@ -8,6 +8,7 @@
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
#include "irrArray.h"
#include "ITexture.h"
#include "IImage.h"
#if defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
......@@ -21,82 +22,52 @@ namespace video
{
class CD3D9Driver;
// forward declaration for RTT depth buffer handling
struct SDepthSurface;
/*!
interface for a Video Driver dependent Texture.
*/
class CD3D9Texture : public ITexture
{
public:
CD3D9Texture(const io::path& name, const core::array<IImage*>& image, E_TEXTURE_TYPE type, CD3D9Driver* driver);
//! constructor
CD3D9Texture(IImage* image, CD3D9Driver* driver,
u32 flags, const io::path& name);
//! rendertarget constructor
CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size, const io::path& name,
const ECOLOR_FORMAT format = ECF_UNKNOWN);
CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size, const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
//! destructor
virtual ~CD3D9Texture();
//! lock function
virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0) _IRR_OVERRIDE_;
virtual void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel = 0) _IRR_OVERRIDE_;
//! unlock function
virtual void unlock() _IRR_OVERRIDE_;
virtual void regenerateMipMapLevels(void* data = 0, u32 layer = 0) _IRR_OVERRIDE_;
//! returns the DIRECT3D9 Texture
IDirect3DTexture9* getDX9Texture() const;
private:
friend class CD3D9Driver;
void createRenderTarget(const ECOLOR_FORMAT format = ECF_UNKNOWN);
void generateRenderTarget();
ECOLOR_FORMAT getBestColorFormat(ECOLOR_FORMAT format);
//! creates the hardware texture
bool createTexture(u32 flags, IImage * image);
void getImageValues(const IImage* image);
//! copies the image to the texture
bool copyTexture(IImage * image);
void uploadTexture(u32 layer, u32 level, void* data);
//! Helper function for mipmap generation.
bool createMipMaps(u32 level=1);
CD3D9Driver* Driver;
//! Helper function for mipmap generation.
void copy16BitMipMap(char* src, char* tgt,
const s32 srcWidth, const s32 srcHeight,
const s32 width, const s32 height,
const s32 pitchsrc, const s32 pitchtgt) const;
D3DFORMAT InternalFormat;
//! Helper function for mipmap generation.
void copy32BitMipMap(char* src, char* tgt,
const s32 srcWidth, const s32 srcHeight,
const s32 width, const s32 height,
const s32 pitchsrc, const s32 pitchtgt) const;
void* LockData;
u32 LockLevel;
//! set Pitch based on the d3d format
void setPitch(D3DFORMAT d3dformat);
bool AutoGenerateMipMaps;
IDirect3DDevice9* Device;
IDirect3DTexture9* Texture;
IDirect3DCubeTexture9* CubeTexture;
IDirect3DSurface9* RTTSurface;
CD3D9Driver* Driver;
u32 MipLevelLocked;
bool HardwareMipMaps;
bool IsCompressed;
};
}
}
} // end namespace video
} // end namespace irr
#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
#endif // __C_DIRECTX9_TEXTURE_H_INCLUDED__
#endif
#endif
......@@ -83,8 +83,6 @@ public:
tmpImage = &Image;
}
Pitch = (*tmpImage)[0]->getPitch();
glGenTextures(1, &TextureName);
const COGLCoreTexture* prevTexture = Driver->getCacheHandler()->getTextureCache().get(0);
......@@ -143,6 +141,8 @@ public:
OriginalSize = size;
Size = OriginalSize;
Pitch = Size.Width * IImage::getBitsPerPixelFromFormat(ColorFormat) / 8;
Driver->getColorFormatParameters(ColorFormat, InternalFormat, PixelFormat, PixelType, &Converter);
glGenTextures(1, &TextureName);
......@@ -284,7 +284,7 @@ public:
Driver->getCacheHandler()->getTextureCache().set(0, prevTexture);
if (LockLevel == 0)
regenerateMipMapLevels(LockImage->getMipMapsData());
regenerateMipMapLevels(0);
}
LockImage->drop();
......@@ -433,6 +433,8 @@ protected:
}
Size = Size.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT));
Pitch = Size.Width * IImage::getBitsPerPixelFromFormat(ColorFormat) / 8;
}
void uploadTexture(bool initTexture, u32 layer, u32 level, void* data)
......@@ -485,7 +487,7 @@ protected:
}
else
{
u32 dataSize = IImage::getDataSizeFromFormat(ColorFormat, Size.Width, height);
u32 dataSize = IImage::getDataSizeFromFormat(ColorFormat, width, height);
switch (TextureType)
{
......
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