source: OGRE/trunk/ogrenew/RenderSystems/GL/include/OgreGLHardwarePixelBuffer.h @ 692

Revision 692, 5.0 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __GLPIXELBUFFER_H__
26#define __GLPIXELBUFFER_H__
27
28#include "OgreGLPrerequisites.h"
29#include "OgreHardwarePixelBuffer.h"
30
31namespace Ogre {
32        class GLHardwarePixelBuffer: public HardwarePixelBuffer
33        {
34        protected: 
35                /// Lock a box
36                PixelBox lockImpl(const Image::Box lockBox,  LockOptions options);
37
38                /// Unlock a box
39                void unlockImpl(void);
40       
41                // Internal buffer; either on-card or in system memory, freed/allocated on demand
42                // depending on buffer usage
43                PixelBox mBuffer;
44        GLenum mGLInternalFormat; // GL internal format
45               
46                // Buffer allocation/freeage
47                void allocateBuffer();
48                void freeBuffer();
49                // Upload a box of pixels to this buffer on the card
50                virtual void upload(const PixelBox &data);
51                // Download a box of pixels from the card
52                virtual void download(const PixelBox &data);
53        public:
54        /// Should be called by HardwareBufferManager
55        GLHardwarePixelBuffer(size_t mWidth, size_t mHeight, size_t mDepth,
56                PixelFormat mFormat,
57                HardwareBuffer::Usage usage);
58               
59                /// @copydoc HardwarePixelBuffer::blitFromMemory
60                void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
61               
62                /// @copydoc HardwarePixelBuffer::blitToMemory
63                void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
64               
65                ~GLHardwarePixelBuffer();
66       
67        /** Bind surface to frame buffer. Needs FBO extension.
68        */
69        virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
70        GLenum getGLFormat() { return mGLInternalFormat; }
71        };
72
73    /** Texture surface.
74    */
75    class GLTextureBuffer: public GLHardwarePixelBuffer
76        {
77    public:
78        /** Texture constructor */
79                GLTextureBuffer(const String &baseName, GLenum target, GLuint id, GLint face, GLint level, Usage usage,
80                        bool softwareMipmap);
81        ~GLTextureBuffer();
82       
83        /// @copydoc GLHardwarePixelBuffer::bindToFramebuffer
84        virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
85        /// @copydoc ardwarePixelBuffer::getRenderTarget
86        RenderTexture* getRenderTarget(size_t);
87        // Upload a box of pixels to this buffer on the card
88                virtual void upload(const PixelBox &data);
89                // Download a box of pixels from the card
90                virtual void download(const PixelBox &data);
91 
92        // Hardware implementation of blitFromMemory
93        virtual void blitFromMemory(const PixelBox &src_orig, const Image::Box &dstBox);
94       
95        // Notify TextureBuffer of destruction of render target
96        void _clearSliceRTT(size_t zoffset)
97        {
98            mSliceTRT[zoffset] = 0;
99        }
100        // Copy from framebuffer
101        void copyFromFramebuffer(size_t zoffset);
102        /// @copydoc HardwarePixelBuffer::blit
103        void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
104        // Blitting implementation
105        void blitFromTexture(GLTextureBuffer *src, const Image::Box &srcBox, const Image::Box &dstBox);
106    protected:
107        // In case this is a texture level
108                GLenum mTarget;
109                GLenum mFaceTarget; // same as mTarget in case of GL_TEXTURE_xD, but cubemap face for cubemaps
110                GLuint mTextureID;
111                GLint mFace;
112                GLint mLevel;
113                bool mSoftwareMipmap;           // Use GLU for mip mapping
114       
115        typedef std::vector<RenderTexture*> SliceTRT;
116        SliceTRT mSliceTRT;
117    };
118     /** Renderbuffer surface.  Needs FBO extension.
119     */
120    class GLRenderBuffer: public GLHardwarePixelBuffer
121        {
122    public:
123        GLRenderBuffer(GLenum format, size_t width, size_t height);
124        ~GLRenderBuffer();
125       
126        /// @copydoc GLHardwarePixelBuffer::bindToFramebuffer
127        virtual void bindToFramebuffer(GLenum attachment, size_t zoffset);
128    protected:
129        // In case this is a  render buffer
130        GLuint mRenderbufferID;
131    };
132};
133
134#endif
Note: See TracBrowser for help on using the repository browser.