Skip to content

GPUImpl

tom5454 edited this page Nov 1, 2023 · 4 revisions

GPU

This is the default GPU context available through the GPU Peripheral, Image.gpuDraw or createWindow functions

Color

Color values can be entered in multiple ways:

  • single ARGB number: 0xAARRGGBB
  • three channels as three separate arguments: R, G, B
  • four channels as four separate arguments: R, G, B, A

VRAM

The GPU Peripheral has an internal buffer for processing called VRAM.
Every operation that works with large amount of data uses this buffer.
The maximum size of this buffer is configurable in the mod's config file with the maxVRAMSize setting.
It has nothing to do with the actual VRAM of the computer

Utility functions

decodeImage(input...)

The function accepts unpacked numbers or buffer references. Returns the decoded image or throws an error if the image is corrupted or too big

getUsedMemory()

Returns the currently used VRAM by the GPU

newImage(width, height)

Creates a new image with the defined size

newBuffer([initial size])

Creates a new byte buffer with the given initial size or 32 bytes as the default.

imageFromBuffer(width, pixels...)

Creates an image with an unpacked ARGB pixels buffer

getMaxMemory()

Returns the maximum available VRAM

getBounds()

Returns the Window object if the context was created using createWindow

getSize()

Returns the context size in pixels

Graphics functions

filledRectangle(x, y, width, height, color)

rectangle(x, y, width, height, color)

lineS(x1, y1, x2, y2, color)

setFont(name)

getFont()

drawText(x, y, text, [text color], [bg color], [size], [padding])

drawTextSmart(x, y, text, [text color], [bg color], [force unicode], [size], [padding])

freeChars()

drawChar(x, y, char, [text color], [bg color], [size])

createWindow3D(x, y, width, height)

clearChars()

delChar(char)

drawBuffer(x, y, image width, scale, argb pixels...)

drawImage(x, y, image ref)

addNewChar(char, width, char data...x16)

createWindow(x, y, w, h)

getTextLength(text, [size], [padding])

getFontDefaultCharID()

setFontDefaultCharID(id)

sync()

fill(color)

line(x1, y1, x2, y2, color)

Tom's Peripherals Wiki

Clone this wiki locally