1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://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 |
|
---|
31 | namespace Ogre {
|
---|
32 |
|
---|
33 | class GLHardwarePixelBuffer: public HardwarePixelBuffer
|
---|
34 | {
|
---|
35 | protected:
|
---|
36 | /// Lock a box
|
---|
37 | PixelBox lockImpl(const Image::Box lockBox, LockOptions options);
|
---|
38 |
|
---|
39 | /// Unlock a box
|
---|
40 | void unlockImpl(void);
|
---|
41 |
|
---|
42 | enum Type {
|
---|
43 | TYPE_TEXTURE, // Texture subsurface
|
---|
44 | TYPE_FRAMEBUFFER, // Framebuffer surface
|
---|
45 | TYPE_PBO // Plain pixel buffer object
|
---|
46 | };
|
---|
47 | Type mType;
|
---|
48 |
|
---|
49 | // In case this is a texture level, define the texture type and ID
|
---|
50 | GLenum mTarget;
|
---|
51 | GLenum mFaceTarget; // same as mTarget in case of GL_TEXTURE_xD, but cubemap face for cubemaps
|
---|
52 | GLuint mTextureID;
|
---|
53 | GLint mFace;
|
---|
54 | GLint mLevel;
|
---|
55 | bool mSoftwareMipmap; // Use GLU for mip mapping
|
---|
56 | // Internal buffer; either on-card or in system memory, freed/allocated on demand
|
---|
57 | // depending on buffer usage
|
---|
58 | PixelBox mBuffer;
|
---|
59 |
|
---|
60 | // Buffer allocation/freeage
|
---|
61 | void allocateBuffer();
|
---|
62 | void freeBuffer();
|
---|
63 | // Upload a box of pixels to this buffer on the card
|
---|
64 | void upload(const PixelBox &data);
|
---|
65 | // Download a box of pixels from the card
|
---|
66 | void download(const PixelBox &data);
|
---|
67 | public:
|
---|
68 | GLHardwarePixelBuffer(GLenum target, GLuint id, GLint face, GLint level, Usage usage,
|
---|
69 | bool softwareMipmap);
|
---|
70 |
|
---|
71 | /// @copydoc HardwarePixelBuffer::blit
|
---|
72 | void blit(HardwarePixelBuffer *src, const Image::Box &srcBox, const Image::Box &dstBox);
|
---|
73 |
|
---|
74 | /// @copydoc HardwarePixelBuffer::blitFromMemory
|
---|
75 | void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
|
---|
76 |
|
---|
77 | /// @copydoc HardwarePixelBuffer::blitToMemory
|
---|
78 | void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
|
---|
79 |
|
---|
80 | ~GLHardwarePixelBuffer();
|
---|
81 | };
|
---|
82 |
|
---|
83 | };
|
---|
84 |
|
---|
85 | #endif
|
---|