• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
71 	{
72 		DONT_CARE = -1
73 	};
74 
75 	ContextType					type;
76 
77 	int							width;
78 	int							height;
79 	SurfaceType					surfaceType;
80 	Visibility					windowVisibility;
81 
82 	int							id;
83 
84 	int							redBits;
85 	int							greenBits;
86 	int							blueBits;
87 	int							alphaBits;
88 	int							depthBits;
89 	int							stencilBits;
90 	int							numSamples;
91 
92 	ResetNotificationStrategy	resetNotificationStrategy;
93 
RenderConfigglu::RenderConfig94 	RenderConfig (ContextType type_ = ContextType())
95 		: type						(type_)
96 		, width						(DONT_CARE)
97 		, height					(DONT_CARE)
98 		, surfaceType				(SURFACETYPE_DONT_CARE)
99 		, windowVisibility			(VISIBILITY_VISIBLE)
100 		, id						(DONT_CARE)
101 		, redBits					(DONT_CARE)
102 		, greenBits					(DONT_CARE)
103 		, blueBits					(DONT_CARE)
104 		, alphaBits					(DONT_CARE)
105 		, depthBits					(DONT_CARE)
106 		, stencilBits				(DONT_CARE)
107 		, numSamples				(DONT_CARE)
108 		, resetNotificationStrategy	(RESET_NOTIFICATION_STRATEGY_NOT_SPECIFIED)
109 	{
110 	}
111 } DE_WARN_UNUSED_TYPE;
112 
113 // Utilities
114 
115 void						parseRenderConfig		(RenderConfig* config, const tcu::CommandLine& cmdLine);
116 RenderConfig::Visibility	parseWindowVisibility	(const tcu::CommandLine& cmdLine);
117 
118 template<typename T>
getValueOrDefault(const RenderConfig & config,const T RenderConfig::* field,T defaultValue)119 T getValueOrDefault (const RenderConfig& config, const T RenderConfig::*field, T defaultValue)
120 {
121 	T value = config.*field;
122 	return value == (T)RenderConfig::DONT_CARE ? defaultValue : value;
123 }
124 
125 } // glu
126 
127 #endif // _GLURENDERCONFIG_HPP
128