Przeglądaj źródła

use the preview window as the main window associated with the OpenGL context

jp9000 12 lat temu
rodzic
commit
24c45458b5
4 zmienionych plików z 23 dodań i 15 usunięć
  1. 1 1
      build/data/obs-studio/locale/en.txt
  2. 17 5
      libobs/obs-video.c
  3. 5 8
      obs/obs-app.cpp
  4. 0 1
      obs/obs-app.hpp

+ 1 - 1
build/data/obs-studio/locale/en.txt

@@ -42,7 +42,7 @@ Settings.Video.DisableAeroWindows="Disable Aero (Windows only)"
 Settings.Video.FPS="FPS:"
 Settings.Video.FPS.Common="Common FPS Values"
 Settings.Video.FPS.Integer="Integer FPS Value"
-Settings.VIdeo.FPS.Fraction="Frame Interval (fraction)"
+Settings.VIdeo.FPS.Fraction="Fractional FPS Value"
 Settings.Video.FPS.Nanoseconds="Frame Interval (nanoseconds)"
 Settings.Video.FPS.Numerator="Numerator:"
 Settings.Video.FPS.Denominator="Denominator:"

+ 17 - 5
libobs/obs-video.c

@@ -36,11 +36,10 @@ static void tick_sources(uint64_t cur_time, uint64_t *last_time)
 	*last_time = cur_time;
 }
 
-static inline void render_display(struct obs_display *display)
+static inline void render_begin(struct obs_display *display)
 {
 	struct vec4 clear_color;
 	uint32_t width, height;
-	size_t i;
 
 	gs_load_swapchain(display ? display->swap : NULL);
 
@@ -58,6 +57,19 @@ static inline void render_display(struct obs_display *display)
 	gs_ortho(0.0f, (float)width, 0.0f, (float)height, -100.0f, 100.0f);
 	gs_setviewport(0, 0, width, height);
 
+}
+
+static inline void render_end(struct obs_display *display)
+{
+	gs_endscene();
+	gs_present();
+}
+
+static void render_display(struct obs_display *display)
+{
+	size_t i;
+	render_begin(display);
+
 	for (i = 0; i < MAX_CHANNELS; i++) {
 		struct obs_source **p_source;
 
@@ -74,8 +86,7 @@ static inline void render_display(struct obs_display *display)
 		}
 	}
 
-	gs_endscene();
-	gs_present();
+	render_end(display);
 }
 
 static inline void render_displays(void)
@@ -85,8 +96,9 @@ static inline void render_displays(void)
 	/* render extra displays/swaps */
 	pthread_mutex_lock(&obs->data.displays_mutex);
 
-	for (i = 0; i < obs->data.displays.num; i++)
+	for (i = 0; i < obs->data.displays.num; i++) {
 		render_display(obs->data.displays.array[i]);
+	}
 
 	pthread_mutex_unlock(&obs->data.displays_mutex);
 

+ 5 - 8
obs/obs-app.cpp

@@ -199,24 +199,24 @@ bool OBSApp::OnInit()
 
 	wxInitAllImageHandlers();
 
-	dummyWindow = new wxFrame(NULL, wxID_ANY, "Dummy Window");
-
 	OBSBasic *mainWindow = new OBSBasic();
 
+	wxSize size = mainWindow->GetPreviewPanel()->GetClientSize();
+
 	/* this is a test */
 	struct obs_video_info ovi;
 	ovi.graphics_module = "libobs-opengl";
 	ovi.fps_num         = 30000;
 	ovi.fps_den         = 1001;
-	ovi.window_width    = 2;
-	ovi.window_height   = 2;
+	ovi.window_width    = size.x;
+	ovi.window_height   = size.y;
 	ovi.base_width      = 1920;
 	ovi.base_height     = 1080;
 	ovi.output_width    = 1280;
 	ovi.output_height   = 720;
 	ovi.output_format   = VIDEO_FORMAT_RGBA;
 	ovi.adapter         = 0;
-	ovi.window          = WxToGSWindow(dummyWindow);
+	ovi.window          = WxToGSWindow(mainWindow->GetPreviewPanel());
 
 	if (!obs_reset_video(&ovi))
 		return false;
@@ -229,9 +229,6 @@ int OBSApp::OnExit()
 {
 	obs_shutdown();
 
-	delete dummyWindow;
-	dummyWindow = NULL;
-
 	return wxApp::OnExit();
 }
 

+ 0 - 1
obs/obs-app.hpp

@@ -29,7 +29,6 @@ public:
 class OBSApp : public OBSAppBase {
 	ConfigFile globalConfig;
 	TextLookup textLookup;
-	wxFrame *dummyWindow;
 
 	bool InitGlobalConfig();
 	bool InitGlobalConfigDefaults();