QB64 Phoenix Edition
why isn't _FULLSCREEN working? - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: why isn't _FULLSCREEN working? (/showthread.php?tid=3951)



why isn't _FULLSCREEN working? - madscijr - 09-20-2025

For some reason my program is not doing fullscreen. 

My display is 1080p, and _FULLSCREEN works with my test program, but when I try it with my real program, like so:

Code: (Select All)
    Screen _NewImage(_DesktopWidth, _DesktopHeight, 32): _ScreenMove 0, 0
    'Screen _NewImage(cScreenSizeX, cScreenSizeY, 32): _ScreenMove 0, 0
    '_FullScreen _Stretch ' *** DIDN'T WORK
    _FullScreen _SquarePixels ' *** ALSO DIDN'T WORK
    _Dest 0: Cls , _RGB32(0, 0, 0)

it doesn't go full screen, or even resize the program window - it stays the same size as when it's screen 0, and it displays 1080p real small, squashed into the little screen 0 program window.

What gives? The only thing different is my real program uses custom fonts. Does _FULLSCREEN not like non-default fonts?

Any help appreciated! The full code to both the real and test programs can be found in the attached ZIP file.

The test program - full screen works fine here:

Code: (Select All)
' Here are some common 16:9 resolutions:
' 1280 x 720 (720p): A standard high-definition (HD) resolution.
' 1600 x 900 (720p): A less common but still valid 16:9 resolution.
' 1920 x 1080 (1080p/Full HD): The resolution you mentioned.
' 2560 x 1440 (1440p/QHD): A popular, higher-resolution option.
' 3840 x 2160 (4K/UHD): The next step up in resolution for video and displays.
' 7680 x 4320 (8K/UHD): The highest standard resolution available.

' Standard resolutions with the 4:3 aspect ratio:
'  320 x  240 QVGA
'  640 x  480 VGA
'  800 x  600 SVGA
' 1024 x  768 XGA
' 1280 x 1024 SXGA

' Screen 0 color names: Black Blue Green Cyan Red Magenta Brown White Gray LightBlue LightGreen LightCyan LightRed LightMagenta Yellow BrightWhite
$Color:0

Dim in$

'FillScreen
TestScreen 0, 0, "Screen 0"
TestScreen 320, 240, "QVGA"
TestScreen 640, 480, "VGA"
TestScreen 800, 600, "SVGA"
TestScreen 1024, 768, "XGA"
TestScreen 1280, 1024, "SXGA"
TestScreen 1280, 720, "720p"
TestScreen 1600, 900, "HD+"
TestScreen 1920, 1080, "1080p"
TestScreen 0, 0, "back to Screen 0"
TestScreen _DesktopWidth, _DesktopHeight, "_DesktopWidth, _DesktopHeight"

Input "ALL DONE. PRESS ENTER TO EXIT"; in$

System

' /////////////////////////////////////////////////////////////////////////////

Sub TestScreen (Width&, Height&, message$)
    Dim in$
    Dim ScreenMode$

    If Width& > 0 And Height& > 0 And Width& <= _DesktopWidth And Height& <= _DesktopHeight Then
        ScreenMode$ = message$ + " (" + _ToStr$(Width&) + ", " + _ToStr$(Height&) + ")"
        Print "PRESS ENTER FOR " + ScreenMode$
        Input in$
        Screen _NewImage(Width&, Height&, 32): _ScreenMove 0, 0
    Else
        ScreenMode$ = message$ + " (" + _ToStr$(_Width) + ", " + _ToStr$(_Height) + ")"
        Print "PRESS ENTER FOR SCREEN 0"
        Input in$
        Screen 0
    End If

    FillScreen

    Locate 1, 1: Print "SCREEN IS: " + ScreenMode$

    Locate 9, 1

    Input "PRESS ENTER FOR _FULLSCREEN _Stretch"; in$
    _FullScreen _Stretch

    Input "PRESS ENTER FOR _FULLSCREEN _Stretch , _Smooth"; in$
    _FullScreen _Stretch , _Smooth

    Input "PRESS ENTER FOR _FULLSCREEN _SquarePixels"; in$
    _FullScreen _SquarePixels

    Input "PRESS ENTER FOR _FULLSCREEN _SquarePixels , _Smooth"; in$
    _FullScreen _SquarePixels , _Smooth

    Input "PRESS ENTER FOR _FULLSCREEN _OFF"; in$
    _FullScreen _Off

    Print

End Sub ' TestScreen

' /////////////////////////////////////////////////////////////////////////////

