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 __GLES2HardwarePixelBuffer_H__ 00030 #define __GLES2HardwarePixelBuffer_H__ 00031 00032 #include "OgreGLES2Prerequisites.h" 00033 #include "OgreHardwarePixelBuffer.h" 00034 00035 namespace Ogre { 00036 class _OgreGLES2Export GLES2HardwarePixelBuffer: 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 00056 // Upload a box of pixels to this buffer on the card 00057 virtual void upload(const PixelBox &data, const Image::Box &dest); 00058 00059 // Download a box of pixels from the card 00060 virtual void download(const PixelBox &data); 00061 00062 public: 00064 GLES2HardwarePixelBuffer(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 virtual ~GLES2HardwarePixelBuffer(); 00075 00078 virtual void bindToFramebuffer(GLenum attachment, size_t zoffset); 00079 GLenum getGLFormat() { return mGLInternalFormat; } 00080 }; 00081 00084 class _OgreGLES2Export GLES2TextureBuffer: public GLES2HardwarePixelBuffer 00085 { 00086 public: 00088 GLES2TextureBuffer(const String &baseName, GLenum target, GLuint id, GLint width, GLint height, GLint depth, GLint internalFormat, 00089 GLint format, GLint face, GLint level, Usage usage, bool softwareMipmap, bool writeGamma, uint fsaa); 00090 virtual ~GLES2TextureBuffer(); 00091 00093 virtual void bindToFramebuffer(GLenum attachment, size_t zoffset); 00094 00096 RenderTexture* getRenderTarget(size_t slice); 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 00113 // Copy from framebuffer 00114 void copyFromFramebuffer(size_t zoffset); 00115 00117 void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox); 00118 // Blitting implementation 00119 void blitFromTexture(GLES2TextureBuffer *src, const Image::Box &srcBox, const Image::Box &dstBox); 00120 00121 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID 00122 // Friends. 00123 protected: 00124 friend class GLES2Texture; 00125 00126 void updateTextureId(GLuint textureID); 00127 #endif 00128 00129 protected: 00130 // In case this is a texture level 00131 GLenum mTarget; 00132 GLenum mFaceTarget; // same as mTarget in case of GL_TEXTURE_xD, but cubemap face for cubemaps 00133 GLuint mTextureID; 00134 GLuint mBufferId; 00135 GLint mFace; 00136 GLint mLevel; 00137 bool mSoftwareMipmap; 00138 00139 typedef vector<RenderTexture*>::type SliceTRT; 00140 SliceTRT mSliceTRT; 00141 00142 void buildMipmaps(const PixelBox &data); 00143 }; 00144 00147 class _OgreGLES2Export GLES2RenderBuffer: public GLES2HardwarePixelBuffer 00148 { 00149 public: 00150 GLES2RenderBuffer(GLenum format, size_t width, size_t height, GLsizei numSamples); 00151 virtual ~GLES2RenderBuffer(); 00152 00154 virtual void bindToFramebuffer(GLenum attachment, size_t zoffset); 00155 00156 protected: 00157 // In case this is a render buffer 00158 GLuint mRenderbufferID; 00159 GLsizei mNumSamples; 00160 }; 00161 } 00162 00163 #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