Browse Source

Warn when using GPU particles with GLES2

Closes #25733.
Rémi Verschelde 6 năm trước cách đây
mục cha
commit
034cd62a77
3 tập tin đã thay đổi với 18 bổ sung6 xóa
  1. 7 6
      core/os/os.h
  2. 5 0
      scene/2d/particles_2d.cpp
  3. 6 0
      scene/3d/particles.cpp

+ 7 - 6
core/os/os.h

@@ -45,12 +45,6 @@
 	@author Juan Linietsky <[email protected]>
 */
 
-enum VideoDriver {
-	VIDEO_DRIVER_GLES3,
-	VIDEO_DRIVER_GLES2,
-	VIDEO_DRIVER_MAX,
-};
-
 class OS {
 
 	static OS *singleton;
@@ -184,9 +178,16 @@ public:
 	virtual VideoMode get_video_mode(int p_screen = 0) const = 0;
 	virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const = 0;
 
+	enum VideoDriver {
+		VIDEO_DRIVER_GLES3,
+		VIDEO_DRIVER_GLES2,
+		VIDEO_DRIVER_MAX,
+	};
+
 	virtual int get_video_driver_count() const;
 	virtual const char *get_video_driver_name(int p_driver) const;
 	virtual int get_current_video_driver() const = 0;
+
 	virtual int get_audio_driver_count() const;
 	virtual const char *get_audio_driver_name(int p_driver) const;
 

+ 5 - 0
scene/2d/particles_2d.cpp

@@ -30,6 +30,7 @@
 
 #include "particles_2d.h"
 
+#include "core/os/os.h"
 #include "scene/resources/particles_material.h"
 #include "scene/scene_string_names.h"
 
@@ -213,6 +214,10 @@ bool Particles2D::get_fractional_delta() const {
 
 String Particles2D::get_configuration_warning() const {
 
+	if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
+		return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles2D node instead. You can use the \"Convert to CPUParticles\" option for this purpose.");
+	}
+
 	String warnings;
 
 	if (process_material.is_null()) {

+ 6 - 0
scene/3d/particles.cpp

@@ -29,6 +29,8 @@
 /*************************************************************************/
 
 #include "particles.h"
+
+#include "core/os/os.h"
 #include "scene/resources/particles_material.h"
 
 #include "servers/visual_server.h"
@@ -224,6 +226,10 @@ bool Particles::get_fractional_delta() const {
 
 String Particles::get_configuration_warning() const {
 
+	if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
+		return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles node instead. You can use the \"Convert to CPUParticles\" option for this purpose.");
+	}
+
 	String warnings;
 
 	bool meshes_found = false;