浏览代码

If Direct3D doesn't initialize, try OpenGL

jp9000 11 年之前
父节点
当前提交
3a2677c502
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      obs/window-basic-main.cpp

+ 14 - 0
obs/window-basic-main.cpp

@@ -1196,6 +1196,12 @@ void OBSBasic::SetService(obs_service_t newService)
 	}
 	}
 }
 }
 
 
+#ifdef _WIN32
+#define IS_WIN32 1
+#else
+#define IS_WIN32 0
+#endif
+
 static inline int AttemptToResetVideo(struct obs_video_info *ovi)
 static inline int AttemptToResetVideo(struct obs_video_info *ovi)
 {
 {
 	int ret = obs_reset_video(ovi);
 	int ret = obs_reset_video(ovi);
@@ -1247,6 +1253,14 @@ int OBSBasic::ResetVideo()
 	ovi.window_height = size.height();
 	ovi.window_height = size.height();
 
 
 	ret = AttemptToResetVideo(&ovi);
 	ret = AttemptToResetVideo(&ovi);
+	if (IS_WIN32 && ret != OBS_VIDEO_SUCCESS) {
+		/* Try OpenGL if DirectX fails on windows */
+		if (astrcmpi(ovi.graphics_module, "libobs-opengl") != 0) {
+			ovi.graphics_module = "libobs-opengl";
+			ret = AttemptToResetVideo(&ovi);
+		}
+	}
+
 	if (ret == OBS_VIDEO_SUCCESS)
 	if (ret == OBS_VIDEO_SUCCESS)
 		obs_add_draw_callback(OBSBasic::RenderMain, this);
 		obs_add_draw_callback(OBSBasic::RenderMain, this);