RenderingServer::create_local_rendering_device null check and docs

Co-authored-by: Clay John <claynjohn@gmail.com>
This commit is contained in:
dzil123 2022-11-19 03:22:27 -08:00
parent 84c404f6bc
commit 9ce9c959ab
2 changed files with 9 additions and 1 deletions

View File

@ -838,6 +838,8 @@
<method name="create_local_rendering_device" qualifiers="const">
<return type="RenderingDevice" />
<description>
Creates a RenderingDevice that can be used to do draw and compute operations on a separate thread. Cannot draw to the screen nor share data with the global RenderingDevice.
[b]Note:[/b] When using the OpenGL backend or when running in headless mode, this function always returns [code]null[/code].
</description>
</method>
<method name="decal_create">
@ -1273,6 +1275,8 @@
<method name="get_rendering_device" qualifiers="const">
<return type="RenderingDevice" />
<description>
Returns the global RenderingDevice.
[b]Note:[/b] When using the OpenGL backend or when running in headless mode, this function always returns [code]null[/code].
</description>
</method>
<method name="get_rendering_info">

View File

@ -1476,7 +1476,11 @@ RenderingDevice *RenderingServer::get_rendering_device() const {
}
RenderingDevice *RenderingServer::create_local_rendering_device() const {
return RenderingDevice::get_singleton()->create_local_device();
RenderingDevice *device = RenderingDevice::get_singleton();
if (!device) {
return nullptr;
}
return device->create_local_device();
}
static Vector<Ref<Image>> _get_imgvec(const TypedArray<Image> &p_layers) {