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 00029 #ifndef __GL3PlusHardwarePixelBuffer_H__ 00030 #define __GL3PlusHardwarePixelBuffer_H__ 00031 00032 #include "OgreGL3PlusPrerequisites.h" 00033 #include "OgreHardwarePixelBuffer.h" 00034 00035 namespace Ogre { 00036 class _OgreGL3PlusExport GL3PlusHardwarePixelBuffer: public HardwarePixelBuffer 00037 { 00038 protected: 00040 PixelBox lockImpl(const Image::Box lockBox, LockOptions options); 00041 00043 void unlockImpl(void); 00044 00045 // Internal buffer; either on-card or in system memory, freed/allocated on demand 00046 // depending on buffer usage 00047 PixelBox mBuffer; 00048 GLenum mGLInternalFormat; // GL internal format 00049 LockOptions mCurrentLockOptions; 00050 00051 // Buffer allocation/freeage 00052 void allocateBuffer(); 00053 00054 void freeBuffer(); 00055 00057 virtual void upload(const PixelBox &data, const Image::Box &dest); 00058 00060 virtual void download(const PixelBox &data); 00061 00062 public: 00064 GL3PlusHardwarePixelBuffer(uint32 mWidth, uint32 mHeight, uint32 mDepth, 00065 PixelFormat mFormat, 00066 HardwareBuffer::Usage usage); 00067 00069 void blitFromMemory(const PixelBox &src, const Image::Box &dstBox); 00070 00072 void blitToMemory(const Image::Box &srcBox, const PixelBox &dst); 00073 00074 ~GL3PlusHardwarePixelBuffer(); 00075 00078 virtual void bindToFramebuffer(GLenum attachment, uint32 zoffset); 00079 GLenum getGLFormat() { return mGLInternalFormat; } 00080 }; 00081 00084 class _OgreGL3PlusExport GL3PlusTextureBuffer: public GL3PlusHardwarePixelBuffer 00085 { 00086 public: 00088 GL3PlusTextureBuffer(const String &baseName, GLenum target, GLuint id, GLint face, 00089 GLint level, Usage usage, bool writeGamma, uint fsaa); 00090 ~GL3PlusTextureBuffer(); 00091 00093 virtual void bindToFramebuffer(GLenum attachment, uint32 zoffset); 00094 00096 RenderTexture* getRenderTarget(size_t); 00097 00099 virtual void upload(const PixelBox &data, const Image::Box &dest); 00100 00102 virtual void download(const PixelBox &data); 00103 00105 virtual void blitFromMemory(const PixelBox &src_orig, const Image::Box &dstBox); 00106 00108 void _clearSliceRTT(size_t zoffset) 00109 { 00110 mSliceTRT[zoffset] = 0; 00111 } 00112 00114 void copyFromFramebuffer(uint32 zoffset); 00115 00117 void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox); 00118 // Blitting implementation 00119 void blitFromTexture(GL3PlusTextureBuffer *src, const Image::Box &srcBox, const Image::Box &dstBox); 00120 protected: 00121 // In case this is a texture level 00122 GLenum mTarget; 00123 GLenum mFaceTarget; // same as mTarget in case of GL_TEXTURE_xD, but cubemap face for cubemaps 00124 GLuint mTextureID; 00125 GLuint mBufferId; 00126 GLint mFace; 00127 GLint mLevel; 00128 00129 typedef vector<RenderTexture*>::type SliceTRT; 00130 SliceTRT mSliceTRT; 00131 }; 00132 00135 class _OgreGL3PlusExport GL3PlusRenderBuffer: public GL3PlusHardwarePixelBuffer 00136 { 00137 public: 00138 GL3PlusRenderBuffer(GLenum format, uint32 width, uint32 height, GLsizei numSamples); 00139 ~GL3PlusRenderBuffer(); 00140 00142 virtual void bindToFramebuffer(GLenum attachment, uint32 zoffset); 00143 00144 protected: 00145 // In case this is a render buffer 00146 GLuint mRenderbufferID; 00147 }; 00148 } 00149 00150 #endif
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:42