October 30, 2020, 07:30:52 AM

Author Topic: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina  (Read 780 times)

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 84
The code below works perfectly fine on windows but does not work on macOS Catalina. Switching to fullscreen triggers some issue that leads to drawing it as in the image linked below code. Any idea how to fix this?

Using SetViewport leads to even weirder issues, both in windowed mode and full screen. It either draws just a part of the bgImg in the bottom left corner of the screen or the top part of bgImg at the top of the screen.

However, if I set a different width and height for the graphics call and leave everything else as is (with or without viewport), it works. For example 1110x619 works fine but 800x450 does not. It is not a matter of aspect ratio (does not matter if it's 16/9 or 4/3 or whatever).

Code: BlitzMax
  1.  
  2. Framework SDL.gl2sdlmax2d
  3. Import brl.jpgloader
  4.  
  5. Global fullscreen%=0
  6.  
  7.  
  8. Graphics 800,600,fullscreen
  9. SetBlend(ALPHABLEND)
  10.  
  11. Global bgImg:TImage=LoadImage("graphics/p1_wallpaper.jpg")
  12. 'Global bgImg:TImage=LoadImage("graphics/bgimg.jpg")
  13. If Not bgImg Then RuntimeError("cant load bgImg")
  14.  
  15. 'SetViewport(0,0,1920,1080)
  16. SetVirtualResolution(1920,1080)
  17.  
  18.  
  19.  
  20. Repeat
  21.  
  22.         Cls
  23.         DrawImage (bgImg,0,0)
  24.         DrawText(MouseX()+","+MouseY(),10,10)
  25.         Flip
  26.        
  27.         If KeyHit (KEY_ESCAPE) Or AppTerminate() Then End
  28.         If KeyHit(KEY_1) Then PrintViewPort()
  29.         If KeyHit(KEY_2)Then printcoords()
  30.         If KeyHit (KEY_3) Then
  31.                 fullscreen=Not(fullscreen)
  32.                 EndGraphics()
  33.                 ReInitGraphics()
  34.         EndIf
  35.                
  36. Forever
  37.  
  38. Function ReInitGraphics()
  39.         Graphics 800,600,fullscreen
  40.         SetVirtualResolution(1920,1080)
  41. EndFunction
  42.  
  43.  
  44. Function PrintViewPort()
  45.         Local xo%, yo%, vw%,vh%
  46.  
  47.         GetViewport(xo,yo,vw,vh)
  48.         Print "viewport:"+xo+","+yo+","+vw+","+vh
  49.         Local x#,y#
  50.         GetOrigin( x,y )
  51.         Print "origin:"+x+","+y
  52. EndFunction
  53.  
  54. Function PrintCoords()
  55.         Print ("x:"+MouseX()+"y:"+MouseY())
  56.         Print("vx:"+VirtualMouseX()+" vy:"+VirtualMouseY())
  57. EndFunction
  58.  
  59.  

Image: https://drive.google.com/file/d/192Kur5i7nMhaIa8yTOcYBdyN0zmcGuBi/view?usp=sharing

Offline Lavalamp

  • Jr. Member
  • **
  • Posts: 11
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #1 on: August 07, 2020, 09:37:47 PM »
I've raised this several times now. :( Additionally if you enable HiDPI you cant create 64-32 bit binary only 32.

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 84
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #2 on: August 08, 2020, 05:29:30 AM »
What is HiDPI and how do you enable it?

I am still having issues with fullscreen mode. CMD+Tab does not work, do you guys have any idea how to fix that?


Offline Derron

  • Hero Member
  • *****
  • Posts: 3237
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #3 on: August 08, 2020, 07:12:51 AM »
Did you raise an issue for it?

I at least mentioned this thread in the issues discord channel for now.


Bye
Ron

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1980
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #4 on: August 08, 2020, 07:43:57 AM »
Checking over the code on a mac I can confirm the errors both with fullscreen and the cmd+tab

It's not and issue with NG its an issue with the code itself. MacOS needs to be set up in a different way to windows. I can't elaborate more as I am having the same issues. but I will come up with a solution for you :)

