Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    docking while the program is running

    Bug Reporting (FUZE 4 Nintendo Switch)
    6
    11
    732
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      hammy_ last edited by

      i'll admit it's not the smartest thing to dock your Switch while something's happening, but i had just undocked mine to test if everything worked undocked (it didn't but i'm too lazy to fix anything) and when i put it back into the dock, everything was downscaled on my TV, everything worked exactly as it did while docked, but it's just displaying that, rather than the standard docked view, inconsequential but i thought i'd put it here

      1 Reply Last reply Reply Quote 1
      • Martin
        Martin Fuze Team last edited by

        Are we talking about your running program or Fuze itself? Because you have to handle the scaling and docked / undocked yourself.

        If it's Fuze then that could be a bug

        1 Reply Last reply Reply Quote 0
        • H
          hammy_ last edited by

          only the program, and yea that makes sense, better to document it than not i guess

          1 Reply Last reply Reply Quote 0
          • Martin
            Martin Fuze Team last edited by Martin

            Here's the help page for the 'docked' command / function:

            https://fuzearena.com/help/view/docked

            1 Reply Last reply Reply Quote 1
            • N
              Nisse5 F last edited by

              If you want to simplify things, you can set the screen mode to 1280x720. That way, docked and undocked mode in your program will use the same screen resolution.

              It's an easy approach, but you'll obviously loose the high resolution in docked mode using that method.

              1 Reply Last reply Reply Quote 2
              • Dave
                Dave Fuze Team last edited by Martin

                ^^^ @Nisse5 's suggestion will absolutely work. You can do setMode(1280, 720) to force the docked resolution into the same as handheld. This will get rid of the scaling issue.

                Another way is to have screen dimension variables which are calculated every frame in your main loop. This sounds taxing, but it really isnt:

                loop
                    clear()
                    screen = { gwidth(), gheight() }
                    // Now we have screen.x and screen.y being calculated in the loop, giving us the correct resolution all the time if we use these screen variables in our program
                    update()
                repeat
                

                Probably simpler to use setMode(), but this way you get to keep the crisp 1920 x 1080 res in TV mode.

                N 1 Reply Last reply Reply Quote 1
                • N
                  Nisse5 F @Dave last edited by

                  @Dave One drawback of using gWidth()/gHeight() is that the code might get a bit unnecessarily complicated to code, since Nintendo Switch basically just have 2 resolutions (one portable resolution and one docked resolution), and these resolutions are predictable from the programmer's standpoint. It's not like on the PC, where the user might use all kinds of crazy screen resolutions.

                  My approach in my current project (keeping 1080p docked and 720p undocked) is to hardcode the layout info using a struct.
                  Something like this:

                  // Define the hardcoded layout "constants" at the initialization of the program
                  
                  // Default values for docked mode,
                  // but use it for undocked as well!
                  struct LayoutCoordsStruct
                     vector point1 = {100, 80}
                     // And so on...
                  endstruct
                  
                  LayoutCoordsStruct DockedLayout
                  // *** Set the undocked layout "constants" here, overriding the defaults
                  LayoutCoordsStruct UndockedLayout
                  UndockedLayout.point1 = {80, 70}
                  
                  
                  // Now, in the actually running code, use the "docked()" within
                  // the update loop to determine what kind of layout that
                  // should be used
                  layout = UndockedLayout
                  if docked() then layout = DockedLayout endif
                  // The coordinates in "layout" will now refer to the correct
                  // view, and is ready to be used!
                  print(layout.point1)
                  
                  1 Reply Last reply Reply Quote 0
                  • waldron
                    waldron F last edited by

                    Now I have a issue with docked, my game was fine before now only plays handheld
                    Comes up with draw sheet scale to large

                    Dave 1 Reply Last reply Reply Quote 0
                    • Dave
                      Dave Fuze Team @waldron last edited by

                      @waldron Put setMode(1920,1080) at the start of your program. Very first line! Should sort you out here.

                      1 Reply Last reply Reply Quote 2
                      • spikey
                        spikey F last edited by spikey

                        For those who had it the other way around: I used setMode(1920,1080) on top of my program and had a text line (drawn with drawMulticoloredText) at the bottom.

                        • When I undocked during the game the line was not shown anymore --> of course because the display has 1280x720
                        • When I redocked everything was ok
                          What helped was applying the setMode(1920,1080) command always if the docking or undocking was happening inside the main loop.

                        It lacks now a bit of performance in undocked (50fps instead of 62fps, not sure if my debug routine is very accurate, if these values are not real-fps but loop counts), but looks nicer.

                        Maybe I read that performance note already here somewhere. ;-)

                        ..ah forgot a code sample:

                        setMode(1920, 1080)
                        _lastDockedStated  = docked()
                        loop
                           clear()
                           if (_lastDockedState != docked()) then
                              setMode(1920, 1080)
                              _lastDockedStated  = docked()
                           endif
                           // main game code
                           update()
                        repeat
                        
                        1 Reply Last reply Reply Quote 0
                        • Martin
                          Martin Fuze Team last edited by Martin

                          So, here's what I did in the last program that I implemented this on...

                          First up, everything is scaled by a scale factor.

                          I have a struct called 'g' which holds game state - standard variables will suffice and will actually be quicker - speed was not important to me in this program.

                          function reScale()
                              g.width = gWidth()
                              g.scale = g.width / 1280
                              // Various other stuff that has to be resized by g.scale
                          return void
                          
                          // Main loop
                          loop
                              clear()
                              if g.width != gWidth() then reScale() endif
                          
                              // Do stuff
                          
                              update()
                          repeat
                          

                          Never mind docked / undocked, ignore them and just look at the width. Simples...

                          1 Reply Last reply Reply Quote 1
                          • First post
                            Last post