~ubuntu-branches/ubuntu/oneiric/nux/oneiric

« back to all changes in this revision

Viewing changes to NuxGraphics/IOpenGLFrameBufferObject.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-11-18 19:17:32 UTC
  • Revision ID: james.westby@ubuntu.com-20101118191732-rn35790vekj6o4my
Tags: upstream-0.9.4
ImportĀ upstreamĀ versionĀ 0.9.4

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 nux
 
27
{
 
28
 
 
29
  class IOpenGLResource;
 
30
  class IOpenGLFrameBufferObject: public IOpenGLResource
 
31
  {
 
32
    NUX_DECLARE_OBJECT_TYPE (IOpenGLFrameBufferObject, IOpenGLResource);
 
33
  public:
 
34
    virtual ~IOpenGLFrameBufferObject();
 
35
 
 
36
    int FormatFrameBufferObject (int Width, int Height, BitmapFormat PixelFormat);
 
37
    int SetRenderTarget (int ColorAttachmentIndex, IntrusiveSP<IOpenGLSurface> pRenderTargetSurface);
 
38
    int SetDepthSurface (IntrusiveSP<IOpenGLSurface> pDepthSurface);
 
39
    IntrusiveSP<IOpenGLSurface> GetRenderTarget (int ColorAttachmentIndex);
 
40
    IntrusiveSP<IOpenGLSurface> GetDepthRenderTarget();
 
41
 
 
42
    int Clear (DWORD Flags, FLOAT red, FLOAT green, FLOAT blue, FLOAT alpha, FLOAT Z, DWORD Stencil);
 
43
 
 
44
    int Activate (bool WithClippingStack = false);
 
45
    //### Restore the original opengl back buffer as defined when creating the opengl context(color + depth + stencil).
 
46
    int Deactivate();
 
47
    bool IsActive()
 
48
    {
 
49
      return _IsActive;
 
50
    }
 
51
 
 
52
    // For 2D screen operations
 
53
    std::vector<Rect> _ClippingRegionStack;
 
54
    void PushClippingRegion (Rect rect);
 
55
    void PopClippingRegion();
 
56
    void EmptyClippingRegion();
 
57
    void ApplyClippingRegion();
 
58
    void SetClippingRegion (int x, int y, int width, int height);
 
59
    Rect GetClippingRegion();
 
60
    int GetWidth() const
 
61
    {
 
62
      return _Width;
 
63
    }
 
64
    int GetHeight() const
 
65
    {
 
66
      return _Height;
 
67
    }
 
68
 
 
69
  private:
 
70
    IOpenGLFrameBufferObject (NUX_FILE_LINE_PROTO);
 
71
 
 
72
    int             _Width;
 
73
    int             _Height;
 
74
    BitmapFormat    _PixelFormat;
 
75
    bool            _IsActive;
 
76
 
 
77
    IntrusiveSP<IOpenGLSurface>     _Depth_Attachment;
 
78
    IntrusiveSP<IOpenGLSurface>     _Stencil_Attachment;
 
79
    std::vector< IntrusiveSP<IOpenGLSurface> > _Color_AttachmentArray;
 
80
 
 
81
    GLFramebufferObject _Fbo;   // The framebuffer object used for rendering to the texture
 
82
    GLRenderbuffer      _Rbo;
 
83
 
 
84
    friend class GpuDevice;
 
85
  };
 
86
 
 
87
}
 
88
 
 
89
#endif // IOPENGLFRAMEBUFFEROBJECT_H