1 /*-------------------------------------------------------------------------
2 * OpenGL Conformance Test Suite
3 * -----------------------------
5 * Copyright (c) 2016 Google Inc.
6 * Copyright (c) 2016 The Khronos Group Inc.
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * \brief OpenGL test context.
23 */ /*-------------------------------------------------------------------*/
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"
37 Context::Context(tcu::TestContext& testCtx, glu::ContextType contextType)
38 : m_testCtx(testCtx), m_renderCtx(DE_NULL), m_contextInfo(DE_NULL)
40 createRenderContext(contextType);
43 Context::~Context(void)
45 destroyRenderContext();
48 void Context::createRenderContext(glu::ContextType& contextType, glu::ContextFlags ctxFlags)
50 DE_ASSERT(!m_renderCtx && !m_contextInfo);
54 glu::RenderConfig renderCfg(glu::ContextType(contextType.getAPI(), contextType.getFlags() | ctxFlags));
56 glu::parseRenderConfig(&renderCfg, m_testCtx.getCommandLine());
58 if (m_testCtx.getCommandLine().getRunMode() != tcu::RUNMODE_EXECUTE)
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;
65 m_renderCtx = glu::createRenderContext(m_testCtx.getPlatform(), m_testCtx.getCommandLine(), renderCfg);
66 m_contextInfo = glu::ContextInfo::create(*m_renderCtx);
68 glw::setCurrentThreadFunctions(&m_renderCtx->getFunctions());
72 destroyRenderContext();
77 void Context::destroyRenderContext(void)
82 m_contextInfo = DE_NULL;
83 m_renderCtx = DE_NULL;
86 const tcu::RenderTarget& Context::getRenderTarget(void) const
88 return m_renderCtx->getRenderTarget();