Skip to main content

Gpu

Struct Gpu 

Source
pub struct Gpu(pub Address);
Expand description

The gpu component (30 methods).

Provided by OpenComputers’ APU, GraphicsCard, GraphicsCardBase.

Tuple Fields§

§0: Address

Implementations§

Source§

impl Gpu

Source

pub fn allocate_buffer( &self, width: Option<Number>, height: Option<Number>, ) -> Result<Number>

allocates a new buffer with dimensions width*height (defaults to max resolution) and appends it to the buffer list. Returns the index of the new buffer and returns nil with an error message on failure. A buffer can be allocated even when there is no screen bound to this gpu. Index 0 is always reserved for the screen and thus the lowest index of an allocated buffer is always 1.

Lua: gpu.allocateBuffer([width: number, height: number]): number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn allocate_buffer_async( &self, width: Option<Number>, height: Option<Number>, ) -> Result<Number>

Self::allocate_buffer without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn bind( &self, address: impl AsRef<[u8]>, reset: Option<bool>, ) -> Result<bool>

Binds the GPU to the screen with the specified address and resets screen settings if reset is true.

Lua: gpu.bind(address:string[, reset:boolean=true]):boolean Indirect call: waits for the next server tick. reset defaults to true.

Source

pub async fn bind_async( &self, address: impl AsRef<[u8]>, reset: Option<bool>, ) -> Result<bool>

Self::bind without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn bitblt( &self, dst: Option<Number>, col: Option<Number>, row: Option<Number>, width: Option<Number>, height: Option<Number>, src: Option<Number>, from_col: Option<Number>, from_row: Option<Number>, ) -> Result<bool>

bitblt from buffer to screen. All parameters are optional. Writes to dst page in rectangle x, y, width, height, defaults to the bound screen and its viewport. Reads data from src page at fx, fy, default is the active page from position 1, 1

Lua: gpu.bitblt([dst: number, col: number, row: number, width: number, height: number, src: number, fromCol: number, fromRow: number]):boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn bitblt_async( &self, dst: Option<Number>, col: Option<Number>, row: Option<Number>, width: Option<Number>, height: Option<Number>, src: Option<Number>, from_col: Option<Number>, from_row: Option<Number>, ) -> Result<bool>

Self::bitblt without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn buffers(&self) -> Result<Number>

Returns an array of indexes of the allocated buffers

Lua: gpu.buffers(): number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn buffers_async(&self) -> Result<Number>

Self::buffers without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn copy( &self, x: impl Into<Number>, y: impl Into<Number>, width: impl Into<Number>, height: impl Into<Number>, tx: impl Into<Number>, ty: impl Into<Number>, ) -> Result<bool>

Copies a portion of the screen from the specified location with the specified size by the specified translation.

Lua: gpu.copy(x:number, y:number, width:number, height:number, tx:number, ty:number):boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn copy_async( &self, x: impl Into<Number>, y: impl Into<Number>, width: impl Into<Number>, height: impl Into<Number>, tx: impl Into<Number>, ty: impl Into<Number>, ) -> Result<bool>

Self::copy without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn fill( &self, x: impl Into<Number>, y: impl Into<Number>, width: impl Into<Number>, height: impl Into<Number>, char: impl AsRef<[u8]>, ) -> Result<bool>

Fills a portion of the screen at the specified position with the specified size with the specified character.

Lua: gpu.fill(x:number, y:number, width:number, height:number, char:string):boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn fill_async( &self, x: impl Into<Number>, y: impl Into<Number>, width: impl Into<Number>, height: impl Into<Number>, char: impl AsRef<[u8]>, ) -> Result<bool>

Self::fill without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn free_all_buffers(&self) -> Result<Number>

Closes all buffers and returns the count. If the active buffer is closed, index moves to 0

Lua: gpu.freeAllBuffers(): number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn free_all_buffers_async(&self) -> Result<Number>

Self::free_all_buffers without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn free_buffer(&self, index: impl Into<Number>) -> Result<bool>

Closes buffer at index. Returns true if a buffer closed. If the current buffer is closed, index moves to 0

Lua: gpu.freeBuffer(index: number): boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn free_buffer_async(&self, index: impl Into<Number>) -> Result<bool>

Self::free_buffer without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn free_memory(&self) -> Result<Number>

