OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGLESHardwarePixelBuffer.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) 2008 Renato Araujo Oliveira Filho <renatox@gmail.com>
8 Copyright (c) 2000-2014 Torus Knot Software Ltd
9 
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16 
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 -----------------------------------------------------------------------------
28 */
29 
30 #ifndef __GLESHardwarePixelBuffer_H__
31 #define __GLESHardwarePixelBuffer_H__
32 
33 #include "OgreGLESPrerequisites.h"
35 
36 namespace Ogre {
38  {
39  protected:
41  PixelBox lockImpl(const Image::Box lockBox, LockOptions options);
42 
44  void unlockImpl(void);
45 
46  // Internal buffer; either on-card or in system memory, freed/allocated on demand
47  // depending on buffer usage
49  GLenum mGLInternalFormat; // GL internal format
50  LockOptions mCurrentLockOptions;
51 
52  // Buffer allocation/freeage
53  void allocateBuffer();
54 
55  void freeBuffer();
56 
57  // Upload a box of pixels to this buffer on the card
58  virtual void upload(const PixelBox &data, const Image::Box &dest);
59 
60  // Download a box of pixels from the card
61  virtual void download(const PixelBox &data);
62 
63  public:
65  GLESHardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth,
66  PixelFormat mFormat,
67  HardwareBuffer::Usage usage);
68 
70  void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
71 
73  void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
74 
75  virtual ~GLESHardwarePixelBuffer();
76 
79  virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
80  GLenum getGLFormat() { return mGLInternalFormat; }
81  };
82 
86  {
87  public:
89  GLESTextureBuffer(const String &baseName, GLenum target, GLuint id, GLint width, GLint height, GLint internalFormat,
90  GLenum format, GLint face, GLint level, Usage usage, bool softwareMipmap, bool writeGamma, uint fsaa);
91  virtual ~GLESTextureBuffer();
92 
94  virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
95 
97  RenderTexture* getRenderTarget(size_t slice);
98 
100  virtual void upload(const PixelBox &data, const Image::Box &dest);
101 
103  virtual void download(const PixelBox &data);
104 
106  virtual void blitFromMemory(const PixelBox &src_orig, const Image::Box &dstBox);
107 
109  void _clearSliceRTT(size_t zoffset)
110  {
111  mSliceTRT[zoffset] = 0;
112  }
113 
114  // Copy from framebuffer
115  void copyFromFramebuffer(size_t zoffset);
116 
118  void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
119  // Blitting implementation
120  void blitFromTexture(GLESTextureBuffer *src, const Image::Box &srcBox, const Image::Box &dstBox);
121 
122 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
123  // Friends.
124  protected:
125  friend class GLESTexture;
126 
127  void updateTextureId(GLuint textureID);
128 #endif
129 
130  protected:
131  // In case this is a texture level
132  GLenum mTarget;
133  GLenum mFaceTarget; // same as mTarget in case of GL_TEXTURE_xD, but cubemap face for cubemaps
134  GLuint mTextureID;
135  GLint mFace;
136  GLint mLevel;
138 
139  typedef std::vector<RenderTexture*> SliceTRT;
141 
142  void buildMipmaps(const PixelBox &data);
143  };
144 
148  {
149  public:
150  GLESRenderBuffer(GLenum format, size_t width, size_t height, GLsizei numSamples);
151  virtual ~GLESRenderBuffer();
152 
154  virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
155 
156  protected:
157  // In case this is a render buffer
159  };
160 }
161 
162 #endif
This class represents a RenderTarget that renders to a Texture.
void _clearSliceRTT(size_t zoffset)
Notify TextureBuffer of destruction of render target.
#define _OgreGLESExport
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:659
PixelFormat
The pixel format used for images, textures, and render surfaces.
Usage
Enums describing buffer usage; not mutually exclusive.
Shared pointer implementation used to share pixel buffers.
Specialisation of HardwareBuffer for a pixel buffer.
_StringBase String
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
std::vector< RenderTexture * > SliceTRT
unsigned int uint