Sub FillScreen
    Dim iLoop1 As Integer
    Dim x, y, width, height As Integer
    Dim fg, bg As _Unsigned Long
    Dim r, g, b, a As Long

    If _PixelSize(0) <> 0 Then
        Cls , _RGB32(0, 0, 0)
        For iLoop1 = 1 To 10
            x = RandomNumber%(0, _Width)
            y = RandomNumber%(0, _Height)
            width = RandomNumber%(0, _Width / 8)
            height = RandomNumber%(0, _Height / 8)
            r = RandomNumber%(0, 255)
            g = RandomNumber%(0, 255)
            b = RandomNumber%(0, 255)
            a = RandomNumber%(0, 255)
            bg = _RGBA32(r, g, b, a)
            DrawRectSolid x, y, width, height, bg
            r = RandomNumber%(0, 255)
            g = RandomNumber%(0, 255)
            b = RandomNumber%(0, 255)
            fg = _RGB32(r, g, b)
            DrawRectOutline x, y, width, height, fg
        Next iLoop1
        Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
    Else
        Cls , Black
    End If
    Locate 3, 1
    Print "_PIXELSIZE(0)  = " + _ToStr$(_PixelSize(0))
    Print "_Width         = " + _ToStr$(_Width)
    Print "_Height        = " + _ToStr$(_Height)
    Print "_DesktopHeight = " + _ToStr$(_DesktopHeight)
    Print "_DesktopWidth  = " + _ToStr$(_DesktopWidth)
    Print
End Sub ' FillScreen

' /////////////////////////////////////////////////////////////////////////////
' Generate random value between Min and Max inclusive.
Function RandomNumber% (Min%, Max%)
    Dim NumSpread%

    ' SET RANDOM SEED
    Randomize Timer

    NumSpread% = (Max% - Min%) + 1

    RandomNumber% = Int(Rnd * NumSpread%) + Min% ' GET RANDOM # BETWEEN Max% AND Min%
End Function ' RandomNumber%

' /////////////////////////////////////////////////////////////////////////////

Sub InitImage (ThisImage&, iWidth&, iHeight&, bgColor~&)
    FreeImage ThisImage&
    ThisImage& = _NewImage(iWidth&, iHeight&, 32)
    _Dest ThisImage&: Cls , bgColor~&
End Sub ' InitImage

' /////////////////////////////////////////////////////////////////////////////

Sub FreeImage (ThisImage&)
    If ThisImage& < -1 Or ThisImage& > 0 Then _FreeImage ThisImage&
End Sub ' FreeImage

' /////////////////////////////////////////////////////////////////////////////
' DRAW A 2-D RECTANGLE (OUTLINE)

' DrawRectOutline x, y, width, height, color
Sub DrawRectOutline (iX As Integer, iY As Integer, iSizeW As Integer, iSizeH As Integer, fgColor As _Unsigned Long)
    Line (iX, iY)-(iX + iSizeW, iY + iSizeH), fgColor, B ' Draw rectangle outline
End Sub ' DrawRectOutline

' /////////////////////////////////////////////////////////////////////////////
' DRAW A 2-D RECTANGLE (SOLID)

' DrawRectSolid x, y, width, height, color
Sub DrawRectSolid (iX As Integer, iY As Integer, iSizeW As Integer, iSizeH As Integer, fgColor As _Unsigned Long)
    Line (iX, iY)-(iX + iSizeW, iY + iSizeH), fgColor, BF ' Draw a solid rectangle
End Sub ' DrawRectSolid



RE: why isn't _FULLSCREEN working? - bplus - 09-20-2025

Looks like its the _ScreenMove 0,0 that's screwing things up

This works normally:
Code: (Select All)
Screen _NewImage(800, 600, 32) ': _ScreenMove 0, 0
_FullScreen

But uncomment and it goes to hell.

If you intend FullScreen then the screen move is stupid anyway!


RE: why isn't _FULLSCREEN working? - madscijr - 09-20-2025

Yeah, it is! It was there when the program was windowed, then when I added _FULLSCREEN, I was lazy and didn't remove it. But I never imagined that would prevent the fullscreen from working! Thank you for figuring this out (I'm assuming, stepped away from the PC, so can't try it out just yet) - I never would have suspected the screen move. I owe you a beer!


RE: why isn't _FULLSCREEN working? - SMcNeill - 09-20-2025

Code: (Select All)
Screen _NewImage(_DesktopWidth, _DesktopHeight, 32)

_Delay .2 'try a delay here so the screen is created before you move it
_ScreenMove 0, 0


_Delay .2 'try a delay here so the screen has finished moving before you _FullScreen it
_FullScreen _SquarePixels
_Dest 0: Cls , _RGB32(0, 0, 0)
Print "Works just fine for old Steve like this."

Self explanatory code above works just peachy fine for me.  Wink


RE: why isn't _FULLSCREEN working? - bplus - 09-20-2025

OK we still need the delays to allow code to setup screens before changing.

here I thought only _ScreenMove _Middle sucked 

Code: (Select All)
Screen _NewImage(800, 600, 32)
_ScreenMove _Middle
'_Delay .1   ' <<< uncomment to work
_FullScreen



RE: why isn't _FULLSCREEN working? - SMcNeill - 09-20-2025

It's because the screens are handled in one thread and the rest of the program in another thread, and sometimes it creates a race condition where you're doing something but the information hasn't been updated on the other screen yet, and then that just... clugs out.

On my new laptop, I'm not seeing the issue even if I ignore the delays with the latest version of QB64PE.  I guess the one thread is running fast enough to keep up with the other and it's allowing me to bypass this type glitch.