Offline Derron

  • Hero Member
  • *****
  • Posts: 3237
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #5 on: August 08, 2020, 08:55:56 AM »
It happen with SDL and non-SDL ?

Code: BlitzMax
  1. SuperStrict
  2. Framework Brl.StandardIO
  3. 'old releases
  4. 'Import Brl.Random
  5. 'new modules
  6. Import Brl.RandomDefault
  7.  
  8. 'NON-SDL
  9. 'Import Brl.GLMax2D
  10. 'SDL
  11. 'Import SDL.GLSDLMax2D
  12. 'or SDL GL2
  13. Import SDL.GL2SDLMax2D
  14.  
  15. Graphics(800, 600)
  16. SetBlend AlphaBlend
  17. SetColor 255,255,255
  18. SetClsColor 40, 80, 160
  19. While Not KeyDown(KEY_ESCAPE)    
  20.     Cls
  21.    
  22.     SeedRnd(MilliSecs() / 1000)
  23.     For Local i :Int = 0 To 100
  24.         SetColor Rand(0,255), Rand(0,255), Rand(0,255)
  25.         DrawText("Hey", Rand(0, GraphicsWidth()-50), Rand(0, GraphicsHeight()-20))
  26.     Next
  27.    
  28.     Flip
  29. Wend
  30.  
  31. End
  32.  

?
(add your virtual resolution commands on your own)

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1980
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #6 on: August 08, 2020, 10:41:37 AM »
@derron- the issue is to do with native Commands and full screen. To do it properly, you have to call the correct commands and have the app core set up in a certain way. Using setgraphics is not the way to do it - especially when switching from windowed mode...

I’m looking into how get the correct result

Offline Derron

  • Hero Member
  • *****
  • Posts: 3237
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #7 on: August 08, 2020, 11:40:30 AM »
SetGraphics should be working ...

SDL provides its own "set fullscreen" thing ...

TSDLWindow.SetFullScreen:
Code: [Select]
Rem
bbdoc: Sets the window's fullscreen state.
returns: 0 on success or a negative error code on failure.
about: @flags may be SDL_WINDOW_FULLSCREEN, for "real" fullscreen with a videomode change; SDL_WINDOW_FULLSCREEN_DESKTOP
for "fake" fullscreen that takes the size of the desktop; and 0 for windowed mode.
End Rem
Method SetFullScreen:Int(flags:UInt)
Return SDL_SetWindowFullscreen(windowPtr, flags)
End Method


I assume it needs a bit more to do "borderless windowed fullscreen" (app without decorations in the size of the "display" but not true full screen).


Code: BlitzMax
  1.  
  2. Graphics(800, 600)
  3. SetBlend AlphaBlend
  4. SetColor 255,255,255
  5. While Not KeyDown(KEY_ESCAPE)    
  6.     Cls
  7.  
  8.         If KeyHit(KEY_SPACE)
  9.                 Local window:TSDLWindow = TSDLGLContext.GetCurrentWindow()
  10.                 If Not window
  11.                         Print "cannot find TSDLWindow - fullscreen switch not possible"
  12.                 Else
  13.                         If Not doFullScreen
  14.                                 doFullscreen = True
  15.  
  16.                                 Local display:TSDLDisplay = window.GetDisplay()
  17.                                 Local displayMode:TSDLDisplayMode = display.GetCurrentDisplayMode()
  18.                                 Print "full active display size: " + displayMode.Width() + "x" + displayMode.Height()
  19.                                 window.SetBordered(0) 'disable borders
  20.                                 window.SetFullScreen(SDL_WINDOW_FULLSCREEN_DESKTOP)
  21.                                 Graphics(displayMode.Width(), displayMode.Height())
  22.                         Else
  23.                                 doFullScreen = False
  24.                                
  25.                                 Print "back to windowed mode"
  26.                                
  27.                                 window.SetBordered(1) 'enable borders
  28.                                 window.SetFullScreen(0)
  29.                                 Graphics(800, 600)
  30.                         EndIf
  31.                 EndIf
  32.         EndIf
  33.    
  34.         SeedRnd(MilliSecs() / 1000)
  35.         For Local i :Int = 0 To 100
  36.                 SetColor Rand(0,255), Rand(0,255), Rand(0,255)
  37.                 DrawText("Hey", Rand(0, GraphicsWidth()-50), Rand(0, GraphicsHeight()-20))
  38.         Next
  39.    
  40.     Flip
  41. Wend
  42.  
  43. End
  44.  

