@@ -112,6 +112,10 @@ static void drop_callback(GLFWwindow* window, int count, const char** paths) {
112
112
s_this->magicOpen (paths[0 ]);
113
113
}
114
114
115
+ static void resize_callback (GLFWwindow* window, int width, int height) {
116
+ s_this->m_setupScreenSize = true ;
117
+ }
118
+
115
119
static void ShowHelpMarker (const char * desc) {
116
120
ImGui::SameLine ();
117
121
ImGui::TextDisabled (" (?)" );
@@ -271,6 +275,7 @@ end)(jit.status()))
271
275
272
276
s_this = this ;
273
277
glfwSetDropCallback (m_window, drop_callback);
278
+ glfwSetWindowSizeCallback (m_window, resize_callback);
274
279
275
280
Resources::loadIcon ([this ](const uint8_t * data, uint32_t size) {
276
281
int x, y, comp;
@@ -511,7 +516,7 @@ end)(jit.status()))
511
516
});
512
517
513
518
startFrame ();
514
- m_currentTexture = 1 ;
519
+ m_currentTexture ^ = 1 ;
515
520
flip ();
516
521
}
517
522
@@ -550,6 +555,26 @@ void PCSX::GUI::startFrame() {
550
555
if (glfwWindowShouldClose (m_window)) g_system->quit ();
551
556
glfwPollEvents ();
552
557
558
+ if (m_setupScreenSize) {
559
+ constexpr float renderRatio = 3 .0f / 4 .0f ;
560
+ int w, h;
561
+
562
+ glfwGetFramebufferSize (m_window, &w, &h);
563
+ m_framebufferSize = ImVec2 (w, h);
564
+ m_renderSize = ImVec2 (w, h);
565
+ normalizeDimensions (m_renderSize, renderRatio);
566
+
567
+ // Reset texture and framebuffer storage
568
+ glBindTexture (GL_TEXTURE_2D, m_offscreenTextures[0 ]);
569
+ glTexImage2D (GL_TEXTURE_2D, 0 , GL_RGBA, m_renderSize.x , m_renderSize.y , 0 , GL_RGBA, GL_UNSIGNED_BYTE, 0 );
570
+ glBindTexture (GL_TEXTURE_2D, m_offscreenTextures[1 ]);
571
+ glTexImage2D (GL_TEXTURE_2D, 0 , GL_RGBA, m_renderSize.x , m_renderSize.y , 0 , GL_RGBA, GL_UNSIGNED_BYTE, 0 );
572
+
573
+ glBindRenderbuffer (GL_RENDERBUFFER, m_offscreenDepthBuffer);
574
+ glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, m_renderSize.x , m_renderSize.y );
575
+ m_setupScreenSize = false ;
576
+ }
577
+
553
578
auto & io = ImGui::GetIO ();
554
579
555
580
if (m_reloadFonts) {
@@ -624,12 +649,10 @@ void PCSX::GUI::flip() {
624
649
glBindFramebuffer (GL_FRAMEBUFFER, m_offscreenFrameBuffer);
625
650
glBindTexture (GL_TEXTURE_2D, m_offscreenTextures[m_currentTexture]);
626
651
627
- glTexImage2D (GL_TEXTURE_2D, 0 , GL_RGBA, m_renderSize.x , m_renderSize.y , 0 , GL_RGBA, GL_UNSIGNED_BYTE, 0 );
628
652
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
629
653
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
630
654
631
655
glBindRenderbuffer (GL_RENDERBUFFER, m_offscreenDepthBuffer);
632
- glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, m_renderSize.x , m_renderSize.y );
633
656
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_offscreenDepthBuffer);
634
657
GLuint texture = m_offscreenTextures[m_currentTexture];
635
658
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0 );
@@ -650,17 +673,15 @@ void PCSX::GUI::flip() {
650
673
651
674
void PCSX::GUI::endFrame () {
652
675
constexpr float renderRatio = 3 .0f / 4 .0f ;
676
+ const int w = m_framebufferSize.x ;
677
+ const int h = m_framebufferSize.y ;
678
+
653
679
auto & io = ImGui::GetIO ();
654
680
// bind back the output frame buffer
655
681
glBindFramebuffer (GL_FRAMEBUFFER, 0 );
656
682
auto & emuSettings = PCSX::g_emulator->settings ;
657
683
auto & debugSettings = emuSettings.get <Emulator::SettingDebugSettings>();
658
684
659
- int w, h;
660
- glfwGetFramebufferSize (m_window, &w, &h);
661
- m_renderSize = ImVec2 (w, h);
662
- normalizeDimensions (m_renderSize, renderRatio);
663
-
664
685
bool changed = false ;
665
686
666
687
m_offscreenShaderEditor.configure (this );
0 commit comments