13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _GLUDRAWUTIL_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _GLUDRAWUTIL_HPP
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL Utilities
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ---------------------------------------------
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Draw call utilities.
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Draw call utilities provide an abstraction for commonly used draw calls.
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * The objective of that abstraction is to allow moving data to buffers
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * and state to VAOs automatically if target context doesn't support
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * user pointers or default VAOs.
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluDefs.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string>
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace glu
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderContext;
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum VertexComponentType
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Standard types: all conversion types apply.
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_UNSIGNED_INT8		= 0,
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_UNSIGNED_INT16,
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_UNSIGNED_INT32,
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_SIGNED_INT8,
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_SIGNED_INT16,
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_SIGNED_INT32,
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Special types: only CONVERT_NONE is allowed.
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_FIXED,
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_HALF_FLOAT,
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_FLOAT,
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_TYPE_LAST
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum VertexComponentConversion
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_CONVERT_NONE = 0,				//!< No conversion: integer types, or floating-point values.
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_CONVERT_NORMALIZE_TO_FLOAT,	//!< Normalize integers to range [0,1] or [-1,1] depending on type.
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_CONVERT_CAST_TO_FLOAT,			//!< Convert to floating-point directly.
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VTX_COMP_CONVERT_LAST
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum IndexType
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	INDEXTYPE_UINT8,
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	INDEXTYPE_UINT16,
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	INDEXTYPE_UINT32,
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	INDEXTYPE_LAST
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum PrimitiveType
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PRIMITIVETYPE_TRIANGLES = 0,
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PRIMITIVETYPE_TRIANGLE_STRIP,
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PRIMITIVETYPE_TRIANGLE_FAN,
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PRIMITIVETYPE_LINES,
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PRIMITIVETYPE_LINE_STRIP,
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PRIMITIVETYPE_LINE_LOOP,
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PRIMITIVETYPE_POINTS,
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PRIMITIVETYPE_PATCHES,
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PRIMITIVETYPE_LAST
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct BindingPoint
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum Type
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_LOCATION = 0,			//!< Binding by numeric location.
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_NAME,					//!< Binding by input name.
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_LAST
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Type			type;			//!< Binding type (name or location).
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string		name;			//!< Input name, or empty if is not binding by name.
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				location;		//!< Input location, or offset to named location if binding by name.
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				BindingPoint (void)											: type(TYPE_LAST), location (0) {}
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	explicit	BindingPoint (int location_)								: type(TYPE_LOCATION), location(location_) {}
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	explicit	BindingPoint (const std::string& name_, int location_ = 0)	: type(TYPE_NAME), name(name_), location(location_) {}
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct VertexArrayPointer
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexComponentType			componentType;	//!< Component type.
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexComponentConversion	convert;		//!< Component conversion type.
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							numComponents;	//!< Number of components per element.
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							numElements;	//!< Number of elements in total.
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							stride;			//!< Element stride.
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const void*					data;			//!< Data pointer.
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexArrayPointer (VertexComponentType componentType_, VertexComponentConversion convert_, int numComponents_, int numElements_, int stride_, const void* data_)
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: componentType	(componentType_)
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, convert		(convert_)
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, numComponents	(numComponents_)
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, numElements	(numElements_)
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, stride		(stride_)
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, data			(data_)
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexArrayPointer (void)
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: componentType	(VTX_COMP_TYPE_LAST)
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, convert		(VTX_COMP_CONVERT_LAST)
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, numComponents	(0)
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, numElements	(0)
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, stride		(0)
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, data			(0)
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct VertexArrayBinding
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BindingPoint		binding;
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexArrayPointer	pointer;
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexArrayBinding (const BindingPoint& binding_, const VertexArrayPointer& pointer_)
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: binding	(binding_)
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, pointer	(pointer_)
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VertexArrayBinding (void)
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct PrimitiveList
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PrimitiveType		type;			//!< Primitive type.
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int					numElements;	//!< Number of elements to be drawn.
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IndexType			indexType;		//!< Index type or INDEXTYPE_LAST if not used
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const void*			indices;		//!< Index list or DE_NULL if not used.
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PrimitiveList (PrimitiveType type_, int numElements_)
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: type			(type_)
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, numElements	(numElements_)
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, indexType		(INDEXTYPE_LAST)
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, indices		(0)
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PrimitiveList (PrimitiveType type_, int numElements_, IndexType indexType_, const void* indices_)
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: type			(type_)
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, numElements	(numElements_)
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, indexType		(indexType_)
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, indices		(indices_)
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	PrimitiveList (void)
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: type			(PRIMITIVETYPE_LAST)
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, numElements	(0)
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, indexType		(INDEXTYPE_LAST)
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, indices		(0)
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DrawUtilCallback
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void	beforeDrawCall	(void) { }
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void	afterDrawCall	(void) { }
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid	draw					(const RenderContext& context, deUint32 program, int numVertexArrays, const VertexArrayBinding* vertexArrays, const PrimitiveList& primitives, DrawUtilCallback* callback = DE_NULL);
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid	drawFromUserPointers	(const RenderContext& context, deUint32 program, int numVertexArrays, const VertexArrayBinding* vertexArrays, const PrimitiveList& primitives, DrawUtilCallback* callback = DE_NULL);
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid	drawFromBuffers			(const RenderContext& context, deUint32 program, int numVertexArrays, const VertexArrayBinding* vertexArrays, const PrimitiveList& primitives, DrawUtilCallback* callback = DE_NULL);
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid	drawFromVAOBuffers		(const RenderContext& context, deUint32 program, int numVertexArrays, const VertexArrayBinding* vertexArrays, const PrimitiveList& primitives, DrawUtilCallback* callback = DE_NULL);
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Shorthands for PrimitiveList
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace pr
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define DECLARE_PR_CTOR(NAME, TYPE)										\
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline PrimitiveList NAME (int numElements)								\
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{																		\
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return PrimitiveList(TYPE, numElements);							\
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}																		\
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline PrimitiveList NAME (int numElements, const deUint8* indices)		\
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{																		\
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return PrimitiveList(TYPE, numElements, INDEXTYPE_UINT8, indices);	\
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}																		\
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline PrimitiveList NAME (int numElements, const deUint16* indices)	\
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{																		\
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return PrimitiveList(TYPE, numElements, INDEXTYPE_UINT16, indices);	\
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}																		\
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline PrimitiveList NAME (int numElements, const deUint32* indices)	\
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{																		\
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return PrimitiveList(TYPE, numElements, INDEXTYPE_UINT32, indices);	\
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}																		\
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DeclarePRCtor##NAME##Unused_s { int unused; }
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2273c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_PR_CTOR(Triangles,		PRIMITIVETYPE_TRIANGLES);
2283c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_PR_CTOR(TriangleStrip,	PRIMITIVETYPE_TRIANGLE_STRIP);
2293c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_PR_CTOR(TriangleFan,	PRIMITIVETYPE_TRIANGLE_FAN);
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2313c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_PR_CTOR(Lines,			PRIMITIVETYPE_LINES);
2323c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_PR_CTOR(LineStrip,		PRIMITIVETYPE_LINE_STRIP);
2333c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_PR_CTOR(LineLineLoop,	PRIMITIVETYPE_LINE_LOOP);
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2353c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_PR_CTOR(Points,			PRIMITIVETYPE_POINTS);
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2373c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_PR_CTOR(Patches,		PRIMITIVETYPE_PATCHES);
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // pr
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Shorthands for VertexArrayBinding
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace va
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define DECLARE_VA_CTOR(NAME, DATATYPE, TYPE, CONVERT)																						\
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline VertexArrayBinding NAME (const std::string& name, int offset, int numComponents, int numElements, int stride, const DATATYPE* data)	\
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{																																			\
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return VertexArrayBinding(BindingPoint(name, offset), VertexArrayPointer(TYPE, CONVERT, numComponents, numElements, stride, data));		\
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}																																			\
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline VertexArrayBinding NAME (const std::string& name, int numComponents, int numElements, int stride, const DATATYPE* data)				\
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{																																			\
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return NAME(name, 0, numComponents, numElements, stride, data);																			\
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}																																			\
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryinline VertexArrayBinding NAME (int location, int numComponents, int numElements, int stride, const DATATYPE* data)							\
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{																																			\
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return VertexArrayBinding(BindingPoint(location), VertexArrayPointer(TYPE, CONVERT, numComponents, numElements, stride, data));			\
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}																																			\
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DeclareVACtor##NAME##Unused_s { int unused; }
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Integer types
2613c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Uint8,			deUint8,		VTX_COMP_UNSIGNED_INT8,		VTX_COMP_CONVERT_NONE);
2623c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Uint16,			deUint16,		VTX_COMP_UNSIGNED_INT16,	VTX_COMP_CONVERT_NONE);
2633c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Uint32,			deUint32,		VTX_COMP_UNSIGNED_INT32,	VTX_COMP_CONVERT_NONE);
2643c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Int8,			deInt8,			VTX_COMP_SIGNED_INT8,		VTX_COMP_CONVERT_NONE);
2653c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Int16,			deInt16,		VTX_COMP_SIGNED_INT16,		VTX_COMP_CONVERT_NONE);
2663c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Int32,			deInt32,		VTX_COMP_SIGNED_INT32,		VTX_COMP_CONVERT_NONE);
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Normalized integers.
2693c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Unorm8,			deUint8,		VTX_COMP_UNSIGNED_INT8,		VTX_COMP_CONVERT_NORMALIZE_TO_FLOAT);
2703c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Unorm16,		deUint16,		VTX_COMP_UNSIGNED_INT16,	VTX_COMP_CONVERT_NORMALIZE_TO_FLOAT);
2713c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Unorm32,		deUint32,		VTX_COMP_UNSIGNED_INT32,	VTX_COMP_CONVERT_NORMALIZE_TO_FLOAT);
2723c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Snorm8,			deInt8,			VTX_COMP_SIGNED_INT8,		VTX_COMP_CONVERT_NORMALIZE_TO_FLOAT);
2733c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Snorm16,		deInt16,		VTX_COMP_SIGNED_INT16,		VTX_COMP_CONVERT_NORMALIZE_TO_FLOAT);
2743c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Snorm32,		deInt32,		VTX_COMP_SIGNED_INT32,		VTX_COMP_CONVERT_NORMALIZE_TO_FLOAT);
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Integers converted to float.
2773c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Uint8Float,		deUint8,		VTX_COMP_UNSIGNED_INT8,		VTX_COMP_CONVERT_CAST_TO_FLOAT);
2783c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Uint16Float,	deUint16,		VTX_COMP_UNSIGNED_INT16,	VTX_COMP_CONVERT_CAST_TO_FLOAT);
2793c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Uint32Float,	deUint32,		VTX_COMP_UNSIGNED_INT32,	VTX_COMP_CONVERT_CAST_TO_FLOAT);
2803c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Int8Float,		deInt8,			VTX_COMP_SIGNED_INT8,		VTX_COMP_CONVERT_CAST_TO_FLOAT);
2813c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Int16Float,		deInt16,		VTX_COMP_SIGNED_INT16,		VTX_COMP_CONVERT_CAST_TO_FLOAT);
2823c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Int32Float,		deInt32,		VTX_COMP_SIGNED_INT32,		VTX_COMP_CONVERT_CAST_TO_FLOAT);
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Special types.
2853c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Fixed,			void,			VTX_COMP_FIXED,				VTX_COMP_CONVERT_NONE);
2863c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Half,			void,			VTX_COMP_HALF_FLOAT,		VTX_COMP_CONVERT_NONE);
2873c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDECLARE_VA_CTOR(Float,			float,			VTX_COMP_FLOAT,				VTX_COMP_CONVERT_NONE);
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#undef DECLARE_VA_CTOR
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // va
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // glu
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLUDRAWUTIL_HPP
296