Merge pull request #68884 from dzil123/create_local_rendering_device_null_check_docs

RenderingServer::create_local_rendering_device - Add null check and update docs
This commit is contained in:
Rémi Verschelde 2022-11-20 11:44:10 +01:00
commit 4a52fb828f
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 9 additions and 1 deletions

View file

@ -838,6 +838,8 @@
<method name="create_local_rendering_device" qualifiers="const"> <method name="create_local_rendering_device" qualifiers="const">
<return type="RenderingDevice" /> <return type="RenderingDevice" />
<description> <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> </description>
</method> </method>
<method name="decal_create"> <method name="decal_create">
@ -1273,6 +1275,8 @@
<method name="get_rendering_device" qualifiers="const"> <method name="get_rendering_device" qualifiers="const">
<return type="RenderingDevice" /> <return type="RenderingDevice" />
<description> <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> </description>
</method> </method>
<method name="get_rendering_info"> <method name="get_rendering_info">

View file

@ -1476,7 +1476,11 @@ RenderingDevice *RenderingServer::get_rendering_device() const {
} }
RenderingDevice *RenderingServer::create_local_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) { static Vector<Ref<Image>> _get_imgvec(const TypedArray<Image> &p_layers) {