possible to hide the window text bar in Blitzmax ?

Started by drfloyd, May 05, 2019, 17:40:03

Previous topic - Next topic

fielder

Quote from: drfloyd on May 05, 2019, 17:40:03
Hello

In a BLITZMAX game, Windowed mode (so not full screen), is there a possibility to hide the textbar at the top ? (to simulate a fullscreen mode)

(I ask this question because I have difficulties with FLIP in fullscreen, and no problem in Window mode)

Thank you (and sorry again for my english very poor)
if you don't want to rewrite the code.. replace the FLIP calls with a function that manage the real FLIP using millisecs(); or something like that...
something that prevent a lot of multiply flips .. or maybe that redraw the entire background of app to make the flip "fluid"

drfloyd

interesting... but i am a casual coder and cannot do that myself ;)

Yes, indeed, I need a function who replace FLIP... a "refresh" function... something which do not swap images but redraw the new image in the buffer.

markcwm

#17
If it's in Blitz3d you could use this - Windowed full screen graphics mode (by Zethrax)

drfloyd

great  !

but BLITZ website is down... and this library no more available.

Qube

Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

markcwm

#20
Yes no need for a library file here, and you only need user32 declarations.

There's also - window (windowed mode) without titlebar and with force redraw (by RemiD).

Yellownakji

#21
Hi.

It looks like your application is undergoing a 'triple buffer' effect, which has happened before when my friend started out.    Please use a delta-timer to limit your framerate and make sure FLIP is called at the END of your loop.

Also, in Graphics(), use the GRAPHICS_BACKBUFFER flag...........

drfloyd

#22
Quote from: markcwm on May 06, 2019, 22:44:53
Yes no need for a library file here, and you only need user32 declarations.

There's also - window (windowed mode) without titlebar and with force redraw (by RemiD).

Thanks, but i am lost

i found the file user32.dll to download... i put it in my folder BIN (is that correct ?)

And then ? What should I add to my code ? :)

In fact, i don't at all how to use libs LOL...

If some one can explain me ? My goal : use USER32.DLL in order to hide the windows bar  + simulate a full screen for a 2D game in Blitz 3D

markcwm

#23
Okay well, user32.dll is a MS Windows dll and is already installed in system32, as is kernel32.dll and gdi32.dll all you really "have" to do is create a text file with the extension .decls in "Blitz3d/userlibs" folder and copy/paste in the functions you intend to use, Blitz3d will then have access to those functions exactly as they are named, after you reload the IDE.

The easiest thing to do is just save the .bb files from the links Qube posted and rename them to .decls. The Win32 consts should be included as a .bb file. Then to keep it simple, just take the init code from Zethrax's example and paste it where your Graphics3d command is, which you should comment out, the windows dll functions start with "api_".

Function GetDesktopSize()
; Gets the width and height of the desktop on the main monitor and returns them in
; the globals G_desktop_screen_width and G_desktop_screen_height.

Local rectangle = CreateBank( 16 )
api_GetClientRect( api_GetDesktopWindow(), rectangle )
G_desktop_screen_width = PeekInt( rectangle, 8 ) - PeekInt( rectangle, 0 )
G_desktop_screen_height = PeekInt( rectangle, 12 ) - PeekInt( rectangle, 4 )
FreeBank rectangle
End Function

; -- Declare Windows API constants.
Const C_GWL_STYLE = -16
Const C_WS_POPUP = $80000000
Const C_HWND_TOP = 0
Const C_SWP_SHOWWINDOW = $0040

; -- Get the width and height of the desktop and place them into these globals.
Global G_desktop_screen_width
Global G_desktop_screen_height
GetDesktopSize()

Global G_viewport_x = 0
Global G_viewport_y = 0
Global G_viewport_width = G_desktop_screen_width
Global G_viewport_height = G_desktop_screen_height

; -- Get the OS handle of the app window.
Global G_app_handle = SystemProperty( "AppHWND" )

If Not Windowed3D() Then RuntimeError "FATAL ERROR: Your computer does not support the rendering of 3D graphics within a window."

Graphics3D G_viewport_width, G_viewport_height, 0, 2

; -- Change the window style to 'WS_POPUP' and then set the window position to force the style to update.
api_SetWindowLong( G_app_handle, C_GWL_STYLE, C_WS_POPUP )
api_SetWindowPos( G_app_handle, C_HWND_TOP, G_viewport_x, G_viewport_y, G_viewport_width, G_viewport_height, C_SWP_SHOWWINDOW )

drfloyd

#24
Great ! Thank you ! It's working, no window bar and "virtual" fullscreen ! And the best : FLIP ploblems as diseapear !!!!!

But there is still a little problem :

My game is 320x240 pixels... So I changed the parameters :

Global G_viewport_width = 320 ;G_desktop_screen_width
Global G_viewport_height = 240; G_desktop_screen_height

But the game appear in a very little part of the screen at the top left....

Is it possible to zoom full screen ?

markcwm

Hmm well, Blitzmax has virtual resolution commands which would make this easy, but Blitz3d doesn't but it should still be possible by copying the screen to an image or sprite texture and scale it up, requiring an extra Flip.

See Sledge's example - http://www.mojolabs.nz/posts.php?topic=62357.

drfloyd

#26
I successfull !!! 320x240 pixels in windowed full screen !!!

And the bonus : FLIP function now works as a real refresh of the screen !!! (you can use several FLIP in a same loop without any problem !)


' windowed
Graphics 320,240,0,60