you might be able to remove the borders when appending the flag to the graphics command:
Graphics(800, 600, 0,0, SDL_WINDOW_BORDERLESS)

Here on linux it does not remove the borders - so I am not sure about it.


bye
Ron

Offline Derron

  • Hero Member
  • *****
  • Posts: 3237
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #8 on: August 08, 2020, 11:58:25 AM »
Another thing to note:

When using "SDL" the window is created using "sdl.mod/sdlgraphics.mod/sdlgraphics.bmx"

In there is the method:
Code: [Select]
Method SDLGraphicsCreateGraphics:TGraphicsContext(width:Int,height:Int,depth:Int,hertz:Int,flags:Int,x:Int,y:Int)
...


Else

If depth Then
windowFlags :| SDL_WINDOW_FULLSCREEN
' mode = MODE_DISPLAY
Else
If flags & $80000000 Then
windowFlags :| SDL_WINDOW_FULLSCREEN_DESKTOP
End If
' mode = MODE_WINDOW
...

Have seen this $80000000 ?? This should correspond to the "SDL_FULLSCREEN" flag ... so when passing this but not providing a "depth" in the graphics command, you should get a desktop sized fullscreen window.

If you try to add this to the initial "graphics()" command in my code you will see an application which occupies your whole desktop - but only renders in the bottom left area in the size of 800x600.

this somehow looks similar to what the OP/Ashmoor experienced.



Edit: With Ashmoor's code get different results on my linux box:
- going into fullscreen and I only see a big big part of a number (so scaled up by some hundred percents)
- going out of fullscreen: works
- going again into fullscreen: works (it now properly scales the bg image for me)

Ok, so I copy pasted the stuff in "Key_3" ... so it automatically goes "into, out, into" ... and it is still borked up there. I added delays, added "cls; flip" lines over and over... but it was not "automatizable". Surely this is not just a bug for "OS X" but more a generic issue with Max2D ? (maybe not on windows though...)

hmmm .. played a bit more with it, and now "windowed -> fullscreen" works for me (linux, only brl.glmax2d, not sdl.glmax2d)

bye
Ron

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 84
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #9 on: August 08, 2020, 06:36:52 PM »
Code: BlitzMax
  1. Import Brl.RandomDefault

I don't have this, was there a new version released? I used BRL.Random

Below are some screenshots gl2SdlMax2d looks exactly like non sdl.

"SDL provides its own "set fullscreen" thing ..."

This looks nice but dock covers the app both in SDL_WINDOW_FULLSCREEN_DESKTOP and SDL_WINDOW_FULLSCREEN

The following code switches to full screen but the resolution is wild: 3070x1438

