SyntaxBomb - Indie Coders

Languages & Coding => BlitzMax / BlitzMax NG => Topic started by: drfloyd on May 05, 2019, 05:40:03 PM

Title: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 05, 2019, 05:40:03 PM
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)
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: Derron on May 05, 2019, 06:02:02 PM
What problem with flip do you have?

Sdl.mod (and the sdl graphics) should allow a borderless window.


Bye
Ron
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 05, 2019, 06:09:39 PM
I use multi FLIP in a loop and it is a big problem in fullscreen, not in window mode.

What is Sdl.mod please ?
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: Derron on May 05, 2019, 06:33:05 PM
A default module in BlitzMax NG.


@ multiple flip
This is not a bug in BlitzMax but most probably in your code.
A flip does swap buffers. Should not matter where you call it and how often.

Bye
Ron
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: markcwm on May 05, 2019, 06:52:21 PM
There's a Blitzmax module tweak that can do this Borderless graphics modes (http://www.mojolabs.nz/posts.php?topic=102797), you'll have to edit the files yourself as this was never included in Blitzmax brl.mod or Maxmods brl.mod (which is Brucey's version).

The alternative as Derron says is to use sdl.mod and it seems wxMax supports this too.
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 05, 2019, 06:53:51 PM
Yes Derron, I know it is not a bug, but my game is finish (1000ko .txt !) in BLITZ3D windowed... I used FLIP as a REFRESH, not as a SWAP.... It don't want to recode ALL in MAX for Fullscreen.... It is for that reason I just want a windowed mode fullscreen

In fact I want to use FLIP as a REFRESH, not as a SWAP.... it is not possible ???

BLITZ NG is now stable and fully fonctional ? (last time I try it, the compilation .EXE was not working)
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: Steve Elliott on May 05, 2019, 07:01:50 PM
Why do you think we flip screens?  Some languages call it a refresh or sync but it accomplishes the same thing.

It means that we don't get flickering, that is why.  You write to a hidden screen then quickly 'flip' the drawn screen into view.  If you draw to a screen as it's updating you would get flickering.  You should have understood this basic concept before ever writing a large program.  It is your fault, not the language.
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 05, 2019, 07:29:17 PM
No, not really the same thing : in some langage the "FLIP" is a single back buffer, a real redraw... and you can insert several "FLIP" anywhere in a loop, without any flickering.

I used it like this (a mistake for BLITZ i know)... It was working in windowed mode, but when I decided to use fullscreen, of course flickering come to me :)

perhaps I am not clear ! LOL
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: Steve Elliott on May 05, 2019, 07:56:39 PM
Flipping screens multiple times is asking for trouble.  You should simply draw to a back buffer and then flip that screen once per game loop.
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: Qube on May 05, 2019, 08:42:36 PM
If I remember correctly in Blitz3D windowed mode the command FLIP didn't didn't work the same as in fullscreen mode. You could draw a few things > flip > draw a little more > flip and it would display fine. Doing that in fullscreen would result in a flickering mess.

In a nutshell drfloyd, you've coded your game to fit with that windowed mode oddity and unfortunately it's not going to be the same in fullscreen mode. In fullscreen mode you are dealing with front and back buffers and there is no magic fix to make it act like windowed mode.
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: Derron on May 05, 2019, 09:56:13 PM
@ Qube
The intial post says "BlitzMax".


bye
Ron
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: Qube on May 05, 2019, 10:17:20 PM
@ Qube
The intial post says "BlitzMax".
I know but later on he mentions his flip thing with Blitz3D and wants his flip thing in Blitz3D to do the same in BlitzMAX to which it doesn't as that not how the flip thing works.
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 05, 2019, 10:29:18 PM
If I remember correctly in Blitz3D windowed mode the command FLIP didn't didn't work the same as in fullscreen mode. You could draw a few things > flip > draw a little more > flip and it would display fine. Doing that in fullscreen would result in a flickering mess.

In a nutshell drfloyd, you've coded your game to fit with that windowed mode oddity and unfortunately it's not going to be the same in fullscreen mode. In fullscreen mode you are dealing with front and back buffers and there is no magic fix to make it act like windowed mode.

exactly, BLITZ 3D was working like this in windowed mode, it was not a swap but a refresh

I will stay in BLITZ and windowed for this game so... to many thins to re-code...
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: Qube on May 05, 2019, 11:15:07 PM
exactly, BLITZ 3D was working like this in windowed mode, it was not a swap but a refresh

I will stay in BLITZ and windowed for this game so... to many thins to re-code...
I'd say that the best thing to do. Finish off your game but as a windowed game. In future and even in windowed mode always have your main loop as clear screen > draw > flip. That way it'll work in windowed and full screen :)
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 06, 2019, 07:22:07 AM
Yes, I will finish in BLITZ 3D & Windowed mode.

Even if a have perhaps find a solution with BLITZ3D (I remember what i want to do : freeze the main graphic screen, and open a little animation in a window)

setbuffer backbuffer()

do
  clear screen
  draw
  FLIP
  gosub addanim
loop

.addanim
  setbuffer frontbuffer()
  draw
  setbuffer backbuffer()
return

It seems to work but this is shit LOL
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: fielder on May 06, 2019, 07:46:52 AM
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"
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 06, 2019, 05:08:54 PM
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.
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: markcwm on May 06, 2019, 05:55:34 PM
If it's in Blitz3d you could use this - Windowed full screen graphics mode (http://www.mojolabs.nz/codearcs.php?code=3076) (by Zethrax)
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 06, 2019, 09:25:29 PM
great  !

but BLITZ website is down... and this library no more available.
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: Qube on May 06, 2019, 09:37:12 PM
great  !

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

Recommended decls and extras :

http://www.mojolabs.nz/codearcs.php?code=1179 - user32.decls
http://www.mojolabs.nz/codearcs.php?code=1180 - kernel32.decls
http://www.mojolabs.nz/codearcs.php?code=1181 - gdi32.decls
http://www.mojolabs.nz/codearcs.php?code=1607 - Win32 Constants
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: markcwm on May 06, 2019, 10:44:53 PM
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 (http://www.mojolabs.nz/codearcs.php?code=3212) (by RemiD).
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: Yellownakji on May 07, 2019, 12:17:45 PM
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...........
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 07, 2019, 05:09:23 PM
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 (http://www.mojolabs.nz/codearcs.php?code=3212) (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
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: markcwm on May 08, 2019, 05:26:45 AM
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_".

Code: [Select]
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 )
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 08, 2019, 09:54:28 AM
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 ?
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: markcwm on May 10, 2019, 04:09:37 AM
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.
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 11, 2019, 11:23:29 PM
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 !)


Code: [Select]
' 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
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: markcwm on May 12, 2019, 03:16:27 AM
Great, nice one drfloyd. I assume it expands to whatever the screen size is, and is anti-aliased.
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on May 12, 2019, 08:28:45 AM
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 ?)
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: fielder on May 28, 2019, 08:26:27 AM
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
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: drfloyd on June 13, 2019, 09:19:37 PM
thank you

it's good, but it is not fullscreen

is it possible to adapt the graphic area to the desktop screen ?
Title: Re: possible to hide the window text bar in Blitzmax ?
Post by: fielder on June 15, 2019, 09:08:16 PM
emh.. on fullscreen there is not title bar...

Code: [Select]
Graphics 640,480,32
alternatively look at this: https://www.syntaxbomb.com/index.php?topic=286.0