13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES Utilities
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief GL Rendering Context.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrGLContext.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrShaderProgram.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluTexture.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace sglr
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4;
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TextureFormat;
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLContext::GLContext (const glu::RenderContext& context, tcu::TestLog& log, deUint32 logFlags, const tcu::IVec4& baseViewport)
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: Context					(context.getType())
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_context					(context)
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_log						(log)
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_logFlags				(logFlags)
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_baseViewport			(baseViewport)
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_curViewport				(0, 0, m_baseViewport.z(), m_baseViewport.w())
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_curScissor				(0, 0, m_baseViewport.z(), m_baseViewport.w())
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_readFramebufferBinding	(0)
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_drawFramebufferBinding	(0)
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_wrapper					(DE_NULL)
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& gl = m_context.getFunctions();
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Logging?
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper = new glu::CallLogWrapper(gl, log);
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->enableLogging((logFlags & GLCONTEXT_LOG_CALLS) != 0);
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Setup base viewport. This offset is active when default framebuffer is active.
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \note Calls related to setting up base viewport are not included in log.
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.viewport(baseViewport.x(), baseViewport.y(), baseViewport.z(), baseViewport.w());
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
653c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGLContext::~GLContext (void)
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& gl = m_context.getFunctions();
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Clean up all still alive objects
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (std::set<deUint32>::const_iterator i = m_allocatedFbos.begin();
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 i != m_allocatedFbos.end(); i++)
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32 fbo = *i;
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.deleteFramebuffers(1, &fbo);
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (std::set<deUint32>::const_iterator i = m_allocatedRbos.begin();
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 i != m_allocatedRbos.end(); i++)
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32 rbo = *i;
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.deleteRenderbuffers(1, &rbo);
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (std::set<deUint32>::const_iterator i = m_allocatedTextures.begin();
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 i != m_allocatedTextures.end(); i++)
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32 tex = *i;
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.deleteTextures(1, &tex);
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (std::set<deUint32>::const_iterator i = m_allocatedBuffers.begin();
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 i != m_allocatedBuffers.end(); i++)
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32 buf = *i;
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.deleteBuffers(1, &buf);
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (std::set<deUint32>::const_iterator i = m_allocatedVaos.begin();
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 i != m_allocatedVaos.end(); i++)
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32 vao = *i;
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.deleteVertexArrays(1, &vao);
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (std::vector<glu::ShaderProgram*>::iterator i = m_programs.begin();
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		i != m_programs.end(); i++)
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		delete *i;
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.useProgram(0);
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	delete m_wrapper;
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::enableLogging (deUint32 logFlags)
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_logFlags = logFlags;
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->enableLogging((logFlags & GLCONTEXT_LOG_CALLS) != 0);
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::IVec2 GLContext::getDrawOffset (void) const
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_drawFramebufferBinding)
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return tcu::IVec2(0, 0);
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return tcu::IVec2(m_baseViewport.x(), m_baseViewport.y());
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::IVec2 GLContext::getReadOffset (void) const
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_readFramebufferBinding)
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return tcu::IVec2(0, 0);
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return tcu::IVec2(m_baseViewport.x(), m_baseViewport.y());
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint GLContext::getWidth (void) const
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_baseViewport.z();
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint GLContext::getHeight (void) const
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_baseViewport.w();
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::activeTexture (deUint32 texture)
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glActiveTexture(texture);
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::texParameteri (deUint32 target, deUint32 pname, int value)
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glTexParameteri(target, pname, value);
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1583c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint32 GLContext::checkFramebufferStatus(deUint32 target)
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_wrapper->glCheckFramebufferStatus(target);
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::viewport (int x, int y, int width, int height)
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_curViewport = tcu::IVec4(x, y, width, height);
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2 offset = getDrawOffset();
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \note For clarity don't add the offset to log
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << TestLog::Message << "glViewport(" << x << ", " << y << ", " << width << ", " << height << ");" << TestLog::EndMessage;
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getFunctions().viewport(x+offset.x(), y+offset.y(), width, height);
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::bindTexture (deUint32 target, deUint32 texture)
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_allocatedTextures.insert(texture);
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBindTexture(target, texture);
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::genTextures (int numTextures, deUint32* textures)
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glGenTextures(numTextures, textures);
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (numTextures > 0)
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedTextures.insert(textures, textures+numTextures);
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::deleteTextures (int numTextures, const deUint32* textures)
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int i = 0; i < numTextures; i++)
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedTextures.erase(textures[i]);
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDeleteTextures(numTextures, textures);
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::bindFramebuffer (deUint32 target, deUint32 framebuffer)
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \todo [2011-10-13 pyry] This is a bit of a hack since test cases assumes 0 default fbo.
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 defaultFbo = m_context.getDefaultFramebuffer();
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TCU_CHECK(framebuffer == 0 || framebuffer != defaultFbo);
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool isValidTarget = target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER;
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (isValidTarget && framebuffer != 0)
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedFbos.insert(framebuffer);
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Update bindings.
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER)
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_readFramebufferBinding = framebuffer;
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER)
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_drawFramebufferBinding = framebuffer;
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (framebuffer == 0) // Redirect 0 to platform-defined default framebuffer.
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_wrapper->glBindFramebuffer(target, defaultFbo);
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_wrapper->glBindFramebuffer(target, framebuffer);
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Update viewport and scissor if we updated draw framebuffer binding \note Not logged for clarity
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER)
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		tcu::IVec2 offset = getDrawOffset();
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_context.getFunctions().viewport(m_curViewport.x()+offset.x(), m_curViewport.y()+offset.y(), m_curViewport.z(), m_curViewport.w());
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_context.getFunctions().scissor(m_curScissor.x()+offset.x(), m_curScissor.y()+offset.y(), m_curScissor.z(), m_curScissor.w());
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::genFramebuffers (int numFramebuffers, deUint32* framebuffers)
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glGenFramebuffers(numFramebuffers, framebuffers);
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (numFramebuffers > 0)
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedFbos.insert(framebuffers, framebuffers+numFramebuffers);
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::deleteFramebuffers (int numFramebuffers, const deUint32* framebuffers)
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int i = 0; i < numFramebuffers; i++)
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedFbos.erase(framebuffers[i]);
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDeleteFramebuffers(numFramebuffers, framebuffers);
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::bindRenderbuffer (deUint32 target, deUint32 renderbuffer)
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_allocatedRbos.insert(renderbuffer);
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBindRenderbuffer(target, renderbuffer);
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::genRenderbuffers (int numRenderbuffers, deUint32* renderbuffers)
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glGenRenderbuffers(numRenderbuffers, renderbuffers);
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (numRenderbuffers > 0)
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedRbos.insert(renderbuffers, renderbuffers+numRenderbuffers);
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::deleteRenderbuffers (int numRenderbuffers, const deUint32* renderbuffers)
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int i = 0; i < numRenderbuffers; i++)
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedRbos.erase(renderbuffers[i]);
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDeleteRenderbuffers(numRenderbuffers, renderbuffers);
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::pixelStorei (deUint32 pname, int param)
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glPixelStorei(pname, param);
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::texImage1D (deUint32 target, int level, deUint32 internalFormat, int width, int border, deUint32 format, deUint32 type, const void* data)
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glTexImage1D(target, level, internalFormat, width, border, format, type, data);
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::texImage2D (deUint32 target, int level, deUint32 internalFormat, int width, int height, int border, deUint32 format, deUint32 type, const void* data)
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::texImage3D (deUint32 target, int level, deUint32 internalFormat, int width, int height, int depth, int border, deUint32 format, deUint32 type, const void* data)
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, data);
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::texSubImage1D (deUint32 target, int level, int xoffset, int width, deUint32 format, deUint32 type, const void* data)
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glTexSubImage1D(target, level, xoffset, width, format, type, data);
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::texSubImage2D (deUint32 target, int level, int xoffset, int yoffset, int width, int height, deUint32 format, deUint32 type, const void* data)
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, data);
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::texSubImage3D (deUint32 target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, deUint32 format, deUint32 type, const void* data)
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::copyTexImage1D (deUint32 target, int level, deUint32 internalFormat, int x, int y, int width, int border)
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Don't log offset.
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << TestLog::Message << "glCopyTexImage1D("
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getTextureTargetStr(target) << ", "
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << level << ", "
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getPixelFormatStr(internalFormat) << ", "
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << x << ", " << y << ", "
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << width << ", " << border << ")"
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  << TestLog::EndMessage;
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2 offset = getReadOffset();
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getFunctions().copyTexImage1D(target, level, internalFormat, offset.x()+x, offset.y()+y, width, border);
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::copyTexImage2D (deUint32 target, int level, deUint32 internalFormat, int x, int y, int width, int height, int border)
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Don't log offset.
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << TestLog::Message << "glCopyTexImage2D("
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getTextureTargetStr(target) << ", "
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << level << ", "
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getPixelFormatStr(internalFormat) << ", "
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << x << ", " << y << ", "
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << width << ", " << height
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << ", " << border << ")"
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  << TestLog::EndMessage;
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2 offset = getReadOffset();
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getFunctions().copyTexImage2D(target, level, internalFormat, offset.x()+x, offset.y()+y, width, height, border);
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::copyTexSubImage1D (deUint32 target, int level, int xoffset, int x, int y, int width)
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << TestLog::Message << "glCopyTexSubImage1D("
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getTextureTargetStr(target) << ", "
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << level << ", "
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << xoffset << ", "
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << x << ", " << y << ", "
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << width << ")"
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  << TestLog::EndMessage;
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2 offset = getReadOffset();
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getFunctions().copyTexSubImage1D(target, level, xoffset, offset.x()+x, offset.y()+y, width);
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::copyTexSubImage2D (deUint32 target, int level, int xoffset, int yoffset, int x, int y, int width, int height)
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << TestLog::Message << "glCopyTexSubImage2D("
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getTextureTargetStr(target) << ", "
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << level
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << ", " << xoffset << ", " << yoffset << ", "
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << x << ", " << y << ", "
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << width << ", " << height << ")"
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  << TestLog::EndMessage;
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2 offset = getReadOffset();
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getFunctions().copyTexSubImage2D(target, level, xoffset, yoffset, offset.x()+x, offset.y()+y, width, height);
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::copyTexSubImage3D (deUint32 target, int level, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height)
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << TestLog::Message << "glCopyTexSubImage3D("
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getTextureTargetStr(target) << ", "
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << level
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << ", " << xoffset << ", " << yoffset << ", " << zoffset << ", "
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << x << ", " << y << ", "
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << width << ", " << height << ")"
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  << TestLog::EndMessage;
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2 offset = getReadOffset();
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getFunctions().copyTexSubImage3D(target, level, xoffset, yoffset, zoffset, offset.x()+x, offset.y()+y, width, height);
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::texStorage2D (deUint32 target, int levels, deUint32 internalFormat, int width, int height)
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glTexStorage2D(target, levels, internalFormat, width, height);
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::texStorage3D (deUint32 target, int levels, deUint32 internalFormat, int width, int height, int depth)
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glTexStorage3D(target, levels, internalFormat, width, height, depth);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::framebufferTexture2D (deUint32 target, deUint32 attachment, deUint32 textarget, deUint32 texture, int level)
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glFramebufferTexture2D(target, attachment, textarget, texture, level);
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::framebufferTextureLayer (deUint32 target, deUint32 attachment, deUint32 texture, int level, int layer)
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glFramebufferTextureLayer(target, attachment, texture, level, layer);
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::framebufferRenderbuffer (deUint32 target, deUint32 attachment, deUint32 renderbuffertarget, deUint32 renderbuffer)
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::getFramebufferAttachmentParameteriv (deUint32 target, deUint32 attachment, deUint32 pname, int* params)
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::renderbufferStorage (deUint32 target, deUint32 internalformat, int width, int height)
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glRenderbufferStorage(target, internalformat, width, height);
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::renderbufferStorageMultisample (deUint32 target, int samples, deUint32 internalFormat, int width, int height)
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glRenderbufferStorageMultisample(target, samples, internalFormat, width, height);
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::bindBuffer (deUint32 target, deUint32 buffer)
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_allocatedBuffers.insert(buffer);
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBindBuffer(target, buffer);
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::genBuffers (int numBuffers, deUint32* buffers)
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glGenBuffers(numBuffers, buffers);
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (numBuffers > 0)
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedBuffers.insert(buffers, buffers+numBuffers);
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::deleteBuffers (int numBuffers, const deUint32* buffers)
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDeleteBuffers(numBuffers, buffers);
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int i = 0; i < numBuffers; i++)
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedBuffers.erase(buffers[i]);
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::bufferData (deUint32 target, deIntptr size, const void* data, deUint32 usage)
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBufferData(target, (glw::GLsizeiptr)size, data, usage);
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::bufferSubData (deUint32 target, deIntptr offset, deIntptr size, const void* data)
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBufferSubData(target, (glw::GLintptr)offset, (glw::GLsizeiptr)size, data);
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::clearColor (float red, float green, float blue, float alpha)
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glClearColor(red, green, blue, alpha);
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::clearDepthf (float depth)
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glClearDepthf(depth);
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::clearStencil (int stencil)
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glClearStencil(stencil);
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::clear (deUint32 buffers)
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glClear(buffers);
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::clearBufferiv (deUint32 buffer, int drawbuffer, const int* value)
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glClearBufferiv(buffer, drawbuffer, value);
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::clearBufferfv (deUint32 buffer, int drawbuffer, const float* value)
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glClearBufferfv(buffer, drawbuffer, value);
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::clearBufferuiv (deUint32 buffer, int drawbuffer, const deUint32* value)
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glClearBufferuiv(buffer, drawbuffer, value);
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::clearBufferfi (deUint32 buffer, int drawbuffer, float depth, int stencil)
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glClearBufferfi(buffer, drawbuffer, depth, stencil);
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::scissor (int x, int y, int width, int height)
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_curScissor = tcu::IVec4(x, y, width, height);
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// \note For clarity don't add the offset to log
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << TestLog::Message << "glScissor(" << x << ", " << y << ", " << width << ", " << height << ");" << TestLog::EndMessage;
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2 offset = getDrawOffset();
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getFunctions().scissor(offset.x()+x, offset.y()+y, width, height);
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::enable (deUint32 cap)
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glEnable(cap);
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::disable (deUint32 cap)
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDisable(cap);
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::stencilFunc (deUint32 func, int ref, deUint32 mask)
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glStencilFunc(func, ref, mask);
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::stencilOp (deUint32 sfail, deUint32 dpfail, deUint32 dppass)
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glStencilOp(sfail, dpfail, dppass);
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::depthFunc (deUint32 func)
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDepthFunc(func);
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::depthRangef (float n, float f)
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDepthRangef(n, f);
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::depthRange (double n, double f)
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDepthRange(n, f);
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::polygonOffset (float factor, float units)
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glPolygonOffset(factor, units);
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::provokingVertex (deUint32 convention)
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glProvokingVertex(convention);
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::primitiveRestartIndex (deUint32 index)
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glPrimitiveRestartIndex(index);
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::stencilFuncSeparate (deUint32 face, deUint32 func, int ref, deUint32 mask)
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glStencilFuncSeparate(face, func, ref, mask);
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::stencilOpSeparate (deUint32 face, deUint32 sfail, deUint32 dpfail, deUint32 dppass)
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glStencilOpSeparate(face, sfail, dpfail, dppass);
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::blendEquation (deUint32 mode)
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBlendEquation(mode);
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::blendEquationSeparate (deUint32 modeRGB, deUint32 modeAlpha)
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBlendEquationSeparate(modeRGB, modeAlpha);
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::blendFunc (deUint32 src, deUint32 dst)
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBlendFunc(src, dst);
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::blendFuncSeparate (deUint32 srcRGB, deUint32 dstRGB, deUint32 srcAlpha, deUint32 dstAlpha)
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::blendColor (float red, float green, float blue, float alpha)
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBlendColor(red, green, blue, alpha);
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::colorMask (deBool r, deBool g, deBool b, deBool a)
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glColorMask(r, g, b, a);
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::depthMask (deBool mask)
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDepthMask(mask);
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::stencilMask (deUint32 mask)
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glStencilMask(mask);
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::stencilMaskSeparate (deUint32 face, deUint32 mask)
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glStencilMaskSeparate(face, mask);
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::blitFramebuffer (int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, deUint32 mask, deUint32 filter)
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2	drawOffset	= getDrawOffset();
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2	readOffset	= getReadOffset();
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << TestLog::Message << "glBlitFramebuffer("
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << srcX0 << ", " << srcY0 << ", " << srcX1 << ", " << srcY1 << ", "
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << dstX0 << ", " << dstY0 << ", " << dstX1 << ", " << dstY1 << ", "
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getBufferMaskStr(mask) << ", "
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getTextureFilterStr(filter) << ")"
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  << TestLog::EndMessage;
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getFunctions().blitFramebuffer(readOffset.x()+srcX0, readOffset.y()+srcY0, readOffset.x()+srcX1, readOffset.y()+srcY1,
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 drawOffset.x()+dstX0, drawOffset.y()+dstY0, drawOffset.x()+dstX1, drawOffset.y()+dstY1,
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											 mask, filter);
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::invalidateSubFramebuffer (deUint32 target, int numAttachments, const deUint32* attachments, int x, int y, int width, int height)
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2 drawOffset = getDrawOffset();
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << TestLog::Message << "glInvalidateSubFramebuffer("
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getFramebufferTargetStr(target) << ", " << numAttachments << ", "
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getInvalidateAttachmentStr(attachments, numAttachments) << ", "
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << x << ", " << y << ", " << width << ", " << height << ")"
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  << TestLog::EndMessage;
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getFunctions().invalidateSubFramebuffer(target, numAttachments, attachments, x+drawOffset.x(), y+drawOffset.y(), width, height);
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::invalidateFramebuffer (deUint32 target, int numAttachments, const deUint32* attachments)
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glInvalidateFramebuffer(target, numAttachments, attachments);
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::bindVertexArray (deUint32 array)
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glBindVertexArray(array);
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::genVertexArrays (int numArrays, deUint32* vertexArrays)
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glGenVertexArrays(numArrays, vertexArrays);
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (numArrays > 0)
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedVaos.insert(vertexArrays, vertexArrays+numArrays);
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::deleteVertexArrays (int numArrays, const deUint32* vertexArrays)
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int i = 0; i < numArrays; i++)
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_allocatedVaos.erase(vertexArrays[i]);
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDeleteVertexArrays(numArrays, vertexArrays);
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::vertexAttribPointer (deUint32 index, int size, deUint32 type, deBool normalized, int stride, const void *pointer)
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glVertexAttribPointer(index, size, type, normalized, stride, pointer);
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::vertexAttribIPointer (deUint32 index, int size, deUint32 type, int stride, const void *pointer)
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glVertexAttribIPointer(index, size, type, stride, pointer);
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::enableVertexAttribArray (deUint32 index)
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glEnableVertexAttribArray(index);
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::disableVertexAttribArray (deUint32 index)
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDisableVertexAttribArray(index);
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::vertexAttribDivisor (deUint32 index, deUint32 divisor)
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glVertexAttribDivisor(index, divisor);
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::vertexAttrib1f (deUint32 index, float x)
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glVertexAttrib1f(index, x);
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::vertexAttrib2f (deUint32 index, float x, float y)
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glVertexAttrib2f(index, x, y);
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::vertexAttrib3f (deUint32 index, float x, float y, float z)
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glVertexAttrib3f(index, x, y, z);
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::vertexAttrib4f (deUint32 index, float x, float y, float z, float w)
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glVertexAttrib4f(index, x, y, z, w);
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::vertexAttribI4i (deUint32 index, deInt32 x, deInt32 y, deInt32 z, deInt32 w)
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glVertexAttribI4i(index, x, y, z, w);
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::vertexAttribI4ui (deUint32 index, deUint32 x, deUint32 y, deUint32 z, deUint32 w)
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glVertexAttribI4ui(index, x, y, z, w);
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7113c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeInt32 GLContext::getAttribLocation (deUint32 program, const char *name)
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_wrapper->glGetAttribLocation(program, name);
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniform1f (deInt32 location, float v0)
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniform1f(location, v0);
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniform1i (deInt32 location, deInt32 v0)
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniform1i(location, v0);
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniform1fv (deInt32 location, deInt32 count, const float* value)
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniform1fv(location, count, value);
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniform2fv (deInt32 location, deInt32 count, const float* value)
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniform2fv(location, count, value);
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniform3fv (deInt32 location, deInt32 count, const float* value)
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniform3fv(location, count, value);
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniform4fv (deInt32 location, deInt32 count, const float* value)
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniform4fv(location, count, value);
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniform1iv (deInt32 location, deInt32 count, const deInt32* value)
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniform1iv(location, count, value);
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniform2iv (deInt32 location, deInt32 count, const deInt32* value)
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniform2iv(location, count, value);
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniform3iv (deInt32 location, deInt32 count, const deInt32* value)
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniform3iv(location, count, value);
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniform4iv (deInt32 location, deInt32 count, const deInt32* value)
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniform4iv(location, count, value);
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniformMatrix3fv (deInt32 location, deInt32 count, deInt32 transpose, const float *value)
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniformMatrix3fv(location, count, transpose, value);
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::uniformMatrix4fv (deInt32 location, deInt32 count, deInt32 transpose, const float *value)
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUniformMatrix4fv(location, count, transpose, value);
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7753c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeInt32 GLContext::getUniformLocation (deUint32 program, const char *name)
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_wrapper->glGetUniformLocation(program, name);
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::lineWidth (float w)
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glLineWidth(w);
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::drawArrays (deUint32 mode, int first, int count)
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDrawArrays(mode, first, count);
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::drawArraysInstanced (deUint32 mode, int first, int count, int instanceCount)
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDrawArraysInstanced(mode, first, count, instanceCount);
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::drawElements (deUint32 mode, int count, deUint32 type, const void *indices)
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDrawElements(mode, count, type, indices);
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::drawElementsInstanced (deUint32 mode, int count, deUint32 type, const void *indices, int instanceCount)
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDrawElementsInstanced(mode, count, type, indices, instanceCount);
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::drawElementsBaseVertex (deUint32 mode, int count, deUint32 type, const void *indices, int baseVertex)
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDrawElementsBaseVertex(mode, count, type, indices, baseVertex);
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::drawElementsInstancedBaseVertex (deUint32 mode, int count, deUint32 type, const void *indices, int instanceCount, int baseVertex)
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDrawElementsInstancedBaseVertex(mode, count, type, indices, instanceCount, baseVertex);
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::drawRangeElements (deUint32 mode, deUint32 start, deUint32 end, int count, deUint32 type, const void *indices)
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDrawRangeElements(mode, start, end, count, type, indices);
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::drawRangeElementsBaseVertex (deUint32 mode, deUint32 start, deUint32 end, int count, deUint32 type, const void *indices, int baseVertex)
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDrawRangeElementsBaseVertex(mode, start, end, count, type, indices, baseVertex);
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::drawArraysIndirect (deUint32 mode, const void *indirect)
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDrawArraysIndirect(mode, indirect);
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::drawElementsIndirect (deUint32 mode, deUint32 type, const void *indirect)
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glDrawElementsIndirect(mode, type, indirect);
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::multiDrawArrays (deUint32 mode, const int* first, const int* count, int primCount)
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glMultiDrawArrays(mode, first, count, primCount);
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::multiDrawElements (deUint32 mode, const int* count, deUint32 type, const void** indices, int primCount)
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glMultiDrawElements(mode, count, type, indices, primCount);
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::multiDrawElementsBaseVertex (deUint32 mode, const int* count, deUint32 type, const void** indices, int primCount, const int* baseVertex)
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glMultiDrawElementsBaseVertex(mode, count, type, indices, primCount, baseVertex);
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8503c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint32 GLContext::createProgram (ShaderProgram* shader)
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_programs.reserve(m_programs.size()+1);
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram* program = DE_NULL;
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!shader->m_hasGeometryShader)
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		program = new glu::ShaderProgram(m_context, glu::makeVtxFragSources(shader->m_vertSrc, shader->m_fragSrc));
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		program = new glu::ShaderProgram(m_context,
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										 glu::ProgramSources() << glu::VertexSource(shader->m_vertSrc)
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															   << glu::FragmentSource(shader->m_fragSrc)
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															   << glu::GeometrySource(shader->m_geomSrc));
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!program->isOk())
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << *program;
867811210088ca91e62eb58a159c39791e550fd0f9aJarkko Pöyry		delete program;
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TCU_FAIL("Compile failed");
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_PROGRAMS) != 0)
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << *program;
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_programs.push_back(program);
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return program->getProgram();
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::deleteProgram (deUint32 program)
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (std::vector<glu::ShaderProgram*>::iterator i = m_programs.begin(); i != m_programs.end(); i++)
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if ((*i)->getProgram() == program)
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			delete *i;
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_programs.erase(i);
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return;
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(!"invalid delete");
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::useProgram (deUint32 program)
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glUseProgram(program);
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::readPixels (int x, int y, int width, int height, deUint32 format, deUint32 type, void* data)
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Don't log offset.
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if ((m_logFlags & GLCONTEXT_LOG_CALLS) != 0)
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_log << TestLog::Message << "glReadPixels("
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << x << ", " << y << ", " << width << ", " << height << ", "
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getPixelFormatStr(format) << ", "
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								  << glu::getTypeStr(type) << ", " << data << ")"
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			  << TestLog::EndMessage;
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec2 offset = getReadOffset();
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getFunctions().readPixels(x+offset.x(), y+offset.y(), width, height, format, type, data);
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9123c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint32 GLContext::getError (void)
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_wrapper->glGetError();
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::finish (void)
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glFinish();
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GLContext::getIntegerv (deUint32 pname, int* params)
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_wrapper->glGetIntegerv(pname, params);
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* GLContext::getString (deUint32 pname)
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (const char*)m_wrapper->glGetString(pname);
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // sglr
933