OgreGLESHardwarePixelBuffer.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) 2008 Renato Araujo Oliveira Filho <renatox@gmail.com>
00008 Copyright (c) 2000-2012 Torus Knot Software Ltd
00009 
00010 Permission is hereby granted, free of charge, to any person obtaining a copy
00011 of this software and associated documentation files (the "Software"), to deal
00012 in the Software without restriction, including without limitation the rights
00013 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00014 copies of the Software, and to permit persons to whom the Software is
00015 furnished to do so, subject to the following conditions:
00016 
00017 The above copyright notice and this permission notice shall be included in
00018 all copies or substantial portions of the Software.
00019 
00020 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00021 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00022 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00023 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00024 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00025 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00026 THE SOFTWARE.
00027 -----------------------------------------------------------------------------
00028 */
00029 
00030 #ifndef __GLESHardwarePixelBuffer_H__
00031 #define __GLESHardwarePixelBuffer_H__
00032 
00033 #include "OgreGLESPrerequisites.h"
00034 #include "OgreHardwarePixelBuffer.h"
00035 
00036 namespace Ogre {
00037     class _OgreGLESExport GLESHardwarePixelBuffer: public HardwarePixelBuffer
00038     {
00039         protected:
00041             PixelBox lockImpl(const Image::Box lockBox,  LockOptions options);
00042 
00044             void unlockImpl(void);
00045 
00046             // Internal buffer; either on-card or in system memory, freed/allocated on demand
00047             // depending on buffer usage
00048             PixelBox mBuffer;
00049             GLenum mGLInternalFormat; // GL internal format
00050             LockOptions mCurrentLockOptions;
00051 
00052             // Buffer allocation/freeage
00053             void allocateBuffer();
00054 
00055             void freeBuffer();
00056 
00057             // Upload a box of pixels to this buffer on the card
00058             virtual void upload(const PixelBox &data, const Image::Box &dest);
00059 
00060             // Download a box of pixels from the card
00061             virtual void download(const PixelBox &data);
00062 
00063         public:
00065             GLESHardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth,
00066                                   PixelFormat mFormat,
00067                                   HardwareBuffer::Usage usage);
00068 
00070             void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
00071 
00073             void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
00074 
00075             virtual ~GLESHardwarePixelBuffer();
00076 
00079             virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
00080             GLenum getGLFormat() { return mGLInternalFormat; }
00081     };
00082 
00085     class _OgreGLESExport GLESTextureBuffer: public GLESHardwarePixelBuffer
00086     {
00087         public:
00089             GLESTextureBuffer(const String &baseName, GLenum target, GLuint id, GLint width, GLint height, GLint internalFormat, 
00090                             GLenum format, GLint face, GLint level, Usage usage, bool softwareMipmap, bool writeGamma, uint fsaa);
00091             virtual ~GLESTextureBuffer();
00092 
00094             virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
00095 
00097             RenderTexture* getRenderTarget(size_t);
00098 
00100             virtual void upload(const PixelBox &data, const Image::Box &dest);
00101 
00103             virtual void download(const PixelBox &data);
00104 
00106             virtual void blitFromMemory(const PixelBox &src_orig, const Image::Box &dstBox);
00107 
00109             void _clearSliceRTT(size_t zoffset)
00110             {
00111                 mSliceTRT[zoffset] = 0;
00112             }
00113 
00114             // Copy from framebuffer
00115             void copyFromFramebuffer(size_t zoffset);
00116 
00118             void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
00119             // Blitting implementation
00120             void blitFromTexture(GLESTextureBuffer *src, const Image::Box &srcBox, const Image::Box &dstBox);
00121         
00122         protected:
00123             // In case this is a texture level
00124             GLenum mTarget;
00125             GLenum mFaceTarget; // same as mTarget in case of GL_TEXTURE_xD, but cubemap face for cubemaps
00126             GLuint mTextureID;
00127             GLint mFace;
00128             GLint mLevel;
00129             bool mSoftwareMipmap;
00130 
00131             typedef std::vector<RenderTexture*> SliceTRT;
00132             SliceTRT mSliceTRT;
00133 
00134             static void buildMipmaps(const PixelBox &data);
00135     };
00136 
00139     class _OgreGLESExport GLESRenderBuffer: public GLESHardwarePixelBuffer
00140     {
00141         public:
00142             GLESRenderBuffer(GLenum format, size_t width, size_t height, GLsizei numSamples);
00143             virtual ~GLESRenderBuffer();
00144 
00146             virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
00147 
00148         protected:
00149             // In case this is a render buffer
00150             GLuint mRenderbufferID;
00151     };
00152 }
00153 
00154 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 2012 21:48:50