提交 c71eb041 编写于 作者: J jp9000

fix startup resize issue on osx

上级 e2a11862
......@@ -119,13 +119,9 @@ OBSBasic::~OBSBasic()
bool OBSBasic::InitGraphics()
{
wxSize size = previewPanel->GetClientSize();
struct obs_video_info ovi;
wxGetApp().GetConfigFPS(ovi.fps_num, ovi.fps_den);
ovi.graphics_module = wxGetApp().GetRenderModule();
ovi.window_width = size.x;
ovi.window_height = size.y;
ovi.base_width = (uint32_t)config_get_uint(GetGlobalConfig(),
"Video", "BaseCX");
ovi.base_height = (uint32_t)config_get_uint(GetGlobalConfig(),
......@@ -138,12 +134,17 @@ bool OBSBasic::InitGraphics()
ovi.adapter = 0;
ovi.window = WxToGSWindow(previewPanel);
if (!obs_reset_video(&ovi))
return false;
//required to make opengl display stuff on osx(?)
ResizePreview(ovi.base_width, ovi.base_height);
SendSizeEvent();
wxSize size = previewPanel->GetMinSize();
ovi.window_width = size.x;
ovi.window_height = size.y;
if (!obs_reset_video(&ovi))
return false;
return true;
}
......@@ -158,19 +159,12 @@ void OBSBasic::OnMinimize(wxIconizeEvent &event)
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 */
wxSize targetSize = GetPreviewContainer()->GetSize();
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;
if (targetAspect > baseAspect)
......@@ -179,6 +173,20 @@ void OBSBasic::OnSize(wxSizeEvent &event)
newSize = wxSize(targetSize.x, targetSize.x / baseAspect);
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_resize(newSize.x, newSize.y);
gs_leavecontext();
......
......@@ -28,6 +28,8 @@ class OBSBasic : public OBSBasicBase {
static void SourceAdded(void *data, calldata_t params);
static void SourceDestroyed(void *data, calldata_t params);
void ResizePreview(uint32_t cx, uint32_t cy);
void AddSource(obs_scene_t scene, const char *id);
void AddSourcePopup();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册