Code: BlitzMax
  1. Framework SDL.gl2sdlmax2d
  2. Import brl.Random
  3.  
  4. Global doFullScreen
  5.  
  6. Graphics(800, 600)
  7.  
  8. Global vrWidth=1920
  9. Global vrHeight=1080
  10.  
  11. SetVirtualResolution(vrWidth, vrHeight)
  12. 'SetViewport(0,0,vrWidth,vrHeight)
  13. 'SetViewport(0,0,vrWidth*2,vrHeight*2)
  14.  
  15. SetBlend AlphaBlend
  16. SetColor 255,255,255
  17. While Not KeyDown(KEY_ESCAPE)    
  18.     Cls
  19.  
  20.         If KeyHit(KEY_SPACE)
  21.                 Local window:TSDLWindow = TSDLGLContext.GetCurrentWindow()
  22.                 If Not window
  23.                         Print "cannot find TSDLWindow - fullscreen switch not possible"
  24.                 Else
  25.                         If Not doFullScreen
  26.                                 doFullscreen = True
  27.  
  28.                                 Local display:TSDLDisplay = window.GetDisplay()
  29.                                 Local displayMode:TSDLDisplayMode = display.GetCurrentDisplayMode()
  30.                                 Print "full active display size: " + displayMode.Width() + "x" + displayMode.Height()
  31.                                 'window.SetBordered(0) 'disable borders
  32.                                 window.SetFullScreen(SDL_WINDOW_FULLSCREEN_DESKTOP)
  33.                                 'Graphics(displayMode.Width(), displayMode.Height())
  34.                         Else
  35.                                 doFullScreen = False
  36.                                
  37.                                 Print "back to windowed mode"
  38.                                
  39.                                 window.SetBordered(1) 'enable borders
  40.                                 window.SetFullScreen(0)
  41.                                 'Graphics(800, 600)
  42.                         EndIf
  43.                 EndIf
  44.         EndIf
  45.    
  46.         SeedRnd(MilliSecs() / 1000)
  47.         For Local i :Int = 0 To 100
  48.                 SetColor Rand(0,255), Rand(0,255), Rand(0,255)
  49.                 DrawText("Hey", Rand(0, vrWidth-50), Rand(0, vrHeight-20))
  50.         Next
  51.                
  52.                 SetScale(2.0,2.0)
  53.                 DrawText(VirtualMouseX()+","+VirtualMouseY(),10,10)
  54.                 SetScale(1.0,1.0)
  55.                
  56.     Flip
  57. Wend
  58.  
  59. End
  60.  

Thing is, I don't really care about using SDL and as long as the app can run, but with BRL the y coordinates are flipped in full screen. MacOS is wild.


Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1980
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #10 on: August 09, 2020, 11:41:21 AM »
@Ashmoor
The macOS itself handles fullscreen and zoom and maximize. And they are all slightly different and they require menu system as well!

Proper fullscreen (which is what you want) can be seen by the third green traffic light and a window - if this is NOT there - then whatever fullscreen you think is right - it isn't <- read and read that again
There used to be a fullscreen option in the app menu under window. but this has been removed. BEWARE to use fullscreen, maximize, zoom, etc you WILL have to have a windows menu for your app!

Fullscreen (ON A MAC) from a window is done by pressing the green button or ctrl+cmd+f <- pressing ctrl+cmd+f again will restore the window. You will also see the window animate from being a window to fullscreen. Cmd+tab will be happy etc.

DO NOT ASSUME ANYTHING ON A MAC.
Do not think using sdl or other frameworks will work correctly - they might, they will more than likely need much more setup and OS specific code to work correct.

Although you can use internal language/sdl commands to force fullscreen on a mac - IT"S NOT PROPER FULLSCREEN. It's a kludge that will eventually give you HUGE headaches, as nothing will quite be right - your users will know instantly - BEWARE!!!!!!!!!!!

I am tracking down some for of code answer for you - but it's not a simple thing... It's a framework. Unfortunately you will HAVE to adopt something similar which will mean recoding your main program loops, etc.

Porting code from windows to mac is not as easy as clicking build - unless you are using something very highlevel like unity - it will take care of the nasty internal framework code for you!

