1 #ifndef _GLURENDERCONFIG_HPP
2 #define _GLURENDERCONFIG_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 rendering configuration.
24 *//*--------------------------------------------------------------------*/
25
26 #include "tcuDefs.hpp"
27 #include "gluRenderContext.hpp"
28
29 namespace tcu
30 {
31 class CommandLine;
32 }
33
34 namespace glu
35 {
36
37 enum ResetNotificationStrategy
38 {
39 RESET_NOTIFICATION_STRATEGY_NOT_SPECIFIED = 0, //!< Not specified, implementation-dependent
40 RESET_NOTIFICATION_STRATEGY_NO_RESET_NOTIFICATION, //!< No reset notification (may not be supported)
41 RESET_NOTIFICATION_STRATEGY_LOSE_CONTEXT_ON_RESET, //!< Lose context on reset (may not be supported)
42
43 RESET_NOTIFICATION_STRATEGY_LAST
44 };
45
46 /*--------------------------------------------------------------------*//*!
47 * \brief Rendering context configuration.
48 *//*--------------------------------------------------------------------*/
49 struct RenderConfig
50 {
51 enum SurfaceType
52 {
53 SURFACETYPE_DONT_CARE = 0,
54 SURFACETYPE_WINDOW, //!< Native window.
55 SURFACETYPE_OFFSCREEN_NATIVE, //!< Native renderable offscreen buffer, such as pixmap or bitmap.
56 SURFACETYPE_OFFSCREEN_GENERIC, //!< Generic offscreen buffer, such as EGL pbuffer.
57
58 SURFACETYPE_LAST
59 };
60
61 enum Visibility
62 {
63 VISIBILITY_HIDDEN = 0,
64 VISIBILITY_VISIBLE,
65 VISIBILITY_FULLSCREEN,
66
67 VISIBILITY_LAST
68 };
69
70 enum ComponentType
71 {
72 COMPONENT_TYPE_DONT_CARE = 0,
73 COMPONENT_TYPE_FIXED,
74 COMPONENT_TYPE_FLOAT,
75
76 COMPONENT_TYPE_LAST
77 };
78
79 enum
80 {
81 DONT_CARE = -1
82 };
83
84 ContextType type;
85
86 int width;
87 int height;
88 SurfaceType surfaceType;
89 Visibility windowVisibility;
90 ComponentType componentType;
91
92 int id;
93
94 int redBits;
95 int greenBits;
96 int blueBits;
97 int alphaBits;
98 int depthBits;
99 int stencilBits;
100 int numSamples;
101
102 ResetNotificationStrategy resetNotificationStrategy;
103
RenderConfigglu::RenderConfig104 RenderConfig(ContextType type_ = ContextType())
105 : type(type_)
106 , width(DONT_CARE)
107 , height(DONT_CARE)
108 , surfaceType(SURFACETYPE_DONT_CARE)
109 , windowVisibility(VISIBILITY_VISIBLE)
110 , componentType(COMPONENT_TYPE_DONT_CARE)
111 , id(DONT_CARE)
112 , redBits(DONT_CARE)
113 , greenBits(DONT_CARE)
114 , blueBits(DONT_CARE)
115 , alphaBits(DONT_CARE)
116 , depthBits(DONT_CARE)
117 , stencilBits(DONT_CARE)
118 , numSamples(DONT_CARE)
119 , resetNotificationStrategy(RESET_NOTIFICATION_STRATEGY_NOT_SPECIFIED)
120 {
121 }
122 } DE_WARN_UNUSED_TYPE;
123
124 // Utilities
125
126 void parseRenderConfig(RenderConfig *config, const tcu::CommandLine &cmdLine);
127 RenderConfig::Visibility parseWindowVisibility(const tcu::CommandLine &cmdLine);
128
129 template <typename T>
getValueOrDefault(const RenderConfig & config,const T RenderConfig::* field,T defaultValue)130 T getValueOrDefault(const RenderConfig &config, const T RenderConfig::*field, T defaultValue)
131 {
132 T value = config.*field;
133 return value == (T)RenderConfig::DONT_CARE ? defaultValue : value;
134 }
135
136 RenderConfig::ComponentType fromEGLComponentType(int eglComponentType);
137 int toEGLComponentType(RenderConfig::ComponentType gluComponentType);
138
139 } // namespace glu
140
141 #endif // _GLURENDERCONFIG_HPP
142