returns the total free memory not allocated to buffers. This does not include the screen.

Lua: gpu.freeMemory(): number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn free_memory_async(&self) -> Result<Number>

Self::free_memory without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get( &self, x: impl Into<Number>, y: impl Into<Number>, ) -> Result<(OcString, Number, Number, Option<Number>, Option<Number>)>

Get the value displayed on the screen at the specified index, as well as the foreground and background color. If the foreground or background is from the palette, returns the palette indices as fourth and fifth results, else nil, respectively.

Lua: gpu.get(x:number, y:number):string, number, number, number or nil, number or nil Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_async( &self, x: impl Into<Number>, y: impl Into<Number>, ) -> Result<(OcString, Number, Number, Option<Number>, Option<Number>)>

Self::get without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_active_buffer(&self) -> Result<Number>

returns the index of the currently selected buffer. 0 is reserved for the screen. Can return 0 even when there is no screen

Lua: gpu.getActiveBuffer(): number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_active_buffer_async(&self) -> Result<Number>

Self::get_active_buffer without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_background(&self) -> Result<(Number, bool)>

Get the current background color and whether it’s from the palette or not.

Lua: gpu.getBackground():number, boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_background_async(&self) -> Result<(Number, bool)>

Self::get_background without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_buffer_size( &self, index: impl Into<Number>, ) -> Result<(Number, Number)>

returns the buffer size at index. Returns the screen resolution for index 0. returns nil for invalid indexes

Lua: gpu.getBufferSize(index: number): number, number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_buffer_size_async( &self, index: impl Into<Number>, ) -> Result<(Number, Number)>

Self::get_buffer_size without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_depth(&self) -> Result<Number>

Returns the currently set color depth in bits.

Lua: gpu.getDepth():number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_depth_async(&self) -> Result<Number>

Self::get_depth without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_foreground(&self) -> Result<(Number, bool)>

Get the current foreground color and whether it’s from the palette or not.

Lua: gpu.getForeground():number, boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_foreground_async(&self) -> Result<(Number, bool)>

Self::get_foreground without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_palette_color(&self, index: impl Into<Number>) -> Result<Number>

Get the palette color at the specified palette index.

Lua: gpu.getPaletteColor(index:number):number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_palette_color_async( &self, index: impl Into<Number>, ) -> Result<Number>

Self::get_palette_color without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_resolution(&self) -> Result<(Number, Number)>

Get the current screen resolution.

Lua: gpu.getResolution():number, number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_resolution_async(&self) -> Result<(Number, Number)>

Self::get_resolution without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_screen(&self) -> Result<OcString>

Get the address of the screen the GPU is currently bound to.

Lua: gpu.getScreen():string Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_screen_async(&self) -> Result<OcString>

Self::get_screen without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn get_viewport(&self) -> Result<(Number, Number)>

Get the current viewport resolution.

Lua: gpu.getViewport():number, number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn get_viewport_async(&self) -> Result<(Number, Number)>

Self::get_viewport without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn max_depth(&self) -> Result<Number>

Gets the maximum supported color depth in bits.

Lua: gpu.maxDepth():number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn max_depth_async(&self) -> Result<Number>

Self::max_depth without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn max_resolution(&self) -> Result<(Number, Number)>

Get the maximum screen resolution.

Lua: gpu.maxResolution():number, number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn max_resolution_async(&self) -> Result<(Number, Number)>

Self::max_resolution without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn set( &self, x: impl Into<Number>, y: impl Into<Number>, value: impl AsRef<[u8]>, vertical: Option<bool>, ) -> Result<bool>

Plots a string value to the screen at the specified position. Optionally writes the string vertically.

Lua: gpu.set(x:number, y:number, value:string[, vertical:boolean]):boolean Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn set_async( &self, x: impl Into<Number>, y: impl Into<Number>, value: impl AsRef<[u8]>, vertical: Option<bool>, ) -> Result<bool>

Self::set without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn set_active_buffer(&self, index: impl Into<Number>) -> Result<Number>

Sets the active buffer to index. 1 is the first vram buffer and 0 is reserved for the screen. returns nil for invalid index (0 is always valid)

Lua: gpu.setActiveBuffer(index: number): number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn set_active_buffer_async( &self, index: impl Into<Number>, ) -> Result<Number>

