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

FieldSchemaRole
nSizeNat16size of this structure in bytes
nVersionNat16structure version, 1n16
dwFlagsNat32pixel-format capability flags
iPixelTypeNat8pixel type
cColorBitsNat8color-buffer bit count
cRedBitsNat8red-channel bit count
cRedShiftNat8red-channel bit shift
cGreenBitsNat8green-channel bit count
cGreenShiftNat8green-channel bit shift
cBlueBitsNat8blue-channel bit count
cBlueShiftNat8blue-channel bit shift
cAlphaBitsNat8alpha-channel bit count
cAlphaShiftNat8alpha-channel bit shift
cAccumBitsNat8accumulation-buffer bit count
cAccumRedBitsNat8accumulation red-channel bit count
cAccumGreenBitsNat8accumulation green-channel bit count
cAccumBlueBitsNat8accumulation blue-channel bit count
cAccumAlphaBitsNat8accumulation alpha-channel bit count
cDepthBitsNat8depth-buffer bit count
cStencilBitsNat8stencil-buffer bit count
cAuxBuffersNat8auxiliary-buffer count
iLayerTypeNat8ignored
bReservedNat8overlay-plane count in bits 0–3; underlay-plane count in bits 4–7
dwLayerMaskNat32ignored
dwVisibleMaskNat32transparent RGB color or color index of an underlay plane
dwDamageMaskNat32ignored

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

Outputs

  • result: Int32 one-based index of the closest matching pixel format, or 0 on failure.

SetPixelFormat

(ppfd format hdc -- result) Sets a device context to a pixel format.

Inputs

  • ppfd: PIXELFORMATDESCRIPTOR Cref borrowed pixel-format descriptor.
  • format: Int32 pixel-format index.
  • hdc: HDC device-context handle; a window's pixel format can be set only once.

Outputs

  • result: Int32 nonzero on success, 0 on failure.

SwapBuffers

(Arg1 -- result) Swaps the front and back buffers when the device context's pixel format includes a back buffer.

Inputs

  • Arg1: HDC device-context handle.

Outputs

  • result: Int32 nonzero on success, 0 on 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