1 USING: destructors help.markup help.syntax kernel math sequences
2 vocabs vocabs.parser words namespaces ;
5 ! break circular dependency
7 "ui.gadgets.worlds" create-vocab drop
8 "world" "ui.gadgets.worlds" create-word drop
9 "ui.gadgets.worlds" vocab-words-assoc use-words
12 ARTICLE: "ui.pixel-formats-attributes" "Pixel format attributes"
13 "The following pixel format attributes can be requested and queried of " { $link pixel-format } "s. Binary attributes are represented by the presence of a symbol in an attribute sequence:"
28 "Integer attributes are represented by a " { $link tuple } " with a single " { $snippet "value" } "slot:"
47 "The following " { $link world } " subclass will request a double-buffered window with minimum 24-bit color and depth buffers, and will throw an error if the requirements aren't met:"
48 { $code """USING: kernel ui.gadgets.worlds ui.pixel-formats ;
49 IN: ui.pixel-formats.examples
51 TUPLE: picky-depth-buffered-world < world ;
53 M: picky-depth-buffered-world world-pixel-format-attributes
56 T{ color-bits { value 24 } }
57 T{ depth-bits { value 24 } }
60 M: picky-depth-buffered-world check-world-pixel-format
62 [ double-buffered pixel-format-attribute 0 = [ "Not double buffered!" throw ] when ]
63 [ color-bits pixel-format-attribute 24 < [ "Not enough color bits!" throw ] when ]
64 [ depth-bits pixel-format-attribute 24 < [ "Not enough depth bits!" throw ] when ]
69 { $description "Requests a double-buffered pixel format." } ;
71 { $description "Requests a stereoscopic pixel format." } ;
74 { $description "Requests a pixel format suitable for offscreen rendering." } ;
76 { $description "Requests a pixel format suitable for fullscreen rendering." }
77 { $notes "On some window systems this is not distinct from " { $link windowed } "." } ;
79 { $description "Requests a pixel format suitable for rendering to a window." } ;
81 { offscreen fullscreen windowed } related-words
84 { $description "Requests a pixel format supported by GPU hardware acceleration." } ;
85 HELP: software-rendered
86 { $description "Requests a pixel format only supported by the window system's default software renderer." } ;
88 { accelerated software-rendered } related-words
91 { $description "Used with " { $link double-buffered } " to request a double-buffered pixel format where the back buffer contents are preserved and copied to the front when buffers are swapped." } ;
93 { double-buffered backing-store } related-words
96 { $description "Requests a pixel format with multisampled antialiasing enabled. The " { $link sample-buffers } " and " { $link samples } " attributes must also be provided to specify the level of multisampling." }
97 { $notes "On some window systems this is not distinct from " { $link supersampled } "." } ;
100 { $description "Requests a pixel format with supersampled antialiasing enabled. The " { $link sample-buffers } " and " { $link samples } " attributes must also be provided to specify the level of supersampling." }
101 { $notes "On some window systems this is not distinct from " { $link multisampled } "." } ;
104 { $description "Used with " { $link multisampled } " or " { $link supersampled } " to request more accurate multisampling of alpha values." } ;
107 { $description "Requests a pixel format where the color buffer is stored in floating-point format." } ;
110 { $class-description "Requests a pixel format with a color buffer of at least " { $snippet "value" } " bits per pixel." } ;
112 { $class-description "Requests a pixel format with a color buffer with at least " { $snippet "value" } " red bits per pixel." } ;
114 { $class-description "Requests a pixel format with a color buffer with at least " { $snippet "value" } " green bits per pixel." } ;
116 { $class-description "Requests a pixel format with a color buffer with at least " { $snippet "value" } " blue bits per pixel." } ;
118 { $class-description "Requests a pixel format with a color buffer with at least " { $snippet "value" } " alpha bits per pixel." } ;
120 { color-float color-bits red-bits green-bits blue-bits alpha-bits } related-words
123 { $class-description "Requests a pixel format with an accumulation buffer of at least " { $snippet "value" } " bits per pixel." } ;
125 { $class-description "Requests a pixel format with an accumulation buffer with at least " { $snippet "value" } " red bits per pixel." } ;
126 HELP: accum-green-bits
127 { $class-description "Requests a pixel format with an accumulation buffer with at least " { $snippet "value" } " green bits per pixel." } ;
128 HELP: accum-blue-bits
129 { $class-description "Requests a pixel format with an accumulation buffer with at least " { $snippet "value" } " blue bits per pixel." } ;
130 HELP: accum-alpha-bits
131 { $class-description "Requests a pixel format with an accumulation buffer with at least " { $snippet "value" } " alpha bits per pixel." } ;
133 { accum-bits accum-red-bits accum-green-bits accum-blue-bits accum-alpha-bits } related-words
136 { $class-description "Requests a pixel format with a depth buffer of at least " { $snippet "value" } " bits per pixel." } ;
139 { $class-description "Requests a pixel format with a stencil buffer of at least " { $snippet "value" } " bits per pixel." } ;
142 { $class-description "Requests a pixel format with at least " { $snippet "value" } " auxiliary buffers." } ;
145 { $class-description "Used with " { $link multisampled } " or " { $link supersampled } " to request a pixel format with at least " { $snippet "value" } " sampling buffers." } ;
148 { $class-description "Used with " { $link multisampled } " or " { $link supersampled } " to request at least " { $snippet "value" } " samples per pixel." } ;
150 { multisampled supersampled sample-alpha sample-buffers samples } related-words
152 HELP: world-pixel-format-attributes
153 { $values { "world" world } { "attributes" sequence } }
154 { $description "Returns the set of " { $link "ui.pixel-formats-attributes" } " that " { $snippet "world" } " requests when grafted. This generic can be overridden by subclasses of " { $snippet "world" } "." }
155 { $notes "The pixel format provided by the window system will not necessarily exactly match the requested attributes. To verify required pixel format attributes, override " { $link check-world-pixel-format } "." } ;
157 HELP: check-world-pixel-format
158 { $values { "world" world } { "pixel-format" pixel-format } }
159 { $description "Verifies that " { $snippet "pixel-format" } " fulfills the requirements of " { $snippet "world" } ". The default method does nothing. Subclasses can override this generic to perform their own checks on the pixel format." } ;
162 { $class-description "The type of pixel format objects. The tuple slot contents should be considered opaque by user code. To check the value of a pixel format's attributes, use the " { $link pixel-format-attribute } " word. Pixel format objects must be freed using the " { $link dispose } " word when they are no longer needed." } ;
165 { $values { "world" world } { "attributes" sequence } { "pixel-format" pixel-format } }
166 { $description "Requests a pixel format suitable for " { $snippet "world" } " with a set of " { $link "ui.pixel-formats-attributes" } ". If no pixel format can be found that satisfies the given attributes, an " { $link invalid-pixel-format-attributes } " error is thrown. Pixel format attributes not supported by the window system are ignored. The returned " { $snippet "pixel-format" } " must be released using the " { $link dispose } " word when it is no longer needed." }
167 { $notes "Pixel formats don't normally need to be directly allocated by user code. If you need to control the pixel format requested by a window, subclass " { $snippet "world" } " and override the " { $link world-pixel-format-attributes } " and " { $link check-world-pixel-format } " words."
169 "The returned pixel format does not necessarily exactly match the requested attributes; the window system will try to find the format that best matches the given attributes. Use " { $link pixel-format-attribute } " to check the actual values of the attributes on the returned pixel format." }
172 HELP: pixel-format-attribute
173 { $values { "pixel-format" pixel-format } { "attribute-name" "one of the " { $link "ui.pixel-formats-attributes" } } { "value" object } }
174 { $description "Returns the value of the requested " { $snippet "attribute-name" } " in " { $snippet "pixel-format" } ". If " { "attribute-name" } " is unsupported by the window system, " { $link f } " is returned." } ;
176 HELP: invalid-pixel-format-attributes
177 { $values { "world" world } { "attributes" sequence } }
178 { $class-description "Thrown by " { $link <pixel-format> } " when the window system is unable to find a pixel format for " { $snippet "world" } " that satisfies the requested " { $snippet "attributes" } "." } ;
180 { world-pixel-format-attributes check-world-pixel-format pixel-format <pixel-format> pixel-format-attribute }
183 ARTICLE: "ui.pixel-formats" "Pixel formats"
184 "The UI allows you to control the window system's OpenGL interface with a cross-platform set of pixel format specifiers:"
185 { $subsections "ui.pixel-formats-attributes" }
187 "Pixel formats can be requested using these attributes:"
191 pixel-format-attribute
194 "If a request for a set of pixel format attributes cannot be satisfied, an error is thrown:"
195 { $subsections invalid-pixel-format-attributes }
197 "Pixel formats are requested as part of opening a window for a " { $link world } ". These generics can be overridden on " { $snippet "world" } " subclasses to control pixel format selection:"
199 world-pixel-format-attributes
200 check-world-pixel-format
204 ABOUT: "ui.pixel-formats"