Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreHardwarePixelBuffer.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __HardwarePixelBuffer__
00026 #define __HardwarePixelBuffer__
00027 
00028 // Precompiler options
00029 #include "OgrePrerequisites.h"
00030 #include "OgreHardwareBuffer.h"
00031 #include "OgreSharedPtr.h"
00032 #include "OgrePixelFormat.h"
00033 #include "OgreImage.h"
00034 
00035 namespace Ogre {
00036 
00043     class _OgreExport HardwarePixelBuffer : public HardwareBuffer
00044     {
00045     protected: 
00046         // Extents
00047         size_t mWidth, mHeight, mDepth;
00048         // Pitches (offsets between rows and slices)
00049         size_t mRowPitch, mSlicePitch;
00050         // Internal format
00051         PixelFormat mFormat;
00052         // Currently locked region
00053         PixelBox mCurrentLock;
00054         
00056         virtual PixelBox lockImpl(const Image::Box lockBox,  LockOptions options) = 0;
00057 
00060         virtual void* lockImpl(size_t offset, size_t length, LockOptions options);
00061 
00063         // virtual void unlockImpl(void) = 0;
00064 
00068         virtual void _clearSliceRTT(size_t zoffset);
00069         friend class RenderTexture;
00070     public:
00072         HardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth,
00073                 PixelFormat mFormat,
00074                 HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer);
00075         ~HardwarePixelBuffer();
00076 
00080         using HardwareBuffer::lock; 
00081 
00088         virtual const PixelBox& lock(const Image::Box& lockBox, LockOptions options);
00090         virtual void* lock(size_t offset, size_t length, LockOptions options);
00091 
00096         const PixelBox& getCurrentLock();
00097         
00099         virtual void readData(size_t offset, size_t length, void* pDest);
00101         virtual void writeData(size_t offset, size_t length, const void* pSource,
00102                 bool discardWholeBuffer = false);
00103         
00114         virtual void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
00115 
00121         void blit(const HardwarePixelBufferSharedPtr &src); 
00122         
00132         virtual void blitFromMemory(const PixelBox &src, const Image::Box &dstBox) = 0;
00133         
00139         void blitFromMemory(const PixelBox &src)
00140         {
00141             blitFromMemory(src, Box(0,0,0,mWidth,mHeight,mDepth));
00142         }
00143         
00151         virtual void blitToMemory(const Image::Box &srcBox, const PixelBox &dst) = 0;
00152 
00158         void blitToMemory(const PixelBox &dst)
00159         {
00160             blitToMemory(Box(0,0,0,mWidth,mHeight,mDepth), dst);
00161         }
00162         
00170         virtual RenderTexture *getRenderTarget(size_t slice=0);
00171         
00173         size_t getWidth() const { return mWidth; }
00175         size_t getHeight() const { return mHeight; }
00177         size_t getDepth() const { return mDepth; }
00179         PixelFormat getFormat() const { return mFormat; }
00180     };
00181 
00183     class _OgreExport HardwarePixelBufferSharedPtr : public SharedPtr<HardwarePixelBuffer>
00184     {
00185     public:
00186         HardwarePixelBufferSharedPtr() : SharedPtr<HardwarePixelBuffer>() {}
00187         explicit HardwarePixelBufferSharedPtr(HardwarePixelBuffer* buf);
00188 
00189 
00190     };
00191 
00192 }
00193 #endif
00194 

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:42 2006