• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Bug GLFW: Windowsizes

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,414
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

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
 
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:
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:
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.
 
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.
 
Back
Top Bottom