Renderbuffer.h 4.33 KB
Newer Older
1
2
3
4
5
6
//
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

7
8
9
// Renderbuffer.h: Defines the wrapper class gl::Renderbuffer, as well as the
// class hierarchy used to store its contents: RenderbufferStorage, Colorbuffer,
// DepthStencilbuffer, Depthbuffer and Stencilbuffer. Implements GL renderbuffer
10
11
12
13
14
15
16
17
18
19
// objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.

#ifndef LIBGLESV2_RENDERBUFFER_H_
#define LIBGLESV2_RENDERBUFFER_H_

#define GL_APICALL
#include <GLES2/gl2.h>
#include <d3d9.h>

#include "common/angleutils.h"
20
#include "libGLESv2/RefCountObject.h"
21
22
23

namespace gl
{
24
25
26
27
28

// A class derived from RenderbufferStorage is created whenever glRenderbufferStorage
// is called. The specific concrete type depends on whether the internal format is
// colour depth, stencil or packed depth/stencil.
class RenderbufferStorage
29
30
{
  public:
31
    RenderbufferStorage();
32

33
    virtual ~RenderbufferStorage() = 0;
34

35
36
37
    virtual bool isColorbuffer() const;
    virtual bool isDepthbuffer() const;
    virtual bool isStencilbuffer() const;
38
39
40
41

    virtual IDirect3DSurface9 *getRenderTarget();
    virtual IDirect3DSurface9 *getDepthStencil();

42
43
44
45
46
    virtual int getWidth() const;
    virtual int getHeight() const;
    virtual GLenum getFormat() const;
    D3DFORMAT getD3DFormat() const;
    GLsizei getSamples() const;
47
48
49
50
51
52
53
    unsigned int getSerial() const;

    static unsigned int issueSerial();

  protected:
    void setSize(int width, int height);
    GLenum mFormat;
54
55
    D3DFORMAT mD3DFormat;
    GLsizei mSamples;
56
57
58
    unsigned int mSerial;

  private:
59
    DISALLOW_COPY_AND_ASSIGN(RenderbufferStorage);
60
61
62
63
64
65
66

    static unsigned int mCurrentSerial;

    int mWidth;
    int mHeight;
};

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Renderbuffer implements the GL renderbuffer object.
// It's only a wrapper for a RenderbufferStorage, but the internal object
// can change whenever glRenderbufferStorage is called.
class Renderbuffer : public RefCountObject
{
  public:
    Renderbuffer(GLuint id, RenderbufferStorage *storage);

    ~Renderbuffer();

    bool isColorbuffer() const;
    bool isDepthbuffer() const;
    bool isStencilbuffer() const;

    IDirect3DSurface9 *getRenderTarget();
    IDirect3DSurface9 *getDepthStencil();

    int getWidth() const;
    int getHeight() const;
    GLenum getFormat() const;
    D3DFORMAT getD3DFormat() const;
    unsigned int getSerial() const;

    void setStorage(RenderbufferStorage *newStorage);
    RenderbufferStorage *getStorage() { return mStorage; }

  private:
    DISALLOW_COPY_AND_ASSIGN(Renderbuffer);

    RenderbufferStorage *mStorage;
};

class Colorbuffer : public RenderbufferStorage
100
101
102
{
  public:
    explicit Colorbuffer(IDirect3DSurface9 *renderTarget);
103
    Colorbuffer(int width, int height, GLenum format, GLsizei samples);
104
105
106

    ~Colorbuffer();

107
    bool isColorbuffer() const;
108

109
110
111
112
    GLuint getRedSize() const;
    GLuint getGreenSize() const;
    GLuint getBlueSize() const;
    GLuint getAlphaSize() const;
113
114
115
116
117
118
119
120
121
122

    IDirect3DSurface9 *getRenderTarget();

  protected:
    IDirect3DSurface9 *mRenderTarget;

  private:
    DISALLOW_COPY_AND_ASSIGN(Colorbuffer);
};

123
class DepthStencilbuffer : public RenderbufferStorage
124
125
{
  public:
126
127
    explicit DepthStencilbuffer(IDirect3DSurface9 *depthStencil);
    DepthStencilbuffer(int width, int height, GLsizei samples);
128

129
    ~DepthStencilbuffer();
130

131
132
    virtual bool isDepthbuffer() const;
    virtual bool isStencilbuffer() const;
133

134
135
    GLuint getDepthSize() const;
    GLuint getStencilSize() const;
136
137
138
139

    IDirect3DSurface9 *getDepthStencil();

  private:
140
    DISALLOW_COPY_AND_ASSIGN(DepthStencilbuffer);
141
142
143
    IDirect3DSurface9 *mDepthStencil;
};

144
class Depthbuffer : public DepthStencilbuffer
145
146
{
  public:
147
148
    explicit Depthbuffer(IDirect3DSurface9 *depthStencil);
    Depthbuffer(int width, int height, GLsizei samples);
149

150
151
152
153
154
155
156
157
    ~Depthbuffer();

    bool isDepthbuffer() const;
    bool isStencilbuffer() const;

  private:
    DISALLOW_COPY_AND_ASSIGN(Depthbuffer);
};
158

159
160
161
162
163
class Stencilbuffer : public DepthStencilbuffer
{
  public:
    explicit Stencilbuffer(IDirect3DSurface9 *depthStencil);
    Stencilbuffer(int width, int height, GLsizei samples);
164

165
    ~Stencilbuffer();
166

167
168
    bool isDepthbuffer() const;
    bool isStencilbuffer() const;
169
170
171
172
173
174
175

  private:
    DISALLOW_COPY_AND_ASSIGN(Stencilbuffer);
};
}

#endif   // LIBGLESV2_RENDERBUFFER_H_