1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __D3D9PIXELBUFFER_H__
|
---|
26 | #define __D3D9PIXELBUFFER_H__
|
---|
27 |
|
---|
28 | #include "OgreD3D9Prerequisites.h"
|
---|
29 | #include "OgreHardwarePixelBuffer.h"
|
---|
30 |
|
---|
31 | #include <d3d9.h>
|
---|
32 | #include <d3dx9.h>
|
---|
33 | namespace Ogre {
|
---|
34 |
|
---|
35 | class D3D9HardwarePixelBuffer: public HardwarePixelBuffer
|
---|
36 | {
|
---|
37 | protected:
|
---|
38 | /// Lock a box
|
---|
39 | PixelBox lockImpl(const Image::Box lockBox, LockOptions options);
|
---|
40 |
|
---|
41 | /// Unlock a box
|
---|
42 | void unlockImpl(void);
|
---|
43 |
|
---|
44 | /// Create (or update) render textures for slices
|
---|
45 | void createRenderTextures(bool update);
|
---|
46 | /// Destroy render textures for slices
|
---|
47 | void destroyRenderTextures();
|
---|
48 |
|
---|
49 | /// D3DDevice pointer
|
---|
50 | IDirect3DDevice9 *mpDev;
|
---|
51 |
|
---|
52 | /// Surface abstracted by this buffer
|
---|
53 | IDirect3DSurface9 *mSurface;
|
---|
54 | /// Volume abstracted by this buffer
|
---|
55 | IDirect3DVolume9 *mVolume;
|
---|
56 | /// Temporary surface in main memory if direct locking of mSurface is not possible
|
---|
57 | IDirect3DSurface9 *mTempSurface;
|
---|
58 | /// Temporary volume in main memory if direct locking of mVolume is not possible
|
---|
59 | IDirect3DVolume9 *mTempVolume;
|
---|
60 |
|
---|
61 | /// Mipmapping
|
---|
62 | bool mDoMipmapGen;
|
---|
63 | bool mHWMipmaps;
|
---|
64 | IDirect3DBaseTexture9 *mMipTex;
|
---|
65 |
|
---|
66 | /// Render targets
|
---|
67 | typedef std::vector<RenderTexture*> SliceTRT;
|
---|
68 | SliceTRT mSliceTRT;
|
---|
69 | public:
|
---|
70 | D3D9HardwarePixelBuffer(HardwareBuffer::Usage usage);
|
---|
71 |
|
---|
72 | /// Call this to associate a D3D surface or volume with this pixel buffer
|
---|
73 | void bind(IDirect3DDevice9 *dev, IDirect3DSurface9 *mSurface, bool update);
|
---|
74 | void bind(IDirect3DDevice9 *dev, IDirect3DVolume9 *mVolume, bool update);
|
---|
75 |
|
---|
76 | /// @copydoc HardwarePixelBuffer::blit
|
---|
77 | void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
|
---|
78 |
|
---|
79 | /// @copydoc HardwarePixelBuffer::blitFromMemory
|
---|
80 | void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
|
---|
81 |
|
---|
82 | /// @copydoc HardwarePixelBuffer::blitToMemory
|
---|
83 | void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
|
---|
84 |
|
---|
85 | /// Internal function to update mipmaps on update of level 0
|
---|
86 | void _genMipmaps();
|
---|
87 |
|
---|
88 | /// Function to set mipmap generation
|
---|
89 | void _setMipmapping(bool doMipmapGen, bool HWMipmaps, IDirect3DBaseTexture9 *mipTex);
|
---|
90 |
|
---|
91 | ~D3D9HardwarePixelBuffer();
|
---|
92 |
|
---|
93 | /// Get rendertarget for z slice
|
---|
94 | RenderTexture *getRenderTarget(size_t zoffset);
|
---|
95 |
|
---|
96 | /// Accessor for surface
|
---|
97 | IDirect3DSurface9 *getSurface() { return mSurface; }
|
---|
98 |
|
---|
99 | /// Notify TextureBuffer of destruction of render target
|
---|
100 | virtual void _clearSliceRTT(size_t zoffset)
|
---|
101 | {
|
---|
102 | mSliceTRT[zoffset] = 0;
|
---|
103 | }
|
---|
104 | };
|
---|
105 | };
|
---|
106 | #endif
|
---|