File tree Expand file tree Collapse file tree 4 files changed +10
-4
lines changed
Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,8 @@ struct Context {
7575
7676 int bufferWidth = -1 ;
7777 int bufferHeight = -1 ;
78- int windowWidth = 1280 ;
79- int windowHeight = 720 ;
78+ int windowWidth = - 1 ; // on init(), get overwritten with defaultWindowWidth if -1
79+ int windowHeight = - 1 ; // ^^^ same
8080 int initWindowPosX = 20 ;
8181 int initWindowPosY = 20 ;
8282 bool windowResizable = true ;
Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ extern float& flightTargetFov;
6969extern float & flightInitialFov;
7070
7171// Default values
72+ extern const int defaultWindowWidth;
73+ extern const int defaultWindowHeight;
7274extern const double defaultNearClipRatio;
7375extern const double defaultFarClipRatio;
7476extern const double defaultFov;
Original file line number Diff line number Diff line change @@ -66,11 +66,11 @@ void readPrefsFile() {
6666
6767 // Set values
6868 // Do some basic validation on the sizes first to work around bugs with bogus values getting written to init file
69- if (prefsJSON.count (" windowWidth" ) > 0 ) {
69+ if (view::windowWidth == - 1 && prefsJSON.count (" windowWidth" ) > 0 ) { // only load if not already set
7070 int val = prefsJSON[" windowWidth" ];
7171 if (val >= 64 && val < 10000 ) view::windowWidth = val;
7272 }
73- if (prefsJSON.count (" windowHeight" ) > 0 ) {
73+ if (view::windowHeight == - 1 && prefsJSON.count (" windowHeight" ) > 0 ) { // only load if not already set
7474 int val = prefsJSON[" windowHeight" ];
7575 if (val >= 64 && val < 10000 ) view::windowHeight = val;
7676 }
@@ -148,6 +148,8 @@ void init(std::string backend) {
148148 if (options::usePrefsFile) {
149149 readPrefsFile ();
150150 }
151+ if (view::windowWidth == -1 ) view::windowWidth = view::defaultWindowWidth;
152+ if (view::windowHeight == -1 ) view::windowHeight = view::defaultWindowHeight;
151153
152154 // Initialize the rendering engine
153155 render::initializeRenderEngine (backend);
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ float& flightInitialFov = state::globalContext.flightInitialFov;
4444
4545
4646// Default values
47+ const int defaultWindowWidth = 1280 ;
48+ const int defaultWindowHeight = 720 ;
4749const double defaultNearClipRatio = 0.005 ;
4850const double defaultFarClipRatio = 20.0 ;
4951const double defaultFov = 45 .;
You can’t perform that action at this time.
0 commit comments