| 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-2006 Torus Knot Software Ltd |
|---|
| 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 | You may alternatively use this source under the terms of a specific version of |
|---|
| 25 | the OGRE Unrestricted License provided you have obtained such a license from |
|---|
| 26 | Torus Knot Software Ltd. |
|---|
| 27 | ----------------------------------------------------------------------------- |
|---|
| 28 | */ |
|---|
| 29 | #ifndef __D3D9PIXELBUFFER_H__ |
|---|
| 30 | #define __D3D9PIXELBUFFER_H__ |
|---|
| 31 | |
|---|
| 32 | #include "OgreD3D9Prerequisites.h" |
|---|
| 33 | #include "OgreHardwarePixelBuffer.h" |
|---|
| 34 | |
|---|
| 35 | #include <d3d9.h> |
|---|
| 36 | #include <d3dx9.h> |
|---|
| 37 | namespace Ogre { |
|---|
| 38 | |
|---|
| 39 | class D3D9HardwarePixelBuffer: public HardwarePixelBuffer |
|---|
| 40 | { |
|---|
| 41 | protected: |
|---|
| 42 | /// Lock a box |
|---|
| 43 | PixelBox lockImpl(const Image::Box lockBox, LockOptions options); |
|---|
| 44 | |
|---|
| 45 | /// Unlock a box |
|---|
| 46 | void unlockImpl(void); |
|---|
| 47 | |
|---|
| 48 | /// Create (or update) render textures for slices |
|---|
| 49 | void createRenderTextures(bool update); |
|---|
| 50 | /// Destroy render textures for slices |
|---|
| 51 | void destroyRenderTextures(); |
|---|
| 52 | |
|---|
| 53 | /// D3DDevice pointer |
|---|
| 54 | IDirect3DDevice9 *mpDev; |
|---|
| 55 | |
|---|
| 56 | /// Surface abstracted by this buffer |
|---|
| 57 | IDirect3DSurface9 *mSurface; |
|---|
| 58 | /// Volume abstracted by this buffer |
|---|
| 59 | IDirect3DVolume9 *mVolume; |
|---|
| 60 | /// Temporary surface in main memory if direct locking of mSurface is not possible |
|---|
| 61 | IDirect3DSurface9 *mTempSurface; |
|---|
| 62 | /// Temporary volume in main memory if direct locking of mVolume is not possible |
|---|
| 63 | IDirect3DVolume9 *mTempVolume; |
|---|
| 64 | |
|---|
| 65 | /// Mipmapping |
|---|
| 66 | bool mDoMipmapGen; |
|---|
| 67 | bool mHWMipmaps; |
|---|
| 68 | IDirect3DBaseTexture9 *mMipTex; |
|---|
| 69 | |
|---|
| 70 | /// Render targets |
|---|
| 71 | typedef std::vector<RenderTexture*> SliceTRT; |
|---|
| 72 | SliceTRT mSliceTRT; |
|---|
| 73 | public: |
|---|
| 74 | D3D9HardwarePixelBuffer(HardwareBuffer::Usage usage); |
|---|
| 75 | |
|---|
| 76 | /// Call this to associate a D3D surface or volume with this pixel buffer |
|---|
| 77 | void bind(IDirect3DDevice9 *dev, IDirect3DSurface9 *mSurface, bool update); |
|---|
| 78 | void bind(IDirect3DDevice9 *dev, IDirect3DVolume9 *mVolume, bool update); |
|---|
| 79 | |
|---|
| 80 | /// @copydoc HardwarePixelBuffer::blit |
|---|
| 81 | void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox); |
|---|
| 82 | |
|---|
| 83 | /// @copydoc HardwarePixelBuffer::blitFromMemory |
|---|
| 84 | void blitFromMemory(const PixelBox &src, const Image::Box &dstBox); |
|---|
| 85 | |
|---|
| 86 | /// @copydoc HardwarePixelBuffer::blitToMemory |
|---|
| 87 | void blitToMemory(const Image::Box &srcBox, const PixelBox &dst); |
|---|
| 88 | |
|---|
| 89 | /// Internal function to update mipmaps on update of level 0 |
|---|
| 90 | void _genMipmaps(); |
|---|
| 91 | |
|---|
| 92 | /// Function to set mipmap generation |
|---|
| 93 | void _setMipmapping(bool doMipmapGen, bool HWMipmaps, IDirect3DBaseTexture9 *mipTex); |
|---|
| 94 | |
|---|
| 95 | ~D3D9HardwarePixelBuffer(); |
|---|
| 96 | |
|---|
| 97 | /// Get rendertarget for z slice |
|---|
| 98 | RenderTexture *getRenderTarget(size_t zoffset); |
|---|
| 99 | |
|---|
| 100 | /// Accessor for surface |
|---|
| 101 | IDirect3DSurface9 *getSurface() { return mSurface; } |
|---|
| 102 | |
|---|
| 103 | /// Notify TextureBuffer of destruction of render target |
|---|
| 104 | virtual void _clearSliceRTT(size_t zoffset) |
|---|
| 105 | { |
|---|
| 106 | mSliceTRT[zoffset] = 0; |
|---|
| 107 | } |
|---|
| 108 | }; |
|---|
| 109 | }; |
|---|
| 110 | #endif |
|---|