Setting resolution on PC builds?
Monkey Targets Forums/Desktop/Setting resolution on PC builds?
| ||
Hi all, I thought I saw this somewhere, but now I can't find it... how do I set the resolution on PC/Mac builds? Also, is there any way to set fullscreen? |
| ||
Open the config.h file in your project and make the required changes. |
| ||
Yeah but how do you do it in code? PC and Mac's have different resolutions. A simple "Graphics 1024,768" command would suffice. I wonder why this is missing...and still missing even today? And modern games are able to switch from fullscreen to windowed modes too... |
| ||
I wonder why this is missing...and still missing even today? Because it is very device specific and only one target would use it... |
| ||
"Open the config.h file in your project and make the required changes." That pretty much makes using monkey for PC games impossible? Plus there shouldn't be some manual workaround IMO. It's a necessity because casual PC games can switch from windowed to fullscreen and back on-the-fly. |
| ||
Isn't the concept of Monkey that it should adapt to the screensize in which it finds itself? If Monkey code is written to do that, then all that needs to be added is some native code to change resolution. In the long run, i suspect there will be modules made with instructions like SetWindowSize() that work on only some platforms. |
| ||
A command doesn't have to work on all targets. Targets that don't need it would simply ignore it. But the PC target definitely needs a way to set resolution and switch between fullscreen and windowed modes. |
| ||
I agree, targets really need platform specific commands. If they are not added officially they need to be added by anybody making a game that hopes to look professional anyway. I would prefer this to be a static thing where it will fail to compile under targets that don't support the command, just wrap them in #if target="GLFW" blocks etc. |
| ||
I've added a command to Diddy which can alter the Windowed resolution at run time, when I looked into this a few weeks ago I dont think the full screen flag can be changed at run time... hope I'm wrong about this. Anyway here is the code which I use in Diddy: Monkey code: Extern Function SetNativeGraphicsSize:Void(w:Int, h:Int) = "diddy::setGraphics" C++ code: class diddy { public: static void setGraphics(int w, int h) { glfwSetWindowSize(w, h); GLFWvidmode desktopMode; glfwGetDesktopMode( &desktopMode ); glfwSetWindowPos( (desktopMode.Width-w)/2,(desktopMode.Height-h)/2 ); } }; In Diddy I have added empty stubs for the rest of the targets apart from HTML5, which now can alter the game canvas size at run time. |
| ||
therevils, where do we define the C++ code at to get this to work? |
| ||
Create your monkey file: Then create a glfw.cpp in the same folder: I've uploaded the files here: http://www.mediafire.com/?4f1l6xbk53jabcd |
| ||
Thanks, for some odd reason when I copied and pasted the codes it through some errors about external not being declared but when i ran your file from the download it actually worked :). But now when ever i change resolution, it totally jacks up the display. Was this suppose to happen or does the resolution have to be set initially during load time so that it doesn't happen? |
| ||
@Neuro Following the code above, I found a Cls statement in the OnRender Method fixed the nasty display problems. Method OnRender:Int() Cls DrawLine 0,0,DeviceWidth(),DeviceHeight() End |
| ||
You can useGLFW_WINDOW_WIDTH=0 GLFW_WINDOW_HEIGHT=0 in the config file (GLFW target), and the game will resize to the actual desktop resolution. |