# 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-2006 Torus Knot Software Ltd
    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 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef __HardwarePixelBuffer__
    00030 #define __HardwarePixelBuffer__
    00031
    00032 // Precompiler options
    00033 #include "OgrePrerequisites.h"
    00034 #include "OgreHardwareBuffer.h"
    00035 #include "OgreSharedPtr.h"
    00036 #include "OgrePixelFormat.h"
    00037 #include "OgreImage.h"
    00038
    00039 namespace Ogre {
    00040
    00047     class _OgreExport HardwarePixelBuffer : public HardwareBuffer
    00048     {
    00049     protected:
    00050         // Extents
    00051         size_t mWidth, mHeight, mDepth;
    00052         // Pitches (offsets between rows and slices)
    00053         size_t mRowPitch, mSlicePitch;
    00054         // Internal format
    00055         PixelFormat mFormat;
    00056         // Currently locked region (local coords)
    00057         PixelBox mCurrentLock;
    00058         // The current locked box of this surface (entire surface coords)
    00059         Image::Box mLockedBox;
    00060
    00062         virtual PixelBox lockImpl(const Image::Box lockBox,  LockOptions options) = 0;
    00063
    00066         virtual void* lockImpl(size_t offset, size_t length, LockOptions options);
    00067
    00069         // virtual void unlockImpl(void) = 0;
    00070
    00074         virtual void _clearSliceRTT(size_t zoffset);
    00075         friend class RenderTexture;
    00076     public:
    00078         HardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth,
    00079                 PixelFormat mFormat,
    00080                 HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer);
    00081         ~HardwarePixelBuffer();
    00082
    00086         using HardwareBuffer::lock;
    00087
    00094         virtual const PixelBox& lock(const Image::Box& lockBox, LockOptions options);
    00096         virtual void* lock(size_t offset, size_t length, LockOptions options);
    00097
    00102         const PixelBox& getCurrentLock();
    00103
    00105         virtual void readData(size_t offset, size_t length, void* pDest);
    00107         virtual void writeData(size_t offset, size_t length, const void* pSource,
    00108                 bool discardWholeBuffer = false);
    00109
    00120         virtual void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
    00121
    00127         void blit(const HardwarePixelBufferSharedPtr &src);
    00128
    00138         virtual void blitFromMemory(const PixelBox &src, const Image::Box &dstBox) = 0;
    00139
    00145         void blitFromMemory(const PixelBox &src)
    00146         {
    00147             blitFromMemory(src, Box(0,0,0,mWidth,mHeight,mDepth));
    00148         }
    00149
    00157         virtual void blitToMemory(const Image::Box &srcBox, const PixelBox &dst) = 0;
    00158
    00164         void blitToMemory(const PixelBox &dst)
    00165         {
    00166             blitToMemory(Box(0,0,0,mWidth,mHeight,mDepth), dst);
    00167         }
    00168
    00176         virtual RenderTexture *getRenderTarget(size_t slice=0);
    00177
    00179         size_t getWidth() const { return mWidth; }
    00181         size_t getHeight() const { return mHeight; }
    00183         size_t getDepth() const { return mDepth; }
    00185         PixelFormat getFormat() const { return mFormat; }
    00186     };
    00187
    00189     class _OgreExport HardwarePixelBufferSharedPtr : public SharedPtr<HardwarePixelBuffer>
    00190     {
    00191     public:
    00192         HardwarePixelBufferSharedPtr() : SharedPtr<HardwarePixelBuffer>() {}
    00193         explicit HardwarePixelBufferSharedPtr(HardwarePixelBuffer* buf);
    00194
    00195
    00196     };
    00197
    00198 }
    00199 #endif
    00200

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Dec 27 17:31:05 2009