subsoap / defos

Extra native OS functions for games written using the Defold game engine
Creative Commons Zero v1.0 Universal
112 stars 16 forks source link

Set Window/View Size Before Game Start #123

Open 11clock opened 2 years ago

11clock commented 2 years ago

If your game’s virtual resolution (display width and display height) is different from what you want your initial window size to be, you need to call set_view_size on your game’s init. While this works, this function isn’t called until after the game has booted up, leaving your game at the actual display resolution for a few frames.

See the below game that was designed to be in 1080p, but has the view size being set to 720p on init (since a 1080p sized window is unreasonable on most displays).

https://i.gyazo.com/03a91663b2ce441fe80caebeb869af24.mp4

A means to set a starting window/view size separate from the display width and height would be nice.

subsoap commented 2 years ago

I'm not sure if this is possible to do with a native extension. Unless somehow we are able to override the default GLFW 2.5 window view size on extension init, and if that is soon enough to prevent the appearance of a larger initial window view size. If that was possible then maybe we could access a game.project setting within native extension init to force an actual extension init window view size that's different from the one set in game.project and used by the engine to determine various view related sizings/orientations.

@11clock I recommend you forking DefOS and just testing to see if hard coding a smaller initial window size within the extension init function works to to solve your issue or not.

AGulev commented 2 years ago

Issue will be fixed after merging this PR https://github.com/subsoap/defos/pull/124 (Pls pay attention that this fix can't be applied before a fix in the engine, read PR description)