Home | History | Annotate | Download | only in opengl
      1 #ifndef _GLUSTRUTIL_HPP
      2 #define _GLUSTRUTIL_HPP
      3 /*-------------------------------------------------------------------------
      4  * drawElements Quality Program OpenGL ES Utilities
      5  * ------------------------------------------------
      6  *
      7  * Copyright 2014 The Android Open Source Project
      8  *
      9  * Licensed under the Apache License, Version 2.0 (the "License");
     10  * you may not use this file except in compliance with the License.
     11  * You may obtain a copy of the License at
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     15  * Unless required by applicable law or agreed to in writing, software
     16  * distributed under the License is distributed on an "AS IS" BASIS,
     17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18  * See the License for the specific language governing permissions and
     19  * limitations under the License.
     20  *
     21  *//*!
     22  * \file
     23  * \brief OpenGL value to string utilities.
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "gluDefs.hpp"
     27 #include "gluRenderContext.hpp"
     28 #include "tcuFormatUtil.hpp"
     29 
     30 namespace glu
     31 {
     32 
     33 // Internal format utilities.
     34 namespace detail
     35 {
     36 
     37 class EnumPointerFmt
     38 {
     39 public:
     40 	typedef const char* (*GetEnumNameFunc) (int value);
     41 
     42 	const deUint32* const	value;
     43 	const deUint32			size;
     44 	const GetEnumNameFunc	getName;
     45 
     46 	EnumPointerFmt (const deUint32* value_, deUint32 size_, GetEnumNameFunc getName_) : value(value_), size(size_), getName(getName_) {}
     47 };
     48 
     49 class BooleanPointerFmt
     50 {
     51 public:
     52 	const deUint8* const	value;
     53 	const deUint32			size;
     54 
     55 	BooleanPointerFmt (const deUint8* value_, deUint32 size_) : value(value_), size(size_) {}
     56 };
     57 
     58 class TextureUnitStr
     59 {
     60 public:
     61 	const deUint32 texUnit;
     62 	TextureUnitStr (deUint32 texUnit_) : texUnit(texUnit_) {}
     63 };
     64 
     65 class TextureParameterValueStr
     66 {
     67 public:
     68 	const deUint32	param;
     69 	const int		value;
     70 	TextureParameterValueStr (deUint32 param_, int value_) : param(param_), value(value_) {}
     71 };
     72 
     73 std::ostream&		operator<<		(std::ostream& str, const TextureUnitStr& unitStr);
     74 std::ostream&		operator<<		(std::ostream& str, const TextureParameterValueStr& valueStr);
     75 std::ostream&		operator<<		(std::ostream& str, const BooleanPointerFmt& fmt);
     76 std::ostream&		operator<<		(std::ostream& str, const EnumPointerFmt& fmt);
     77 
     78 } // detail
     79 
     80 inline detail::EnumPointerFmt getEnumPointerStr (const deUint32* value, deInt32 size, detail::EnumPointerFmt::GetEnumNameFunc getName)
     81 {
     82 	return detail::EnumPointerFmt(value, (deUint32)de::max(0, size), getName);
     83 }
     84 
     85 inline detail::BooleanPointerFmt getBooleanPointerStr (const deUint8* value, deInt32 size)
     86 {
     87 	return detail::BooleanPointerFmt(value, (deUint32)de::max(0, size));
     88 }
     89 
     90 inline detail::TextureUnitStr						getTextureUnitStr			(deUint32 unit) { return detail::TextureUnitStr(unit); }
     91 inline detail::TextureParameterValueStr				getTextureParameterValueStr	(deUint32 param, int value) { return detail::TextureParameterValueStr(param, value); }
     92 detail::EnumPointerFmt								getInvalidateAttachmentStr	(const deUint32* attachments, int numAttachments);
     93 
     94 std::ostream&										operator<<					(std::ostream& str, ApiType apiType);
     95 std::ostream&										operator<<					(std::ostream& str, ContextType contextType);
     96 
     97 // prevent implicit conversions from bool to int.
     98 //
     99 // While it is well-defined that (int)true == GL_TRUE and (int)false == GL_FALSE,
    100 // using these functions to convert non-GL-types suggests a that the calling code is
    101 // mixing and matching GLboolean and bool types which may not be safe.
    102 //
    103 // \note return value is void to prevent compilation. Otherwise this would only break linking.
    104 void	getBooleanPointerStr	(const bool* value, deInt32 size);	// delete
    105 void	getBooleanStr			(bool);								// delete
    106 void	getBooleanName			(bool);								// delete
    107 
    108 #include "gluStrUtilPrototypes.inl"
    109 
    110 } // glu
    111 
    112 #endif // _GLUSTRUTIL_HPP
    113