~thumper/nux/next-changes

« back to all changes in this revision

Viewing changes to NuxGraphics/IOpenGLFrameBufferObject.h

  • Committer: Neil Jagdish Patel
  • Date: 2010-09-01 21:15:42 UTC
  • Revision ID: neil.patel@canonical.com-20100901211542-cw2ce3ak28unouwb
Add NuxGraphics with licensing

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Inalogic Inc.
 
3
 *
 
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.
 
7
 *
 
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.
 
13
 * 
 
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/>
 
17
 *
 
18
 * Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
 
19
 *
 
20
 */
 
21
 
 
22
 
 
23
#ifndef IOPENGLFRAMEBUFFEROBJECT_H
 
24
#define IOPENGLFRAMEBUFFEROBJECT_H
 
25
 
 
26
NAMESPACE_BEGIN_OGL
 
27
 
 
28
class IOpenGLResource;
 
29
class IOpenGLFrameBufferObject: public IOpenGLResource
 
30
{
 
31
    DECLARE_OBJECT_TYPE(IOpenGLFrameBufferObject, IOpenGLResource);
 
32
public:
 
33
    virtual ~IOpenGLFrameBufferObject();
 
34
 
 
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();
 
40
 
 
41
    int Clear(DWORD Flags, FLOAT red, FLOAT green, FLOAT blue, FLOAT alpha, FLOAT Z, DWORD Stencil);
 
42
 
 
43
    int Activate(bool WithClippingStack = false);
 
44
    //### Restore the original opengl back buffer as defined when creating the opengl context(color + depth + stencil).
 
45
    int Deactivate();
 
46
    bool IsActive()
 
47
    {
 
48
        return _IsActive;
 
49
    }
 
50
 
 
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;}
 
61
 
 
62
private:
 
63
    IOpenGLFrameBufferObject(unsigned int Width = 4, unsigned int Height = 4, BitmapFormat PixelFormat = BITFMT_R8G8B8A8);
 
64
 
 
65
    unsigned int                    _Width;
 
66
    unsigned int                    _Height;
 
67
    BitmapFormat    _PixelFormat;
 
68
    bool             _IsActive;
 
69
 
 
70
    TRefGL<IOpenGLSurface>     _Depth_Attachment;
 
71
    TRefGL<IOpenGLSurface>     _Stencil_Attachment;
 
72
    std::vector< TRefGL<IOpenGLSurface> > _Color_AttachmentArray;
 
73
 
 
74
    GLFramebufferObject _Fbo;   // The framebuffer object used for rendering to the texture
 
75
    GLRenderbuffer      _Rbo;
 
76
 
 
77
    friend class GLDeviceFactory;
 
78
};
 
79
 
 
80
NAMESPACE_END_OGL
 
81
 
 
82
#endif // IOPENGLFRAMEBUFFEROBJECT_H