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-2012 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
    00044         // Internal buffer; either on-card or in system memory, freed/allocated on demand
    00045         // depending on buffer usage
    00046         PixelBox mBuffer;
    00047         GLenum mGLInternalFormat; // GL internal format
    00048         LockOptions mCurrentLockOptions;
    00049
    00050         // Buffer allocation/freeage
    00051         void allocateBuffer();
    00052         void freeBuffer();
    00053         // Upload a box of pixels to this buffer on the card
    00054         virtual void upload(const PixelBox &data, const Image::Box &dest);
    00055         // Download a box of pixels from the card
    00056         virtual void download(const PixelBox &data);
    00057     public:
    00059         GLHardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t 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, size_t zoffset);
    00074         GLenum getGLFormat() { return mGLInternalFormat; }
    00075     };
    00076
    00079     class _OgreGLExport GLTextureBuffer: public GLHardwarePixelBuffer
    00080     {
    00081     public:
    00083         GLTextureBuffer(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, size_t zoffset);
    00090         RenderTexture* getRenderTarget(size_t);
    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(size_t zoffset);
    00107         void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
    00108         // Blitting implementation
    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
    00119         typedef vector<RenderTexture*>::type SliceTRT;
    00120         SliceTRT mSliceTRT;
    00121     };
    00124     class _OgreGLExport GLRenderBuffer: public GLHardwarePixelBuffer
    00125     {
    00126     public:
    00127         GLRenderBuffer(GLenum format, size_t width, size_t height, GLsizei numSamples);
    00128         ~GLRenderBuffer();
    00129
    00131         virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
    00132     protected:
    00133         // In case this is a render buffer
    00134         GLuint mRenderbufferID;
    00135     };
    00136 }
    00137
    00138 #endif

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:21