I'm sorry this is not an easy answer...  :'(

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 84
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #11 on: August 11, 2020, 12:54:35 PM »
I have managed to get some code to work and fit my needs. Here it is:

Code: BlitzMax
  1.  
  2. Framework SDL.gl2sdlmax2d
  3. Import brl.jpgloader
  4. Import brl.Random
  5. Import brl.StandardIO
  6.  
  7. Global isFullScreen
  8.  
  9. Global bgImg:TImage=LoadImage("graphics/screen_tester1.jpg")
  10. If Not bgImg Then RuntimeError("cant load bgImg")
  11.  
  12.  
  13. Global vrWidth=1920
  14. Global vrHeight=1080
  15.  
  16. Global wWidth=960
  17. Global wHeight=600
  18.  
  19. Global fsWidth=DesktopWidth()
  20. Global fsHeight=DesktopHeight()
  21.  
  22. Graphics (wWidth,wHeight)
  23. SetBlend AlphaBlend
  24. SetVirtualResolution(vrWidth, vrHeight)
  25.  
  26.  
  27. Repeat
  28.  
  29.         Cls
  30.         If KeyHit (KEY_SPACE) Then
  31.                 EndGraphics()
  32.                
  33.                 If Not isFullScreen Then
  34.                         'switch to full screen
  35.                         isFullScreen=True
  36.                        
  37.                         Graphics (fsWidth, fsHeight)
  38.                         SetVirtualResolution(1920,1080)
  39.                        
  40.                         Local window:TSDLWindow = TSDLGLContext.GetCurrentWindow()
  41.                         window.SetFullScreen(SDL_WINDOW_FULLSCREEN_DESKTOP)
  42.                        
  43.                 Else
  44.                         'switch to windowed
  45.                         isFullScreen=False
  46.                          
  47.                         Graphics (wWidth,wHeight)
  48.                         SetVirtualResolution(1920,1080)
  49.                         Local window:TSDLWindow = TSDLGLContext.GetCurrentWindow()
  50.                         window.SetFullScreen(0)
  51.                
  52.                 EndIf
  53.                
  54.        
  55.         EndIf
  56.  
  57. 'draw something so we can check
  58.                 DrawImage(bgImg,0,0)
  59.                
  60.         SeedRnd(MilliSecs() / 1000)
  61.         For Local i :Int = 0 To 100
  62.                 SetColor Rand(0,255), Rand(0,255), Rand(0,255)
  63.                 DrawText("Hey", Rand(0, vrWidth-50), Rand(0, vrHeight-20))
  64.         Next
  65.                 SetColor (255,255,255)
  66.                
  67.                 SetScale(2.0,2.0)
  68.                 DrawText("rm:"+MouseX()+","+MouseY(),10,30)
  69.                 DrawText(VirtualMouseX()+","+VirtualMouseY(),10,10)
  70.                 SetScale(1.0,1.0)
  71.                
  72.                 Local x:Float, y:Float
  73.                 x=VirtualMouseX(); y=VirtualMouseY()
  74.                
  75.                 DrawRect(x-5,y-5,10,10)
  76.  
  77.         Flip()
  78.  
  79. 'end condition
  80.         If KeyHit(KEY_ESCAPE) Or AppTerminate() Then End
  81. Forever
  82.  
  83.  

For some reason if I switch to full screen using the code above, calling osascript no longer works. Does anyone have any idea why or how to fix it?



Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1980
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #12 on: August 12, 2020, 06:30:57 AM »
sooo. You hacked a fullscreen - that's not proper fullscreen. \o/
And now you want to install some virus or do some other 'nasty' scriptkiddie stuff too? And MacOS wont let you...

Offline Ashmoor

  • Jr. Member
  • **
  • Posts: 84
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #13 on: August 17, 2020, 04:36:29 PM »
Why is this not "proper" full screen? Can you please explain what is expected of a proper full screen?

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1980
Re: BlitzmaxNG fullscreen virtual resolution issues macOS Catalina
« Reply #14 on: August 18, 2020, 06:47:26 AM »
first 2 questions for you:
1. do you use a mac?
2. did you compile the code on a mac?

ok. here's a detailed version to read:
https://www.techjunkie.com/leave-full-screen-os-x/

next
A mac is NOT windows. they use completely different commands and have different ways of doing things.

what is fullscreen on a mac?
- Is when a window covers the entire screen including the menu and taskbar.
- Putting the mouse at the top of the screen in this mode will show the menu and the title bar and allow you to switch mode back to window or OTHER screens - the mac can have multiple screens even on a mac with one monitor!
- a mac app which has TRUE fullscreen ability (see above) has a green top left button. this can be pressed to go into fullscreen
- ctrl+cmd+f will switch from window to fullscreen. the window will usually animate when it does this.
- cmd+tab will also function normally
- the app will  'window' as a menu item with sometimes minimise, zoom, fullscreen added.

anything else is NOT considered by apple or users as fullscreen - it MUST behave the way it should and use the correct icons, etc



 

SimplePortal 2.3.6 © 2008-2014, SimplePortal