diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2019-09-13 20:08:05 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2020-01-06 00:37:56 +0100 |
commit | 0cad2c0cd103a7d616d55e4d5c973a20f398115f (patch) | |
tree | fcd956c7c349397a62c8c9ede96f5d1812b0980e | |
parent | 61dd7748cafafca08b8f87183ddf42de06b58911 (diff) |
Add VisualServer methods to get the video adapter name and vendor
These methods can be used in scripts to retrieve the OpenGL
`GL_RENDERER` and `GL_VENDOR` strings (respectively).
This closes #28404.
-rw-r--r-- | doc/classes/VisualServer.xml | 16 | ||||
-rw-r--r-- | drivers/dummy/rasterizer_dummy.h | 2 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 3 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_storage_gles2.cpp | 10 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_storage_gles2.h | 2 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_gles3.cpp | 3 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 10 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.h | 2 | ||||
-rw-r--r-- | servers/visual/rasterizer.h | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 10 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 8 | ||||
-rw-r--r-- | servers/visual_server.cpp | 2 | ||||
-rw-r--r-- | servers/visual_server.h | 2 |
14 files changed, 70 insertions, 4 deletions
diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml index 5c29601134..8d60da7a3f 100644 --- a/doc/classes/VisualServer.xml +++ b/doc/classes/VisualServer.xml @@ -1397,6 +1397,22 @@ Returns the id of the test texture. Creates one if none exists. </description> </method> + <method name="get_video_adapter_name" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns the name of the video adapter (e.g. "GeForce GTX 1080/PCIe/SSE2"). + [b]Note:[/b] When running a headless or server binary, this function returns an empty string. + </description> + </method> + <method name="get_video_adapter_vendor" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns the vendor of the video adapter (e.g. "NVIDIA Corporation"). + [b]Note:[/b] When running a headless or server binary, this function returns an empty string. + </description> + </method> <method name="get_white_texture"> <return type="RID"> </return> diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index 167159c7e9..00758a73a4 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -742,6 +742,8 @@ public: int get_captured_render_info(VS::RenderInfo p_info) { return 0; } int get_render_info(VS::RenderInfo p_info) { return 0; } + String get_video_adapter_name() const { return String(); } + String get_video_adapter_vendor() const { return String(); } static RasterizerStorage *base_singleton; diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index cac124ff5f..c4e9541a36 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -263,8 +263,7 @@ void RasterizerGLES2::initialize() { #endif // GLES_OVER_GL #endif // CAN_DEBUG - const GLubyte *renderer = glGetString(GL_RENDERER); - print_line("OpenGL ES 2.0 Renderer: " + String((const char *)renderer)); + print_line("OpenGL ES 2.0 Renderer: " + VisualServer::get_singleton()->get_video_adapter_name()); storage->initialize(); canvas->initialize(); scene->initialize(); diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 94a7d4e1b5..bb087a7f47 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -5766,6 +5766,16 @@ int RasterizerStorageGLES2::get_render_info(VS::RenderInfo p_info) { } } +String RasterizerStorageGLES2::get_video_adapter_name() const { + + return (const char *)glGetString(GL_RENDERER); +} + +String RasterizerStorageGLES2::get_video_adapter_vendor() const { + + return (const char *)glGetString(GL_VENDOR); +} + void RasterizerStorageGLES2::initialize() { RasterizerStorageGLES2::system_fbo = 0; diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index 62926ce713..83697b9872 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -1307,6 +1307,8 @@ public: virtual int get_captured_render_info(VS::RenderInfo p_info); virtual int get_render_info(VS::RenderInfo p_info); + virtual String get_video_adapter_name() const; + virtual String get_video_adapter_vendor() const; RasterizerStorageGLES2(); }; diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index d428fe33ee..ef2c318807 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -186,8 +186,7 @@ void RasterizerGLES3::initialize() { } */ - const GLubyte *renderer = glGetString(GL_RENDERER); - print_line("OpenGL ES 3.0 Renderer: " + String((const char *)renderer)); + print_line("OpenGL ES 3.0 Renderer: " + VisualServer::get_singleton()->get_video_adapter_name()); storage->initialize(); canvas->initialize(); scene->initialize(); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index bf742f4d25..c02f17ab95 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -8095,6 +8095,16 @@ int RasterizerStorageGLES3::get_render_info(VS::RenderInfo p_info) { } } +String RasterizerStorageGLES3::get_video_adapter_name() const { + + return (const char *)glGetString(GL_RENDERER); +} + +String RasterizerStorageGLES3::get_video_adapter_vendor() const { + + return (const char *)glGetString(GL_VENDOR); +} + void RasterizerStorageGLES3::initialize() { RasterizerStorageGLES3::system_fbo = 0; diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 833cdb4a94..bd853852fe 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -1467,6 +1467,8 @@ public: virtual int get_captured_render_info(VS::RenderInfo p_info); virtual int get_render_info(VS::RenderInfo p_info); + virtual String get_video_adapter_name() const; + virtual String get_video_adapter_vendor() const; RasterizerStorageGLES3(); }; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 74741a946c..0008b809b7 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -588,6 +588,8 @@ public: virtual int get_captured_render_info(VS::RenderInfo p_info) = 0; virtual int get_render_info(VS::RenderInfo p_info) = 0; + virtual String get_video_adapter_name() const = 0; + virtual String get_video_adapter_vendor() const = 0; static RasterizerStorage *base_singleton; RasterizerStorage(); diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 4d680667cb..23736b5e63 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -153,6 +153,16 @@ int VisualServerRaster::get_render_info(RenderInfo p_info) { return VSG::storage->get_render_info(p_info); } +String VisualServerRaster::get_video_adapter_name() const { + + return VSG::storage->get_video_adapter_name(); +} + +String VisualServerRaster::get_video_adapter_vendor() const { + + return VSG::storage->get_video_adapter_vendor(); +} + /* TESTING */ void VisualServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 54c46b1812..1a1e86833e 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -680,6 +680,8 @@ public: /* STATUS INFORMATION */ virtual int get_render_info(RenderInfo p_info); + virtual String get_video_adapter_name() const; + virtual String get_video_adapter_vendor() const; virtual RID get_test_cube(); diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index f5875f4fad..9535c7f50d 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -602,6 +602,14 @@ public: return visual_server->get_render_info(p_info); } + virtual String get_video_adapter_name() const { + return visual_server->get_video_adapter_name(); + } + + virtual String get_video_adapter_vendor() const { + return visual_server->get_video_adapter_vendor(); + } + FUNC4(set_boot_image, const Ref<Image> &, const Color &, bool, bool) FUNC1(set_default_clear_color, const Color &) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 1f72848b15..b9b492e758 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -2032,6 +2032,8 @@ void VisualServer::_bind_methods() { ClassDB::bind_method(D_METHOD("init"), &VisualServer::init); ClassDB::bind_method(D_METHOD("finish"), &VisualServer::finish); ClassDB::bind_method(D_METHOD("get_render_info", "info"), &VisualServer::get_render_info); + ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &VisualServer::get_video_adapter_name); + ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &VisualServer::get_video_adapter_vendor); #ifndef _3D_DISABLED ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &VisualServer::make_sphere_mesh); diff --git a/servers/visual_server.h b/servers/visual_server.h index 9aeee731b3..33a9e8d72b 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -1017,6 +1017,8 @@ public: }; virtual int get_render_info(RenderInfo p_info) = 0; + virtual String get_video_adapter_name() const = 0; + virtual String get_video_adapter_vendor() const = 0; /* Materials for 2D on 3D */ |