OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreHardwarePixelBuffer.h
Go to the documentation of this file.
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-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __HardwarePixelBuffer__
29 #define __HardwarePixelBuffer__
30 
31 // Precompiler options
32 #include "OgrePrerequisites.h"
33 #include "OgreHardwareBuffer.h"
34 #include "OgreSharedPtr.h"
35 #include "OgrePixelFormat.h"
36 #include "OgrePixelBox.h"
37 
38 #include "OgreImage.h"
39 #include "OgreSharedPtr.h"
40 #include "OgreHeaderPrefix.h"
41 
42 namespace Ogre {
43 
57  {
58  protected:
60  uint32 mWidth, mHeight, mDepth;
62  size_t mRowPitch, mSlicePitch;
69 
70 
72  virtual PixelBox lockImpl(const Image::Box &lockBox, LockOptions options) = 0;
73 
76  virtual void* lockImpl(size_t offset, size_t length, LockOptions options);
77 
81  virtual void _clearSliceRTT(size_t zoffset);
82  friend class RenderTexture;
83  public:
85  HardwarePixelBuffer(uint32 mWidth, uint32 mHeight, uint32 mDepth,
86  PixelFormat mFormat,
87  HardwareBuffer::Usage usage, bool useSystemMemory, bool useShadowBuffer);
89 
93  using HardwareBuffer::lock;
94 
101  virtual const PixelBox& lock(const Image::Box& lockBox, LockOptions options);
103  virtual void* lock(size_t offset, size_t length, LockOptions options, UploadOptions uploadOpt = HBU_DEFAULT);
104 
109  const PixelBox& getCurrentLock();
110 
112  virtual void readData(size_t offset, size_t length, void* pDest);
114  virtual void writeData(size_t offset, size_t length, const void* pSource,
115  bool discardWholeBuffer = false);
116 
127  virtual void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
128 
134  void blit(const HardwarePixelBufferSharedPtr &src);
135 
145  virtual void blitFromMemory(const PixelBox &src, const Image::Box &dstBox) = 0;
146 
152  void blitFromMemory(const PixelBox &src)
153  {
154  blitFromMemory(src, Box(0,0,0,mWidth,mHeight,mDepth));
155  }
156 
164  virtual void blitToMemory(const Image::Box &srcBox, const PixelBox &dst) = 0;
165 
171  void blitToMemory(const PixelBox &dst)
172  {
173  blitToMemory(Box(0,0,0,mWidth,mHeight,mDepth), dst);
174  }
175 
183  virtual RenderTexture *getRenderTarget(size_t slice=0);
184 
186  uint32 getWidth() const { return mWidth; }
188  uint32 getHeight() const { return mHeight; }
190  uint32 getDepth() const { return mDepth; }
192  PixelFormat getFormat() const { return mFormat; }
193  };
194 
196  class _OgreExport HardwarePixelBufferSharedPtr : public SharedPtr<HardwarePixelBuffer>
197  {
198  public:
201 
202 
203  };
204 
207 }
208 
209 #include "OgreHeaderSuffix.h"
210 
211 #endif
212 
PixelBox mCurrentLock
Currently locked region (local coords)
unsigned int uint32
Definition: OgrePlatform.h:420
#define _OgreExport
Definition: OgrePlatform.h:255
This class represents a RenderTarget that renders to a Texture.
void blitFromMemory(const PixelBox &src)
Convenience function that blits a pixelbox from memory to the entire buffer.
LockOptions
Locking options.
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:689
virtual void * lock(size_t offset, size_t length, LockOptions options, UploadOptions uploadOpt=HBU_DEFAULT)
Lock the buffer for (potentially) reading / writing.
uint32 getWidth() const
Gets the width of this buffer.
PixelFormat
The pixel format used for images, textures, and render surfaces.
Usage
Enums describing buffer usage; not mutually exclusive.
UploadOptions
Device load options The following enum is used to controls how data is loaded to devices in a multi d...
Shared pointer implementation used to share pixel buffers.
Specialisation of HardwareBuffer for a pixel buffer.
PixelFormat getFormat() const
Gets the native pixel format of this buffer.
uint32 getDepth() const
Gets the depth of this buffer.
Abstract class defining common features of hardware buffers.
Reference-counted shared pointer, used for objects where implicit destruction is required.
Image::Box mLockedBox
The current locked box of this surface (entire surface coords)
PixelFormat mFormat
Internal format.
void blitToMemory(const PixelBox &dst)
Convenience function that blits this entire buffer to a pixelbox.
uint32 getHeight() const
Gets the height of this buffer.