Gpu: Difference between revisions
Appearance
mNo edit summary |
No edit summary |
||
| Line 15: | Line 15: | ||
|- | |- | ||
|<code>:newBuffer(integer:width, integer:height)</code> | |<code>:newBuffer(integer:width, integer:height)</code> | ||
|<code> | |<code>TextBufferUD</code> | ||
|Attempts to allocate and return a new [[TextBuffer]] of the given size. | |Attempts to allocate and return a new [[TextBuffer]] of the given size. | ||
|- | |- | ||
| Line 25: | Line 25: | ||
|<code>int</code> | |<code>int</code> | ||
|Frees all buffers allocated by this GPU and returns the number of freed buffers. | |Frees all buffers allocated by this GPU and returns the number of freed buffers. | ||
|} | |||
=== TextBufferUD === | |||
You can interact with textBuffers using the following api: | |||
{| class="wikitable" | |||
|+ TextBufferUD properties | |||
|- | |||
! Name !! Type !! Read/Write !! Description | |||
|- | |||
| <code>width</code> || <code>int</code> || READ || rowspan="2" | The width/height of this buffer, as specified in <code>GpuUD:newBuffer(...)</code>. | |||
|- | |||
|<code>height</code> | |||
|<code>int</code> | |||
|READ | |||
|- | |||
|<code>isAlive</code> | |||
|<code>bool</code> | |||
|READ | |||
|Whether this buffer is still alive, i.e. has not been deleted yet via <code>:free()</code>. | |||
|} | |||
In the following, <code>x</code> refers to the horizontal axis (like <code>width</code>) and <code>y</code> refers to the vertical axis (like <code>height</code>). | |||
{| class="wikitable" | |||
|+ TextBufferUD methods | |||
|- | |||
! Name !! Returns !! Description | |||
|- | |||
|<code>:getTextAsString()</code> | |||
|<code>string</code> | |||
|Returns the entire content of this buffer as a single string. | |||
|- | |||
|<code>:free()</code> | |||
|<code>void</code> | |||
|Deletes this buffer, releasing the held video memory. | |||
|- | |||
|<code>:getFg(x:int, y:int)</code> | |||
|<code>byte</code> | |||
|Returns the foreground color of this position. Currently does not have any visible effect. | |||
|- | |||
|<code>:getBg(x:int, y:int)</code> | |||
|<code>byte</code> | |||
|Returns the background color of this position. Currently does not have any visible effect. | |||
|- | |||
|<code>:getText(x:int, y:int)</code> | |||
|<code>char</code> | |||
|Returns a single-letter string representing the letter stored at this position. | |||
|- | |||
|<code>:set(x:int, y:int, chr:char, fgColor:byte, bgColor: byte)</code> | |||
|<code>void</code> | |||
|Sets the given position's character data, foreground and background color. Any arguments except for the position may be nil and will then have no effect. Color rendering is currently not implemented. | |||
|- | |||
|<code>:rotRows(cnt:int)</code> | |||
|<code>void</code> | |||
|Rotates the lines of the buffer, allowing for efficient implementation of scrolling. | |||
|- | |||
|<code>:clearRow(line:int)</code> | |||
|<code>void</code> | |||
|Clears the given line, resetting colors and text content of all positions of the given line. | |||
|- | |||
|<code>:newline()</code> | |||
|<code>void</code> | |||
|Shorthand for: <code>clearRow(0); rotRows(1);</code> | |||
|- | |||
|<code>:pasteText(x:int, y:int, mode:PasteMode, uText:string)</code> | |||
|<code>x:int, y:int</code> | |||
|Pastes the given text <code>uText</code> at the given position with the given pasteMode <code>mode</code>. Returns the position directly after the pasted text. So when performing multiple paste-operations you likely want to supply the previously returned position as the next position argument. | |||
|- | |||
|<code>:pasteText(x:int, y:int, mode:PasteMode, uText:string)</code> | |||
|<code>x:int, y:int</code> | |||
| | |||
|- | |||
|<code>:pasteText(x:int, y:int, mode:PasteMode, uText:string)</code> | |||
|<code>x:int, y:int</code> | |||
| | |||
|} | |} | ||
{{Navbox content}} | {{Navbox content}} | ||
Revision as of 14:34, 18 August 2026
The GpuUD component is what allows for rendering to screens. It offers the following functionality:
| Name | Type | Read/Write | Description |
|---|---|---|---|
remainingVideoRam |
integer |
READ | The amount of video ram remaining. Every alive buffer requires a certain amount of video memory. |
| Name | Returns | Description |
|---|---|---|
:newBuffer(integer:width, integer:height)
|
TextBufferUD
|
Attempts to allocate and return a new TextBuffer of the given size. |
:assignBuffer(textBufferUD, screenBlockUD:screenComponent)
|
void
|
Assigns the given textBuffer to the given Screen, displaying the contents on the screen. |
:freeAllBuffers()
|
int
|
Frees all buffers allocated by this GPU and returns the number of freed buffers. |
TextBufferUD
You can interact with textBuffers using the following api:
| Name | Type | Read/Write | Description |
|---|---|---|---|
width |
int |
READ | The width/height of this buffer, as specified in GpuUD:newBuffer(...).
|
height
|
int
|
READ | |
isAlive
|
bool
|
READ | Whether this buffer is still alive, i.e. has not been deleted yet via :free().
|
In the following, x refers to the horizontal axis (like width) and y refers to the vertical axis (like height).
| Name | Returns | Description |
|---|---|---|
:getTextAsString()
|
string
|
Returns the entire content of this buffer as a single string. |
:free()
|
void
|
Deletes this buffer, releasing the held video memory. |
:getFg(x:int, y:int)
|
byte
|
Returns the foreground color of this position. Currently does not have any visible effect. |
:getBg(x:int, y:int)
|
byte
|
Returns the background color of this position. Currently does not have any visible effect. |
:getText(x:int, y:int)
|
char
|
Returns a single-letter string representing the letter stored at this position. |
:set(x:int, y:int, chr:char, fgColor:byte, bgColor: byte)
|
void
|
Sets the given position's character data, foreground and background color. Any arguments except for the position may be nil and will then have no effect. Color rendering is currently not implemented. |
:rotRows(cnt:int)
|
void
|
Rotates the lines of the buffer, allowing for efficient implementation of scrolling. |
:clearRow(line:int)
|
void
|
Clears the given line, resetting colors and text content of all positions of the given line. |
:newline()
|
void
|
Shorthand for: clearRow(0); rotRows(1);
|
:pasteText(x:int, y:int, mode:PasteMode, uText:string)
|
x:int, y:int
|
Pastes the given text uText at the given position with the given pasteMode mode. Returns the position directly after the pasted text. So when performing multiple paste-operations you likely want to supply the previously returned position as the next position argument.
|
:pasteText(x:int, y:int, mode:PasteMode, uText:string)
|
x:int, y:int
|
|
:pasteText(x:int, y:int, mode:PasteMode, uText:string)
|
x:int, y:int
|