OgreGLHardwarePixelBuffer.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-2013 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 __GLPIXELBUFFER_H__
00029 #define __GLPIXELBUFFER_H__
00030 
00031 #include "OgreGLPrerequisites.h"
00032 #include "OgreHardwarePixelBuffer.h"
00033 
00034 namespace Ogre {
00035     class _OgreGLExport GLHardwarePixelBuffer: public HardwarePixelBuffer
00036     {
00037     protected:  
00039         PixelBox lockImpl(const Image::Box lockBox,  LockOptions options);
00040 
00042         void unlockImpl(void);
00043         
00046         PixelBox mBuffer;
00047         GLenum mGLInternalFormat; 
00048         LockOptions mCurrentLockOptions;
00049         
00051         void allocateBuffer();
00052         void freeBuffer();
00054         virtual void upload(const PixelBox &data, const Image::Box &dest);
00056         virtual void download(const PixelBox &data);
00057     public:
00059         GLHardwarePixelBuffer(uint32 mWidth, uint32 mHeight, uint32 mDepth,
00060                 PixelFormat mFormat,
00061                 HardwareBuffer::Usage usage);
00062         
00064         void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
00065         
00067         void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
00068         
00069         ~GLHardwarePixelBuffer();
00070         
00073         virtual void bindToFramebuffer(GLenum attachment, uint32 zoffset);
00074         GLenum getGLFormat() { return mGLInternalFormat; }
00075     };
00076 
00079     class _OgreGLExport GLTextureBuffer: public GLHardwarePixelBuffer
00080     {
00081     public:
00083         GLTextureBuffer(GLSupport& support, const String &baseName, GLenum target, GLuint id, GLint face,
00084             GLint level, Usage usage, bool softwareMipmap, bool writeGamma, uint fsaa);
00085         ~GLTextureBuffer();
00086         
00088         virtual void bindToFramebuffer(GLenum attachment, uint32 zoffset);
00090         RenderTexture* getRenderTarget(size_t slice);
00092         virtual void upload(const PixelBox &data, const Image::Box &dest);
00094         virtual void download(const PixelBox &data);
00095   
00097         virtual void blitFromMemory(const PixelBox &src_orig, const Image::Box &dstBox);
00098         
00100         void _clearSliceRTT(size_t zoffset)
00101         {
00102             mSliceTRT[zoffset] = 0;
00103         }
00105         void copyFromFramebuffer(uint32 zoffset);
00107         void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
00109         void blitFromTexture(GLTextureBuffer *src, const Image::Box &srcBox, const Image::Box &dstBox);
00110     protected:
00111         // In case this is a texture level
00112         GLenum mTarget;
00113         GLenum mFaceTarget; // same as mTarget in case of GL_TEXTURE_xD, but cubemap face for cubemaps
00114         GLuint mTextureID;
00115         GLint mFace;
00116         GLint mLevel;
00117         bool mSoftwareMipmap;       // Use GLU for mip mapping
00118         bool mHwGamma;
00119 
00120         typedef vector<RenderTexture*>::type SliceTRT;
00121         SliceTRT mSliceTRT;
00122 
00123         GLSupport& mGLSupport;
00124     };
00127     class _OgreGLExport GLRenderBuffer: public GLHardwarePixelBuffer
00128     {
00129     public:
00130         GLRenderBuffer(GLenum format, uint32 width, uint32 height, GLsizei numSamples);
00131         ~GLRenderBuffer();
00132         
00134         virtual void bindToFramebuffer(GLenum attachment, uint32 zoffset);
00135     protected:
00137         GLuint mRenderbufferID;
00138     };
00139 }
00140 
00141 #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 Mon Jul 27 2020 13:40:42