'\" t .\" Title: waffle_config .\" Author: Chad Versace .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 03/25/2021 .\" Manual: Waffle Manual .\" Source: waffle .\" Language: English .\" .TH "WAFFLE_CONFIG" "3" "03/25/2021" "waffle" "Waffle Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" waffle_config, waffle_config_choose, waffle_config_destroy, waffle_config_get_native \- class waffle_config .SH "SYNOPSIS" .sp .ft B .nf #include struct waffle_config; .fi .ft .HP \w'struct\ waffle_config*\ waffle_config_choose('u .BI "struct waffle_config* waffle_config_choose(struct\ waffle_display\ *" "display" ", const\ int32_t\ " "attrib_list" "[]);" .HP \w'bool\ waffle_config_destroy('u .BI "bool waffle_config_destroy(struct\ waffle_config\ *" "self" ");" .HP \w'union\ waffle_native_config*\ waffle_config_get_native('u .BI "union waffle_native_config* waffle_config_get_native(struct\ waffle_config\ *" "self" ");" .SH "DESCRIPTION" .PP \fBstruct waffle_config\fR .RS 4 An opaque type\&. .RE .PP \fBwaffle_config_choose()\fR .RS 4 Choose a config on \fIdisplay\fR that satifisfies the set of attributes specified by \fIattrib_list\fR\&. The config can later be used to create surfaces and contexts with \fBwaffle_window_create\fR(3) and \fBwaffle_context_create\fR(3)\&. .sp \fIattrib_list\fR consists of a zero\-terminated sequence of name/value pairs\&. If an attribute is absent from \fIattrib_list\fR, then it assumes its default value\&. If \fIattrib_list\fR is null, then it is intrepreted the same as the empty list, which is the list that contains only the terminal zero\&. See the section called \(lqATTRIBUTES\(rq below for details on the set of attributes that may appear in \fIattrib_list\fR\&. .sp .RE .PP \fBwaffle_config_destroy()\fR .RS 4 Destroy the config and release its memory\&. .RE .PP \fBwaffle_config_get_native()\fR .RS 4 Get the config\*(Aqs underlying native objects\&. Use \fBfree\fR(3) to deallocate the returned pointer\&. See \fBwaffle_native\fR(3) for the definition of \fBunion waffle_native_config\fR\&. .RE .SH "DISCUSSION" .PP The context attributes (\fBWAFFLE_CONTEXT_*\fR) have quirks that are specific to the native platform\&. Waffle attempts to accomdate those quirks in a platform\-neutral way as much as possible, but not all quirks can be eliminated through a platform abstraction layer\&. The quirks are documented below in detail\&. .PP For example, one quirk that Waffle is able to accommodate is that some platforms require specification of context attributes at different times\&. GLX requires that the context attributes be specified at time of context creation [\fBglXCreateContextAttribsARB\fR(3)] but MacOS requires the attributes to be specified when choosing a config [\fBCGLChoosePixelFormat\fR]\&. Therefore, Waffle is constrained by MacOS to require the attributes at time of \fBwaffle_config_choose()\fR\&. .PP For additional documentation on the behavior of context attributes on each platform, refer to the following: .RS 4 .PP For GLX, refer to the \m[blue]\fBGLX 1\&.4 Specification\fR\m[]\&\s-2\u[1]\d\s+2 and the specifications for extensions \m[blue]\fBGLX_ARB_create_context_profile\fR\m[]\&\s-2\u[2]\d\s+2 and \m[blue]\fBGLX_EXT_create_context_es2_profile\fR\m[]\&\s-2\u[3]\d\s+2\&. .RE .RS 4 .PP For EGL, refer to the \m[blue]\fBEGL 1\&.4 Specification\fR\m[]\&\s-2\u[4]\d\s+2 and the specifications for extension \m[blue]\fBEGL_KHR_create_context\fR\m[]\&\s-2\u[5]\d\s+2\&. .RE .RS 4 .PP For CGL, refer to the documentation of \fBkCGLPFAOpenGLProfile\fR in the \m[blue]\fBCGL Reference\fR\m[]\&\s-2\u[6]\d\s+2\&. .RE .SH "ATTRIBUTES" .PP \fBWAFFLE_CONTEXT_API\fR .RS 4 This is a required attribute; it has no default value\&. It must be one of: .RS 4 \fBWAFFLE_CONTEXT_OPENGL\fR .RE .RS 4 \fBWAFFLE_CONTEXT_OPENGL_ES1\fR .RE .RS 4 \fBWAFFLE_CONTEXT_OPENGL_ES2\fR .RE .RS 4 \fBWAFFLE_CONTEXT_OPENGL_ES3\fR .RE .sp The actual set of supported values depends on the native platform\&. To check if the system supports a given API, use \fBwaffle_display_supports_context_api\fR(3)\&. Invariants and expectations for each platform are discussed below\&. .sp On Android, \fBWAFFLE_CONTEXT_OPENGL_ES1\fR is always supported\&. Beginning with Ice Cream Sandwich (that is, Android 4\&.0), \fBWAFFLE_CONTEXT_OPENGL_ES2\fR is also supported\&. Use \fBwaffle_display_supports_context_api\fR(3) to check if additional APIs are supported\&. .sp On GLX, \fBWAFFLE_CONTEXT_OPENGL\fR is always supported\&. The system may optionally support additional APIs\&. .sp On EGL platforms other than Android, no API is guaranteed to be supported\&. One must use \fBwaffle_display_supports_context_api\fR(3) to check for supported APIs\&. .sp On MacOS, only \fBWAFFLE_CONTEXT_OPENGL\fR is supported\&. This may change in the future if Apple adds support for additional APIs\&. .RE .PP \fBWAFFLE_CONTEXT_MAJOR_VERSION\fR .br \fBWAFFLE_CONTEXT_MINOR_VERSION\fR .RS 4 This pair of attributes is optional\&. They specify the context version that \fBwaffle_context_create\fR(3) will request\&. .sp The pair\*(Aqs default value and set of accepted values depend on the value of \fBWAFFLE_CONTEXT_API\fR and the native platform\&. Below is described in detail the rules by which waffle filters the set of accepted values according to the value of \fBWAFFLE_CONTEXT_API\fR\&. Even if \fBwaffle_config_choose()\fR accepts the requested version and successfully returns a config, the native platform may later reject the requested version when \fBwaffle_context_create\fR(3) is called\&. .sp If the requested API is \fBWAFFLE_CONTEXT_OPENGL_ES1\fR, then the default value is 1\&.0\&. The only accepted values are 1\&.0 and 1\&.1\&. .sp If the requested API is \fBWAFFLE_CONTEXT_OPENGL_ES2\fR, then the default value is 2\&.0\&. Waffle accepts any value that is at least 2\&.0 and strictly less than 3\&.0\&. .sp If the requested API is \fBWAFFLE_CONTEXT_OPENGL_ES3\fR, then the default value is 3\&.0\&. Waffle accepts any value that is at least 3\&.0 and strictly less than 4\&.0\&. .sp If the requested API is \fBWAFFLE_CONTEXT_OPENGL\fR, then the default and minimum accepted value is 1\&.0\&. .RE .PP \fBWAFFLE_CONTEXT_PROFILE\fR .RS 4 This attributes is optional\&. It specifies the context profile that \fBwaffle_context_create\fR(3) will request\&. .sp The attribute\*(Aqs default value and set of accepted values depend on the values of \fBWAFFLE_CONTEXT_API\fR, \fBWAFFLE_CONTEXT_MAJOR_VERSION\fR, \fBWAFFLE_CONTEXT_MINOR_VERSION\fR, and the native platform\&. Below is described in detail the rules by which waffle decides the default value and the set of accepted values\&. Even if \fBwaffle_config_choose()\fR accepts the requested profile and successfully returns a config, the native platform may later reject the requested profile when \fBwaffle_context_create\fR(3) is called\&. .sp If the requested API is \fBWAFFLE_CONTEXT_OPENGL_ES1\fR, \fBWAFFLE_CONTEXT_OPENGL_ES2\fR, or \fBWAFFLE_CONTEXT_OPENGL_ES3\fR, then the default and only accepted value is \fBWAFFLE_NONE\fR\&. .sp If the requested API is \fBWAFFLE_CONTEXT_OPENGL\fR and the requested version is less than 3\&.2, then the default and only accepted value is \fBWAFFLE_NONE\fR\&. .sp If the requested API is \fBWAFFLE_CONTEXT_OPENGL\fR and the requested version is at least 3\&.2, then default value is \fBWAFFLE_CONTEXT_CORE_PROFILE\fR\&. The set of accepted values is \fBWAFFLE_CONTEXT_CORE_PROFILE\fR and \fBWAFFLE_CONTEXT_COMPATIBILITY_PROFILE\fR\&. .RE .PP \fBWAFFLE_CONTEXT_FORWARD_COMPATIBLE\fR .RS 4 This attribute, if true, instructs \fBwaffle_context_create\fR(3) to create a forward\-compatible context\&. However, even if \fBwaffle_config_choose()\fR successfully returns a config for a forward\-compatible context, the native platform may later reject it when \fBwaffle_context_create\fR(3) is called\&. .sp Forward\-compatible contexts do not support functionality marked as deprecated by that version of the API\&. A non\-forward\-compatible context supports all functionality in that version, deprecated or not\&. .sp This attribute is optional and its default value is false(0)\&. Valid values are true(1), false(0), and \fBWAFFLE_DONT_CARE\fR\&. However, true(1) is valid only if the requested context API is \fBWAFFLE_CONTEXT_OPENGL\fR and its version is at least 3\&.0\&. .RE .PP \fBWAFFLE_CONTEXT_DEBUG\fR .RS 4 This attribute, if true, instructs \fBwaffle_context_create\fR(3) to create a debug context\&. However, even if \fBwaffle_config_choose()\fR successfully returns a config for a debug context, the native platform may later reject it when \fBwaffle_context_create\fR(3) is called\&. .sp Debug contexts are intended for use during application development, to provide additional runtime checking, validation, and logging functionality while possibly incurring performance penalties\&. The additional functionality provided by debug contexts may vary according to the implementation\&. In some cases a debug context may be identical to a non\-debug context\&. .sp This attribute is optional and its default value is false(0)\&. Valid values are true(1), false(0), and \fBWAFFLE_DONT_CARE\fR\&. .RE .PP \fBWAFFLE_CONTEXT_ROBUST_ACCESS\fR .RS 4 This attribute, if true, instructs \fBwaffle_context_create\fR(3) to create a robust access context\&. .sp Robust access contexts can implement additional runtime checks, such as bounds checks for various operations\&. .sp This attribute is optional and its default value is false(0)\&. Valid values are true(1), false(0), and \fBWAFFLE_DONT_CARE\fR\&. .RE .PP \fBWAFFLE_RED_SIZE\fR .br \fBWAFFLE_GREEN_SIZE\fR .br \fBWAFFLE_BLUE_SIZE\fR .br \fBWAFFLE_ALPHA_SIZE\fR .br \fBWAFFLE_DEPTH_SIZE\fR .br \fBWAFFLE_STENCIL_SIZE\fR .RS 4 The default value for each size attribute is \fB0\fR\&. Valid values are the non\-negative integers and \fBWAFFLE_DONT_CARE\fR\&. If the requested size for a channel is 0, then any surface created with the config will lack that channel\&. If the requested size for a channel is positive, then the number of bits in that channel for any surface created with the config will be at least the requested size\&. .RE .PP \fBWAFFLE_SAMPLE_BUFFERS\fR .br \fBWAFFLE_SAMPLES\fR .RS 4 The default value of \fBWAFFLE_SAMPLE_BUFFERS\fR is false(0)\&. Valid values are true(1), false(0), and \fBWAFFLE_DONT_CARE\fR\&. The attribute specifies if a surface created with this config is double\-buffered\&. If false, then any surface created with the config will not be multisampled\&. If true, the any surface created with the config will be multisampled, where the number of samples will be at least \fBWAFFLE_SAMPLES\fR\&. .sp The default value of \fBWAFFLE_SAMPLES\fR is \fB0\fR\&. Valid values are the non\-negative integers and \fBWAFFLE_DONT_CARE\fR\&. .RE .PP \fBWAFFLE_DOUBLE_BUFFERED\fR .RS 4 The default value is true(1)\&. Valid values are true(1), false(0), and \fBWAFFLE_DONT_CARE\fR\&. This attribute specifies if a surface created with this config is double\-buffered\&. .RE .PP \fBWAFFLE_ACCUM_BUFFER\fR .RS 4 The default value is false(0)\&. Valid values are true(1), false(0), and \fBWAFFLE_DONT_CARE\fR\&. This attribute specifies if a surface created with this config possesses an accumulation buffer\&. .RE .SH "RETURN VALUE" .PP Functions whose return type is \fBbool\fR return true on success and false on failure\&. Functions whose return type is a pointer return \fBNULL\fR on failure\&. Use \fBwaffle_error_get_info\fR(3) to get information about any errors\&. .SH "ERRORS" .PP See \fBwaffle_error\fR(3) for the complete list of waffle\*(Aqs error codes\&. .PP Listed below are the errors specific to the \fBwaffle_config\fR functions\&. .PP \fBwaffle_config_choose()\fR .RS 4 .PP \fBWAFFLE_ERROR_BAD_ATTRIBUTE\fR .RS 4 An item in \fIattrib_list\fR is unrecognized or has an invalid value, or a required attribute is missing\&. .RE .PP \fBWAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM\fR .RS 4 If the native platform does not expose the necessary functionality to create a context with the properties specified by config or if waffle can predetermine that the native platform will reject the config at context creation, but otherwise the requested attributes are valid, then \fBWAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM\fR is emitted\&. .sp For example, .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} GLX supports creation of an OpenGL ES2 context only if libGLESv2\&.so\&.2 is installed and if GLX_EXT_create_context_es2_profile is exposed as both a server and client extension\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} MacOS does not support the OpenGL 3\&.2 Compatibility Profile, and it supports the OpenGL 3\&.2 Core Profile only for MacOS >= 10\&.7 on select GPU\*(Aqs\&. .RE .sp .RE .RE .SH "EXAMPLES" .SS "Example 1" .PP Choose a config for an OpenGL legacy context that has at least 8 bits in each of the RGBA channels\&. .sp .if n \{\ .RS 4 .\} .nf #include #include static const int32_t init_attrib_list[] = { WAFFLE_PLATFORM, WAFFLE_PLATFORM_GLX, 0, }; static const int32_t config_attrib_list[] = { WAFFLE_CONTEXT_API, WAFFLE_CONTEXT_OPENGL, WAFFLE_RED_SIZE, 8, WAFFLE_GREEN_SIZE, 8, WAFFLE_BLUE_SIZE, 8, WAFFLE_ALPHA_SIZE, 8, 0, }; int main() { struct waffle_display *display; struct waffle_config *config; bool ok; ok = waffle_init(init_attrib_list); if (!ok) exit(EXIT_FAILURE); display = waffle_display_connect(NULL); if (!display) exit(EXIT_FAILURE); config = waffle_config_choose(config_attrib_list); if (!config) exit(EXIT_FAILURE); // Now clean up\&. waffle_config_destroy(config); waffle_display_disconnect(display); return EXIT_SUCCESS; } .fi .if n \{\ .RE .\} .sp .SS "Example 2" .PP An attribute list for creating an OpenGL 3\&.2 Core Profile context that has depth and stencil buffers and some non\-zero number of bits in each of the RGB channels\&. Since the default value of \fBWAFFLE_ALPHA_SIZE\fR is \fBWAFFLE_DONT_CARE\fR, the config may not have an alpha channel\&. .sp .if n \{\ .RS 4 .\} .nf const int32_t attrib_list[] = { WAFFLE_CONTEXT_API, WAFFLE_CONTEXT_OPENGL, WAFFLE_CONTEXT_MAJOR_VERSION, 3, WAFFLE_CONTEXT_MINOR_VERSION, 2, WAFFLE_CONTEXT_PROFILE, WAFFLE_CONTEXT_CORE_PROFILE, WAFFLE_RED_SIZE, 1, WAFFLE_GREEN_SIZE, 1, WAFFLE_BLUE_SIZE, 1, WAFFLE_DEPTH_SIZE, 24, WAFFLE_STENCIL_SIZE, 8, 0, }; .fi .if n \{\ .RE .\} .sp .SH "ISSUES" .PP Please report bugs or and feature requests to \m[blue]\fB\%https://gitlab.freedesktop.org/mesa/waffle/issues\fR\m[]\&. .SH "SEE ALSO" .PP \fBwaffle\fR(7) \fBwaffle_context_create\fR(3) \fBwaffle_window_create\fR(3) .SH "AUTHOR" .PP \fBChad Versace\fR <\&chad\&.versace@linux\&.intel\&.com\&> .RS 4 Maintainer .RE .SH "COPYRIGHT" .br Copyright \(co 2013 Intel .br .PP This manual page is licensed under the Creative Commons Attribution\-ShareAlike 3\&.0 United States License (CC BY\-SA 3\&.0)\&. To view a copy of this license, visit \m[blue]\fB\%http://creativecommons.org.license/by-sa/3.0/us\fR\m[]\&. .sp .SH "NOTES" .IP " 1." 4 GLX 1.4 Specification .RS 4 \%http://www.opengl.org/registry/doc/glx1.4.pdf .RE .IP " 2." 4 GLX_ARB_create_context_profile .RS 4 \%http://www.opengl.org/registry/specs/ARB/glx_create_context.txt .RE .IP " 3." 4 GLX_EXT_create_context_es2_profile .RS 4 \%http://www.opengl.org/registry/specs/EXT/glx_create_context_es2_profile.txt .RE .IP " 4." 4 EGL 1.4 Specification .RS 4 \%http://www.khronos.org/registry/egl/specs/eglspec.1.4.20110406.pdf .RE .IP " 5." 4 EGL_KHR_create_context .RS 4 \%http://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_create_context.txt .RE .IP " 6." 4 CGL Reference .RS 4 \%https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CGL_OpenGL/Reference/reference.html .RE