aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CD3D9Texture.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CD3D9Texture.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CD3D9Texture.h130
1 files changed, 130 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CD3D9Texture.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CD3D9Texture.h
new file mode 100644
index 0000000..812aa71
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CD3D9Texture.h
@@ -0,0 +1,130 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __C_DIRECTX9_TEXTURE_H_INCLUDED__
6#define __C_DIRECTX9_TEXTURE_H_INCLUDED__
7
8#include "IrrCompileConfig.h"
9#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
10
11#include "ITexture.h"
12#include "IImage.h"
13#if defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
14#include "irrMath.h" // needed by borland for sqrtf define
15#endif
16#include <d3d9.h>
17
18namespace irr
19{
20namespace video
21{
22
23class CD3D9Driver;
24// forward declaration for RTT depth buffer handling
25struct SDepthSurface;
26/*!
27 interface for a Video Driver dependent Texture.
28*/
29class CD3D9Texture : public ITexture
30{
31public:
32
33 //! constructor
34 CD3D9Texture(IImage* image, CD3D9Driver* driver,
35 u32 flags, const io::path& name, void* mipmapData=0);
36
37 //! rendertarget constructor
38 CD3D9Texture(CD3D9Driver* driver, const core::dimension2d<u32>& size, const io::path& name,
39 const ECOLOR_FORMAT format = ECF_UNKNOWN);
40
41 //! destructor
42 virtual ~CD3D9Texture();
43
44 //! lock function
45 virtual void* lock(E_TEXTURE_LOCK_MODE mode=ETLM_READ_WRITE, u32 mipmapLevel=0);
46
47 //! unlock function
48 virtual void unlock();
49
50 //! Returns original size of the texture.
51 virtual const core::dimension2d<u32>& getOriginalSize() const;
52
53 //! Returns (=size) of the texture.
54 virtual const core::dimension2d<u32>& getSize() const;
55
56 //! returns driver type of texture (=the driver, who created the texture)
57 virtual E_DRIVER_TYPE getDriverType() const;
58
59 //! returns color format of texture
60 virtual ECOLOR_FORMAT getColorFormat() const;
61
62 //! returns pitch of texture (in bytes)
63 virtual u32 getPitch() const;
64
65 //! returns the DIRECT3D9 Texture
66 IDirect3DBaseTexture9* getDX9Texture() const;
67
68 //! returns if texture has mipmap levels
69 bool hasMipMaps() const;
70
71 //! Regenerates the mip map levels of the texture. Useful after locking and
72 //! modifying the texture
73 virtual void regenerateMipMapLevels(void* mipmapData=0);
74
75 //! returns if it is a render target
76 virtual bool isRenderTarget() const;
77
78 //! Returns pointer to the render target surface
79 IDirect3DSurface9* getRenderTargetSurface();
80
81private:
82 friend class CD3D9Driver;
83
84 void createRenderTarget(const ECOLOR_FORMAT format = ECF_UNKNOWN);
85
86 //! creates the hardware texture
87 bool createTexture(u32 flags, IImage * image);
88
89 //! copies the image to the texture
90 bool copyTexture(IImage * image);
91
92 //! Helper function for mipmap generation.
93 bool createMipMaps(u32 level=1);
94
95 //! Helper function for mipmap generation.
96 void copy16BitMipMap(char* src, char* tgt,
97 s32 width, s32 height, s32 pitchsrc, s32 pitchtgt) const;
98
99 //! Helper function for mipmap generation.
100 void copy32BitMipMap(char* src, char* tgt,
101 s32 width, s32 height, s32 pitchsrc, s32 pitchtgt) const;
102
103 //! set Pitch based on the d3d format
104 void setPitch(D3DFORMAT d3dformat);
105
106 IDirect3DDevice9* Device;
107 IDirect3DTexture9* Texture;
108 IDirect3DSurface9* RTTSurface;
109 CD3D9Driver* Driver;
110 SDepthSurface* DepthSurface;
111 core::dimension2d<u32> TextureSize;
112 core::dimension2d<u32> ImageSize;
113 s32 Pitch;
114 u32 MipLevelLocked;
115 ECOLOR_FORMAT ColorFormat;
116
117 bool HasMipMaps;
118 bool HardwareMipMaps;
119 bool IsRenderTarget;
120};
121
122
123} // end namespace video
124} // end namespace irr
125
126#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
127
128#endif // __C_DIRECTX9_TEXTURE_H_INCLUDED__
129
130