Browse Source

add code to select renderer

jp9000 12 years ago
parent
commit
197c56c9ae
3 changed files with 46 additions and 6 deletions
  1. 8 0
      obs/obs-app.cpp
  2. 5 6
      obs/platform-windows.cpp
  3. 33 0
      obs/settings-basic-video.cpp

+ 8 - 0
obs/obs-app.cpp

@@ -69,6 +69,14 @@ bool OBSApp::InitGlobalConfigDefaults()
 	uint32_t cx = monitors[0].cx;
 	uint32_t cy = monitors[0].cy;
 
+#if _WIN32
+	config_set_default_string(globalConfig, "Video", "Renderer",
+			"Direct3D 11");
+#else
+	config_set_default_string(globalConfig, "Video", "Renderer",
+			"OpenGL");
+#endif
+
 	config_set_default_uint(globalConfig, "Video", "BaseCX",   cx);
 	config_set_default_uint(globalConfig, "Video", "BaseCY",   cy);
 

+ 5 - 6
obs/platform-windows.cpp

@@ -36,12 +36,11 @@ static BOOL CALLBACK OBSMonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor,
 {
 	vector<MonitorInfo> &monitors = *(vector<MonitorInfo> *)param;
 
-	MonitorInfo monitor;
-	monitor.x  = rect->left;
-	monitor.y  = rect->top;
-	monitor.cx = rect->right - rect->left;
-	monitor.cy = rect->bottom - rect->top;
-	monitors.push_back(monitor);
+	monitors.emplace_back(
+			rect->left,
+			rect->top,
+			rect->right - rect->left,
+			rect->bottom - rect->top);
 	return true;
 }
 

+ 33 - 0
obs/settings-basic-video.cpp

@@ -30,6 +30,7 @@ class BasicVideoData : public BasicSettingsData {
 	ConnectorList connections;
 
 	int AddRes(uint32_t cx, uint32_t cy);
+	void LoadOther();
 	void LoadResolutionData();
 	void LoadFPSData();
 	void LoadFPSCommon();
@@ -41,6 +42,7 @@ class BasicVideoData : public BasicSettingsData {
 	void BaseResListChanged(wxCommandEvent &event);
 	void OutputResListChanged(wxCommandEvent &event);
 
+	void SaveOther();
 	void SaveFPSData();
 	void SaveFPSCommon();
 	void SaveFPSInteger();
@@ -107,6 +109,24 @@ int BasicVideoData::AddRes(uint32_t cx, uint32_t cy)
 	return window->baseResList->Append(res.str().c_str());
 }
 
+void BasicVideoData::LoadOther()
+{
+	const char *renderer = config_get_string(GetGlobalConfig(), "Video",
+			"Renderer");
+
+	window->rendererList->Clear();
+	window->rendererList->Append("OpenGL");
+#ifdef _WIN32
+	window->rendererList->Append("Direct3D 11");
+#endif
+
+	int sel = window->rendererList->FindString(renderer);
+	if (sel == wxNOT_FOUND)
+		sel = 0;
+
+	window->rendererList->SetSelection(sel);
+}
+
 void BasicVideoData::LoadResolutionData()
 {
 	window->baseResList->Clear();
@@ -243,6 +263,7 @@ BasicVideoData::BasicVideoData(OBSBasicSettings *window)
 {
 	LoadResolutionData();
 	LoadFPSData();
+	LoadOther();
 
 	/* load connectors after loading data to prevent them from triggering */
 	connections.Add(window->baseResList, wxEVT_TEXT,
@@ -289,6 +310,17 @@ void BasicVideoData::OutputResListChanged(wxCommandEvent &event)
 	window->videoChangedText->Show();
 }
 
+void BasicVideoData::SaveOther()
+{
+	int sel = window->rendererList->GetSelection();
+	if (sel == wxNOT_FOUND)
+		return;
+
+	wxString renderer = window->rendererList->GetString(sel);
+	config_set_string(GetGlobalConfig(), "Video", "Renderer",
+			renderer.c_str());
+}
+
 void BasicVideoData::SaveFPSData()
 {
 	int id = window->fpsTypeList->GetCurrentPage()->GetId();
@@ -302,6 +334,7 @@ void BasicVideoData::SaveFPSData()
 	}
 
 	config_set_string(GetGlobalConfig(), "Video", "FPSType", type);
+	SaveOther();
 	SaveFPSCommon();
 	SaveFPSInteger();
 	SaveFPSFraction();