Windows WGL declarations for OpenGL rendering-context creation, destruction, procedure lookup, and current-context binding.


Imported functions

Stack effects list a C function's parameters with the first parameter on top; see importFunction.

wglCreateContext

(Arg1 -- result) Creates an OpenGL rendering context for a device context.

Inputs

  • Arg1: HDC device-context handle whose pixel format is already set with SetPixelFormat.

Outputs

  • result: HGLRC rendering-context handle, or NIL on failure.

wglDeleteContext

(Arg1 -- result) Deletes an OpenGL rendering context.

Inputs

  • Arg1: HGLRC rendering-context handle to delete.

Outputs

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

wglGetProcAddress

(procedureName -- result) Retrieves an extension procedure address for the current OpenGL rendering context.

Inputs

  • procedureName: Natx address of a zero-terminated byte string naming the procedure.

Outputs

  • result: Natx raw procedure address, or 0nx if no rendering context is current or lookup fails; to call the procedure, view the address as Code with addressToReference and a codeRef signature.

wglMakeCurrent

(arg2 arg1 -- result) Makes a rendering context current for a device context.

Inputs

  • arg2: HGLRC rendering-context handle, or a NIL HGLRC to release the calling thread's current context.
  • arg1: HDC device-context handle, ignored when arg2 is NIL.

Outputs

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

Signature examples

Printing imported names during compilation shows the exact imported signatures.

"control"          use
"windows/opengl32" use

{} Int32 {} [
  @wglCreateContext printStack _:;
  @wglDeleteContext printStack _:;
  @wglGetProcAddress printStack _:;
  @wglMakeCurrent printStack _:;
  0
] "main" exportFunction

Expected Output During Compilation

{Arg1: {DC: (); unused: Int32;} Cref;} {GLRC: (); unused: Int32;} Cref {convention: "";} codeRef
{Arg1: {GLRC: (); unused: Int32;} Cref;} Int32 {convention: "";} codeRef
{lpParameter: Natx;} Natx {convention: "";} codeRef
{arg1: {DC: (); unused: Int32;} Cref; arg2: {GLRC: (); unused: Int32;} Cref;} Int32 {convention: "";} codeRef

wglGetProcAddress prints its input as lpParameter: a Code schema is identified by its input schemas, output and options, not by the input names, and printing uses the names of the first signature of that structure, here one imported from kernel32.


See also