|
@@ -119,13 +119,9 @@ OBSBasic::~OBSBasic()
|
|
|
|
|
|
bool OBSBasic::InitGraphics()
|
|
bool OBSBasic::InitGraphics()
|
|
{
|
|
{
|
|
- wxSize size = previewPanel->GetClientSize();
|
|
|
|
-
|
|
|
|
struct obs_video_info ovi;
|
|
struct obs_video_info ovi;
|
|
wxGetApp().GetConfigFPS(ovi.fps_num, ovi.fps_den);
|
|
wxGetApp().GetConfigFPS(ovi.fps_num, ovi.fps_den);
|
|
ovi.graphics_module = wxGetApp().GetRenderModule();
|
|
ovi.graphics_module = wxGetApp().GetRenderModule();
|
|
- ovi.window_width = size.x;
|
|
|
|
- ovi.window_height = size.y;
|
|
|
|
ovi.base_width = (uint32_t)config_get_uint(GetGlobalConfig(),
|
|
ovi.base_width = (uint32_t)config_get_uint(GetGlobalConfig(),
|
|
"Video", "BaseCX");
|
|
"Video", "BaseCX");
|
|
ovi.base_height = (uint32_t)config_get_uint(GetGlobalConfig(),
|
|
ovi.base_height = (uint32_t)config_get_uint(GetGlobalConfig(),
|
|
@@ -138,12 +134,17 @@ bool OBSBasic::InitGraphics()
|
|
ovi.adapter = 0;
|
|
ovi.adapter = 0;
|
|
ovi.window = WxToGSWindow(previewPanel);
|
|
ovi.window = WxToGSWindow(previewPanel);
|
|
|
|
|
|
- if (!obs_reset_video(&ovi))
|
|
|
|
- return false;
|
|
|
|
-
|
|
|
|
//required to make opengl display stuff on osx(?)
|
|
//required to make opengl display stuff on osx(?)
|
|
|
|
+ ResizePreview(ovi.base_width, ovi.base_height);
|
|
SendSizeEvent();
|
|
SendSizeEvent();
|
|
|
|
|
|
|
|
+ wxSize size = previewPanel->GetMinSize();
|
|
|
|
+ ovi.window_width = size.x;
|
|
|
|
+ ovi.window_height = size.y;
|
|
|
|
+
|
|
|
|
+ if (!obs_reset_video(&ovi))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -158,19 +159,12 @@ void OBSBasic::OnMinimize(wxIconizeEvent &event)
|
|
event.Skip();
|
|
event.Skip();
|
|
}
|
|
}
|
|
|
|
|
|
-void OBSBasic::OnSize(wxSizeEvent &event)
|
|
|
|
|
|
+void OBSBasic::ResizePreview(uint32_t cx, uint32_t cy)
|
|
{
|
|
{
|
|
- struct obs_video_info ovi;
|
|
|
|
-
|
|
|
|
- event.Skip();
|
|
|
|
-
|
|
|
|
- if (!obs_get_video_info(&ovi))
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
/* resize preview panel to fix to the top section of the window */
|
|
/* resize preview panel to fix to the top section of the window */
|
|
wxSize targetSize = GetPreviewContainer()->GetSize();
|
|
wxSize targetSize = GetPreviewContainer()->GetSize();
|
|
double targetAspect = double(targetSize.x) / double(targetSize.y);
|
|
double targetAspect = double(targetSize.x) / double(targetSize.y);
|
|
- double baseAspect = double(ovi.base_width) / double(ovi.base_height);
|
|
|
|
|
|
+ double baseAspect = double(cx) / double(cy);
|
|
wxSize newSize;
|
|
wxSize newSize;
|
|
|
|
|
|
if (targetAspect > baseAspect)
|
|
if (targetAspect > baseAspect)
|
|
@@ -179,6 +173,20 @@ void OBSBasic::OnSize(wxSizeEvent &event)
|
|
newSize = wxSize(targetSize.x, targetSize.x / baseAspect);
|
|
newSize = wxSize(targetSize.x, targetSize.x / baseAspect);
|
|
|
|
|
|
GetPreviewPanel()->SetMinSize(newSize);
|
|
GetPreviewPanel()->SetMinSize(newSize);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void OBSBasic::OnSize(wxSizeEvent &event)
|
|
|
|
+{
|
|
|
|
+ struct obs_video_info ovi;
|
|
|
|
+
|
|
|
|
+ event.Skip();
|
|
|
|
+
|
|
|
|
+ if (!obs_get_video_info(&ovi))
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ ResizePreview(ovi.base_width, ovi.base_height);
|
|
|
|
+ wxSize newSize = previewPanel->GetMinSize();
|
|
|
|
+
|
|
gs_entercontext(obs_graphics());
|
|
gs_entercontext(obs_graphics());
|
|
gs_resize(newSize.x, newSize.y);
|
|
gs_resize(newSize.x, newSize.y);
|
|
gs_leavecontext();
|
|
gs_leavecontext();
|