July 7, 2016 at 11:48 am #1832
This might be a possible bug. If you start with the window as Resizable then change to Fullscreen (F12) it renders ok, but if you start on Fullscreen it displays nothing.
Can anyone confirm this is the case? if so i’ll raise it.July 7, 2016 at 11:50 am #1833Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677[crayon-5ceb1a184a9b5507323093 inline="true" ]'System#Import "<std>"#Import "<mojo>"Using mojo..Using std..' GlobalsGlobal window:MainWindowFunction Main()New AppInstance()window = New MainWindow("Main Window",1024,768,WindowFlags.Resizable) 'Fullscreen/ResizableApp.Run()EndClass MainWindow Extends WindowField IsPaused:BoolField IsSuspended:BoolField ShowFPS:Bool=TrueMethod New(title:String, width:Int, height:Int, flags:WindowFlags)' Setup displaySuper.New(title, width, height, flags)'Virtual ResolutionLayout = "letterbox"MinSize=New Vec2i(640,480)MaxSize=New Vec2i(width,height)ClearColor = Color.BlackMouse.PointerVisible=FalseEnd MethodMethod OnRender(canvas:Canvas) Override'RenderApp.RequestRender()'MessageLocal message:String="Hello from Monkey2!"canvas.Color=Color.Whitecanvas.DrawText(message,Width/2-Style.DefaultFont.TextWidth(message)/2,Height/2)'SystemIf (ShowFPS) canvas.DrawText("FPS-" + App.FPS,0,0)End MethodMethod OnKeyEvent( event:KeyEvent ) OverrideSelect event.TypeCase EventType.KeyDownSelect event.KeyCase Key.F12Fullscreen = Not FullscreenCase Key.EscapeApp.Terminate()Case Key.FShowFPS=Not ShowFPSEndEndEndMethod OnWindowEvent(event:WindowEvent) OverrideSelect event.TypeCase EventType.WindowMovedCase EventType.WindowResizedApp.RequestRender()Case EventType.WindowGainedFocusSelf.IsSuspended = FalseCase EventType.WindowLostFocusSelf.IsSuspended = TrueDefaultSuper.OnWindowEvent(event)EndEndEnd ClassJuly 7, 2016 at 10:09 pm #1855
I found that if you change the layout=”letterbox” line to something else then it works. I have not delved deep into Monkey2 to know what the problem might be.
btw – when I tried the fullscreen mode the first time my computer became very slow after ending the program. This for around 10 seconds. The mouse moved really slow and the music in the background played very weird. Never seen anything like this before on this gaming laptop.July 7, 2016 at 11:31 pm #1862
Thanks for checking! Hopefully Mark can determine the problem here.
Also haven’t seen any slow downs like that myself.July 8, 2016 at 2:35 am #1868
I’ve raised an issue for this:
https://github.com/blitz-research/monkey2/issues/24July 8, 2016 at 7:13 am #1880
To use “letterbox” layout, you need to also provide an ‘OnMeasure:Vec2i() Override’ method, or mojo wont know what size you want the letterbox ‘content’ to be, ie: the size of the window and the size of the letterbox are 2 different things. Adding this fixes the problem here:Monkey1234Method OnMeasure:Vec2i() OverrideReturn New Vec2i( 1024,768 )End
The default OnMeasure() returns (0,0) which is likely to cause problems! I may change this (or maybe add a check for silly letterbox sizes?) but the solution remains the same – OnMeasure should be implemented when using “letterbox” layout.
Note the Fullscreen property is @hidden as it’s still under development (sorry if I used it in a banana). There will definitely be *some* way to do this (I quite like the idea of a ‘Flags’ property so you can update any flag after window creation) so use it for now but it may be flaky. Actually, the fact that it’s working here means that it’s broken(!) as it’s ignoring the (0,0) letterbox size you requested!July 8, 2016 at 7:18 am #1881
Ok – thanks for taking a look Mark!
You must be logged in to reply to this topic.