Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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-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 __GLPIXELBUFFER_H__
00026 #define __GLPIXELBUFFER_H__
00027 
00028 #include "OgreGLPrerequisites.h"
00029 #include "OgreHardwarePixelBuffer.h"
00030 
00031 namespace Ogre {
00032     class GLHardwarePixelBuffer: public HardwarePixelBuffer
00033     {
00034     protected:  
00036         PixelBox lockImpl(const Image::Box lockBox,  LockOptions options);
00037 
00039         void unlockImpl(void);
00040         
00041         // Internal buffer; either on-card or in system memory, freed/allocated on demand
00042         // depending on buffer usage
00043         PixelBox mBuffer;
00044         GLenum mGLInternalFormat; // GL internal format
00045         LockOptions mCurrentLockOptions;
00046         
00047         // Buffer allocation/freeage
00048         void allocateBuffer();
00049         void freeBuffer();
00050         // Upload a box of pixels to this buffer on the card
00051         virtual void upload(const PixelBox &data);
00052         // Download a box of pixels from the card
00053         virtual void download(const PixelBox &data);
00054     public:
00056         GLHardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth,
00057                 PixelFormat mFormat,
00058                 HardwareBuffer::Usage usage);
00059         
00061         void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
00062         
00064         void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
00065         
00066         ~GLHardwarePixelBuffer();
00067         
00070         virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
00071         GLenum getGLFormat() { return mGLInternalFormat; }
00072     };
00073 
00076     class GLTextureBuffer: public GLHardwarePixelBuffer
00077     {
00078     public:
00080         GLTextureBuffer(const String &baseName, GLenum target, GLuint id, GLint face, GLint level, Usage usage, 
00081             bool softwareMipmap);
00082         ~GLTextureBuffer();
00083         
00085         virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
00087         RenderTexture* getRenderTarget(size_t);
00088         // Upload a box of pixels to this buffer on the card
00089         virtual void upload(const PixelBox &data);
00090         // Download a box of pixels from the card
00091         virtual void download(const PixelBox &data);
00092   
00093         // Hardware implementation of blitFromMemory
00094         virtual void blitFromMemory(const PixelBox &src_orig, const Image::Box &dstBox);
00095         
00096         // Notify TextureBuffer of destruction of render target
00097         void _clearSliceRTT(size_t zoffset)
00098         {
00099             mSliceTRT[zoffset] = 0;
00100         }
00101         // Copy from framebuffer
00102         void copyFromFramebuffer(size_t zoffset);
00104         void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
00105         // Blitting implementation
00106         void blitFromTexture(GLTextureBuffer *src, const Image::Box &srcBox, const Image::Box &dstBox);
00107     protected:
00108         // In case this is a texture level
00109         GLenum mTarget;
00110         GLenum mFaceTarget; // same as mTarget in case of GL_TEXTURE_xD, but cubemap face for cubemaps
00111         GLuint mTextureID;
00112         GLint mFace;
00113         GLint mLevel;
00114         bool mSoftwareMipmap;       // Use GLU for mip mapping
00115         
00116         typedef std::vector<RenderTexture*> SliceTRT;
00117         SliceTRT mSliceTRT;
00118     };
00121     class GLRenderBuffer: public GLHardwarePixelBuffer
00122     {
00123     public:
00124         GLRenderBuffer(GLenum format, size_t width, size_t height);
00125         ~GLRenderBuffer();
00126         
00128         virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
00129     protected:
00130         // In case this is a  render buffer
00131         GLuint mRenderbufferID;
00132     };
00133 };
00134 
00135 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jan 21 10:01:36 2007