make high dpi support a flag in applicationconfig

This commit is contained in:
a dinosaur 2024-08-05 15:47:39 +10:00
parent d896f2eaa7
commit b08fc1c51b
2 changed files with 6 additions and 2 deletions

View File

@ -23,10 +23,13 @@ public class Application {
}
// Create SDL window
var windowFlags = SDL_WindowFlags(SDL_WINDOW_HIGH_PIXEL_DENSITY)
var windowFlags = SDL_WindowFlags(0)
if (cfg.flags.contains(.resizable)) {
windowFlags |= SDL_WindowFlags(SDL_WINDOW_RESIZABLE)
}
if (cfg.flags.contains(.highDPI)) {
windowFlags |= SDL_WindowFlags(SDL_WINDOW_HIGH_PIXEL_DENSITY)
}
window = SDL_CreateWindow(cfg.title, cfg.width, cfg.height, windowFlags)
guard window != nil else {
print("SDL_CreateWindow() error: \(String(cString: SDL_GetError()))", to: &stderr)
@ -134,6 +137,7 @@ public struct ApplicationConfiguration {
}
static let resizable = Flags(rawValue: 1 << 0)
static let highDPI = Flags(rawValue: 1 << 1)
}
public enum VSyncMode {

View File

@ -5,7 +5,7 @@ let app = Application(
width: 1280,
height: 720,
title: "Voxelotl Demo",
flags: .resizable,
flags: [ .resizable, .highDPI ],
vsyncMode: .on(interval: 1)))
exit(app.run())