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 { 00042 class _OgreExport HardwarePixelBuffer : public HardwareBuffer 00043 { 00044 protected: 00045 // Extents 00046 size_t mWidth, mHeight, mDepth; 00047 // Pitches (offsets between rows and slices) 00048 size_t mRowPitch, mSlicePitch; 00049 // Internal format 00050 PixelFormat mFormat; 00051 // Currently locked region 00052 PixelBox mCurrentLock; 00053 00055 virtual PixelBox lockImpl(const Image::Box lockBox, LockOptions options) = 0; 00056 00059 virtual void* lockImpl(size_t offset, size_t length, LockOptions options); 00060 00062 // virtual void unlockImpl(void) = 0; 00063 public: 00065 HardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth, 00066 PixelFormat mFormat, 00067 HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer); 00068 ~HardwarePixelBuffer(); 00069 00073 using HardwareBuffer::lock; 00074 00081 virtual const PixelBox& lock(const Image::Box& lockBox, LockOptions options); 00083 virtual void* lock(size_t offset, size_t length, LockOptions options); 00084 00089 const PixelBox& getCurrentLock(); 00090 00092 virtual void readData(size_t offset, size_t length, void* pDest); 00094 virtual void writeData(size_t offset, size_t length, const void* pSource, 00095 bool discardWholeBuffer = false); 00096 00107 virtual void blit(HardwarePixelBuffer *src, const Image::Box &srcBox, const Image::Box &dstBox); 00108 00114 void blit(HardwarePixelBuffer *src) 00115 { 00116 blit(src, 00117 Box(0,0,0,src->getWidth(),src->getHeight(),src->getDepth()), 00118 Box(0,0,0,mWidth,mHeight,mDepth) 00119 ); 00120 } 00121 00131 virtual void blitFromMemory(const PixelBox &src, const Image::Box &dstBox) = 0; 00132 00138 void blitFromMemory(const PixelBox &src) 00139 { 00140 blitFromMemory(src, Box(0,0,0,mWidth,mHeight,mDepth)); 00141 } 00142 00150 virtual void blitToMemory(const Image::Box &srcBox, const PixelBox &dst) = 0; 00151 00157 void blitToMemory(const PixelBox &dst) 00158 { 00159 blitToMemory(Box(0,0,0,mWidth,mHeight,mDepth), dst); 00160 } 00161 00163 size_t getWidth() const { return mWidth; } 00165 size_t getHeight() const { return mHeight; } 00167 size_t getDepth() const { return mDepth; } 00169 PixelFormat getFormat() const { return mFormat; } 00170 }; 00171 00173 class _OgreExport HardwarePixelBufferSharedPtr : public SharedPtr<HardwarePixelBuffer> 00174 { 00175 public: 00176 HardwarePixelBufferSharedPtr() : SharedPtr<HardwarePixelBuffer>() {} 00177 explicit HardwarePixelBufferSharedPtr(HardwarePixelBuffer* buf); 00178 00179 00180 }; 00181 00182 } 00183 #endif 00184
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Feb 12 12:59:46 2006