Struct RenderingDevice
pub struct RenderingDevice { /* private fields */ }Expand description
Godot class RenderingDevice.
Inherits Object.
Related symbols:
rendering_device: sidecar module with related enum/flag types
See also Godot docs for RenderingDevice.
§Not instantiable
This class cannot be constructed. Obtain Gd<RenderingDevice> instances via Godot APIs.
§Final class
This class is final, meaning you cannot inherit from it, and it comes without I* interface trait. It is still possible that other Godot classes inherit from it, but that is limited to the engine itself.
§Godot docs
RenderingDevice is an abstraction for working with modern low-level graphics APIs such as Vulkan. Compared to RenderingServer (which works with Godot’s own rendering subsystems), RenderingDevice is much lower-level and allows working more directly with the underlying graphics APIs. RenderingDevice is used in Godot to provide support for several modern low-level graphics APIs while reducing the amount of code duplication required. RenderingDevice can also be used in your own projects to perform things that are not exposed by RenderingServer or high-level nodes, such as using compute shaders.
On startup, Godot creates a global RenderingDevice which can be retrieved using get_rendering_device. This global RenderingDevice performs drawing to the screen.
Local RenderingDevices: Using create_local_rendering_device, you can create “secondary” rendering devices to perform drawing and GPU compute operations on separate threads.
Note: RenderingDevice assumes intermediate knowledge of modern graphics APIs such as Vulkan, Direct3D 12, Metal or WebGPU. These graphics APIs are lower-level than OpenGL or Direct3D 11, requiring you to perform what was previously done by the graphics driver itself. If you have difficulty understanding the concepts used in this class, follow the Vulkan Tutorial or Vulkan Guide. It’s recommended to have existing modern OpenGL or Direct3D 11 knowledge before attempting to learn a low-level graphics API.
Note: RenderingDevice is not available when running in headless mode or when using the Compatibility rendering method.
Implementations§
§impl RenderingDevice
impl RenderingDevice
pub const INVALID_ID: i32 = - 1i32
pub const INVALID_FORMAT_ID: i32 = - 1i32
pub fn texture_create(
&mut self,
format: impl AsArg<Option<Gd<RdTextureFormat>>>,
view: impl AsArg<Option<Gd<RdTextureView>>>,
) -> Rid
pub fn texture_create( &mut self, format: impl AsArg<Option<Gd<RdTextureFormat>>>, view: impl AsArg<Option<Gd<RdTextureView>>>, ) -> Rid
To set the default parameters, use texture_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a new texture. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
Note: data takes an Array of PackedByteArrays. For TextureType::TYPE_1D, TextureType::TYPE_2D, and TextureType::TYPE_3D types, this array should only have one element, a PackedByteArray containing all the data for the texture. For _ARRAY and _CUBE types, the length should be the same as the number of [member RDTextureFormat.array_layers] in format.
Note: Not to be confused with texture_2d_create, which creates the Godot-specific Texture2D resource as opposed to the graphics API’s own texture type.
pub fn texture_create_ex<'ex>(
&'ex mut self,
format: impl AsArg<Option<Gd<RdTextureFormat>>> + 'ex,
view: impl AsArg<Option<Gd<RdTextureView>>> + 'ex,
) -> ExTextureCreate<'ex>
pub fn texture_create_ex<'ex>( &'ex mut self, format: impl AsArg<Option<Gd<RdTextureFormat>>> + 'ex, view: impl AsArg<Option<Gd<RdTextureView>>> + 'ex, ) -> ExTextureCreate<'ex>
Creates a new texture. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
Note: data takes an Array of PackedByteArrays. For TextureType::TYPE_1D, TextureType::TYPE_2D, and TextureType::TYPE_3D types, this array should only have one element, a PackedByteArray containing all the data for the texture. For _ARRAY and _CUBE types, the length should be the same as the number of [member RDTextureFormat.array_layers] in format.
Note: Not to be confused with texture_2d_create, which creates the Godot-specific Texture2D resource as opposed to the graphics API’s own texture type.
Creates a shared texture using the specified view and the texture information from with_texture.
This will be freed automatically when the with_texture is freed.
To set the default parameters, use texture_create_shared_from_slice_ex and its builder methods. See the book for detailed usage instructions.
Creates a shared texture using the specified view and the texture information from with_texture’s layer and mipmap. The number of included mipmaps from the original texture can be controlled using the mipmaps parameter. Only relevant for textures with multiple layers, such as 3D textures, texture arrays and cubemaps. For single-layer textures, use texture_create_shared.
For 2D textures (which only have one layer), layer must be 0.
Note: Layer slicing is only supported for 2D texture arrays, not 3D textures or cubemaps.
This will be freed automatically when the with_texture is freed.
Creates a shared texture using the specified view and the texture information from with_texture’s layer and mipmap. The number of included mipmaps from the original texture can be controlled using the mipmaps parameter. Only relevant for textures with multiple layers, such as 3D textures, texture arrays and cubemaps. For single-layer textures, use texture_create_shared.
For 2D textures (which only have one layer), layer must be 0.
Note: Layer slicing is only supported for 2D texture arrays, not 3D textures or cubemaps.
This will be freed automatically when the with_texture is freed.
pub fn texture_create_from_extension(
&mut self,
type_: TextureType,
format: DataFormat,
samples: TextureSamples,
usage_flags: TextureUsageBits,
image: u64,
width: u64,
height: u64,
depth: u64,
layers: u64,
) -> Rid
pub fn texture_create_from_extension( &mut self, type_: TextureType, format: DataFormat, samples: TextureSamples, usage_flags: TextureUsageBits, image: u64, width: u64, height: u64, depth: u64, layers: u64, ) -> Rid
To set the default parameters, use texture_create_from_extension_ex and its builder methods. See the book for detailed usage instructions.
Returns an RID for an existing image (VkImage) with the given type, format, samples, usage_flags, width, height, depth, layers, and mipmaps. This can be used to allow Godot to render onto foreign images.
pub fn texture_create_from_extension_ex<'ex>(
&'ex mut self,
type_: TextureType,
format: DataFormat,
samples: TextureSamples,
usage_flags: TextureUsageBits,
image: u64,
width: u64,
height: u64,
depth: u64,
layers: u64,
) -> ExTextureCreateFromExtension<'ex>
pub fn texture_create_from_extension_ex<'ex>( &'ex mut self, type_: TextureType, format: DataFormat, samples: TextureSamples, usage_flags: TextureUsageBits, image: u64, width: u64, height: u64, depth: u64, layers: u64, ) -> ExTextureCreateFromExtension<'ex>
Returns an RID for an existing image (VkImage) with the given type, format, samples, usage_flags, width, height, depth, layers, and mipmaps. This can be used to allow Godot to render onto foreign images.
pub fn texture_update(
&mut self,
texture: Rid,
layer: u32,
data: &PackedArray<u8>,
) -> Error
pub fn texture_update( &mut self, texture: Rid, layer: u32, data: &PackedArray<u8>, ) -> Error
Updates texture data with new data, replacing the previous data in place. The updated texture data must have the same dimensions and format. For 2D textures (which only have one layer), layer must be 0. Returns @GlobalScope.OK if the update was successful, @GlobalScope.ERR_INVALID_PARAMETER otherwise.
Note: Updating textures is forbidden during creation of a draw or compute list.
Note: The existing texture can’t be updated while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to FinalAction::CONTINUE) to update this texture.
Note: The existing texture requires the TextureUsageBits::CAN_UPDATE_BIT to be updatable.
pub fn texture_get_data(&mut self, texture: Rid, layer: u32) -> PackedArray<u8>
pub fn texture_get_data(&mut self, texture: Rid, layer: u32) -> PackedArray<u8>
Returns the texture data for the specified layer as raw binary data. For 2D textures (which only have one layer), layer must be 0.
Note: texture can’t be retrieved while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to FinalAction::CONTINUE) to retrieve this texture. Otherwise, an error is printed and an empty PackedByteArray is returned.
Note: texture requires the TextureUsageBits::CAN_COPY_FROM_BIT to be retrieved. Otherwise, an error is printed and an empty PackedByteArray is returned.
Note: This method will block the GPU from working until the data is retrieved. Refer to texture_get_data_async for an alternative that returns the data in more performant way.
pub fn texture_get_data_async(
&mut self,
texture: Rid,
layer: u32,
callback: &Callable,
) -> Error
pub fn texture_get_data_async( &mut self, texture: Rid, layer: u32, callback: &Callable, ) -> Error
Asynchronous version of texture_get_data. RenderingDevice will call callback in a certain amount of frames with the data the texture had at the time of the request.
Note: At the moment, the delay corresponds to the amount of frames specified by [member ProjectSettings.rendering/rendering_device/vsync/frame_queue_size].
Note: Downloading large textures can have a prohibitive cost for real-time even when using the asynchronous method due to hardware bandwidth limitations. When dealing with large resources, you can adjust settings such as [member ProjectSettings.rendering/rendering_device/staging_buffer/texture_download_region_size_px] and [member ProjectSettings.rendering/rendering_device/staging_buffer/block_size_kb] to improve the transfer speed at the cost of extra memory.
func _texture_get_data_callback(array):
value = array.decode_u32(0)
...
rd.texture_get_data_async(texture, 0, _texture_get_data_callback)pub fn texture_is_format_supported_for_usage(
&self,
format: DataFormat,
usage_flags: TextureUsageBits,
) -> bool
pub fn texture_is_format_supported_for_usage( &self, format: DataFormat, usage_flags: TextureUsageBits, ) -> bool
Returns true if the specified format is supported for the given usage_flags, false otherwise.
Returns true if the texture is shared, false otherwise. See RDTextureView.
pub fn texture_is_valid(&mut self, texture: Rid) -> bool
pub fn texture_is_valid(&mut self, texture: Rid) -> bool
Returns true if the texture is valid, false otherwise.
pub fn texture_set_discardable(&mut self, texture: Rid, discardable: bool)
pub fn texture_set_discardable(&mut self, texture: Rid, discardable: bool)
Updates the discardable property of texture.
If a texture is discardable, its contents do not need to be preserved between frames. This flag is only relevant when the texture is used as target in a draw list.
This information is used by RenderingDevice to figure out if a texture’s contents can be discarded, eliminating unnecessary writes to memory and boosting performance.
pub fn texture_is_discardable(&mut self, texture: Rid) -> bool
pub fn texture_is_discardable(&mut self, texture: Rid) -> bool
Returns true if the texture is discardable, false otherwise. See RDTextureFormat or texture_set_discardable.
pub fn texture_copy(
&mut self,
from_texture: Rid,
to_texture: Rid,
from_pos: Vector3,
to_pos: Vector3,
size: Vector3,
src_mipmap: u32,
dst_mipmap: u32,
src_layer: u32,
dst_layer: u32,
) -> Error
pub fn texture_copy( &mut self, from_texture: Rid, to_texture: Rid, from_pos: Vector3, to_pos: Vector3, size: Vector3, src_mipmap: u32, dst_mipmap: u32, src_layer: u32, dst_layer: u32, ) -> Error
Copies the from_texture to to_texture with the specified from_pos, to_pos and size coordinates. The Z axis of the from_pos, to_pos and size must be 0 for 2-dimensional textures. Source and destination mipmaps/layers must also be specified, with these parameters being 0 for textures without mipmaps or single-layer textures. Returns @GlobalScope.OK if the texture copy was successful or @GlobalScope.ERR_INVALID_PARAMETER otherwise.
Note: from_texture texture can’t be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to FinalAction::CONTINUE) to copy this texture.
Note: from_texture texture requires the TextureUsageBits::CAN_COPY_FROM_BIT to be retrieved.
Note: to_texture can’t be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to FinalAction::CONTINUE) to copy this texture.
Note: to_texture requires the TextureUsageBits::CAN_COPY_TO_BIT to be retrieved.
Note: from_texture and to_texture must be of the same type (color or depth).
pub fn texture_clear(
&mut self,
texture: Rid,
color: Color,
base_mipmap: u32,
mipmap_count: u32,
base_layer: u32,
layer_count: u32,
) -> Error
pub fn texture_clear( &mut self, texture: Rid, color: Color, base_mipmap: u32, mipmap_count: u32, base_layer: u32, layer_count: u32, ) -> Error
Clears the specified texture by replacing all of its pixels with the specified color. base_mipmap and mipmap_count determine which mipmaps of the texture are affected by this clear operation, while base_layer and layer_count determine which layers of a 3D texture (or texture array) are affected by this clear operation. For 2D textures (which only have one layer by design), base_layer must be 0 and layer_count must be 1.
Note: texture can’t be cleared while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to FinalAction::CONTINUE) to clear this texture.
pub fn texture_resolve_multisample(
&mut self,
from_texture: Rid,
to_texture: Rid,
) -> Error
pub fn texture_resolve_multisample( &mut self, from_texture: Rid, to_texture: Rid, ) -> Error
Resolves the from_texture texture onto to_texture with multisample antialiasing enabled. This must be used when rendering a framebuffer for MSAA to work. Returns @GlobalScope.OK if successful, @GlobalScope.ERR_INVALID_PARAMETER otherwise.
Note: from_texture and to_texture textures must have the same dimension, format and type (color or depth).
Note: from_texture can’t be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to FinalAction::CONTINUE) to resolve this texture.
Note: from_texture requires the TextureUsageBits::CAN_COPY_FROM_BIT to be retrieved.
Note: from_texture must be multisampled and must also be 2D (or a slice of a 3D/cubemap texture).
Note: to_texture can’t be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to FinalAction::CONTINUE) to resolve this texture.
Note: to_texture texture requires the TextureUsageBits::CAN_COPY_TO_BIT to be retrieved.
Note: to_texture texture must not be multisampled and must also be 2D (or a slice of a 3D/cubemap texture).
pub fn texture_get_format(
&mut self,
texture: Rid,
) -> Option<Gd<RdTextureFormat>>
pub fn texture_get_format( &mut self, texture: Rid, ) -> Option<Gd<RdTextureFormat>>
Returns the data format used to create this texture.
pub fn texture_get_native_handle(&mut self, texture: Rid) -> u64
pub fn texture_get_native_handle(&mut self, texture: Rid) -> u64
Returns the internal graphics handle for this texture object. For use when communicating with third-party APIs mostly with GDExtension.
Note: This function returns a uint64_t which internally maps to a GLuint (OpenGL) or VkImage (Vulkan).
pub fn framebuffer_format_create(
&mut self,
attachments: &Array<Gd<RdAttachmentFormat>>,
) -> i64
pub fn framebuffer_format_create( &mut self, attachments: &Array<Gd<RdAttachmentFormat>>, ) -> i64
To set the default parameters, use framebuffer_format_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a new framebuffer format with the specified attachments and view_count. Returns the new framebuffer’s unique framebuffer format ID.
If view_count is greater than or equal to 2, enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.
pub fn framebuffer_format_create_ex<'ex>(
&'ex mut self,
attachments: &'ex Array<Gd<RdAttachmentFormat>>,
) -> ExFramebufferFormatCreate<'ex>
pub fn framebuffer_format_create_ex<'ex>( &'ex mut self, attachments: &'ex Array<Gd<RdAttachmentFormat>>, ) -> ExFramebufferFormatCreate<'ex>
Creates a new framebuffer format with the specified attachments and view_count. Returns the new framebuffer’s unique framebuffer format ID.
If view_count is greater than or equal to 2, enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.
pub fn framebuffer_format_create_multipass(
&mut self,
attachments: &Array<Gd<RdAttachmentFormat>>,
passes: &Array<Gd<RdFramebufferPass>>,
) -> i64
pub fn framebuffer_format_create_multipass( &mut self, attachments: &Array<Gd<RdAttachmentFormat>>, passes: &Array<Gd<RdFramebufferPass>>, ) -> i64
To set the default parameters, use framebuffer_format_create_multipass_ex and its builder methods. See the book for detailed usage instructions.
Creates a multipass framebuffer format with the specified attachments, passes and view_count and returns its ID. If view_count is greater than or equal to 2, enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.
pub fn framebuffer_format_create_multipass_ex<'ex>(
&'ex mut self,
attachments: &'ex Array<Gd<RdAttachmentFormat>>,
passes: &'ex Array<Gd<RdFramebufferPass>>,
) -> ExFramebufferFormatCreateMultipass<'ex>
pub fn framebuffer_format_create_multipass_ex<'ex>( &'ex mut self, attachments: &'ex Array<Gd<RdAttachmentFormat>>, passes: &'ex Array<Gd<RdFramebufferPass>>, ) -> ExFramebufferFormatCreateMultipass<'ex>
Creates a multipass framebuffer format with the specified attachments, passes and view_count and returns its ID. If view_count is greater than or equal to 2, enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.
pub fn framebuffer_format_create_empty(&mut self) -> i64
pub fn framebuffer_format_create_empty(&mut self) -> i64
To set the default parameters, use framebuffer_format_create_empty_ex and its builder methods. See the book for detailed usage instructions.
Creates a new empty framebuffer format with the specified number of samples and returns its ID.
pub fn framebuffer_format_create_empty_ex<'ex>(
&'ex mut self,
) -> ExFramebufferFormatCreateEmpty<'ex>
pub fn framebuffer_format_create_empty_ex<'ex>( &'ex mut self, ) -> ExFramebufferFormatCreateEmpty<'ex>
Creates a new empty framebuffer format with the specified number of samples and returns its ID.
pub fn framebuffer_format_get_texture_samples(
&mut self,
format: i64,
) -> TextureSamples
pub fn framebuffer_format_get_texture_samples( &mut self, format: i64, ) -> TextureSamples
To set the default parameters, use framebuffer_format_get_texture_samples_ex and its builder methods. See the book for detailed usage instructions.
Returns the number of texture samples used for the given framebuffer format ID (returned by framebuffer_get_format).
pub fn framebuffer_format_get_texture_samples_ex<'ex>(
&'ex mut self,
format: i64,
) -> ExFramebufferFormatGetTextureSamples<'ex>
pub fn framebuffer_format_get_texture_samples_ex<'ex>( &'ex mut self, format: i64, ) -> ExFramebufferFormatGetTextureSamples<'ex>
Returns the number of texture samples used for the given framebuffer format ID (returned by framebuffer_get_format).
pub fn framebuffer_create(&mut self, textures: &Array<Rid>) -> Rid
pub fn framebuffer_create(&mut self, textures: &Array<Rid>) -> Rid
To set the default parameters, use framebuffer_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a new framebuffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when any of the textures is freed.
pub fn framebuffer_create_ex<'ex>(
&'ex mut self,
textures: &'ex Array<Rid>,
) -> ExFramebufferCreate<'ex>
pub fn framebuffer_create_ex<'ex>( &'ex mut self, textures: &'ex Array<Rid>, ) -> ExFramebufferCreate<'ex>
Creates a new framebuffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when any of the textures is freed.
pub fn framebuffer_create_multipass(
&mut self,
textures: &Array<Rid>,
passes: &Array<Gd<RdFramebufferPass>>,
) -> Rid
pub fn framebuffer_create_multipass( &mut self, textures: &Array<Rid>, passes: &Array<Gd<RdFramebufferPass>>, ) -> Rid
To set the default parameters, use framebuffer_create_multipass_ex and its builder methods. See the book for detailed usage instructions.
Creates a new multipass framebuffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when any of the textures is freed.
pub fn framebuffer_create_multipass_ex<'ex>(
&'ex mut self,
textures: &'ex Array<Rid>,
passes: &'ex Array<Gd<RdFramebufferPass>>,
) -> ExFramebufferCreateMultipass<'ex>
pub fn framebuffer_create_multipass_ex<'ex>( &'ex mut self, textures: &'ex Array<Rid>, passes: &'ex Array<Gd<RdFramebufferPass>>, ) -> ExFramebufferCreateMultipass<'ex>
Creates a new multipass framebuffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when any of the textures is freed.
pub fn framebuffer_create_empty(&mut self, size: Vector2i) -> Rid
pub fn framebuffer_create_empty(&mut self, size: Vector2i) -> Rid
To set the default parameters, use framebuffer_create_empty_ex and its builder methods. See the book for detailed usage instructions.
Creates a new empty framebuffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn framebuffer_create_empty_ex<'ex>(
&'ex mut self,
size: Vector2i,
) -> ExFramebufferCreateEmpty<'ex>
pub fn framebuffer_create_empty_ex<'ex>( &'ex mut self, size: Vector2i, ) -> ExFramebufferCreateEmpty<'ex>
Creates a new empty framebuffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn framebuffer_get_format(&mut self, framebuffer: Rid) -> i64
pub fn framebuffer_get_format(&mut self, framebuffer: Rid) -> i64
Returns the format ID of the framebuffer specified by the framebuffer RID. This ID is guaranteed to be unique for the same formats and does not need to be freed.
pub fn framebuffer_is_valid(&self, framebuffer: Rid) -> bool
pub fn framebuffer_is_valid(&self, framebuffer: Rid) -> bool
Returns true if the framebuffer specified by the framebuffer RID is valid, false otherwise.
pub fn sampler_create(
&mut self,
state: impl AsArg<Option<Gd<RdSamplerState>>>,
) -> Rid
pub fn sampler_create( &mut self, state: impl AsArg<Option<Gd<RdSamplerState>>>, ) -> Rid
Creates a new sampler. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn sampler_is_format_supported_for_filter(
&self,
format: DataFormat,
sampler_filter: SamplerFilter,
) -> bool
pub fn sampler_is_format_supported_for_filter( &self, format: DataFormat, sampler_filter: SamplerFilter, ) -> bool
Returns true if implementation supports using a texture of format with the given sampler_filter.
pub fn vertex_buffer_create(&mut self, size_bytes: u32) -> Rid
pub fn vertex_buffer_create(&mut self, size_bytes: u32) -> Rid
To set the default parameters, use vertex_buffer_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a new vertex buffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn vertex_buffer_create_ex<'ex>(
&'ex mut self,
size_bytes: u32,
) -> ExVertexBufferCreate<'ex>
pub fn vertex_buffer_create_ex<'ex>( &'ex mut self, size_bytes: u32, ) -> ExVertexBufferCreate<'ex>
Creates a new vertex buffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn vertex_format_create(
&mut self,
vertex_descriptions: &Array<Gd<RdVertexAttribute>>,
) -> i64
pub fn vertex_format_create( &mut self, vertex_descriptions: &Array<Gd<RdVertexAttribute>>, ) -> i64
Creates a new vertex format with the specified vertex_descriptions. Returns a unique vertex format ID corresponding to the newly created vertex format.
pub fn vertex_array_create(
&mut self,
vertex_count: u32,
vertex_format: i64,
src_buffers: &Array<Rid>,
) -> Rid
pub fn vertex_array_create( &mut self, vertex_count: u32, vertex_format: i64, src_buffers: &Array<Rid>, ) -> Rid
To set the default parameters, use vertex_array_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a vertex array based on the specified buffers. Optionally, offsets (in bytes) may be defined for each buffer.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when any of the src_buffers is freed.
pub fn vertex_array_create_ex<'ex>(
&'ex mut self,
vertex_count: u32,
vertex_format: i64,
src_buffers: &'ex Array<Rid>,
) -> ExVertexArrayCreate<'ex>
pub fn vertex_array_create_ex<'ex>( &'ex mut self, vertex_count: u32, vertex_format: i64, src_buffers: &'ex Array<Rid>, ) -> ExVertexArrayCreate<'ex>
Creates a vertex array based on the specified buffers. Optionally, offsets (in bytes) may be defined for each buffer.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when any of the src_buffers is freed.
pub fn index_buffer_create(
&mut self,
size_indices: u32,
format: IndexBufferFormat,
) -> Rid
pub fn index_buffer_create( &mut self, size_indices: u32, format: IndexBufferFormat, ) -> Rid
To set the default parameters, use index_buffer_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a new index buffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn index_buffer_create_ex<'ex>(
&'ex mut self,
size_indices: u32,
format: IndexBufferFormat,
) -> ExIndexBufferCreate<'ex>
pub fn index_buffer_create_ex<'ex>( &'ex mut self, size_indices: u32, format: IndexBufferFormat, ) -> ExIndexBufferCreate<'ex>
Creates a new index buffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn index_array_create(
&mut self,
index_buffer: Rid,
index_offset: u32,
index_count: u32,
) -> Rid
pub fn index_array_create( &mut self, index_buffer: Rid, index_offset: u32, index_count: u32, ) -> Rid
Creates a new index array. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when the index_buffer is freed.
pub fn shader_compile_spirv_from_source(
&mut self,
shader_source: impl AsArg<Option<Gd<RdShaderSource>>>,
) -> Option<Gd<RdShaderSpirv>>
pub fn shader_compile_spirv_from_source( &mut self, shader_source: impl AsArg<Option<Gd<RdShaderSource>>>, ) -> Option<Gd<RdShaderSpirv>>
To set the default parameters, use shader_compile_spirv_from_source_ex and its builder methods. See the book for detailed usage instructions.
Compiles a SPIR-V from the shader source code in shader_source and returns the SPIR-V as an RDShaderSPIRV. This intermediate language shader is portable across different GPU models and driver versions, but cannot be run directly by GPUs until compiled into a binary shader using shader_compile_binary_from_spirv.
If allow_cache is true, make use of the shader cache generated by Godot. This avoids a potentially lengthy shader compilation step if the shader is already in cache. If allow_cache is false, Godot’s shader cache is ignored and the shader will always be recompiled.
pub fn shader_compile_spirv_from_source_ex<'ex>(
&'ex mut self,
shader_source: impl AsArg<Option<Gd<RdShaderSource>>> + 'ex,
) -> ExShaderCompileSpirvFromSource<'ex>
pub fn shader_compile_spirv_from_source_ex<'ex>( &'ex mut self, shader_source: impl AsArg<Option<Gd<RdShaderSource>>> + 'ex, ) -> ExShaderCompileSpirvFromSource<'ex>
Compiles a SPIR-V from the shader source code in shader_source and returns the SPIR-V as an RDShaderSPIRV. This intermediate language shader is portable across different GPU models and driver versions, but cannot be run directly by GPUs until compiled into a binary shader using shader_compile_binary_from_spirv.
If allow_cache is true, make use of the shader cache generated by Godot. This avoids a potentially lengthy shader compilation step if the shader is already in cache. If allow_cache is false, Godot’s shader cache is ignored and the shader will always be recompiled.
pub fn shader_compile_binary_from_spirv(
&mut self,
spirv_data: impl AsArg<Option<Gd<RdShaderSpirv>>>,
) -> PackedArray<u8>
pub fn shader_compile_binary_from_spirv( &mut self, spirv_data: impl AsArg<Option<Gd<RdShaderSpirv>>>, ) -> PackedArray<u8>
To set the default parameters, use shader_compile_binary_from_spirv_ex and its builder methods. See the book for detailed usage instructions.
Compiles a binary shader from spirv_data and returns the compiled binary data as a PackedByteArray. This compiled shader is specific to the GPU model and driver version used; it will not work on different GPU models or even different driver versions. See also shader_compile_spirv_from_source.
name is an optional human-readable name that can be given to the compiled shader for organizational purposes.
pub fn shader_compile_binary_from_spirv_ex<'ex>(
&'ex mut self,
spirv_data: impl AsArg<Option<Gd<RdShaderSpirv>>> + 'ex,
) -> ExShaderCompileBinaryFromSpirv<'ex>
pub fn shader_compile_binary_from_spirv_ex<'ex>( &'ex mut self, spirv_data: impl AsArg<Option<Gd<RdShaderSpirv>>> + 'ex, ) -> ExShaderCompileBinaryFromSpirv<'ex>
Compiles a binary shader from spirv_data and returns the compiled binary data as a PackedByteArray. This compiled shader is specific to the GPU model and driver version used; it will not work on different GPU models or even different driver versions. See also shader_compile_spirv_from_source.
name is an optional human-readable name that can be given to the compiled shader for organizational purposes.
pub fn shader_create_from_spirv(
&mut self,
spirv_data: impl AsArg<Option<Gd<RdShaderSpirv>>>,
) -> Rid
pub fn shader_create_from_spirv( &mut self, spirv_data: impl AsArg<Option<Gd<RdShaderSpirv>>>, ) -> Rid
To set the default parameters, use shader_create_from_spirv_ex and its builder methods. See the book for detailed usage instructions.
Creates a new shader instance from SPIR-V intermediate code. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method. See also shader_compile_spirv_from_source and shader_create_from_bytecode.
pub fn shader_create_from_spirv_ex<'ex>(
&'ex mut self,
spirv_data: impl AsArg<Option<Gd<RdShaderSpirv>>> + 'ex,
) -> ExShaderCreateFromSpirv<'ex>
pub fn shader_create_from_spirv_ex<'ex>( &'ex mut self, spirv_data: impl AsArg<Option<Gd<RdShaderSpirv>>> + 'ex, ) -> ExShaderCreateFromSpirv<'ex>
Creates a new shader instance from SPIR-V intermediate code. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method. See also shader_compile_spirv_from_source and shader_create_from_bytecode.
pub fn shader_create_from_bytecode(
&mut self,
binary_data: &PackedArray<u8>,
) -> Rid
pub fn shader_create_from_bytecode( &mut self, binary_data: &PackedArray<u8>, ) -> Rid
To set the default parameters, use shader_create_from_bytecode_ex and its builder methods. See the book for detailed usage instructions.
Creates a new shader instance from a binary compiled shader. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method. See also shader_compile_binary_from_spirv and shader_create_from_spirv.
pub fn shader_create_from_bytecode_ex<'ex>(
&'ex mut self,
binary_data: &'ex PackedArray<u8>,
) -> ExShaderCreateFromBytecode<'ex>
pub fn shader_create_from_bytecode_ex<'ex>( &'ex mut self, binary_data: &'ex PackedArray<u8>, ) -> ExShaderCreateFromBytecode<'ex>
Creates a new shader instance from a binary compiled shader. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method. See also shader_compile_binary_from_spirv and shader_create_from_spirv.
pub fn shader_create_placeholder(&mut self) -> Rid
pub fn shader_create_placeholder(&mut self) -> Rid
Create a placeholder RID by allocating an RID without initializing it for use in shader_create_from_bytecode. This allows you to create an RID for a shader and pass it around, but defer compiling the shader to a later time.
pub fn shader_get_vertex_input_attribute_mask(&mut self, shader: Rid) -> u64
pub fn shader_get_vertex_input_attribute_mask(&mut self, shader: Rid) -> u64
Returns the internal vertex input mask. Internally, the vertex input mask is an unsigned integer consisting of the locations (specified in GLSL via. layout(location = ...)) of the input variables (specified in GLSL by the in keyword).
pub fn uniform_buffer_create(&mut self, size_bytes: u32) -> Rid
pub fn uniform_buffer_create(&mut self, size_bytes: u32) -> Rid
To set the default parameters, use uniform_buffer_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a new uniform buffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn uniform_buffer_create_ex<'ex>(
&'ex mut self,
size_bytes: u32,
) -> ExUniformBufferCreate<'ex>
pub fn uniform_buffer_create_ex<'ex>( &'ex mut self, size_bytes: u32, ) -> ExUniformBufferCreate<'ex>
Creates a new uniform buffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn storage_buffer_create(&mut self, size_bytes: u32) -> Rid
pub fn storage_buffer_create(&mut self, size_bytes: u32) -> Rid
To set the default parameters, use storage_buffer_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a storage buffer with the specified data and usage. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn storage_buffer_create_ex<'ex>(
&'ex mut self,
size_bytes: u32,
) -> ExStorageBufferCreate<'ex>
pub fn storage_buffer_create_ex<'ex>( &'ex mut self, size_bytes: u32, ) -> ExStorageBufferCreate<'ex>
Creates a storage buffer with the specified data and usage. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn texture_buffer_create(
&mut self,
size_bytes: u32,
format: DataFormat,
) -> Rid
pub fn texture_buffer_create( &mut self, size_bytes: u32, format: DataFormat, ) -> Rid
To set the default parameters, use texture_buffer_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a new texture buffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn texture_buffer_create_ex<'ex>(
&'ex mut self,
size_bytes: u32,
format: DataFormat,
) -> ExTextureBufferCreate<'ex>
pub fn texture_buffer_create_ex<'ex>( &'ex mut self, size_bytes: u32, format: DataFormat, ) -> ExTextureBufferCreate<'ex>
Creates a new texture buffer. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
pub fn uniform_set_create(
&mut self,
uniforms: &Array<Gd<RdUniform>>,
shader: Rid,
shader_set: u32,
) -> Rid
pub fn uniform_set_create( &mut self, uniforms: &Array<Gd<RdUniform>>, shader: Rid, shader_set: u32, ) -> Rid
Creates a new uniform set. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when the shader or any of the RIDs in the uniforms is freed.
pub fn uniform_set_is_valid(&mut self, uniform_set: Rid) -> bool
pub fn uniform_set_is_valid(&mut self, uniform_set: Rid) -> bool
Checks if the uniform_set is valid, i.e. is owned.
pub fn buffer_copy(
&mut self,
src_buffer: Rid,
dst_buffer: Rid,
src_offset: u32,
dst_offset: u32,
size: u32,
) -> Error
pub fn buffer_copy( &mut self, src_buffer: Rid, dst_buffer: Rid, src_offset: u32, dst_offset: u32, size: u32, ) -> Error
Copies size bytes from the src_buffer at src_offset into dst_buffer at dst_offset.
Prints an error if:
-
sizeexceeds the size of eithersrc_bufferordst_bufferat their corresponding offsets -
a draw list is currently active (created by
draw_list_begin) -
a compute list is currently active (created by
compute_list_begin)
pub fn buffer_update(
&mut self,
buffer: Rid,
offset: u32,
size_bytes: u32,
data: &PackedArray<u8>,
) -> Error
pub fn buffer_update( &mut self, buffer: Rid, offset: u32, size_bytes: u32, data: &PackedArray<u8>, ) -> Error
Updates a region of size_bytes bytes, starting at offset, in the buffer, with the specified data.
Prints an error if:
-
the region specified by
offset+size_bytesexceeds the buffer -
a draw list is currently active (created by
draw_list_begin) -
a compute list is currently active (created by
compute_list_begin)
pub fn buffer_clear(
&mut self,
buffer: Rid,
offset: u32,
size_bytes: u32,
) -> Error
pub fn buffer_clear( &mut self, buffer: Rid, offset: u32, size_bytes: u32, ) -> Error
Clears the contents of the buffer, clearing size_bytes bytes, starting at offset.
Prints an error if:
-
the size isn’t a multiple of four
-
the region specified by
offset+size_bytesexceeds the buffer -
a draw list is currently active (created by
draw_list_begin) -
a compute list is currently active (created by
compute_list_begin)
pub fn buffer_get_data(&mut self, buffer: Rid) -> PackedArray<u8>
pub fn buffer_get_data(&mut self, buffer: Rid) -> PackedArray<u8>
To set the default parameters, use buffer_get_data_ex and its builder methods. See the book for detailed usage instructions.
Returns a copy of the data of the specified buffer, optionally offset_bytes and size_bytes can be set to copy only a portion of the buffer.
Note: This method will block the GPU from working until the data is retrieved. Refer to buffer_get_data_async for an alternative that returns the data in more performant way.
pub fn buffer_get_data_ex<'ex>(
&'ex mut self,
buffer: Rid,
) -> ExBufferGetData<'ex>
pub fn buffer_get_data_ex<'ex>( &'ex mut self, buffer: Rid, ) -> ExBufferGetData<'ex>
Returns a copy of the data of the specified buffer, optionally offset_bytes and size_bytes can be set to copy only a portion of the buffer.
Note: This method will block the GPU from working until the data is retrieved. Refer to buffer_get_data_async for an alternative that returns the data in more performant way.
pub fn buffer_get_data_async(
&mut self,
buffer: Rid,
callback: &Callable,
) -> Error
pub fn buffer_get_data_async( &mut self, buffer: Rid, callback: &Callable, ) -> Error
To set the default parameters, use buffer_get_data_async_ex and its builder methods. See the book for detailed usage instructions.
Asynchronous version of buffer_get_data. RenderingDevice will call callback in a certain amount of frames with the data the buffer had at the time of the request.
Note: At the moment, the delay corresponds to the amount of frames specified by [member ProjectSettings.rendering/rendering_device/vsync/frame_queue_size].
Note: Downloading large buffers can have a prohibitive cost for real-time even when using the asynchronous method due to hardware bandwidth limitations. When dealing with large resources, you can adjust settings such as [member ProjectSettings.rendering/rendering_device/staging_buffer/block_size_kb] to improve the transfer speed at the cost of extra memory.
func _buffer_get_data_callback(array):
value = array.decode_u32(0)
...
rd.buffer_get_data_async(buffer, _buffer_get_data_callback)pub fn buffer_get_data_async_ex<'ex>(
&'ex mut self,
buffer: Rid,
callback: &'ex Callable,
) -> ExBufferGetDataAsync<'ex>
pub fn buffer_get_data_async_ex<'ex>( &'ex mut self, buffer: Rid, callback: &'ex Callable, ) -> ExBufferGetDataAsync<'ex>
Asynchronous version of buffer_get_data. RenderingDevice will call callback in a certain amount of frames with the data the buffer had at the time of the request.
Note: At the moment, the delay corresponds to the amount of frames specified by [member ProjectSettings.rendering/rendering_device/vsync/frame_queue_size].
Note: Downloading large buffers can have a prohibitive cost for real-time even when using the asynchronous method due to hardware bandwidth limitations. When dealing with large resources, you can adjust settings such as [member ProjectSettings.rendering/rendering_device/staging_buffer/block_size_kb] to improve the transfer speed at the cost of extra memory.
func _buffer_get_data_callback(array):
value = array.decode_u32(0)
...
rd.buffer_get_data_async(buffer, _buffer_get_data_callback)pub fn buffer_get_device_address(&mut self, buffer: Rid) -> u64
pub fn buffer_get_device_address(&mut self, buffer: Rid) -> u64
Returns the address of the given buffer which can be passed to shaders in any way to access underlying data. Buffer must have been created with this feature enabled.
Note: You must check that the GPU supports this functionality by calling has_feature with Features::BUFFER_DEVICE_ADDRESS as a parameter.
pub fn render_pipeline_create(
&mut self,
shader: Rid,
framebuffer_format: i64,
vertex_format: i64,
primitive: RenderPrimitive,
rasterization_state: impl AsArg<Option<Gd<RdPipelineRasterizationState>>>,
multisample_state: impl AsArg<Option<Gd<RdPipelineMultisampleState>>>,
stencil_state: impl AsArg<Option<Gd<RdPipelineDepthStencilState>>>,
color_blend_state: impl AsArg<Option<Gd<RdPipelineColorBlendState>>>,
) -> Rid
pub fn render_pipeline_create( &mut self, shader: Rid, framebuffer_format: i64, vertex_format: i64, primitive: RenderPrimitive, rasterization_state: impl AsArg<Option<Gd<RdPipelineRasterizationState>>>, multisample_state: impl AsArg<Option<Gd<RdPipelineMultisampleState>>>, stencil_state: impl AsArg<Option<Gd<RdPipelineDepthStencilState>>>, color_blend_state: impl AsArg<Option<Gd<RdPipelineColorBlendState>>>, ) -> Rid
To set the default parameters, use render_pipeline_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a new render pipeline. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when the shader is freed.
pub fn render_pipeline_create_ex<'ex>(
&'ex mut self,
shader: Rid,
framebuffer_format: i64,
vertex_format: i64,
primitive: RenderPrimitive,
rasterization_state: impl AsArg<Option<Gd<RdPipelineRasterizationState>>> + 'ex,
multisample_state: impl AsArg<Option<Gd<RdPipelineMultisampleState>>> + 'ex,
stencil_state: impl AsArg<Option<Gd<RdPipelineDepthStencilState>>> + 'ex,
color_blend_state: impl AsArg<Option<Gd<RdPipelineColorBlendState>>> + 'ex,
) -> ExRenderPipelineCreate<'ex>
pub fn render_pipeline_create_ex<'ex>( &'ex mut self, shader: Rid, framebuffer_format: i64, vertex_format: i64, primitive: RenderPrimitive, rasterization_state: impl AsArg<Option<Gd<RdPipelineRasterizationState>>> + 'ex, multisample_state: impl AsArg<Option<Gd<RdPipelineMultisampleState>>> + 'ex, stencil_state: impl AsArg<Option<Gd<RdPipelineDepthStencilState>>> + 'ex, color_blend_state: impl AsArg<Option<Gd<RdPipelineColorBlendState>>> + 'ex, ) -> ExRenderPipelineCreate<'ex>
Creates a new render pipeline. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when the shader is freed.
pub fn render_pipeline_is_valid(&mut self, render_pipeline: Rid) -> bool
pub fn render_pipeline_is_valid(&mut self, render_pipeline: Rid) -> bool
Returns true if the render pipeline specified by the render_pipeline RID is valid, false otherwise.
pub fn compute_pipeline_create(&mut self, shader: Rid) -> Rid
pub fn compute_pipeline_create(&mut self, shader: Rid) -> Rid
To set the default parameters, use compute_pipeline_create_ex and its builder methods. See the book for detailed usage instructions.
Creates a new compute pipeline. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when the shader is freed.
pub fn compute_pipeline_create_ex<'ex>(
&'ex mut self,
shader: Rid,
) -> ExComputePipelineCreate<'ex>
pub fn compute_pipeline_create_ex<'ex>( &'ex mut self, shader: Rid, ) -> ExComputePipelineCreate<'ex>
Creates a new compute pipeline. It can be accessed with the RID that is returned.
Once finished with your RID, you will want to free the RID using the RenderingDevice’s free_rid method.
This will be freed automatically when the shader is freed.
pub fn compute_pipeline_is_valid(&mut self, compute_pipeline: Rid) -> bool
pub fn compute_pipeline_is_valid(&mut self, compute_pipeline: Rid) -> bool
Returns true if the compute pipeline specified by the compute_pipeline RID is valid, false otherwise.
pub fn screen_get_width(&self) -> i32
pub fn screen_get_width(&self) -> i32
To set the default parameters, use screen_get_width_ex and its builder methods. See the book for detailed usage instructions.
Returns the window width matching the graphics API context for the given window ID (in pixels). Despite the parameter being named screen, this returns the window size. See also screen_get_height.
Note: Only the main RenderingDevice returned by get_rendering_device has a width. If called on a local RenderingDevice, this method prints an error and returns INVALID_ID.
pub fn screen_get_width_ex<'ex>(&'ex self) -> ExScreenGetWidth<'ex>
pub fn screen_get_width_ex<'ex>(&'ex self) -> ExScreenGetWidth<'ex>
Returns the window width matching the graphics API context for the given window ID (in pixels). Despite the parameter being named screen, this returns the window size. See also screen_get_height.
Note: Only the main RenderingDevice returned by get_rendering_device has a width. If called on a local RenderingDevice, this method prints an error and returns INVALID_ID.
pub fn screen_get_height(&self) -> i32
pub fn screen_get_height(&self) -> i32
To set the default parameters, use screen_get_height_ex and its builder methods. See the book for detailed usage instructions.
Returns the window height matching the graphics API context for the given window ID (in pixels). Despite the parameter being named screen, this returns the window size. See also screen_get_width.
Note: Only the main RenderingDevice returned by get_rendering_device has a height. If called on a local RenderingDevice, this method prints an error and returns INVALID_ID.
pub fn screen_get_height_ex<'ex>(&'ex self) -> ExScreenGetHeight<'ex>
pub fn screen_get_height_ex<'ex>(&'ex self) -> ExScreenGetHeight<'ex>
Returns the window height matching the graphics API context for the given window ID (in pixels). Despite the parameter being named screen, this returns the window size. See also screen_get_width.
Note: Only the main RenderingDevice returned by get_rendering_device has a height. If called on a local RenderingDevice, this method prints an error and returns INVALID_ID.
pub fn screen_get_framebuffer_format(&self) -> i64
pub fn screen_get_framebuffer_format(&self) -> i64
To set the default parameters, use screen_get_framebuffer_format_ex and its builder methods. See the book for detailed usage instructions.
Returns the framebuffer format of the given screen.
Note: Only the main RenderingDevice returned by get_rendering_device has a format. If called on a local RenderingDevice, this method prints an error and returns INVALID_ID.
pub fn screen_get_framebuffer_format_ex<'ex>(
&'ex self,
) -> ExScreenGetFramebufferFormat<'ex>
pub fn screen_get_framebuffer_format_ex<'ex>( &'ex self, ) -> ExScreenGetFramebufferFormat<'ex>
Returns the framebuffer format of the given screen.
Note: Only the main RenderingDevice returned by get_rendering_device has a format. If called on a local RenderingDevice, this method prints an error and returns INVALID_ID.
pub fn draw_list_begin_for_screen(&mut self) -> i64
pub fn draw_list_begin_for_screen(&mut self) -> i64
To set the default parameters, use draw_list_begin_for_screen_ex and its builder methods. See the book for detailed usage instructions.
High-level variant of draw_list_begin, with the parameters automatically being adjusted for drawing onto the window specified by the screen ID.
Note: Cannot be used with local RenderingDevices, as these don’t have a screen. If called on a local RenderingDevice, draw_list_begin_for_screen returns INVALID_ID.
pub fn draw_list_begin_for_screen_ex<'ex>(
&'ex mut self,
) -> ExDrawListBeginForScreen<'ex>
pub fn draw_list_begin_for_screen_ex<'ex>( &'ex mut self, ) -> ExDrawListBeginForScreen<'ex>
High-level variant of draw_list_begin, with the parameters automatically being adjusted for drawing onto the window specified by the screen ID.
Note: Cannot be used with local RenderingDevices, as these don’t have a screen. If called on a local RenderingDevice, draw_list_begin_for_screen returns INVALID_ID.
pub fn draw_list_begin(&mut self, framebuffer: Rid) -> i64
pub fn draw_list_begin(&mut self, framebuffer: Rid) -> i64
To set the default parameters, use draw_list_begin_ex and its builder methods. See the book for detailed usage instructions.
Starts a list of raster drawing commands created with the draw_* methods. The returned value should be passed to other draw_list_* functions.
Multiple draw lists cannot be created at the same time; you must finish the previous draw list first using draw_list_end.
A simple drawing operation might look like this (code is not a complete example):
var rd = RenderingDevice.new()
var clear_colors = PackedColorArray([Color(0, 0, 0, 0), Color(0, 0, 0, 0), Color(0, 0, 0, 0)])
var draw_list = rd.draw_list_begin(framebuffers[i], RenderingDevice.CLEAR_COLOR_ALL, clear_colors, true, 1.0f, true, 0, Rect2(), RenderingDevice.OPAQUE_PASS)
# Draw opaque.
rd.draw_list_bind_render_pipeline(draw_list, raster_pipeline)
rd.draw_list_bind_uniform_set(draw_list, raster_base_uniform, 0)
rd.draw_list_set_push_constant(draw_list, raster_push_constant, raster_push_constant.size())
rd.draw_list_draw(draw_list, false, 1, slice_triangle_count[i] * 3)
# Draw wire.
rd.draw_list_bind_render_pipeline(draw_list, raster_pipeline_wire)
rd.draw_list_bind_uniform_set(draw_list, raster_base_uniform, 0)
rd.draw_list_set_push_constant(draw_list, raster_push_constant, raster_push_constant.size())
rd.draw_list_draw(draw_list, false, 1, slice_triangle_count[i] * 3)
rd.draw_list_end()The draw_flags indicates if the texture attachments of the framebuffer should be cleared or ignored. Only one of the two flags can be used for each individual attachment. Ignoring an attachment means that any contents that existed before the draw list will be completely discarded, reducing the memory bandwidth used by the render pass but producing garbage results if the pixels aren’t replaced. The default behavior allows the engine to figure out the right operation to use if the texture is discardable, which can result in increased performance. See RDTextureFormat or texture_set_discardable.
The breadcrumb parameter can be an arbitrary 32-bit integer that is useful to diagnose GPU crashes. If Godot is built in dev or debug mode; when the GPU crashes Godot will dump all shaders that were being executed at the time of the crash and the breadcrumb is useful to diagnose what passes did those shaders belong to.
It does not affect rendering behavior and can be set to 0. It is recommended to use [enum BreadcrumbMarker] enumerations for consistency but it’s not required. It is also possible to use bitwise operations to add extra data. e.g.
rd.draw_list_begin(fb[i], RenderingDevice.CLEAR_COLOR_ALL, clear_colors, true, 1.0f, true, 0, Rect2(), RenderingDevice.OPAQUE_PASS | 5)pub fn draw_list_begin_ex<'ex>(
&'ex mut self,
framebuffer: Rid,
) -> ExDrawListBegin<'ex>
pub fn draw_list_begin_ex<'ex>( &'ex mut self, framebuffer: Rid, ) -> ExDrawListBegin<'ex>
Starts a list of raster drawing commands created with the draw_* methods. The returned value should be passed to other draw_list_* functions.
Multiple draw lists cannot be created at the same time; you must finish the previous draw list first using draw_list_end.
A simple drawing operation might look like this (code is not a complete example):
var rd = RenderingDevice.new()
var clear_colors = PackedColorArray([Color(0, 0, 0, 0), Color(0, 0, 0, 0), Color(0, 0, 0, 0)])
var draw_list = rd.draw_list_begin(framebuffers[i], RenderingDevice.CLEAR_COLOR_ALL, clear_colors, true, 1.0f, true, 0, Rect2(), RenderingDevice.OPAQUE_PASS)
# Draw opaque.
rd.draw_list_bind_render_pipeline(draw_list, raster_pipeline)
rd.draw_list_bind_uniform_set(draw_list, raster_base_uniform, 0)
rd.draw_list_set_push_constant(draw_list, raster_push_constant, raster_push_constant.size())
rd.draw_list_draw(draw_list, false, 1, slice_triangle_count[i] * 3)
# Draw wire.
rd.draw_list_bind_render_pipeline(draw_list, raster_pipeline_wire)
rd.draw_list_bind_uniform_set(draw_list, raster_base_uniform, 0)
rd.draw_list_set_push_constant(draw_list, raster_push_constant, raster_push_constant.size())
rd.draw_list_draw(draw_list, false, 1, slice_triangle_count[i] * 3)
rd.draw_list_end()The draw_flags indicates if the texture attachments of the framebuffer should be cleared or ignored. Only one of the two flags can be used for each individual attachment. Ignoring an attachment means that any contents that existed before the draw list will be completely discarded, reducing the memory bandwidth used by the render pass but producing garbage results if the pixels aren’t replaced. The default behavior allows the engine to figure out the right operation to use if the texture is discardable, which can result in increased performance. See RDTextureFormat or texture_set_discardable.
The breadcrumb parameter can be an arbitrary 32-bit integer that is useful to diagnose GPU crashes. If Godot is built in dev or debug mode; when the GPU crashes Godot will dump all shaders that were being executed at the time of the crash and the breadcrumb is useful to diagnose what passes did those shaders belong to.
It does not affect rendering behavior and can be set to 0. It is recommended to use [enum BreadcrumbMarker] enumerations for consistency but it’s not required. It is also possible to use bitwise operations to add extra data. e.g.
rd.draw_list_begin(fb[i], RenderingDevice.CLEAR_COLOR_ALL, clear_colors, true, 1.0f, true, 0, Rect2(), RenderingDevice.OPAQUE_PASS | 5)pub fn draw_list_begin_split(
&mut self,
framebuffer: Rid,
splits: u32,
initial_color_action: InitialAction,
final_color_action: FinalAction,
initial_depth_action: InitialAction,
final_depth_action: FinalAction,
) -> PackedArray<i64>
pub fn draw_list_begin_split( &mut self, framebuffer: Rid, splits: u32, initial_color_action: InitialAction, final_color_action: FinalAction, initial_depth_action: InitialAction, final_depth_action: FinalAction, ) -> PackedArray<i64>
To set the default parameters, use draw_list_begin_split_ex and its builder methods. See the book for detailed usage instructions.
This method does nothing and always returns an empty PackedInt64Array.
pub fn draw_list_begin_split_ex<'ex>(
&'ex mut self,
framebuffer: Rid,
splits: u32,
initial_color_action: InitialAction,
final_color_action: FinalAction,
initial_depth_action: InitialAction,
final_depth_action: FinalAction,
) -> ExDrawListBeginSplit<'ex>
pub fn draw_list_begin_split_ex<'ex>( &'ex mut self, framebuffer: Rid, splits: u32, initial_color_action: InitialAction, final_color_action: FinalAction, initial_depth_action: InitialAction, final_depth_action: FinalAction, ) -> ExDrawListBeginSplit<'ex>
This method does nothing and always returns an empty PackedInt64Array.
pub fn draw_list_set_blend_constants(&mut self, draw_list: i64, color: Color)
pub fn draw_list_set_blend_constants(&mut self, draw_list: i64, color: Color)
Sets blend constants for the specified draw_list to color. Blend constants are used only if the graphics pipeline is created with PipelineDynamicStateFlags::BLEND_CONSTANTS flag set.
pub fn draw_list_bind_render_pipeline(
&mut self,
draw_list: i64,
render_pipeline: Rid,
)
pub fn draw_list_bind_render_pipeline( &mut self, draw_list: i64, render_pipeline: Rid, )
Binds render_pipeline to the specified draw_list.
pub fn draw_list_bind_uniform_set(
&mut self,
draw_list: i64,
uniform_set: Rid,
set_index: u32,
)
pub fn draw_list_bind_uniform_set( &mut self, draw_list: i64, uniform_set: Rid, set_index: u32, )
Binds uniform_set to the specified draw_list. A set_index must also be specified, which is an identifier starting from 0 that must match the one expected by the draw list.
pub fn draw_list_bind_vertex_array(&mut self, draw_list: i64, vertex_array: Rid)
pub fn draw_list_bind_vertex_array(&mut self, draw_list: i64, vertex_array: Rid)
Binds vertex_array to the specified draw_list.
pub fn draw_list_bind_vertex_buffers_format(
&mut self,
draw_list: i64,
vertex_format: i64,
vertex_count: u32,
vertex_buffers: &Array<Rid>,
)
pub fn draw_list_bind_vertex_buffers_format( &mut self, draw_list: i64, vertex_format: i64, vertex_count: u32, vertex_buffers: &Array<Rid>, )
To set the default parameters, use draw_list_bind_vertex_buffers_format_ex and its builder methods. See the book for detailed usage instructions.
Binds a set of vertex_buffers directly to the specified draw_list using vertex_format without creating a vertex array RID. Provide the number of vertices in vertex_count; optional per-buffer byte offsets may also be supplied.
pub fn draw_list_bind_vertex_buffers_format_ex<'ex>(
&'ex mut self,
draw_list: i64,
vertex_format: i64,
vertex_count: u32,
vertex_buffers: &'ex Array<Rid>,
) -> ExDrawListBindVertexBuffersFormat<'ex>
pub fn draw_list_bind_vertex_buffers_format_ex<'ex>( &'ex mut self, draw_list: i64, vertex_format: i64, vertex_count: u32, vertex_buffers: &'ex Array<Rid>, ) -> ExDrawListBindVertexBuffersFormat<'ex>
Binds a set of vertex_buffers directly to the specified draw_list using vertex_format without creating a vertex array RID. Provide the number of vertices in vertex_count; optional per-buffer byte offsets may also be supplied.
pub fn draw_list_bind_index_array(&mut self, draw_list: i64, index_array: Rid)
pub fn draw_list_bind_index_array(&mut self, draw_list: i64, index_array: Rid)
Binds index_array to the specified draw_list.
pub fn draw_list_set_push_constant(
&mut self,
draw_list: i64,
buffer: &PackedArray<u8>,
size_bytes: u32,
)
pub fn draw_list_set_push_constant( &mut self, draw_list: i64, buffer: &PackedArray<u8>, size_bytes: u32, )
Sets the push constant data to buffer for the specified draw_list. The shader determines how this binary data is used. The buffer’s size in bytes must also be specified in size_bytes (this can be obtained by calling the len method on the passed buffer).
pub fn draw_list_draw(
&mut self,
draw_list: i64,
use_indices: bool,
instances: u32,
)
pub fn draw_list_draw( &mut self, draw_list: i64, use_indices: bool, instances: u32, )
To set the default parameters, use draw_list_draw_ex and its builder methods. See the book for detailed usage instructions.
Submits draw_list for rendering on the GPU. This is the raster equivalent to compute_list_dispatch.
pub fn draw_list_draw_ex<'ex>(
&'ex mut self,
draw_list: i64,
use_indices: bool,
instances: u32,
) -> ExDrawListDraw<'ex>
pub fn draw_list_draw_ex<'ex>( &'ex mut self, draw_list: i64, use_indices: bool, instances: u32, ) -> ExDrawListDraw<'ex>
Submits draw_list for rendering on the GPU. This is the raster equivalent to compute_list_dispatch.
pub fn draw_list_draw_indirect(
&mut self,
draw_list: i64,
use_indices: bool,
buffer: Rid,
)
pub fn draw_list_draw_indirect( &mut self, draw_list: i64, use_indices: bool, buffer: Rid, )
To set the default parameters, use draw_list_draw_indirect_ex and its builder methods. See the book for detailed usage instructions.
Submits draw_list for rendering on the GPU with the given parameters stored in the buffer at offset. Parameters being integers: vertex count, instance count, first vertex, first instance. And when using indices: index count, instance count, first index, vertex offset, first instance. Buffer must have been created with StorageBufferUsage::DISPATCH_INDIRECT flag.
pub fn draw_list_draw_indirect_ex<'ex>(
&'ex mut self,
draw_list: i64,
use_indices: bool,
buffer: Rid,
) -> ExDrawListDrawIndirect<'ex>
pub fn draw_list_draw_indirect_ex<'ex>( &'ex mut self, draw_list: i64, use_indices: bool, buffer: Rid, ) -> ExDrawListDrawIndirect<'ex>
Submits draw_list for rendering on the GPU with the given parameters stored in the buffer at offset. Parameters being integers: vertex count, instance count, first vertex, first instance. And when using indices: index count, instance count, first index, vertex offset, first instance. Buffer must have been created with StorageBufferUsage::DISPATCH_INDIRECT flag.
pub fn draw_list_enable_scissor(&mut self, draw_list: i64)
pub fn draw_list_enable_scissor(&mut self, draw_list: i64)
To set the default parameters, use draw_list_enable_scissor_ex and its builder methods. See the book for detailed usage instructions.
Creates a scissor rectangle and enables it for the specified draw_list. Scissor rectangles are used for clipping by discarding fragments that fall outside a specified rectangular portion of the screen. See also draw_list_disable_scissor.
Note: The specified rect is automatically intersected with the screen’s dimensions, which means it cannot exceed the screen’s dimensions.
pub fn draw_list_enable_scissor_ex<'ex>(
&'ex mut self,
draw_list: i64,
) -> ExDrawListEnableScissor<'ex>
pub fn draw_list_enable_scissor_ex<'ex>( &'ex mut self, draw_list: i64, ) -> ExDrawListEnableScissor<'ex>
Creates a scissor rectangle and enables it for the specified draw_list. Scissor rectangles are used for clipping by discarding fragments that fall outside a specified rectangular portion of the screen. See also draw_list_disable_scissor.
Note: The specified rect is automatically intersected with the screen’s dimensions, which means it cannot exceed the screen’s dimensions.
pub fn draw_list_disable_scissor(&mut self, draw_list: i64)
pub fn draw_list_disable_scissor(&mut self, draw_list: i64)
Removes and disables the scissor rectangle for the specified draw_list. See also draw_list_enable_scissor.
pub fn draw_list_switch_to_next_pass(&mut self) -> i64
pub fn draw_list_switch_to_next_pass(&mut self) -> i64
Switches to the next draw pass.
pub fn draw_list_switch_to_next_pass_split(
&mut self,
splits: u32,
) -> PackedArray<i64>
pub fn draw_list_switch_to_next_pass_split( &mut self, splits: u32, ) -> PackedArray<i64>
This method does nothing and always returns an empty PackedInt64Array.
pub fn draw_list_end(&mut self)
pub fn draw_list_end(&mut self)
Finishes a list of raster drawing commands created with the draw_* methods.
pub fn compute_list_begin(&mut self) -> i64
pub fn compute_list_begin(&mut self) -> i64
Starts a list of compute commands created with the compute_* methods. The returned value should be passed to other compute_list_* functions.
Multiple compute lists cannot be created at the same time; you must finish the previous compute list first using compute_list_end.
A simple compute operation might look like this (code is not a complete example):
var rd = RenderingDevice.new()
var compute_list = rd.compute_list_begin()
rd.compute_list_bind_compute_pipeline(compute_list, compute_shader_dilate_pipeline)
rd.compute_list_bind_uniform_set(compute_list, compute_base_uniform_set, 0)
rd.compute_list_bind_uniform_set(compute_list, dilate_uniform_set, 1)
for i in atlas_slices:
rd.compute_list_set_push_constant(compute_list, push_constant, push_constant.size())
rd.compute_list_dispatch(compute_list, group_size.x, group_size.y, group_size.z)
# No barrier, let them run all together.
rd.compute_list_end()pub fn compute_list_bind_compute_pipeline(
&mut self,
compute_list: i64,
compute_pipeline: Rid,
)
pub fn compute_list_bind_compute_pipeline( &mut self, compute_list: i64, compute_pipeline: Rid, )
Tells the GPU what compute pipeline to use when processing the compute list. If the shader has changed since the last time this function was called, Godot will unbind all descriptor sets and will re-bind them inside compute_list_dispatch.
pub fn compute_list_set_push_constant(
&mut self,
compute_list: i64,
buffer: &PackedArray<u8>,
size_bytes: u32,
)
pub fn compute_list_set_push_constant( &mut self, compute_list: i64, buffer: &PackedArray<u8>, size_bytes: u32, )
Sets the push constant data to buffer for the specified compute_list. The shader determines how this binary data is used. The buffer’s size in bytes must also be specified in size_bytes (this can be obtained by calling the len method on the passed buffer).
pub fn compute_list_bind_uniform_set(
&mut self,
compute_list: i64,
uniform_set: Rid,
set_index: u32,
)
pub fn compute_list_bind_uniform_set( &mut self, compute_list: i64, uniform_set: Rid, set_index: u32, )
Binds the uniform_set to this compute_list. Godot ensures that all textures in the uniform set have the correct Vulkan access masks. If Godot had to change access masks of textures, it will raise a Vulkan image memory barrier.
pub fn compute_list_dispatch(
&mut self,
compute_list: i64,
x_groups: u32,
y_groups: u32,
z_groups: u32,
)
pub fn compute_list_dispatch( &mut self, compute_list: i64, x_groups: u32, y_groups: u32, z_groups: u32, )
Submits the compute list for processing on the GPU. This is the compute equivalent to draw_list_draw.
pub fn compute_list_dispatch_indirect(
&mut self,
compute_list: i64,
buffer: Rid,
offset: u32,
)
pub fn compute_list_dispatch_indirect( &mut self, compute_list: i64, buffer: Rid, offset: u32, )
Submits the compute list for processing on the GPU with the given group counts stored in the buffer at offset. Buffer must have been created with StorageBufferUsage::DISPATCH_INDIRECT flag.
pub fn compute_list_add_barrier(&mut self, compute_list: i64)
pub fn compute_list_add_barrier(&mut self, compute_list: i64)
Raises a Vulkan compute barrier in the specified compute_list.
pub fn compute_list_end(&mut self)
pub fn compute_list_end(&mut self)
Finishes a list of compute commands created with the compute_* methods.
pub fn free_rid(&mut self, rid: Rid)
pub fn free_rid(&mut self, rid: Rid)
Tries to free an object in the RenderingDevice. To avoid memory leaks, this should be called after using an object as memory management does not occur automatically when using RenderingDevice directly.
pub fn capture_timestamp(&mut self, name: impl AsArg<GString>)
pub fn capture_timestamp(&mut self, name: impl AsArg<GString>)
Creates a timestamp marker with the specified name. This is used for performance reporting with the get_captured_timestamp_cpu_time, get_captured_timestamp_gpu_time and get_captured_timestamp_name methods.
pub fn get_captured_timestamps_count(&self) -> u32
pub fn get_captured_timestamps_count(&self) -> u32
Returns the total number of timestamps (rendering steps) available for profiling.
pub fn get_captured_timestamps_frame(&self) -> u64
pub fn get_captured_timestamps_frame(&self) -> u64
Returns the index of the last frame rendered that has rendering timestamps available for querying.
pub fn get_captured_timestamp_gpu_time(&self, index: u32) -> u64
pub fn get_captured_timestamp_gpu_time(&self, index: u32) -> u64
Returns the timestamp in GPU time for the rendering step specified by index (in microseconds since the engine started). See also get_captured_timestamp_cpu_time and capture_timestamp.
pub fn get_captured_timestamp_cpu_time(&self, index: u32) -> u64
pub fn get_captured_timestamp_cpu_time(&self, index: u32) -> u64
Returns the timestamp in CPU time for the rendering step specified by index (in microseconds since the engine started). See also get_captured_timestamp_gpu_time and capture_timestamp.
pub fn get_captured_timestamp_name(&self, index: u32) -> GString
pub fn get_captured_timestamp_name(&self, index: u32) -> GString
Returns the timestamp’s name for the rendering step specified by index. See also capture_timestamp.
pub fn has_feature(&self, feature: Features) -> bool
pub fn has_feature(&self, feature: Features) -> bool
Returns true if the feature is supported by the GPU.
pub fn limit_get(&self, limit: Limit) -> u64
pub fn limit_get(&self, limit: Limit) -> u64
Returns the value of the specified limit. This limit varies depending on the current graphics hardware (and sometimes the driver version). If the given limit is exceeded, rendering errors will occur.
Limits for various graphics hardware can be found in the Vulkan Hardware Database.
pub fn get_frame_delay(&self) -> u32
pub fn get_frame_delay(&self) -> u32
Returns the frame count kept by the graphics API. Higher values result in higher input lag, but with more consistent throughput. For the main RenderingDevice, frames are cycled (usually 3 with triple-buffered V-Sync enabled). However, local RenderingDevices only have 1 frame.
pub fn submit(&mut self)
pub fn submit(&mut self)
Pushes the frame setup and draw command buffers then marks the local device as currently processing (which allows calling sync).
Note: Only available in local RenderingDevices.
pub fn sync(&mut self)
pub fn sync(&mut self)
pub fn barrier(&mut self)
pub fn barrier(&mut self)
To set the default parameters, use barrier_ex and its builder methods. See the book for detailed usage instructions.
This method does nothing.
pub fn barrier_ex<'ex>(&'ex mut self) -> ExBarrier<'ex>
pub fn barrier_ex<'ex>(&'ex mut self) -> ExBarrier<'ex>
This method does nothing.
pub fn full_barrier(&mut self)
pub fn full_barrier(&mut self)
This method does nothing.
pub fn create_local_device(&mut self) -> Option<Gd<RenderingDevice>>
pub fn create_local_device(&mut self) -> Option<Gd<RenderingDevice>>
Create a new local RenderingDevice. This is most useful for performing compute operations on the GPU independently from the rest of the engine.
pub fn set_resource_name(&mut self, id: Rid, name: impl AsArg<GString>)
pub fn set_resource_name(&mut self, id: Rid, name: impl AsArg<GString>)
Sets the resource name for id to name. This is used for debugging with third-party tools such as RenderDoc.
The following types of resources can be named: texture, sampler, vertex buffer, index buffer, uniform buffer, texture buffer, storage buffer, uniform set buffer, shader, render pipeline and compute pipeline. Framebuffers cannot be named. Attempting to name an incompatible resource type will print an error.
Note: Resource names are only set when the engine runs in verbose mode (is_stdout_verbose = true), or when using an engine build compiled with the dev_mode=yes SCons option. The graphics driver must also support the VK_EXT_DEBUG_UTILS_EXTENSION_NAME Vulkan extension for named resources to work.
pub fn draw_command_begin_label(
&mut self,
name: impl AsArg<GString>,
color: Color,
)
pub fn draw_command_begin_label( &mut self, name: impl AsArg<GString>, color: Color, )
Create a command buffer debug label region that can be displayed in third-party tools such as RenderDoc. All regions must be ended with a draw_command_end_label call. When viewed from the linear series of submissions to a single queue, calls to draw_command_begin_label and draw_command_end_label must be matched and balanced.
The VK_EXT_DEBUG_UTILS_EXTENSION_NAME Vulkan extension must be available and enabled for command buffer debug label region to work. See also draw_command_end_label.
pub fn draw_command_insert_label(
&mut self,
name: impl AsArg<GString>,
color: Color,
)
pub fn draw_command_insert_label( &mut self, name: impl AsArg<GString>, color: Color, )
This method does nothing.
pub fn draw_command_end_label(&mut self)
pub fn draw_command_end_label(&mut self)
Ends the command buffer debug label region started by a draw_command_begin_label call.
pub fn get_device_vendor_name(&self) -> GString
pub fn get_device_vendor_name(&self) -> GString
Returns the vendor of the video adapter (e.g. “NVIDIA Corporation”). Equivalent to get_video_adapter_vendor. See also get_device_name.
pub fn get_device_name(&self) -> GString
pub fn get_device_name(&self) -> GString
Returns the name of the video adapter (e.g. “GeForce GTX 1080/PCIe/SSE2”). Equivalent to get_video_adapter_name. See also get_device_vendor_name.
pub fn get_device_pipeline_cache_uuid(&self) -> GString
pub fn get_device_pipeline_cache_uuid(&self) -> GString
Returns the universally unique identifier for the pipeline cache. This is used to cache shader files on disk, which avoids shader recompilations on subsequent engine runs. This UUID varies depending on the graphics card model, but also the driver version. Therefore, updating graphics drivers will invalidate the shader cache.
pub fn get_memory_usage(&self, type_: MemoryType) -> u64
pub fn get_memory_usage(&self, type_: MemoryType) -> u64
Returns the memory usage in bytes corresponding to the given type. When using Vulkan, these statistics are calculated by Vulkan Memory Allocator.
pub fn get_driver_resource(
&self,
resource: DriverResource,
rid: Rid,
index: u64,
) -> u64
pub fn get_driver_resource( &self, resource: DriverResource, rid: Rid, index: u64, ) -> u64
Returns the unique identifier of the driver resource for the specified rid. Some driver resource types ignore the specified rid. index is always ignored but must be specified anyway.
pub fn get_perf_report(&self) -> GString
pub fn get_perf_report(&self) -> GString
Returns a string with a performance report from the past frame. Updates every frame.
pub fn get_driver_and_device_memory_report(&self) -> GString
pub fn get_driver_and_device_memory_report(&self) -> GString
Returns string report in CSV format using the following methods:
This is only used by Vulkan in debug builds. Godot must also be started with the --extra-gpu-memory-tracking command line argument.
pub fn get_tracked_object_name(&self, type_index: u32) -> GString
pub fn get_tracked_object_name(&self, type_index: u32) -> GString
Returns the name of the type of object for the given type_index. This value must be in range [0; get_tracked_object_type_count - 1]. If get_tracked_object_type_count is 0, then type argument is ignored and always returns the same string.
The return value is important because it gives meaning to the types passed to get_driver_memory_by_object_type, get_driver_allocs_by_object_type, get_device_memory_by_object_type, and get_device_allocs_by_object_type. Examples of strings it can return (not exhaustive):
-
DEVICE_MEMORY
-
PIPELINE_CACHE
-
SWAPCHAIN_KHR
-
COMMAND_POOL
Thus if e.g. get_tracked_object_name(5) returns “COMMAND_POOL”, then get_device_memory_by_object_type(5) returns the bytes used by the GPU for command pools.
This is only used by Vulkan in debug builds. Godot must also be started with the --extra-gpu-memory-tracking command line argument.
pub fn get_tracked_object_type_count(&self) -> u64
pub fn get_tracked_object_type_count(&self) -> u64
Returns how many types of trackable objects there are.
This is only used by Vulkan in debug builds. Godot must also be started with the --extra-gpu-memory-tracking command line argument.
pub fn get_driver_total_memory(&self) -> u64
pub fn get_driver_total_memory(&self) -> u64
Returns how much bytes the GPU driver is using for internal driver structures.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
pub fn get_driver_allocation_count(&self) -> u64
pub fn get_driver_allocation_count(&self) -> u64
Returns how many allocations the GPU driver has performed for internal driver structures.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
pub fn get_driver_memory_by_object_type(&self, type_: u32) -> u64
pub fn get_driver_memory_by_object_type(&self, type_: u32) -> u64
Same as get_driver_total_memory but filtered for a given object type.
The type argument must be in range [0; get_tracked_object_type_count - 1]. If get_tracked_object_type_count is 0, then type argument is ignored and always returns 0.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
pub fn get_driver_allocs_by_object_type(&self, type_: u32) -> u64
pub fn get_driver_allocs_by_object_type(&self, type_: u32) -> u64
Same as get_driver_allocation_count but filtered for a given object type.
The type argument must be in range [0; get_tracked_object_type_count - 1]. If get_tracked_object_type_count is 0, then type argument is ignored and always returns 0.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
pub fn get_device_total_memory(&self) -> u64
pub fn get_device_total_memory(&self) -> u64
Returns how much bytes the GPU is using.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
pub fn get_device_allocation_count(&self) -> u64
pub fn get_device_allocation_count(&self) -> u64
Returns how many allocations the GPU has performed for internal driver structures.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
pub fn get_device_memory_by_object_type(&self, type_: u32) -> u64
pub fn get_device_memory_by_object_type(&self, type_: u32) -> u64
Same as get_device_total_memory but filtered for a given object type.
The type argument must be in range [0; get_tracked_object_type_count - 1]. If get_tracked_object_type_count is 0, then type argument is ignored and always returns 0.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
pub fn get_device_allocs_by_object_type(&self, type_: u32) -> u64
pub fn get_device_allocs_by_object_type(&self, type_: u32) -> u64
Same as get_device_allocation_count but filtered for a given object type.
The type argument must be in range [0; get_tracked_object_type_count - 1]. If get_tracked_object_type_count is 0, then type argument is ignored and always returns 0.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
Methods from Deref<Target = Object>§
pub fn get_script(&self) -> Option<Gd<Script>>
pub fn set_script(&mut self, script: impl AsArg<Option<Gd<Script>>>)
pub fn connect( &mut self, signal: impl AsArg<StringName>, callable: &Callable, ) -> Error
pub fn connect_flags( &mut self, signal: impl AsArg<StringName>, callable: &Callable, flags: ConnectFlags, ) -> Error
pub fn is_class(&self, class: impl AsArg<GString>) -> bool
pub fn is_class(&self, class: impl AsArg<GString>) -> bool
Returns true if the object inherits from the given class. See also get_class.
var sprite2d = Sprite2D.new()
sprite2d.is_class("Sprite2D") # Returns true
sprite2d.is_class("Node") # Returns true
sprite2d.is_class("Node3D") # Returns falseNote: This method ignores class_name declarations in the object’s script.
pub fn set(&mut self, property: impl AsArg<StringName>, value: &Variant)
pub fn set(&mut self, property: impl AsArg<StringName>, value: &Variant)
Assigns value to the given property. If the property does not exist or the given value’s type doesn’t match, nothing happens.
var node = Node2D.new()
node.set("global_scale", Vector2(8, 2.5))
print(node.global_scale) # Prints (8.0, 2.5)Note: In C#, property must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.
pub fn get(&self, property: impl AsArg<StringName>) -> Variant
pub fn get(&self, property: impl AsArg<StringName>) -> Variant
Returns the Variant value of the given property. If the property does not exist, this method returns null.
var node = Node2D.new()
node.rotation = 1.5
var a = node.get("rotation") # a is 1.5Note: In C#, property must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.
pub fn set_indexed(
&mut self,
property_path: impl AsArg<NodePath>,
value: &Variant,
)
pub fn set_indexed( &mut self, property_path: impl AsArg<NodePath>, value: &Variant, )
Assigns a new value to the property identified by the property_path. The path should be a NodePath relative to this object, and can use the colon character (:) to access nested properties.
var node = Node2D.new()
node.set_indexed("position", Vector2(42, 0))
node.set_indexed("position:y", -10)
print(node.position) # Prints (42.0, -10.0)Note: In C#, property_path must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.
pub fn get_indexed(&self, property_path: impl AsArg<NodePath>) -> Variant
pub fn get_indexed(&self, property_path: impl AsArg<NodePath>) -> Variant
Gets the object’s property indexed by the given property_path. The path should be a NodePath relative to the current object and can use the colon character (:) to access nested properties.
Examples: "position:x" or "material:next_pass:blend_mode".
var node = Node2D.new()
node.position = Vector2(5, -10)
var a = node.get_indexed("position") # a is Vector2(5, -10)
var b = node.get_indexed("position:y") # b is -10Note: In C#, property_path must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.
Note: This method does not support actual paths to nodes in the SceneTree, only sub-property paths. In the context of nodes, use get_node_and_resource instead.
pub fn get_property_list(&self) -> Array<Dictionary<Variant, Variant>>
pub fn get_property_list(&self) -> Array<Dictionary<Variant, Variant>>
Returns the object’s property list as an Array of dictionaries. Each Dictionary contains the following entries:
-
nameis the property’s name, as aString; -
class_nameis an emptyStringName, unless the property isVariantType::OBJECTand it inherits from a class; -
typeis the property’s type, as anint(see [enum Variant.Type]); -
hintis how the property is meant to be edited (see [enum PropertyHint]); -
hint_stringdepends on the hint (see [enum PropertyHint]); -
usageis a combination of [enum PropertyUsageFlags].
Note: In GDScript, all class members are treated as properties. In C# and GDExtension, it may be necessary to explicitly mark class members as Godot properties using decorators or attributes.
pub fn get_method_list(&self) -> Array<Dictionary<Variant, Variant>>
pub fn get_method_list(&self) -> Array<Dictionary<Variant, Variant>>
Returns this object’s methods and their signatures as an Array of dictionaries. Each Dictionary contains the following entries:
-
nameis the name of the method, as aString; -
argsis anArrayof dictionaries representing the arguments; -
default_argsis the default arguments as anArrayof variants; -
flagsis a combination of [enum MethodFlags]; -
idis the method’s internal identifierint; -
returnis the returned value, as aDictionary;
Note: The dictionaries of args and return are formatted identically to the results of get_property_list, although not all entries are used.
pub fn property_can_revert(&self, property: impl AsArg<StringName>) -> bool
pub fn property_can_revert(&self, property: impl AsArg<StringName>) -> bool
Returns true if the given property has a custom default value. Use property_get_revert to get the property’s default value.
Note: This method is used by the Inspector dock to display a revert icon. The object must implement [method _property_can_revert] to customize the default value. If [method _property_can_revert] is not implemented, this method returns false.
pub fn property_get_revert(&self, property: impl AsArg<StringName>) -> Variant
pub fn property_get_revert(&self, property: impl AsArg<StringName>) -> Variant
Returns the custom default value of the given property. Use property_can_revert to check if the property has a custom default value.
Note: This method is used by the Inspector dock to display a revert icon. The object must implement [method _property_get_revert] to customize the default value. If [method _property_get_revert] is not implemented, this method returns null.
pub fn set_meta(&mut self, name: impl AsArg<StringName>, value: &Variant)
pub fn set_meta(&mut self, name: impl AsArg<StringName>, value: &Variant)
Adds or changes the entry name inside the object’s metadata. The metadata value can be any Variant, although some types cannot be serialized correctly.
If value is null, the entry is removed. This is the equivalent of using remove_meta. See also has_meta and get_meta.
Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.
Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.
pub fn remove_meta(&mut self, name: impl AsArg<StringName>)
pub fn remove_meta(&mut self, name: impl AsArg<StringName>)
Removes the given entry name from the object’s metadata. See also has_meta, get_meta and set_meta.
Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.
Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.
pub fn get_meta(&self, name: impl AsArg<StringName>) -> Variant
pub fn get_meta(&self, name: impl AsArg<StringName>) -> Variant
To set the default parameters, use get_meta_ex and its builder methods. See the book for detailed usage instructions.
Returns the object’s metadata value for the given entry name. If the entry does not exist, returns default. If default is null, an error is also generated.
Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.
Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.
pub fn get_meta_ex<'ex>(
&'ex self,
name: impl AsArg<StringName> + 'ex,
) -> ExGetMeta<'ex>
pub fn get_meta_ex<'ex>( &'ex self, name: impl AsArg<StringName> + 'ex, ) -> ExGetMeta<'ex>
Returns the object’s metadata value for the given entry name. If the entry does not exist, returns default. If default is null, an error is also generated.
Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.
Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.
pub fn has_meta(&self, name: impl AsArg<StringName>) -> bool
pub fn has_meta(&self, name: impl AsArg<StringName>) -> bool
Returns true if a metadata entry is found with the given name. See also get_meta, set_meta and remove_meta.
Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.
Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.
pub fn get_meta_list(&self) -> Array<StringName>
pub fn get_meta_list(&self) -> Array<StringName>
Returns the object’s metadata entry names as an Array of StringNames.
pub fn add_user_signal(&mut self, signal: impl AsArg<GString>)
pub fn add_user_signal(&mut self, signal: impl AsArg<GString>)
To set the default parameters, use add_user_signal_ex and its builder methods. See the book for detailed usage instructions.
Adds a user-defined signal named signal. Optional arguments for the signal can be added as an Array of dictionaries, each defining a name String and a type int (see [enum Variant.Type]). See also has_user_signal and remove_user_signal.
add_user_signal("hurt", [
{ "name": "damage", "type": TYPE_INT },
{ "name": "source", "type": TYPE_OBJECT }
])pub fn add_user_signal_ex<'ex>(
&'ex mut self,
signal: impl AsArg<GString> + 'ex,
) -> ExAddUserSignal<'ex>
pub fn add_user_signal_ex<'ex>( &'ex mut self, signal: impl AsArg<GString> + 'ex, ) -> ExAddUserSignal<'ex>
Adds a user-defined signal named signal. Optional arguments for the signal can be added as an Array of dictionaries, each defining a name String and a type int (see [enum Variant.Type]). See also has_user_signal and remove_user_signal.
add_user_signal("hurt", [
{ "name": "damage", "type": TYPE_INT },
{ "name": "source", "type": TYPE_OBJECT }
])pub fn has_user_signal(&self, signal: impl AsArg<StringName>) -> bool
pub fn has_user_signal(&self, signal: impl AsArg<StringName>) -> bool
Returns true if the given user-defined signal name exists. Only signals added with add_user_signal are included. See also remove_user_signal.
pub fn remove_user_signal(&mut self, signal: impl AsArg<StringName>)
pub fn remove_user_signal(&mut self, signal: impl AsArg<StringName>)
Removes the given user signal signal from the object. See also add_user_signal and has_user_signal.
pub fn emit_signal(
&mut self,
signal: impl AsArg<StringName>,
varargs: &[Variant],
) -> Error
pub fn emit_signal( &mut self, signal: impl AsArg<StringName>, varargs: &[Variant], ) -> Error
Emits the given signal by name. The signal must exist, so it should be a built-in signal of this class or one of its inherited classes, or a user-defined signal (see add_user_signal). This method supports a variable number of arguments, so parameters can be passed as a comma separated list.
Returns Error::ERR_UNAVAILABLE if signal does not exist or the parameters are invalid.
emit_signal("hit", "sword", 100)
emit_signal("game_over")Note: In C#, signal must be in snake_case when referring to built-in Godot signals. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.
§Panics
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will panic in such a case.
pub fn try_emit_signal(
&mut self,
signal: impl AsArg<StringName>,
varargs: &[Variant],
) -> Result<Error, CallError>
pub fn try_emit_signal( &mut self, signal: impl AsArg<StringName>, varargs: &[Variant], ) -> Result<Error, CallError>
§Return type
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will return Err in such a case.
pub fn call(
&mut self,
method: impl AsArg<StringName>,
varargs: &[Variant],
) -> Variant
pub fn call( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Variant
Calls the method on the object and returns the result. This method supports a variable number of arguments, so parameters can be passed as a comma separated list.
var node = Node3D.new()
node.call("rotate", Vector3(1.0, 0.0, 0.0), 1.571)Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.
§Panics
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will panic in such a case.
pub fn try_call(
&mut self,
method: impl AsArg<StringName>,
varargs: &[Variant],
) -> Result<Variant, CallError>
pub fn try_call( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Result<Variant, CallError>
§Return type
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will return Err in such a case.
pub fn call_deferred(
&mut self,
method: impl AsArg<StringName>,
varargs: &[Variant],
) -> Variant
pub fn call_deferred( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Variant
Calls the method on the object during idle time. Always returns null, not the method’s result.
Idle time happens mainly at the end of process and physics frames. In it, deferred calls will be run until there are none left, which means you can defer calls from other deferred calls and they’ll still be run in the current idle time cycle. This means you should not call a method deferred from itself (or from a method called by it), as this causes infinite recursion the same way as if you had called the method directly.
This method supports a variable number of arguments, so parameters can be passed as a comma separated list.
var node = Node3D.new()
node.call_deferred("rotate", Vector3(1.0, 0.0, 0.0), 1.571)For methods that are deferred from the same thread, the order of execution at idle time is identical to the order in which call_deferred was called.
See also call_deferred.
Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.
Note: If you’re looking to delay the function call by a frame, refer to the SceneTree.process_frame and SceneTree.physics_frame signals.
var node = Node3D.new()
# Make a Callable and bind the arguments to the node's rotate() call.
var callable = node.rotate.bind(Vector3(1.0, 0.0, 0.0), 1.571)
# Connect the callable to the process_frame signal, so it gets called in the next process frame.
# CONNECT_ONE_SHOT makes sure it only gets called once instead of every frame.
get_tree().process_frame.connect(callable, CONNECT_ONE_SHOT)§Panics
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will panic in such a case.
pub fn try_call_deferred(
&mut self,
method: impl AsArg<StringName>,
varargs: &[Variant],
) -> Result<Variant, CallError>
pub fn try_call_deferred( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Result<Variant, CallError>
§Return type
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will return Err in such a case.
pub fn set_deferred(
&mut self,
property: impl AsArg<StringName>,
value: &Variant,
)
pub fn set_deferred( &mut self, property: impl AsArg<StringName>, value: &Variant, )
Assigns value to the given property, at the end of the current frame. This is equivalent to calling set through call_deferred.
var node = Node2D.new()
add_child(node)
node.rotation = 1.5
node.set_deferred("rotation", 3.0)
print(node.rotation) # Prints 1.5
await get_tree().process_frame
print(node.rotation) # Prints 3.0Note: In C#, property must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.
pub fn callv(
&mut self,
method: impl AsArg<StringName>,
arg_array: &AnyArray,
) -> Variant
pub fn callv( &mut self, method: impl AsArg<StringName>, arg_array: &AnyArray, ) -> Variant
Calls the method on the object and returns the result. Unlike call, this method expects all parameters to be contained inside arg_array.
var node = Node3D.new()
node.callv("rotate", [Vector3(1.0, 0.0, 0.0), 1.571])Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.
pub fn has_method(&self, method: impl AsArg<StringName>) -> bool
pub fn has_method(&self, method: impl AsArg<StringName>) -> bool
Returns true if the given method name exists in the object.
Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.
pub fn get_method_argument_count(&self, method: impl AsArg<StringName>) -> i32
pub fn get_method_argument_count(&self, method: impl AsArg<StringName>) -> i32
Returns the number of arguments of the given method by name.
Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.
pub fn has_signal(&self, signal: impl AsArg<StringName>) -> bool
pub fn has_signal(&self, signal: impl AsArg<StringName>) -> bool
Returns true if the given signal name exists in the object.
Note: In C#, signal must be in snake_case when referring to built-in Godot signals. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.
pub fn get_signal_list(&self) -> Array<Dictionary<Variant, Variant>>
pub fn get_signal_list(&self) -> Array<Dictionary<Variant, Variant>>
Returns the list of existing signals as an Array of dictionaries.
Note: Due to the implementation, each Dictionary is formatted very similarly to the returned values of get_method_list.
pub fn get_signal_connection_list(
&self,
signal: impl AsArg<StringName>,
) -> Array<Dictionary<Variant, Variant>>
pub fn get_signal_connection_list( &self, signal: impl AsArg<StringName>, ) -> Array<Dictionary<Variant, Variant>>
Returns an Array of connections for the given signal name. Each connection is represented as a Dictionary that contains three entries:
pub fn get_incoming_connections(&self) -> Array<Dictionary<Variant, Variant>>
pub fn get_incoming_connections(&self) -> Array<Dictionary<Variant, Variant>>
Returns an Array of signal connections received by this object. Each connection is represented as a Dictionary that contains three entries:
pub fn disconnect(
&mut self,
signal: impl AsArg<StringName>,
callable: &Callable,
)
pub fn disconnect( &mut self, signal: impl AsArg<StringName>, callable: &Callable, )
Disconnects a signal by name from a given callable. If the connection does not exist, generates an error. Use is_connected to make sure that the connection exists.
pub fn is_connected(
&self,
signal: impl AsArg<StringName>,
callable: &Callable,
) -> bool
pub fn is_connected( &self, signal: impl AsArg<StringName>, callable: &Callable, ) -> bool
Returns true if a connection exists between the given signal name and callable.
Note: In C#, signal must be in snake_case when referring to built-in Godot signals. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.
pub fn has_connections(&self, signal: impl AsArg<StringName>) -> bool
pub fn has_connections(&self, signal: impl AsArg<StringName>) -> bool
Returns true if any connection exists on the given signal name.
Note: In C#, signal must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.
pub fn set_block_signals(&mut self, enable: bool)
pub fn set_block_signals(&mut self, enable: bool)
If set to true, the object becomes unable to emit signals. As such, emit_signal and signal connections will not work, until it is set to false.
pub fn is_blocking_signals(&self) -> bool
pub fn is_blocking_signals(&self) -> bool
Returns true if the object is blocking its signals from being emitted. See set_block_signals.
pub fn notify_property_list_changed(&mut self)
pub fn notify_property_list_changed(&mut self)
Emits the property_list_changed signal. This is mainly used to refresh the editor, so that the Inspector and editor plugins are properly updated.
pub fn set_message_translation(&mut self, enable: bool)
pub fn set_message_translation(&mut self, enable: bool)
If set to true, allows the object to translate messages with tr and tr_n. Enabled by default. See also can_translate_messages.
pub fn can_translate_messages(&self) -> bool
pub fn can_translate_messages(&self) -> bool
Returns true if the object is allowed to translate messages with tr and tr_n. See also set_message_translation.
pub fn tr(&self, message: impl AsArg<StringName>) -> GString
pub fn tr(&self, message: impl AsArg<StringName>) -> GString
To set the default parameters, use tr_ex and its builder methods. See the book for detailed usage instructions.
Translates a message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation. Note that most Control nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.
If can_translate_messages is false, or no translation is available, this method returns the message without changes. See set_message_translation.
For detailed examples, see Internationalizing games.
Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate.
pub fn tr_ex<'ex>(&'ex self, message: impl AsArg<StringName> + 'ex) -> ExTr<'ex>
pub fn tr_ex<'ex>(&'ex self, message: impl AsArg<StringName> + 'ex) -> ExTr<'ex>
Translates a message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation. Note that most Control nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.
If can_translate_messages is false, or no translation is available, this method returns the message without changes. See set_message_translation.
For detailed examples, see Internationalizing games.
Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate.
pub fn tr_n(
&self,
message: impl AsArg<StringName>,
plural_message: impl AsArg<StringName>,
n: i32,
) -> GString
pub fn tr_n( &self, message: impl AsArg<StringName>, plural_message: impl AsArg<StringName>, n: i32, ) -> GString
To set the default parameters, use tr_n_ex and its builder methods. See the book for detailed usage instructions.
Translates a message or plural_message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation.
If can_translate_messages is false, or no translation is available, this method returns message or plural_message, without changes. See set_message_translation.
The n is the number, or amount, of the message’s subject. It is used by the translation system to fetch the correct plural form for the current language.
For detailed examples, see Localization using gettext.
Note: Negative and float numbers may not properly apply to some countable subjects. It’s recommended to handle these cases with tr.
Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate_plural.
pub fn tr_n_ex<'ex>(
&'ex self,
message: impl AsArg<StringName> + 'ex,
plural_message: impl AsArg<StringName> + 'ex,
n: i32,
) -> ExTrN<'ex>
pub fn tr_n_ex<'ex>( &'ex self, message: impl AsArg<StringName> + 'ex, plural_message: impl AsArg<StringName> + 'ex, n: i32, ) -> ExTrN<'ex>
Translates a message or plural_message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation.
If can_translate_messages is false, or no translation is available, this method returns message or plural_message, without changes. See set_message_translation.
The n is the number, or amount, of the message’s subject. It is used by the translation system to fetch the correct plural form for the current language.
For detailed examples, see Localization using gettext.
Note: Negative and float numbers may not properly apply to some countable subjects. It’s recommended to handle these cases with tr.
Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate_plural.
pub fn get_translation_domain(&self) -> StringName
pub fn get_translation_domain(&self) -> StringName
Returns the name of the translation domain used by tr and tr_n. See also TranslationServer.
pub fn set_translation_domain(&mut self, domain: impl AsArg<StringName>)
pub fn set_translation_domain(&mut self, domain: impl AsArg<StringName>)
Sets the name of the translation domain used by tr and tr_n. See also TranslationServer.
pub fn is_queued_for_deletion(&self) -> bool
pub fn is_queued_for_deletion(&self) -> bool
Returns true if the queue_free method was called for the object.
pub fn cancel_free(&mut self)
pub fn cancel_free(&mut self)
If this method is called during ObjectNotification::PREDELETE, this object will reject being freed and will remain allocated. This is mostly an internal function used for error handling to avoid the user from freeing objects when they are not intended to.
pub fn notify(&mut self, what: ObjectNotification)
pub fn notify(&mut self, what: ObjectNotification)
⚠️ Sends a Godot notification to all classes inherited by the object.
Triggers calls to on_notification(), and depending on the notification, also to Godot’s lifecycle callbacks such as ready().
Starts from the highest ancestor (the Object class) and goes down the hierarchy.
See also Godot docs for Object::notification().
§Panics
If you call this method on a user-defined object while holding a GdRef or GdMut guard on the instance, you will encounter
a panic. The reason is that the receiving virtual method on_notification() acquires a GdMut lock dynamically, which must
be exclusive.
pub fn notify_reversed(&mut self, what: ObjectNotification)
pub fn notify_reversed(&mut self, what: ObjectNotification)
⚠️ Like Self::notify(), but starts at the most-derived class and goes up the hierarchy.
See docs of that method, including the panics.
Trait Implementations§
§impl Bounds for RenderingDevice
impl Bounds for RenderingDevice
§impl Debug for RenderingDevice
impl Debug for RenderingDevice
§impl Deref for RenderingDevice
impl Deref for RenderingDevice
§impl DerefMut for RenderingDevice
impl DerefMut for RenderingDevice
§fn deref_mut(&mut self) -> &mut <RenderingDevice as Deref>::Target
fn deref_mut(&mut self) -> &mut <RenderingDevice as Deref>::Target
§impl GodotClass for RenderingDevice
impl GodotClass for RenderingDevice
§const INIT_LEVEL: InitLevel = crate::init::InitLevel::Scene
const INIT_LEVEL: InitLevel = crate::init::InitLevel::Scene
§fn class_id() -> ClassId
fn class_id() -> ClassId
§fn inherits<Base>() -> boolwhere
Base: GodotClass,
fn inherits<Base>() -> boolwhere
Base: GodotClass,
§impl Inherits<Object> for RenderingDevice
impl Inherits<Object> for RenderingDevice
§const IS_SAME_CLASS: bool = false
const IS_SAME_CLASS: bool = false
Self == Base. Read more§impl WithSignals for RenderingDevice
impl WithSignals for RenderingDevice
§type SignalCollection<'c, C: WithSignals> = SignalsOfObject<'c, C>
type SignalCollection<'c, C: WithSignals> = SignalsOfObject<'c, C>
Auto Trait Implementations§
impl Freeze for RenderingDevice
impl RefUnwindSafe for RenderingDevice
impl !Send for RenderingDevice
impl !Sync for RenderingDevice
impl Unpin for RenderingDevice
impl UnsafeUnpin for RenderingDevice
impl UnwindSafe for RenderingDevice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Inherits<T> for Twhere
T: GodotClass,
impl<T> Inherits<T> for Twhere
T: GodotClass,
§const IS_SAME_CLASS: bool = true
const IS_SAME_CLASS: bool = true
Self == Base. Read more