' full screen borderless *******************************************************************
Type MONITORINFO

        Field cbSize:Int

        Field rcMonitorLeft:Int
        Field rcMonitorTop:Int
        Field rcMonitorRight:Int
        Field rcMonitorBottom:Int

        Field rcWorkLeft:Int
        Field rcWorkTop:Int
        Field rcWorkRight:Int
        Field rcWorkBottom:Int

        Field dwFlags:Int

End Type

' Win32 constants...

Const MONITOR_DEFAULTTONEAREST:Int      = 2

Const GWL_STYLE:Int                                     = -16
Const GWL_EXSTYLE:Int                           = -20

Const HWND_TOP:Int                                      = 0
Const SWP_FRAMECHANGED:Int                      = $20

Const WS_POPUP:Int                                      = $80000000
Const WS_VISIBLE:Int                            = $10000000
Const WS_CAPTION:Int                            = $C00000
Const WS_THICKFRAME:Int                         = $00040000
Const WS_MINIMIZE:Int                           = $20000000
Const WS_MAXIMIZE:Int                           = $01000000
Const WS_SYSMENU:Int                            = $80000

Const WS_EX_DLGMODALFRAME:Int           = $00000001
Const WS_EX_CLIENTEDGE:Int                      = $200
Const WS_EX_STATICEDGE:Int                      = $20000

' Win32 function pointers...

Global FindWindow (lpClassName:Byte Ptr, lpWindowName:Byte Ptr) "win32"
Global MonitorFromWindow (hwnd:Int, dwFlags:Int)                                "win32"
Global GetMonitorInfo (hMonitor:Int, lpmi:Byte Ptr)                             "win32"
Global GetWindowLong (hwnd:Int, nIndex:Int)                                             "win32"
Global SetWindowLong (hwnd:Int, nIndex:Int, dwNewLong:Int)              "win32"
Global SetWindowPos (hWnd:Int, hWndInsertAfter:Int, X:Int, Y:Int, cx:Int, cy:Int, uFlags:Int)

' Set up function pointers...

Local user32:Int = LoadLibraryA ("user32.dll")

If user32

        FindWindow                      = GetProcAddress (user32, "FindWindowA")
        MonitorFromWindow       = GetProcAddress (user32, "MonitorFromWindow")
        GetMonitorInfo          = GetProcAddress (user32, "GetMonitorInfoA")
        GetWindowLong           = GetProcAddress (user32, "GetWindowLongA")
        SetWindowLong           = GetProcAddress (user32, "SetWindowLongA")
        SetWindowPos            = GetProcAddress (user32, "SetWindowPos")
       
        If Not (FindWindow And MonitorFromWindow And GetMonitorInfo And GetWindowLong And SetWindowLong And SetWindowPos)
                Print "Missing function!"
                End
        EndIf
       
EndIf

' AppTitle allocated as C-string...

Local cbytes:Byte Ptr = AppTitle.ToCString ()

' Find app window...

Local appwindow:Int = FindWindow (Null, cbytes)

' Free C-string memory...

MemFree cbytes

' Find which monitor the app window is on...

Local monitor:Int = MonitorFromWindow (appwindow, MONITOR_DEFAULTTONEAREST)

' Monitor info...

Local mi:MONITORINFO = New MONITORINFO
mi.cbSize = SizeOf (MONITORINFO)

GetMonitorInfo monitor, mi

' Read window style/extended style...

Local style:Int         = GetWindowLong (appwindow, GWL_STYLE)
Local exstyle:Int       = GetWindowLong (appwindow, GWL_EXSTYLE)

' Prepare to remove unwanted styles...

style   = style And Not (WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU)
exstyle = exstyle And Not (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)

' Remove unwanted styles...

SetWindowLong (appwindow, GWL_STYLE, style | WS_POPUP | WS_VISIBLE | SWP_FRAMECHANGED)
SetWindowLong (appwindow, GWL_EXSTYLE, exstyle)

' Update window...

SetWindowPos appwindow, HWND_TOP, mi.rcMonitorLeft, mi.rcMonitorTop, mi.rcMonitorRight - mi.rcMonitorLeft, mi.rcMonitorBottom - mi.rcMonitorTop, 0



in fact the solution was here :
https://www.syntaxbomb.com/index.php?topic=286.0

markcwm

#27
Great, nice one drfloyd. I assume it expands to whatever the screen size is, and is anti-aliased.

drfloyd

#28
yes,

whatever the screen size, no resolution swap ! (you just indicate the res of your game : Graphics 320,240,0,60 if 320x240)
anti aliased
and no FLIP problem

I don't know if it is as fast as a real fullscreen ? I suppose yes ? If someone can try with one of his Blitzmax game ? I have tried with some BLITZMAX samples, it seems to be perfect !

(and I don't know if someone can adapt this code to BLITZ 3D ?)

fielder

#29
Quote from: drfloyd on May 05, 2019, 17:40:03
Hello

In a BLITZMAX game, Windowed mode (so not full screen), is there a possibility to hide the textbar at the top ? (to simulate a fullscreen mode)

(I ask this question because I have difficulties with FLIP in fullscreen, and no problem in Window mode)

Thank you (and sorry again for my english very poor)

                hWnd = GetActiveWindow()
      Local tmp:Long = GetWindowLongA( hWnd, GWL_STYLE )
      tmp :~ WS_CAPTION
      SetWindowLongA( hWnd, GWL_STYLE, tmp )
      SetWindowPos( hwnd, 0, 0,0, 640,480, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED )

another example about windows api: http://mojolabs.nz/posts.php?topic=89650