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