[graphics] Another possible way to handle windowed (#1653)

* [gfx] fixes for when the window is force to weird size

* a better way

* Another way to handle windowed mode
This commit is contained in:
water111
2022-07-15 18:59:13 -04:00
committed by GitHub
parent 3b558e093e
commit 9bdb6d11d1
4 changed files with 5 additions and 10 deletions
+2 -2
View File
@@ -73,8 +73,8 @@ static constexpr int PAT_MAT_COUNT = 23;
struct GfxGlobalSettings {
// note: this is actually the size of the display that ISN'T letterboxed
// the excess space is what will be letterboxed away.
int lbox_w;
int lbox_h;
int lbox_w = 640;
int lbox_h = 480;
// actual game resolution
int game_res_w = 640;
@@ -483,6 +483,7 @@ void OpenGLRenderer::setup_frame(const RenderOptions& settings) {
} else {
lg::error("bad framebuffer setup. fbo: {}, tex: {}, zbuf: {}, fbo2: {}, tex2: {}",
fbo_state.fbo, fbo_state.tex, fbo_state.zbuf, fbo_state.fbo2, fbo_state.tex2);
lg::error("size was: {} x {}\n", fbo_state.width, fbo_state.height);
fbo_state.delete_objects();
}
} else {
-1
View File
@@ -140,7 +140,6 @@ static int gl_init(GfxSettings& settings) {
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_FALSE);
}
glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
return 0;
}
+2 -7
View File
@@ -64,6 +64,7 @@
((= 'windowed (-> obj display-mode))
(set! (-> obj win-width) width)
(set! (-> obj win-height) height)
(pc-set-window-size (max PC_MIN_WIDTH (-> obj win-width)) (max PC_MIN_HEIGHT (-> obj win-height)))
)
(else
(set! (-> obj width) width)
@@ -197,15 +198,10 @@
(if (< (pc-get-screen-rate -1) (-> obj target-fps))
(pc-set-vsync #f))
(pc-set-frame-rate (-> obj target-fps)))
(if (and (= 'windowed (-> obj display-mode))
(or (!= (-> obj win-width) (-> obj real-width))
(!= (-> obj win-height) (-> obj real-height))))
(pc-set-window-size (max PC_MIN_WIDTH (-> obj win-width)) (max PC_MIN_HEIGHT (-> obj win-height))))
)
;; do game resolution
(if (= (-> obj display-mode) 'windowed)
(pc-set-game-resolution (-> obj win-width) (-> obj win-height))
(pc-set-game-resolution (-> obj real-width) (-> obj real-height))
(pc-set-game-resolution (-> obj width) (-> obj height)))
;; set msaa sample rate. if invalid, just reset to 4.
@@ -1018,7 +1014,6 @@
(define *pc-settings* (new 'global 'pc-settings))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; entity debugging
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;