2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
23
#ifndef IOPENGLFRAMEBUFFEROBJECT_H
24
#define IOPENGLFRAMEBUFFEROBJECT_H
28
class IOpenGLResource;
29
class IOpenGLFrameBufferObject: public IOpenGLResource
31
DECLARE_OBJECT_TYPE(IOpenGLFrameBufferObject, IOpenGLResource);
33
virtual ~IOpenGLFrameBufferObject();
35
int FormatFrameBufferObject(unsigned int Width, unsigned int Height, BitmapFormat PixelFormat);
36
int SetRenderTarget(unsigned int ColorAttachmentIndex, TRefGL<IOpenGLSurface> pRenderTargetSurface);
37
int SetDepthSurface(TRefGL<IOpenGLSurface> pDepthSurface);
38
TRefGL<IOpenGLSurface> GetRenderTarget(unsigned int ColorAttachmentIndex);
39
TRefGL<IOpenGLSurface> GetDepthRenderTarget();
41
int Clear(DWORD Flags, FLOAT red, FLOAT green, FLOAT blue, FLOAT alpha, FLOAT Z, DWORD Stencil);
43
int Activate(bool WithClippingStack = false);
44
//### Restore the original opengl back buffer as defined when creating the opengl context(color + depth + stencil).
51
// For 2D screen operations
52
std::vector<Rect> _ClippingRegionStack;
53
void PushClippingRegion(Rect rect);
54
void PopClippingRegion();
55
void EmptyClippingRegion();
56
void ApplyClippingRegion();
57
void SetClippingRegion(int x, int y, unsigned int width, unsigned int height);
58
Rect GetClippingRegion();
59
int GetWidth() const {return _Width;}
60
int GetHeight() const {return _Height;}
63
IOpenGLFrameBufferObject(unsigned int Width = 4, unsigned int Height = 4, BitmapFormat PixelFormat = BITFMT_R8G8B8A8);
67
BitmapFormat _PixelFormat;
70
TRefGL<IOpenGLSurface> _Depth_Attachment;
71
TRefGL<IOpenGLSurface> _Stencil_Attachment;
72
std::vector< TRefGL<IOpenGLSurface> > _Color_AttachmentArray;
74
GLFramebufferObject _Fbo; // The framebuffer object used for rendering to the texture
77
friend class GLDeviceFactory;
82
#endif // IOPENGLFRAMEBUFFEROBJECT_H