Windows GDI declarations for pixel-format selection, pixel-format installation, and buffer swapping on one device context.
Schemas
PIXELFORMATDESCRIPTOR
(-- PIXELFORMATDESCRIPTOR) Defines the descriptor used for pixel-format selection.Dict schema
| Field | Schema | Role |
|---|---|---|
nSize | Nat16 | size of this structure in bytes |
nVersion | Nat16 | structure version, 1n16 |
dwFlags | Nat32 | pixel-format capability flags |
iPixelType | Nat8 | pixel type |
cColorBits | Nat8 | color-buffer bit count |
cRedBits | Nat8 | red-channel bit count |
cRedShift | Nat8 | red-channel bit shift |
cGreenBits | Nat8 | green-channel bit count |
cGreenShift | Nat8 | green-channel bit shift |
cBlueBits | Nat8 | blue-channel bit count |
cBlueShift | Nat8 | blue-channel bit shift |
cAlphaBits | Nat8 | alpha-channel bit count |
cAlphaShift | Nat8 | alpha-channel bit shift |
cAccumBits | Nat8 | accumulation-buffer bit count |
cAccumRedBits | Nat8 | accumulation red-channel bit count |
cAccumGreenBits | Nat8 | accumulation green-channel bit count |
cAccumBlueBits | Nat8 | accumulation blue-channel bit count |
cAccumAlphaBits | Nat8 | accumulation alpha-channel bit count |
cDepthBits | Nat8 | depth-buffer bit count |
cStencilBits | Nat8 | stencil-buffer bit count |
cAuxBuffers | Nat8 | auxiliary-buffer count |
iLayerType | Nat8 | ignored |
bReserved | Nat8 | overlay-plane count in bits 0–3; underlay-plane count in bits 4–7 |
dwLayerMask | Nat32 | ignored |
dwVisibleMask | Nat32 | transparent RGB color or color index of an underlay plane |
dwDamageMask | Nat32 | ignored |
Imported functions
Stack effects list a C function's parameters with the first parameter on top; see importFunction.
ChoosePixelFormat
(ppfd hdc -- result) Chooses the pixel format that most closely matches a descriptor.Inputs
ppfd:PIXELFORMATDESCRIPTORCrefborrowed requested pixel-format descriptor withnSizeset to its byte size andnVersionset to1n16.hdc:HDCdevice-context handle.
Outputs
result:Int32one-based index of the closest matching pixel format, or0on failure.
SetPixelFormat
(ppfd format hdc -- result) Sets a device context to a pixel format.Inputs
ppfd:PIXELFORMATDESCRIPTORCrefborrowed pixel-format descriptor.format:Int32pixel-format index.hdc:HDCdevice-context handle; a window's pixel format can be set only once.
Outputs
result:Int32nonzeroon success,0on failure.
SwapBuffers
(Arg1 -- result) Swaps the front and back buffers when the device context's pixel format includes a back buffer.Inputs
Arg1:HDCdevice-context handle.
Outputs
result:Int32nonzeroon success,0on failure.
Signature example
Printing @ChoosePixelFormat during compilation shows its imported Code signature.
"control" use
"windows/gdi32" use
{} Int32 {} [
@ChoosePixelFormat printStack _:;
0
] "main" exportFunction
Expected Output During Compilation
{hdc: {DC: (); unused: Int32;} Cref; ppfd: {nSize: Nat16; nVersion: Nat16; dwFlags: Nat32; iPixelType: Nat8; cColorBits: Nat8; cRedBits: Nat8; cRedShift: Nat8; cGreenBits: Nat8; cGreenShift: Nat8; cBlueBits: Nat8; cBlueShift: Nat8; cAlphaBits: Nat8; cAlphaShift: Nat8; cAccumBits: Nat8; cAccumRedBits: Nat8; cAccumGreenBits: Nat8; cAccumBlueBits: Nat8; cAccumAlphaBits: Nat8; cDepthBits: Nat8; cStencilBits: Nat8; cAuxBuffers: Nat8; iLayerType: Nat8; bReserved: Nat8; dwLayerMask: Nat32; dwVisibleMask: Nat32; dwDamageMask: Nat32;} Cref;} Int32 {convention: "";} codeRef
See also
- windows/user32: User32 windowing, message, cursor, monitor, and device-context declarations.
- windows/opengl32: OpenGL32 WGL context declarations.