OGRE: OgreHardwarePixelBuffer.h Source File - OGRE Documentation

# 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-2009 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028 #ifndef __HardwarePixelBuffer__
    00029 #define __HardwarePixelBuffer__
    00030
    00031 // Precompiler options
    00032 #include "OgrePrerequisites.h"
    00033 #include "OgreHardwareBuffer.h"
    00034 #include "OgreSharedPtr.h"
    00035 #include "OgrePixelFormat.h"
    00036 #include "OgreImage.h"
    00037
    00038 namespace Ogre {
    00039
    00052     class _OgreExport HardwarePixelBuffer : public HardwareBuffer
    00053     {
    00054     protected:
    00055         // Extents
    00056         size_t mWidth, mHeight, mDepth;
    00057         // Pitches (offsets between rows and slices)
    00058         size_t mRowPitch, mSlicePitch;
    00059         // Internal format
    00060         PixelFormat mFormat;
    00061         // Currently locked region (local coords)
    00062         PixelBox mCurrentLock;
    00063         // The current locked box of this surface (entire surface coords)
    00064         Image::Box mLockedBox;
    00065
    00066
    00068         virtual PixelBox lockImpl(const Image::Box lockBox,  LockOptions options) = 0;
    00069
    00072         virtual void* lockImpl(size_t offset, size_t length, LockOptions options);
    00073
    00075         // virtual void unlockImpl(void) = 0;
    00076
    00080         virtual void _clearSliceRTT(size_t zoffset);
    00081         friend class RenderTexture;
    00082     public:
    00084         HardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth,
    00085                 PixelFormat mFormat,
    00086                 HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer);
    00087         ~HardwarePixelBuffer();
    00088
    00092         using HardwareBuffer::lock;
    00093
    00100         virtual const PixelBox& lock(const Image::Box& lockBox, LockOptions options);
    00102         virtual void* lock(size_t offset, size_t length, LockOptions options);
    00103
    00108         const PixelBox& getCurrentLock();
    00109
    00111         virtual void readData(size_t offset, size_t length, void* pDest);
    00113         virtual void writeData(size_t offset, size_t length, const void* pSource,
    00114                 bool discardWholeBuffer = false);
    00115
    00126         virtual void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
    00127
    00133         void blit(const HardwarePixelBufferSharedPtr &src);
    00134
    00144         virtual void blitFromMemory(const PixelBox &src, const Image::Box &dstBox) = 0;
    00145
    00151         void blitFromMemory(const PixelBox &src)
    00152         {
    00153             blitFromMemory(src, Box(0,0,0,mWidth,mHeight,mDepth));
    00154         }
    00155
    00163         virtual void blitToMemory(const Image::Box &srcBox, const PixelBox &dst) = 0;
    00164
    00170         void blitToMemory(const PixelBox &dst)
    00171         {
    00172             blitToMemory(Box(0,0,0,mWidth,mHeight,mDepth), dst);
    00173         }
    00174
    00182         virtual RenderTexture *getRenderTarget(size_t slice=0);
    00183
    00185         size_t getWidth() const { return mWidth; }
    00187         size_t getHeight() const { return mHeight; }
    00189         size_t getDepth() const { return mDepth; }
    00191         PixelFormat getFormat() const { return mFormat; }
    00192     };
    00193
    00195     class _OgreExport HardwarePixelBufferSharedPtr : public SharedPtr<HardwarePixelBuffer>
    00196     {
    00197     public:
    00198         HardwarePixelBufferSharedPtr() : SharedPtr<HardwarePixelBuffer>() {}
    00199         explicit HardwarePixelBufferSharedPtr(HardwarePixelBuffer* buf);
    00200
    00201
    00202     };
    00203
    00206 }
    00207 #endif
    00208

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:51