summaryrefslogtreecommitdiff
path: root/tests/glean/dsconfig.h
blob: 8df2abceae865cb1e18447c47e004801548d17f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// BEGIN_COPYRIGHT
// 
// Copyright (C) 1999  Allen Akin   All Rights Reserved.
//
// multisample changes: Copyright (c) 2008 VMware, Inc.  All rights reserved.
// 
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the
// Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
// KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL ALLEN AKIN BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// 
// END_COPYRIGHT




// dsconfig.h:  Drawing surface configuration utilities

// This class abstracts the basic characteristics of drawing surfaces
// (size, depth, ancillary buffers, etc.) and operations on them.  It
// serves as a wrapper for X11 Visual and FBConfig information on
// X11-based systems, and PixelFormatDescriptor information on
// Win32-based systems.


#ifndef __dsconfig_h__
#define __dsconfig_h__

#include <string>
#include <vector>
#include "glwrap.h"

using namespace std;

namespace GLEAN {

class DrawingSurfaceConfig {
    public:

	// Constructors/Destructor:

#   if defined(__X11__)
	DrawingSurfaceConfig(::Display* dpy, ::XVisualInfo* pvi);
#     if defined(GLX_VERSION_1_3)
	DrawingSurfaceConfig(::Display* dpy, ::GLXFBConfig* pfbc);
#     endif
#   elif defined(__WIN__)
	DrawingSurfaceConfig(int id, ::PIXELFORMATDESCRIPTOR *ppfd);
#   elif defined(__BEWIN__)
	DrawingSurfaceConfig();
#	elif defined(__AGL__)
	DrawingSurfaceConfig(int id, ::AGLPixelFormat pfd);
#   endif

	DrawingSurfaceConfig(string& s);	// s is a canonical description

	// Exceptions:

	struct Error { };		// Base class for errors.
	struct Syntax: public Error {	// Syntax error in constructor string.
		const char* err;
		int position;
		Syntax(const char* e, int p) {
			err = e;
			position = p;
		}
	};

	// Attributes:

#   if defined(__X11__)
	::XVisualInfo* vi;		// XVisualInfo pointer
	::XID visID;			// Visual ID.
#     if defined(GLX_VERSION_1_3)
	::GLXFBConfig* fbc;
	::XID fbcID;			// Framebuffer Config ID.
#     endif
#   elif defined(__WIN__)
	::PIXELFORMATDESCRIPTOR pfd;
	int pfdID;
#   elif defined(__AGL__)
	AGLPixelFormat    pf;
	int 			pfID;
#	endif

	bool canRGBA;			// Can be used with RGBA contexts.

	bool canCI;			// Can be used with color index
					// contexts.

	int bufSize;			// Total depth of color buffer.

	int level;			// Framebuffer level.
					// (<0 for underlay, 0 for main,
					// >0 for overlay)

	bool db;			// True if double buffered.

	bool stereo;			// True if stereo-capable.

	int aux;			// Number of aux color buffers.

	int r;				// Depth of red channel.

	int g;				// Depth of green channel.

	int b;				// Depth of blue channel.

	int a;				// Depth of alpha channel.

	int z;				// Depth of ``z'' (depth) buffer.

	int s;				// Depth of stencil buffer.

	int accR;			// Depth of accum buf red channel.

	int accG;			// Depth of accum buf green channel.

	int accB;			// Depth of accum buf blue channel.

	int accA;			// Depth of accum buf alpha channel.

	int samples;                    // Number of samples per pixel.
					// Zero indicates a non-ms config.

	bool canWindow;			// True if can be used for windows.

#   if defined(__X11__)
	bool canPixmap;			// True if can be used for pixmaps.
#     if defined(GLX_VERSION_1_3)
	bool canPBuffer;		// True if can be used for pbuffers.

	int maxPBufferWidth;		// Maximum width of PBuffer that
					// may be created with this config.

	int maxPBufferHeight;		// Maximum height of PBuffer that
					// may be created with this config.

	int maxPBufferPixels;		// Maximum size (in pixels) of
					// PBuffer that may be created with
					// this config.
#     endif
#   endif

	bool canWinSysRender;		// True if the native window system
					// can render to a drawable created
					// with this config.

	bool fast;			// True if config is probably
					// hardware accelerated.  (On GLX,
					// it must not be marked ``slow.'')

	bool conformant;		// True if config is advertised as
					// conforming to the OpenGL spec.

	bool transparent;		// True if config has some pixel value
					// that is transparent (e.g., for
					// overlays).

	int transR;			// Transparent color red value.

	int transG;			// Transparent color green value.

	int transB;			// Transparent color blue value.

	int transA;			// Transparent color alpha value.

	int transI;			// Transparent color index value.

	// Utilities:

	void zeroFields();

	string canonicalDescription();
		// Return a string containing all the attributes in a
		// drawing surface configuration.  This allows the config
		// to be stored and recreated (essentially for use by
		// configuration-matching algorithms in test result
		// comparisons).

	string conciseDescription();
		// Return a description string that elides default
		// attribute values and expresses some attributes in
		// compressed form.  Intended to be more easily readable
		// for humans than the canonical description, at the
		// cost of some ambiguity.

	int match(vector<DrawingSurfaceConfig*>& choices);
		// Find the index of the config from ``choices'' that most
		// closely matches the config specified by ``*this''. 
		// The matching scheme is heuristic, but intended to
		// be good enough that test results for configs on one
		// machine may be compared with test results for
		// configs on another machine.

        bool equal(const DrawingSurfaceConfig &config) const;

}; // class DrawingSurfaceConfig

} // namespace GLEAN

#endif // __dsconfig_h__