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 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(size_t mWidth, size_t mHeight, size_t 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 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); 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 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 GLint mFace; 00126 GLint mLevel; 00127 bool mSoftwareMipmap; 00128 00129 typedef vector<RenderTexture*>::type SliceTRT; 00130 SliceTRT mSliceTRT; 00131 00132 void buildMipmaps(const PixelBox &data); 00133 }; 00134 00137 class _OgreGLES2Export GLES2RenderBuffer: public GLES2HardwarePixelBuffer 00138 { 00139 public: 00140 GLES2RenderBuffer(GLenum format, size_t width, size_t height, GLsizei numSamples); 00141 virtual ~GLES2RenderBuffer(); 00142 00144 virtual void bindToFramebuffer(GLenum attachment, size_t zoffset); 00145 00146 protected: 00147 // In case this is a render buffer 00148 GLuint mRenderbufferID; 00149 }; 00150 } 00151 00152 #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