Bug Windowsizes

Jimmy

New member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
569
Some desperate christmasnight-coding being done here.. and I might have run into a window-bug or not I'm not sure?
Maybe that last resolution-problem isn't totally solved just yet, please correct me if I'm wrong.

I feel that I need to understand why windows & screens behaves like they do before I start coding for real because I think it has changed since the two versions.

Got the last version of Cerberus installed and using macOS

code_language.cerberus:
Import mojo2

Function Main()
    New MyApp
End

Class MyApp Extends App

    Field canvas:Canvas
 
    Method OnCreate()
        canvas = New Canvas
       SetSwapInterval 1
        SetUpdateRate 0
      
       Local width:Int = 1440 ' Change these to your
       Local height:Int = 900 ' native resolution
      
       ' --------------------------------------------------------------   
       ' SetViewport and SetProjection2d seems to be a must now to set window-size programatically.
       ' I just want to doublecheck that this is correct before I continue start coding for real.         
       ' --------------------------------------------------------------   
      
       ' I noticed something about windows sizes :
    
       ' This window will have a size of exactly width x height, but you won't get reszibility here of course
          ' SetDeviceWindow width,height, 4
          ' canvas.SetViewport 0,0,width,height
       ' canvas.SetProjection2d 0,width,0,height
      
       ' This is the troubling one, it won't give you a window of width x height but minus any menubar and dock! It will fill the free desktop space instead!
       SetDeviceWindow width,height,2+4
          canvas.SetViewport 0,0,width,height
       canvas.SetProjection2d 0,width,0,height
       ' --------------------------------------------------------------   
                
    End
 
    Method OnUpdate()
            If KeyHit(KEY_ESCAPE) Then EndApp
    End
      
    Method OnRender()
        canvas.Clear 0,0,1   
        canvas.Flush
    End
    
End
 

Jimmy

New member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
569
Here's another example where you can see how Mojo2 only shows a 640x480

I guess I'm wondering if you are *supposed* to need :
canvas.SetViewport 0,0,width,height
canvas.SetProjection2d 0,width,0,height


whenever you do a SetDeviceWindow width, height? (because that will make everything allright)



Screenshot 2020-12-24 at 16.44.16.png
Screenshot 2020-12-24 at 16.44.13.png
 
Last edited:

Jimmy

New member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
569
In case I didn't explain the problem well I'm wondering two things and maybe they are just normal behaviours in GLFW.. I just want to make sure everything works as it should.

1) SetDevice needs SetViewport and SetProjection2d commands to make it display the correct size and no garbage onscreen.

2) When you create a resizable window, you can never get a bigger window than your free desktop space (that will be your native resolution minus any menus and docks). It kind of makes sense to be able to reach all the controls of course. Again, just checking so the bug is completely dead.
 
Last edited:

Jimmy

New member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
569
I kind of answered the first question myself now by testing on a lot of older Cerberus versions, it have always behaved this way anyways. But a confirmation that this is indeed the correct behaviour would help a lot.

The other thing concerning about resizable windows being restrained to "free desktop space" instead of actual maximum native resolution might be GLFW-related? Either way it's nothing practical to have that kind of big windows I'm just concerned that everything works as it should. If you want resizable windows you just need to be aware of this I guess.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,815
I kind of answered the first question myself now by testing on a lot of older Cerberus versions, it have always behaved this way anyways. But a confirmation that this is indeed the correct behaviour would help a lot.
I am glad you did, as your first assumption that it was doing fine 2 versions before was not the correct one.

And yes, that is currently how it works. In mojo2 you can have multiple canvas, each with its own viewport and projection. And as it is up to the developer when to draw it to the screen, there is no way to make mojo2 resize everything automatically.
So when you resize, either via code or when the user resizes the window, you as the developer should react on the resizing.

The problems here see currently are the following:
  1. The OnResize method is not called all the time, only when you size the window via the mouse. Imho it should also be called when you alter the window size via code.
  2. SetDeviceWindow and SetDeviceWindowSize behave differently somehow, as the first still have the drawing area top left and the later one not.
I will look into this.
 
Top Bottom