Self::set_active_buffer without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn set_background( &self, value: impl Into<Number>, palette: Option<bool>, ) -> Result<(Number, Option<Number>)>

Sets the background color to the specified value. Optionally takes an explicit palette index. Returns the old value and if it was from the palette its palette index.

Lua: gpu.setBackground(value:number[, palette:boolean]):number, number or nil Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn set_background_async( &self, value: impl Into<Number>, palette: Option<bool>, ) -> Result<(Number, Option<Number>)>

Self::set_background without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn set_depth(&self, depth: impl Into<Number>) -> Result<Number>

Set the color depth. Returns the previous value.

Lua: gpu.setDepth(depth:number):number Indirect call: waits for the next server tick.

Source

pub async fn set_depth_async(&self, depth: impl Into<Number>) -> Result<Number>

Self::set_depth without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn set_foreground( &self, value: impl Into<Number>, palette: Option<bool>, ) -> Result<(Number, Option<Number>)>

Sets the foreground color to the specified value. Optionally takes an explicit palette index. Returns the old value and if it was from the palette its palette index.

Lua: gpu.setForeground(value:number[, palette:boolean]):number, number or nil Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn set_foreground_async( &self, value: impl Into<Number>, palette: Option<bool>, ) -> Result<(Number, Option<Number>)>

Self::set_foreground without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn set_palette_color( &self, index: impl Into<Number>, color: impl Into<Number>, ) -> Result<Number>

Set the palette color at the specified palette index. Returns the previous value.

Lua: gpu.setPaletteColor(index:number, color:number):number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn set_palette_color_async( &self, index: impl Into<Number>, color: impl Into<Number>, ) -> Result<Number>

Self::set_palette_color without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn set_resolution( &self, width: impl Into<Number>, height: impl Into<Number>, ) -> Result<bool>

Set the screen resolution. Returns true if the resolution changed.

Lua: gpu.setResolution(width:number, height:number):boolean Indirect call: waits for the next server tick.

Source

pub async fn set_resolution_async( &self, width: impl Into<Number>, height: impl Into<Number>, ) -> Result<bool>

Self::set_resolution without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn set_viewport( &self, width: impl Into<Number>, height: impl Into<Number>, ) -> Result<bool>

Set the viewport resolution. Cannot exceed the screen resolution. Returns true if the resolution changed.

Lua: gpu.setViewport(width:number, height:number):boolean Indirect call: waits for the next server tick.

Source

pub async fn set_viewport_async( &self, width: impl Into<Number>, height: impl Into<Number>, ) -> Result<bool>

Self::set_viewport without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Source

pub fn total_memory(&self) -> Result<Number>

returns the total memory size of the gpu vram. This does not include the screen.

Lua: gpu.totalMemory(): number Direct call (runs immediately, drawing on the per-tick budget).

Source

pub async fn total_memory_async(&self) -> Result<Number>

Self::total_memory without blocking: the call is queued, and the program keeps running until the result comes back; see crate::task.

Trait Implementations§

Source§

impl Clone for Gpu

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Component for Gpu

Source§

const KIND: &'static str = "gpu"

The OpenComputers component type, such as "gpu".
Source§

fn from_address(address: Address) -> Self

Wraps an address without checking what is there.
Source§

fn address(&self) -> &Address

Source§

fn first() -> Option<Self>

The first component of this type, by address order.
Source§

fn all() -> Vec<Self>

Every component of this type, by address order.
Source§

fn at(address: impl Into<Address>) -> Option<Self>

The component at address, if it is of this type.
Source§

fn invoke(&self, method: &str, args: Vec<Value>) -> Result<Vec<Value>>

An untyped call, for methods the wrapper doesn’t know.
Source§

fn invoke_async(&self, method: &str, args: Vec<Value>) -> Call ⓘ

Component::invoke without blocking; see invoke_async.
Source§

impl Debug for Gpu

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Gpu

Source§

impl Hash for Gpu

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Gpu

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Gpu

Auto Trait Implementations§

§

impl Forget for Gpu

§

impl Freeze for Gpu

§

impl Move for Gpu

§

impl RefUnwindSafe for Gpu

§

impl Send for Gpu

§

impl Sync for Gpu

§

impl Unpin for Gpu

§

impl UnsafeUnpin for Gpu

§

impl UnwindSafe for Gpu

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.