1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
4 *
5 * Copyright (c) 2016 Google Inc.
6 * Copyright (c) 2016 The Khronos Group Inc.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */ /*!
21 * \file
22 * \brief OpenGL test context.
23 */ /*-------------------------------------------------------------------*/
24
25 #include "glcContext.hpp"
26 #include "gluContextInfo.hpp"
27 #include "gluDummyRenderContext.hpp"
28 #include "gluFboRenderContext.hpp"
29 #include "gluRenderConfig.hpp"
30 #include "gluRenderContext.hpp"
31 #include "glwWrapper.hpp"
32 #include "tcuCommandLine.hpp"
33
34 namespace deqp
35 {
36
Context(tcu::TestContext & testCtx,glu::ContextType contextType)37 Context::Context(tcu::TestContext& testCtx, glu::ContextType contextType)
38 : m_testCtx(testCtx), m_renderCtx(DE_NULL), m_contextInfo(DE_NULL)
39 {
40 createRenderContext(contextType);
41 }
42
~Context(void)43 Context::~Context(void)
44 {
45 destroyRenderContext();
46 }
47
createRenderContext(glu::ContextType & contextType,glu::ContextFlags ctxFlags)48 void Context::createRenderContext(glu::ContextType& contextType, glu::ContextFlags ctxFlags)
49 {
50 DE_ASSERT(!m_renderCtx && !m_contextInfo);
51
52 try
53 {
54 glu::RenderConfig renderCfg(glu::ContextType(contextType.getAPI(), contextType.getFlags() | ctxFlags));
55
56 glu::parseRenderConfig(&renderCfg, m_testCtx.getCommandLine());
57
58 if (m_testCtx.getCommandLine().getRunMode() != tcu::RUNMODE_EXECUTE)
59 {
60 // \todo [2016-11-16 pyry] Create DummyRenderContext instead to allow generating all case lists
61 // on a system that doesn't support some GL(ES) versions.
62 renderCfg.surfaceType = glu::RenderConfig::SURFACETYPE_OFFSCREEN_GENERIC;
63 }
64
65 m_renderCtx = glu::createRenderContext(m_testCtx.getPlatform(), m_testCtx.getCommandLine(), renderCfg);
66 m_contextInfo = glu::ContextInfo::create(*m_renderCtx);
67
68 glw::setCurrentThreadFunctions(&m_renderCtx->getFunctions());
69 }
70 catch (...)
71 {
72 destroyRenderContext();
73 throw;
74 }
75 }
76
destroyRenderContext(void)77 void Context::destroyRenderContext(void)
78 {
79 delete m_contextInfo;
80 delete m_renderCtx;
81
82 m_contextInfo = DE_NULL;
83 m_renderCtx = DE_NULL;
84 }
85
getRenderTarget(void) const86 const tcu::RenderTarget& Context::getRenderTarget(void) const
87 {
88 return m_renderCtx->getRenderTarget();
89 }
90
91 } // deqp
92