xref: /aosp_15_r20/external/deqp/framework/opengl/gluFboRenderContext.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _GLUFBORENDERCONTEXT_HPP
2 #define _GLUFBORENDERCONTEXT_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program OpenGL ES Utilities
5  * ------------------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief OpenGL ES context wrapper that uses FBO as default framebuffer.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "gluRenderContext.hpp"
28 #include "tcuRenderTarget.hpp"
29 
30 namespace tcu
31 {
32 class CommandLine;
33 }
34 
35 namespace glu
36 {
37 
38 class ContextFactory;
39 struct RenderConfig;
40 
41 /*--------------------------------------------------------------------*//*!
42  * \brief OpenGL ES context wrapper that uses FBO as default framebuffer.
43  *//*--------------------------------------------------------------------*/
44 class FboRenderContext : public RenderContext
45 {
46 public:
47     FboRenderContext(RenderContext *context, const RenderConfig &config);
48     FboRenderContext(const ContextFactory &factory, const RenderConfig &config, const tcu::CommandLine &cmdLine);
49     virtual ~FboRenderContext(void);
50 
getType(void) const51     virtual ContextType getType(void) const
52     {
53         return m_context->getType();
54     }
getFunctions(void) const55     virtual const glw::Functions &getFunctions(void) const
56     {
57         return m_context->getFunctions();
58     }
getRenderTarget(void) const59     virtual const tcu::RenderTarget &getRenderTarget(void) const
60     {
61         return m_renderTarget;
62     }
63     virtual void postIterate(void);
64 
getDefaultFramebuffer(void) const65     virtual uint32_t getDefaultFramebuffer(void) const
66     {
67         return m_framebuffer;
68     }
getProcAddress(const char * name) const69     virtual glw::GenericFuncType getProcAddress(const char *name) const
70     {
71         return m_context->getProcAddress(name);
72     }
73 
74     virtual void makeCurrent(void);
75 
76 private:
77     void createFramebuffer(const RenderConfig &config);
78     void destroyFramebuffer(void);
79 
80     RenderContext *m_context;
81     uint32_t m_framebuffer;
82     uint32_t m_colorBuffer;
83     uint32_t m_depthStencilBuffer;
84     tcu::RenderTarget m_renderTarget;
85 };
86 
87 // RenderConfig to format mapping utilities, useful for platforms like iOS.
88 uint32_t chooseColorFormat(const RenderConfig &config);
89 uint32_t chooseDepthStencilFormat(const RenderConfig &config);
90 
91 } // namespace glu
92 
93 #endif // _GLUFBORENDERCONTEXT_HPP
94