• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 // Framebuffer.h: Defines the Framebuffer class. Implements GL framebuffer
16 // objects and related functionality.
17 
18 #ifndef LIBGL_FRAMEBUFFER_H_
19 #define LIBGL_FRAMEBUFFER_H_
20 
21 #include "common/Object.hpp"
22 #include "Image.hpp"
23 
24 #define _GDI32_
25 #include <windows.h>
26 #include <GL/GL.h>
27 #include <GL/glext.h>
28 
29 namespace gl
30 {
31 class Renderbuffer;
32 class Colorbuffer;
33 class Depthbuffer;
34 class Stencilbuffer;
35 class DepthStencilbuffer;
36 
37 class Framebuffer
38 {
39 public:
40 	Framebuffer();
41 
42 	virtual ~Framebuffer();
43 
44 	void setColorbuffer(GLenum type, GLuint colorbuffer);
45 	void setDepthbuffer(GLenum type, GLuint depthbuffer);
46 	void setStencilbuffer(GLenum type, GLuint stencilbuffer);
47 
48 	void detachTexture(GLuint texture);
49 	void detachRenderbuffer(GLuint renderbuffer);
50 
51 	Image *getRenderTarget();
52 	Image *getDepthStencil();
53 
54 	Renderbuffer *getColorbuffer();
55 	Renderbuffer *getDepthbuffer();
56 	Renderbuffer *getStencilbuffer();
57 
58 	GLenum getColorbufferType();
59 	GLenum getDepthbufferType();
60 	GLenum getStencilbufferType();
61 
62 	GLuint getColorbufferName();
63 	GLuint getDepthbufferName();
64 	GLuint getStencilbufferName();
65 
66 	bool hasStencil();
67 
68 	virtual GLenum completeness();
69 	GLenum completeness(int &width, int &height, int &samples);
70 
71 protected:
72 	GLenum mColorbufferType;
73 	BindingPointer<Renderbuffer> mColorbufferPointer;
74 
75 	GLenum mDepthbufferType;
76 	BindingPointer<Renderbuffer> mDepthbufferPointer;
77 
78 	GLenum mStencilbufferType;
79 	BindingPointer<Renderbuffer> mStencilbufferPointer;
80 
81 private:
82 	Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle) const;
83 };
84 
85 class DefaultFramebuffer : public Framebuffer
86 {
87 public:
88 	DefaultFramebuffer(Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
89 
90 	virtual GLenum completeness();
91 };
92 
93 }
94 
95 #endif   // LIBGL_FRAMEBUFFER_H_
96