2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
8 This manual page is licensed under the Creative Commons Attribution-ShareAlike 3.0 United States License (CC BY-SA 3.0
9 US). To view a copy of this license, visit http://creativecommons.org.license/by-sa/3.0/us.
14 xmlns:xi="http://www.w3.org/2001/XInclude">
16 <!-- See http://www.docbook.org/tdg/en/html/refentry.html. -->
19 <refentrytitle>waffle_config</refentrytitle>
20 <manvolnum>3</manvolnum>
24 <refname>waffle_config</refname>
25 <refname>waffle_config_choose</refname>
26 <refname>waffle_config_destroy</refname>
27 <refname>waffle_config_get_native</refname>
28 <refpurpose>class <classname>waffle_config</classname></refpurpose>
32 <title>Waffle Manual</title>
33 <productname>waffle</productname>
34 <xi:include href="common/author-chad.versace.xml"/>
35 <xi:include href="common/copyright.xml"/>
36 <xi:include href="common/legalnotice.xml"/>
41 <funcsynopsis language="C">
44 #include <waffle.h>
50 <funcdef>struct waffle_config* <function>waffle_config_choose</function></funcdef>
51 <paramdef>struct waffle_display *<parameter>display</parameter></paramdef>
52 <paramdef>const int32_t <parameter>attrib_list</parameter>[]</paramdef>
56 <funcdef>bool <function>waffle_config_destroy</function></funcdef>
57 <paramdef>struct waffle_config *<parameter>self</parameter></paramdef>
61 <funcdef>union waffle_native_config* <function>waffle_config_get_native</function></funcdef>
62 <paramdef>struct waffle_config *<parameter>self</parameter></paramdef>
69 <title>Description</title>
74 <term><type>struct waffle_config</type></term>
83 <term><function>waffle_config_choose()</function></term>
86 Choose a config on <parameter>display</parameter> that satifisfies the set of attributes specified by
87 <parameter>attrib_list</parameter>.
89 The config can later be used to create surfaces and contexts with
91 <citerefentry><refentrytitle><function>waffle_window_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry> and
92 <citerefentry><refentrytitle><function>waffle_context_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>.
96 <parameter>attrib_list</parameter> consists of a zero-terminated sequence of name/value pairs. If an
97 attribute is absent from <parameter>attrib_list</parameter>, then it assumes its default value. If
98 <parameter>attrib_list</parameter> is null, then it is intrepreted the same as the empty list, which is the
99 list that contains only the terminal zero.
101 See <xref linkend="sect.attributes"/> below for details on the set of attributes that may appear in
102 <parameter>attrib_list</parameter>.
111 <term><function>waffle_config_destroy()</function></term>
114 Destroy the config and release its memory.
120 <term><function>waffle_config_get_native()</function></term>
123 Get the config's underlying native objects. Use
124 <citerefentry><refentrytitle><function>free</function></refentrytitle><manvolnum>3</manvolnum></citerefentry> to deallocate the
126 See <citerefentry><refentrytitle>waffle_native</refentrytitle><manvolnum>3</manvolnum></citerefentry>
127 for the definition of <type>union waffle_native_config</type>.
136 <title>Discussion</title>
139 The context attributes (<constant>WAFFLE_CONTEXT_*</constant>) have quirks that are specific to the native
140 platform. Waffle attempts to accomdate those quirks in a platform-neutral way as much as possible, but not all
141 quirks can be eliminated through a platform abstraction layer. The quirks are documented below in detail.
145 For example, one quirk that Waffle is able to accommodate is that some platforms require specification of context
146 attributes at different times. GLX requires that the context attributes be specified at time of context creation
147 [<citerefentry><refentrytitle><function>glXCreateContextAttribsARB</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>]
148 but MacOS requires the attributes to be specified when choosing
149 a config [<function>CGLChoosePixelFormat</function>]. Therefore, Waffle is constrained by MacOS to require the
150 attributes at time of <function>waffle_config_choose()</function>.
154 For additional documentation on the behavior of context attributes on each platform, refer to the following:
159 For GLX, refer to the
160 <ulink url="http://www.opengl.org/registry/doc/glx1.4.pdf">GLX 1.4 Specification</ulink>
161 and the specifications for extensions
162 <ulink url="http://www.opengl.org/registry/specs/ARB/glx_create_context.txt">GLX_ARB_create_context_profile</ulink> and
163 <ulink url="http://www.opengl.org/registry/specs/EXT/glx_create_context_es2_profile.txt">GLX_EXT_create_context_es2_profile</ulink>.
167 For EGL, refer to the
168 <ulink url="http://www.khronos.org/registry/egl/specs/eglspec.1.4.20110406.pdf">EGL 1.4 Specification</ulink>
169 and the specifications for extension
170 <ulink url="http://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_create_context.txt">EGL_KHR_create_context</ulink>.
174 For CGL, refer to the documentation of <function>kCGLPFAOpenGLProfile</function> in the
175 <ulink url="https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CGL_OpenGL/Reference/reference.html">CGL Reference</ulink>.
183 id="sect.attributes">
185 <title>Attributes</title>
190 <term><constant>WAFFLE_CONTEXT_API</constant></term>
193 This is a required attribute; it has no default value. It must be one of:
195 <member><constant>WAFFLE_CONTEXT_OPENGL</constant></member>
196 <member><constant>WAFFLE_CONTEXT_OPENGL_ES1</constant></member>
197 <member><constant>WAFFLE_CONTEXT_OPENGL_ES2</constant></member>
198 <member><constant>WAFFLE_CONTEXT_OPENGL_ES3</constant></member>
202 The actual set of supported values depends on the native platform. To check if the system supports a given
204 <citerefentry><refentrytitle><function>waffle_display_supports_context_api</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>.
205 Invariants and expectations for each platform are discussed below.
208 On Android, <constant>WAFFLE_CONTEXT_OPENGL_ES1</constant> is always supported. Beginning with Ice Cream
209 Sandwich (that is, Android 4.0), <constant>WAFFLE_CONTEXT_OPENGL_ES2</constant> is also supported. Use
210 <citerefentry><refentrytitle><function>waffle_display_supports_context_api</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
211 to check if additional APIs are supported.
214 On GLX, <constant>WAFFLE_CONTEXT_OPENGL</constant> is always supported. The system may optionally support
218 On EGL platforms other than Android, no API is guaranteed to be supported. One must use
219 <citerefentry><refentrytitle><function>waffle_display_supports_context_api</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
220 to check for supported APIs.
223 On MacOS, only <constant>WAFFLE_CONTEXT_OPENGL</constant> is supported. This may change in the future if
224 Apple adds support for additional APIs.
230 <term><constant>WAFFLE_CONTEXT_MAJOR_VERSION</constant></term>
231 <term><constant>WAFFLE_CONTEXT_MINOR_VERSION</constant></term>
234 This pair of attributes is optional.
236 They specify the context version that
237 <citerefentry><refentrytitle><function>waffle_context_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
242 The pair's default value and set of accepted values depend on the value of
243 <constant>WAFFLE_CONTEXT_API</constant> and the native platform.
245 Below is described in detail the rules by which waffle filters the set of accepted values according to the
246 value of <constant>WAFFLE_CONTEXT_API</constant>.
248 Even if <function>waffle_config_choose()</function> accepts the requested version
249 and successfully returns a config,
251 the native platform may later reject the requested version when
252 <citerefentry><refentrytitle><function>waffle_context_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
257 If the requested API is <constant>WAFFLE_CONTEXT_OPENGL_ES1</constant>,
258 then the default value is 1.0.
260 The only accepted values are 1.0 and 1.1.
264 If the requested API is <constant>WAFFLE_CONTEXT_OPENGL_ES2</constant>,
265 then the default value is 2.0.
267 Waffle accepts any value that is at least 2.0 and strictly less than 3.0.
271 If the requested API is <constant>WAFFLE_CONTEXT_OPENGL_ES3</constant>,
272 then the default value is 3.0.
274 Waffle accepts any value that is at least 3.0 and strictly less than 4.0.
278 If the requested API is <constant>WAFFLE_CONTEXT_OPENGL</constant>,
279 then the default and minimum accepted value is 1.0.
285 <term><constant>WAFFLE_CONTEXT_PROFILE</constant></term>
288 This attributes is optional.
290 It specifies the context profile that
291 <citerefentry><refentrytitle><function>waffle_context_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
296 The attribute's default value and set of accepted values depend on the values of
297 <constant>WAFFLE_CONTEXT_API</constant>,
298 <constant>WAFFLE_CONTEXT_MAJOR_VERSION</constant>,
299 <constant>WAFFLE_CONTEXT_MINOR_VERSION</constant>,
300 and the native platform.
302 Below is described in detail the rules by which waffle decides
304 the default value and the set of accepted values.
306 Even if <function>waffle_config_choose()</function> accepts the requested profile
307 and successfully returns a config,
309 the native platform may later reject the requested profile when
310 <citerefentry><refentrytitle><function>waffle_context_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
315 If the requested API is
316 <constant>WAFFLE_CONTEXT_OPENGL_ES1</constant>,
317 <constant>WAFFLE_CONTEXT_OPENGL_ES2</constant>, or
318 <constant>WAFFLE_CONTEXT_OPENGL_ES3</constant>,
320 then the default and only accepted value is <constant>WAFFLE_NONE</constant>.
324 If the requested API is <constant>WAFFLE_CONTEXT_OPENGL</constant>
326 and the requested version is less than 3.2,
328 then the default and only accepted value is <constant>WAFFLE_NONE</constant>.
332 If the requested API is <constant>WAFFLE_CONTEXT_OPENGL</constant>
334 and the requested version is at least 3.2,
336 then default value is <constant>WAFFLE_CONTEXT_CORE_PROFILE</constant>.
338 The set of accepted values is
340 <constant>WAFFLE_CONTEXT_CORE_PROFILE</constant> and
341 <constant>WAFFLE_CONTEXT_COMPATIBILITY_PROFILE</constant>.
347 <term><constant>WAFFLE_CONTEXT_FORWARD_COMPATIBLE</constant></term>
350 This attribute, if true, instructs
351 <citerefentry><refentrytitle><function>waffle_context_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
352 to create a forward-compatible context.
354 However, even if <function>waffle_config_choose()</function>
355 successfully returns a config for a forward-compatible context, the
356 native platform may later reject it when
357 <citerefentry><refentrytitle><function>waffle_context_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
361 Forward-compatible contexts do not support functionality marked as
362 deprecated by that version of the API. A non-forward-compatible
363 context supports all functionality in that version, deprecated or
367 This attribute is optional and its default value is false(0).
369 Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>.
371 However, true(1) is valid only if
372 the requested context API is <constant>WAFFLE_CONTEXT_OPENGL</constant>
373 and its version is at least 3.0.
379 <term><constant>WAFFLE_CONTEXT_DEBUG</constant></term>
382 This attribute, if true, instructs
383 <citerefentry><refentrytitle><function>waffle_context_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
384 to create a debug context.
386 However, even if <function>waffle_config_choose()</function>
387 successfully returns a config for a debug context, the
388 native platform may later reject it when
389 <citerefentry><refentrytitle><function>waffle_context_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
393 Debug contexts are intended for use during application development, to provide additional runtime checking,
394 validation, and logging functionality while possibly incurring performance penalties. The additional
395 functionality provided by debug contexts may vary according to the implementation. In some cases a debug
396 context may be identical to a non-debug context.
399 This attribute is optional and its default value is false(0).
401 Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>.
407 <term><constant>WAFFLE_CONTEXT_ROBUST_ACCESS</constant></term>
410 This attribute, if true, instructs
411 <citerefentry><refentrytitle><function>waffle_context_create</function></refentrytitle><manvolnum>3</manvolnum></citerefentry>
412 to create a robust access context.
415 Robust access contexts can implement additional runtime checks, such as bounds checks for various
419 This attribute is optional and its default value is false(0).
421 Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>.
427 <term><constant>WAFFLE_RED_SIZE</constant></term>
428 <term><constant>WAFFLE_GREEN_SIZE</constant></term>
429 <term><constant>WAFFLE_BLUE_SIZE</constant></term>
430 <term><constant>WAFFLE_ALPHA_SIZE</constant></term>
431 <term><constant>WAFFLE_DEPTH_SIZE</constant></term>
432 <term><constant>WAFFLE_STENCIL_SIZE</constant></term>
435 The default value for each size attribute is <constant>0</constant>.
437 Valid values are the non-negative integers and <constant>WAFFLE_DONT_CARE</constant>.
439 If the requested size
440 for a channel is 0, then any surface created with the config will lack that channel. If the requested size
441 for a channel is positive, then the number of bits in that channel for any surface created with the config
442 will be at least the requested size.
448 <term><constant>WAFFLE_SAMPLE_BUFFERS</constant></term>
449 <term><constant>WAFFLE_SAMPLES</constant></term>
452 The default value of <constant>WAFFLE_SAMPLE_BUFFERS</constant> is false(0).
454 Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>.
456 The attribute specifies if a surface created with this config is double-buffered.
458 If false, then any surface created with the config will not be multisampled. If true, the any surface
459 created with the config will be multisampled, where the number of samples will be at least
460 <constant>WAFFLE_SAMPLES</constant>.
463 The default value of <constant>WAFFLE_SAMPLES</constant> is <constant>0</constant>.
465 Valid values are the non-negative integers and <constant>WAFFLE_DONT_CARE</constant>.
471 <term><constant>WAFFLE_DOUBLE_BUFFERED</constant></term>
474 The default value is true(1).
476 Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>.
478 This attribute specifies if a surface created with this config is double-buffered.
484 <term><constant>WAFFLE_ACCUM_BUFFER</constant></term>
487 The default value is false(0).
489 Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>.
491 This attribute specifies if a surface created with this config possesses an accumulation buffer.
500 <title>Return Value</title>
501 <xi:include href="common/return-value.xml"/>
505 <title>Errors</title>
507 <xi:include href="common/error-codes.xml"/>
510 Listed below are the errors specific to the <type>waffle_config</type> functions.
516 <term><function>waffle_config_choose()</function></term>
521 <term><errorcode>WAFFLE_ERROR_BAD_ATTRIBUTE</errorcode></term>
524 An item in <parameter>attrib_list</parameter> is unrecognized or has an invalid value, or a required
525 attribute is missing.
531 <term><errorcode>WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM</errorcode></term>
534 If the native platform does not expose the necessary functionality to create a context with the
535 properties specified by config
537 or if waffle can predetermine that the native platform will reject the config at context creation,
539 but otherwise the requested attributes are valid,
541 then <constant>WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM</constant> is emitted.
550 GLX supports creation of an OpenGL ES2 context only if libGLESv2.so.2 is installed and if
551 GLX_EXT_create_context_es2_profile is exposed as both a server and client extension.
556 MacOS does not support the OpenGL 3.2 Compatibility Profile, and it supports the OpenGL 3.2 Core Profile
557 only for MacOS >= 10.7 on select GPU's.
575 <title>Examples</title>
578 <title>Example 1</title>
581 Choose a config for an OpenGL legacy context that has at least 8 bits in each of the RGBA channels.
588 static const int32_t init_attrib_list[] = {
589 WAFFLE_PLATFORM, WAFFLE_PLATFORM_GLX,
593 static const int32_t config_attrib_list[] = {
594 WAFFLE_CONTEXT_API, WAFFLE_CONTEXT_OPENGL,
597 WAFFLE_GREEN_SIZE, 8,
599 WAFFLE_ALPHA_SIZE, 8,
607 struct waffle_display *display;
608 struct waffle_config *config;
612 ok = waffle_init(init_attrib_list);
616 display = waffle_display_connect(NULL);
620 config = waffle_config_choose(config_attrib_list);
625 waffle_config_destroy(config);
626 waffle_display_disconnect(display);
635 <title>Example 2</title>
638 An attribute list for creating an OpenGL 3.2 Core Profile context that has depth and stencil buffers and some
639 non-zero number of bits in each of the RGB channels. Since the default value of
640 <constant>WAFFLE_ALPHA_SIZE</constant> is <constant>WAFFLE_DONT_CARE</constant>, the config may not have an
645 const int32_t attrib_list[] = {
646 WAFFLE_CONTEXT_API, WAFFLE_CONTEXT_OPENGL,
647 WAFFLE_CONTEXT_MAJOR_VERSION, 3,
648 WAFFLE_CONTEXT_MINOR_VERSION, 2,
649 WAFFLE_CONTEXT_PROFILE, WAFFLE_CONTEXT_CORE_PROFILE,
652 WAFFLE_GREEN_SIZE, 1,
655 WAFFLE_DEPTH_SIZE, 24,
656 WAFFLE_STENCIL_SIZE, 8,
666 <xi:include href="common/issues.xml"/>
669 <title>See Also</title>
671 <citerefentry><refentrytitle>waffle</refentrytitle><manvolnum>7</manvolnum></citerefentry>
672 <citerefentry><refentrytitle>waffle_context_create</refentrytitle><manvolnum>3</manvolnum></citerefentry>
673 <citerefentry><refentrytitle>waffle_window_create</refentrytitle><manvolnum>3</manvolnum></citerefentry>
680 vim:tw=120 et ts=2 sw=2: