3 // Copyright (C) 1999 Allen Akin All Rights Reserved.
5 // multisample changes: Copyright (c) 2008 VMware, Inc. All rights reserved.
7 // Permission is hereby granted, free of charge, to any person
8 // obtaining a copy of this software and associated documentation
9 // files (the "Software"), to deal in the Software without
10 // restriction, including without limitation the rights to use,
11 // copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the
13 // Software is furnished to do so, subject to the following
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
21 // KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
22 // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
26 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 // DEALINGS IN THE SOFTWARE.
34 // dsconfig.h: Drawing surface configuration utilities
36 // This class abstracts the basic characteristics of drawing surfaces
37 // (size, depth, ancillary buffers, etc.) and operations on them. It
38 // serves as a wrapper for X11 Visual and FBConfig information on
39 // X11-based systems, and PixelFormatDescriptor information on
40 // Win32-based systems.
43 #ifndef __dsconfig_h__
44 #define __dsconfig_h__
54 class DrawingSurfaceConfig
{
57 // Constructors/Destructor:
60 DrawingSurfaceConfig(::Display
* dpy
, ::XVisualInfo
* pvi
);
61 # if defined(GLX_VERSION_1_3)
62 DrawingSurfaceConfig(::Display
* dpy
, ::GLXFBConfig
* pfbc
);
64 # elif defined(__WIN__)
65 DrawingSurfaceConfig(int id
, ::PIXELFORMATDESCRIPTOR
*ppfd
);
66 # elif defined(__BEWIN__)
67 DrawingSurfaceConfig();
68 # elif defined(__AGL__)
69 DrawingSurfaceConfig(int id
, ::AGLPixelFormat pfd
);
72 DrawingSurfaceConfig(string
& s
); // s is a canonical description
76 struct Error
{ }; // Base class for errors.
77 struct Syntax
: public Error
{ // Syntax error in constructor string.
80 Syntax(const char* e
, int p
) {
89 ::XVisualInfo
* vi
; // XVisualInfo pointer
90 ::XID visID
; // Visual ID.
91 # if defined(GLX_VERSION_1_3)
93 ::XID fbcID
; // Framebuffer Config ID.
95 # elif defined(__WIN__)
96 ::PIXELFORMATDESCRIPTOR
*pfd
;
98 # elif defined(__AGL__)
103 bool canRGBA
; // Can be used with RGBA contexts.
105 bool canCI
; // Can be used with color index
108 int bufSize
; // Total depth of color buffer.
110 int level
; // Framebuffer level.
111 // (<0 for underlay, 0 for main,
114 bool db
; // True if double buffered.
116 bool stereo
; // True if stereo-capable.
118 int aux
; // Number of aux color buffers.
120 int r
; // Depth of red channel.
122 int g
; // Depth of green channel.
124 int b
; // Depth of blue channel.
126 int a
; // Depth of alpha channel.
128 int z
; // Depth of ``z'' (depth) buffer.
130 int s
; // Depth of stencil buffer.
132 int accR
; // Depth of accum buf red channel.
134 int accG
; // Depth of accum buf green channel.
136 int accB
; // Depth of accum buf blue channel.
138 int accA
; // Depth of accum buf alpha channel.
140 int samples
; // Number of samples per pixel.
141 // Zero indicates a non-ms config.
143 bool canWindow
; // True if can be used for windows.
145 # if defined(__X11__)
146 bool canPixmap
; // True if can be used for pixmaps.
147 # if defined(GLX_VERSION_1_3)
148 bool canPBuffer
; // True if can be used for pbuffers.
150 int maxPBufferWidth
; // Maximum width of PBuffer that
151 // may be created with this config.
153 int maxPBufferHeight
; // Maximum height of PBuffer that
154 // may be created with this config.
156 int maxPBufferPixels
; // Maximum size (in pixels) of
157 // PBuffer that may be created with
162 bool canWinSysRender
; // True if the native window system
163 // can render to a drawable created
166 bool fast
; // True if config is probably
167 // hardware accelerated. (On GLX,
168 // it must not be marked ``slow.'')
170 bool conformant
; // True if config is advertised as
171 // conforming to the OpenGL spec.
173 bool transparent
; // True if config has some pixel value
174 // that is transparent (e.g., for
177 int transR
; // Transparent color red value.
179 int transG
; // Transparent color green value.
181 int transB
; // Transparent color blue value.
183 int transA
; // Transparent color alpha value.
185 int transI
; // Transparent color index value.
191 string
canonicalDescription();
192 // Return a string containing all the attributes in a
193 // drawing surface configuration. This allows the config
194 // to be stored and recreated (essentially for use by
195 // configuration-matching algorithms in test result
198 string
conciseDescription();
199 // Return a description string that elides default
200 // attribute values and expresses some attributes in
201 // compressed form. Intended to be more easily readable
202 // for humans than the canonical description, at the
203 // cost of some ambiguity.
205 int match(vector
<DrawingSurfaceConfig
*>& choices
);
206 // Find the index of the config from ``choices'' that most
207 // closely matches the config specified by ``*this''.
208 // The matching scheme is heuristic, but intended to
209 // be good enough that test results for configs on one
210 // machine may be compared with test results for
211 // configs on another machine.
213 bool equal(const DrawingSurfaceConfig
&config
) const;
215 }; // class DrawingSurfaceConfig
219 #endif // __dsconfig_h__