# 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
    00046         // Buffer allocation/freeage
    00047         void allocateBuffer();
    00048         void freeBuffer();
    00049         // Upload a box of pixels to this buffer on the card
    00050         virtual void upload(const PixelBox &data);
    00051         // Download a box of pixels from the card
    00052         virtual void download(const PixelBox &data);
    00053     public:
    00055         GLHardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth,
    00056                 PixelFormat mFormat,
    00057                 HardwareBuffer::Usage usage);
    00058
    00060         void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
    00061
    00063         void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
    00064
    00065         ~GLHardwarePixelBuffer();
    00066
    00069         virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
    00070         GLenum getGLFormat() { return mGLInternalFormat; }
    00071     };
    00072
    00075     class GLTextureBuffer: public GLHardwarePixelBuffer
    00076     {
    00077     public:
    00079         GLTextureBuffer(const String &baseName, GLenum target, GLuint id, GLint face, GLint level, Usage usage,
    00080             bool softwareMipmap);
    00081         ~GLTextureBuffer();
    00082
    00084         virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
    00086         RenderTexture* getRenderTarget(size_t);
    00087         // Upload a box of pixels to this buffer on the card
    00088         virtual void upload(const PixelBox &data);
    00089         // Download a box of pixels from the card
    00090         virtual void download(const PixelBox &data);
    00091
    00092         // Hardware implementation of blitFromMemory
    00093         virtual void blitFromMemory(const PixelBox &src_orig, const Image::Box &dstBox);
    00094
    00095         // Notify TextureBuffer of destruction of render target
    00096         void _clearSliceRTT(size_t zoffset)
    00097         {
    00098             mSliceTRT[zoffset] = 0;
    00099         }
    00100         // Copy from framebuffer
    00101         void copyFromFramebuffer(size_t zoffset);
    00103         void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
    00104         // Blitting implementation
    00105         void blitFromTexture(GLTextureBuffer *src, const Image::Box &srcBox, const Image::Box &dstBox);
    00106     protected:
    00107         // In case this is a texture level
    00108         GLenum mTarget;
    00109         GLenum mFaceTarget; // same as mTarget in case of GL_TEXTURE_xD, but cubemap face for cubemaps
    00110         GLuint mTextureID;
    00111         GLint mFace;
    00112         GLint mLevel;
    00113         bool mSoftwareMipmap;       // Use GLU for mip mapping
    00114
    00115         typedef std::vector<RenderTexture*> SliceTRT;
    00116         SliceTRT mSliceTRT;
    00117     };
    00120     class GLRenderBuffer: public GLHardwarePixelBuffer
    00121     {
    00122     public:
    00123         GLRenderBuffer(GLenum format, size_t width, size_t height);
    00124         ~GLRenderBuffer();
    00125
    00127         virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
    00128     protected:
    00129         // In case this is a  render buffer
    00130         GLuint mRenderbufferID;
    00131     };
    00132 };
    00133
    00134 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 17 15:39:08 2006