Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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. [OpenGL ES 2.0.24] section 4.4 page 105. |
| 17 | |
| 18 | #ifndef LIBGLES_CM_FRAMEBUFFER_H_ |
| 19 | #define LIBGLES_CM_FRAMEBUFFER_H_ |
| 20 | |
| 21 | #include "common/Object.hpp" |
| 22 | #include "common/Image.hpp" |
| 23 | |
| 24 | #include <GLES/gl.h> |
| 25 | |
| 26 | namespace es1 |
| 27 | { |
| 28 | class Renderbuffer; |
| 29 | class Colorbuffer; |
| 30 | class Depthbuffer; |
| 31 | class Stencilbuffer; |
| 32 | class DepthStencilbuffer; |
| 33 | |
| 34 | class Framebuffer |
| 35 | { |
| 36 | public: |
| 37 | Framebuffer(); |
| 38 | |
| 39 | virtual ~Framebuffer(); |
| 40 | |
Nicolas Capens | 0ccc71d | 2018-03-23 10:13:06 -0400 | [diff] [blame] | 41 | void setColorbuffer(GLenum type, GLuint colorbuffer, GLint level = 0); |
| 42 | void setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level = 0); |
| 43 | void setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level = 0); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 44 | |
| 45 | void detachTexture(GLuint texture); |
| 46 | void detachRenderbuffer(GLuint renderbuffer); |
| 47 | |
| 48 | egl::Image *getRenderTarget(); |
| 49 | egl::Image *getDepthBuffer(); |
| 50 | egl::Image *getStencilBuffer(); |
| 51 | |
| 52 | Renderbuffer *getColorbuffer(); |
| 53 | Renderbuffer *getDepthbuffer(); |
| 54 | Renderbuffer *getStencilbuffer(); |
| 55 | |
| 56 | GLenum getColorbufferType(); |
| 57 | GLenum getDepthbufferType(); |
| 58 | GLenum getStencilbufferType(); |
| 59 | |
| 60 | GLuint getColorbufferName(); |
| 61 | GLuint getDepthbufferName(); |
| 62 | GLuint getStencilbufferName(); |
| 63 | |
| 64 | bool hasStencil(); |
| 65 | |
| 66 | virtual GLenum completeness(); |
| 67 | GLenum completeness(int &width, int &height, int &samples); |
| 68 | |
| 69 | GLenum getImplementationColorReadFormat(); |
| 70 | GLenum getImplementationColorReadType(); |
| 71 | |
| 72 | protected: |
| 73 | GLenum mColorbufferType; |
| 74 | gl::BindingPointer<Renderbuffer> mColorbufferPointer; |
| 75 | |
| 76 | GLenum mDepthbufferType; |
| 77 | gl::BindingPointer<Renderbuffer> mDepthbufferPointer; |
| 78 | |
| 79 | GLenum mStencilbufferType; |
| 80 | gl::BindingPointer<Renderbuffer> mStencilbufferPointer; |
| 81 | |
| 82 | private: |
Nicolas Capens | 0ccc71d | 2018-03-23 10:13:06 -0400 | [diff] [blame] | 83 | Renderbuffer *lookupRenderbuffer(GLenum type, GLuint handle, GLint level) const; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | class DefaultFramebuffer : public Framebuffer |
| 87 | { |
| 88 | public: |
| 89 | DefaultFramebuffer(Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil); |
| 90 | }; |
| 91 | |
| 92 | } |
| 93 | |
| 94 | #endif // LIBGLES_CM_FRAMEBUFFER_H_ |