13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _GLUCONTEXTINFO_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _GLUCONTEXTINFO_HPP
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 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 Context Info Class.
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluDefs.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string>
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <set>
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace glu
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderContext;
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T, class ComputeValue>
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CachedValue
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CachedValue (ComputeValue compute = ComputeValue(), const T& defaultValue = T())
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: m_compute		(compute)
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_value		(defaultValue)
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, m_isComputed	(false)
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const T& getValue (const RenderContext& context) const
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!m_isComputed)
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_value			= m_compute(context);
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_isComputed	= true;
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return m_value;
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ComputeValue	m_compute;
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	mutable T		m_value;
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	mutable bool	m_isComputed;
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GetCompressedTextureFormats
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::set<int> operator() (const RenderContext& context) const;
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypedef CachedValue<std::set<int>, GetCompressedTextureFormats>	CompressedTextureFormats;
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*!
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Context information & limit query.
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ContextInfo
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual										~ContextInfo						(void);
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual int									getInt								(int param) const;
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual bool								getBool								(int param) const;
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual const char*							getString							(int param) const;
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual bool								isVertexUniformLoopSupported		(void) const { return true; }
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual bool								isVertexDynamicLoopSupported		(void) const { return true; }
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual bool								isFragmentHighPrecisionSupported	(void) const { return true; }
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual bool								isFragmentUniformLoopSupported		(void) const { return true; }
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual bool								isFragmentDynamicLoopSupported		(void) const { return true; }
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual bool								isCompressedTextureFormatSupported	(int format) const;
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
92460696f1f20279174be21b8efa3131c3b0a2e3caMika Isojärvi	const std::vector<std::string>&				getExtensions						(void) const { return m_extensions; }
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										isExtensionSupported				(const char* extName) const;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static ContextInfo*							create								(const RenderContext& context);
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												ContextInfo							(const RenderContext& context);
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const RenderContext&						m_context;
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												ContextInfo							(const ContextInfo& other);
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ContextInfo&								operator=							(const ContextInfo& other);
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
106460696f1f20279174be21b8efa3131c3b0a2e3caMika Isojärvi	std::vector<std::string>					m_extensions;
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	CompressedTextureFormats					m_compressedTextureFormats;
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // glu
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _GLUCONTEXTINFO_HPP
113