It is currently Fri Feb 26, 2021 7:42 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: OpenWindowedScreen has no Autostretch
PostPosted: Thu Nov 08, 2012 4:40 am 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1488
Location: North by Northwest
Using OpenWindowedScreen for the first time on MacOS.
Autostretch doesn't work.
The main window is smaller than an image displayed in the windowed screen.
(main window has desktop size 1366x768 and the screen has 1920x1080 HTPC size)
On the Windows OS the screen (and the image) shrink and can be seen 100% on MacOS not.

How to activate autostretch on MacOS?

Thanks

_________________

I am to provide the public with beneficial shocks.
Alfred Hitshock


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen has no Autostretch
PostPosted: Thu Nov 08, 2012 8:37 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2088
Location: USA
Works here. You may want to post an example code of your issue. ;)

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen has no Autostretch
PostPosted: Sun Nov 11, 2012 6:36 am 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1488
Location: North by Northwest
On MacOS the following code only shows a quarter of the image...

Code:
If OpenWindow(0, 0, 0, 960, 540, "Gadget and sprites!", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  InitSprite()
  InitKeyboard()
  UseJPEGImageDecoder()
  ; open 1920 x 1080 screen
  OpenWindowedScreen(WindowID(0), 0, 0, 1920, 1080, 1, 0, 0, #PB_Screen_SmartSynchronization)
  ; load 1920x1080 jpg image
  ; macos
  LoadSprite(0, GetPathPart(ProgramFilename()) + "../../../" + "img/weather.jpg", #PB_Sprite_Texture | #PB_Sprite_Alpha | #PB_Sprite_Memory)
  ; windows
  ;LoadSprite(0, "img/weather.jpg", #PB_Sprite_Texture | #PB_Sprite_Alpha | #PB_Sprite_Memory)
  Repeat
   
    ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back)
    event = WaitWindowEvent(10)
   
    FlipBuffers()
   
    ClearScreen(RGB(0,0,0))

    DisplaySprite(0, 0, 0)
   
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape) Or event = #PB_Event_CloseWindow
EndIf


On Windows the whole image is shown...

_________________

I am to provide the public with beneficial shocks.
Alfred Hitshock


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen has no Autostretch
PostPosted: Sun Nov 11, 2012 8:26 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2088
Location: USA
I see what you are saying. Since your screen size is larger then your window size, you have to maximize then restore it back in order for it to fit the screen. Notice I change the window width and height by 1 pixel, to give a slightly maximized effect. Then it is returned to actual size with ResizeWindow(). This basically sets up the stretch feature on first launch. Here you go...

Code:
If OpenWindow(0, 0, 0, 961, 541, "Gadget and sprites!", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  InitSprite()
  InitKeyboard()
  UseJPEGImageDecoder()
  ; open 1920 x 1080 screen
  OpenWindowedScreen(WindowID(0), 0, 0, 1920, 1080, 1, 0, 0, #PB_Screen_SmartSynchronization)
  ; load 1920x1080 jpg image
  ; macos
  LoadSprite(0, "/Users/jbaker/Desktop/paradise.jpg", #PB_Sprite_Texture | #PB_Sprite_Alpha | #PB_Sprite_Memory)
  ; windows
  ;LoadSprite(0, "img/weather.jpg", #PB_Sprite_Texture | #PB_Sprite_Alpha | #PB_Sprite_Memory)
  ResizeWindow(0, #PB_Ignore, #PB_Ignore, 960, 540)
  Repeat
   
    ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back)
    event = WaitWindowEvent(10)
   
    FlipBuffers()
   
    ClearScreen(RGB(0,0,0))

    DisplaySprite(0, 0, 0)
   
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape) Or event = #PB_Event_CloseWindow
EndIf

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen has no Autostretch
PostPosted: Mon Nov 12, 2012 4:53 am 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1488
Location: North by Northwest
Thank you for this workaround.

IMHO OpenWindowedScreen should work the same on all OS though.

_________________

I am to provide the public with beneficial shocks.
Alfred Hitshock


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen has no Autostretch
PostPosted: Mon Nov 12, 2012 8:49 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 2088
Location: USA
No problem. ;)

Fred just did recently get the stretch feature working on Mac. So it being new, it may not behave exactly like the Windows version. I'm just glad it works now. :D

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen has no Autostretch
PostPosted: Sun Feb 09, 2020 1:45 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14181
Location: France
Seems to work just fine in current version, can anybody else confirm ?

Code:
If OpenWindow(0, 0, 0, 960, 540, "Gadget and sprites!", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  InitSprite()
  InitKeyboard()
  UseJPEGImageDecoder()
  ; open 1920 x 1080 screen
  OpenWindowedScreen(WindowID(0), 0, 0, 1920, 1080, 1, 0, 0, #PB_Screen_SmartSynchronization)
  ; load 1920x1080 jpg image
  ; macos
  ;
  CreateSprite(0, 1920, 1080)
 ; LoadSprite(0, GetPathPart(ProgramFilename()) + "../../../" + "img/weather.jpg")
  ; windows
  ;LoadSprite(0, "img/weather.jpg", #PB_Sprite_Texture | #PB_Sprite_Alpha | #PB_Sprite_Memory)
  Repeat
   
    ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back)
    event = WaitWindowEvent(10)
   
    FlipBuffers()
   
    ClearScreen(RGB(0,0,255))

    DisplaySprite(0, 0, 0)
   
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape) Or event = #PB_Event_CloseWindow
EndIf


Screen should be full black


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen has no Autostretch
PostPosted: Mon Jun 22, 2020 11:39 am 
Offline
User
User

Joined: Mon Nov 18, 2013 7:24 am
Posts: 17
There are still issues with how OpenWindowedScreen works on MacOS (MacOS 10.15.5 and PB 5.72). Using the code posted at the end for testing:

1) On a "non-retina" screen connected to the Mac, everything works as expected, EXCEPT: mouse is captured, but is actually offset from the window so that when you click, you actually click on somewhere else on the desktop and your window loses focus. The mouse is "captured" off of the window, making Windowed Screens with captured mouse unusable.

2) On a "retina" screen (in-built laptop screen), a window of 500x500 is double the size of a screen of 500x500. This sort of makes sense, as the rendering surface is actually higher DPI, but the desktop DPI gets reported as 1.00, making it hard to adjust for.

3) On a "retina" screen, if you attempt to create the 2x resolution surface as above and then scale up the window to 2x size, the surface doesn't seem to scale with the window. The ClearScreen() still clears the entire window, but the mouse and ScreenOutput() drawing is clipped to the bottom-left quarter of the windowed screen?

I can attempt to explain better if needed.

Code:
EnableExplicit

Structure Point
  x.f
  y.f
EndStructure

Structure Platform
  x1.f
  y1.f
  x2.f
  y2.f
EndStructure

Declare CreatePlatform(x1.f, y1.f, x2.f, y2.f)
Declare CreateMouse()

; General pre-setup stuff / initializations
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
  MessageRequester("Startup error", "There was an error initializing the hardware. Exiting...")
  End
EndIf

UsePNGImageDecoder()

; General constants
#SCREEN_WIDTH = 500
#SCREEN_HEIGHT = 500

ExamineDesktops()

If OpenWindow(0, 100, 100, #SCREEN_WIDTH/2, #SCREEN_HEIGHT/2, "PB DRAWING TEST", #PB_Window_ScreenCentered) = 0
  MessageRequester("Startup error", "There was an error opening the window. Exiting...")
  End
EndIf
 

; Open the screen for rendering...
If OpenWindowedScreen(WindowID(0),0,0, #SCREEN_WIDTH, #SCREEN_HEIGHT, 1, 0, 0, #PB_Screen_WaitSynchronization) = 0
  MessageRequester("Startup error", "There was an error initializing rendering. Exiting...")
  End
EndIf

CreateMouse();
ReleaseMouse(1)

Debug(Str(DesktopResolutionX()))
SetFrameRate(60)

Define e.i ; event handler
Define quit = #False

Define lastClick.Point
lastClick\x = 0
lastClick\y = 0

Global NewList platforms.Platform()

; initialize some test platforms
Define i.i
For i = 0 To 1000
  CreatePlatform(Random(#SCREEN_WIDTH), Random(#SCREEN_HEIGHT), Random(#SCREEN_WIDTH), Random(#SCREEN_HEIGHT))
Next

;ReleaseMouse(#True)

Define MouseClicked.a = #False
ReleaseMouse(0)

;- Start the main loop -----------------------
Repeat
  ;- Process events loop ---------------------
  Repeat
    e = WindowEvent()
    Select e
      Case #PB_Event_CloseWindow
        quit = #True
       
    EndSelect
  Until e = 0
 
  ;- Main game loop -------------------------
   
  ExamineKeyboard()
  ExamineMouse()
 
  If MouseButton(#PB_MouseButton_Left)
    If Not MouseClicked
      ; The mouse was clicked and we need to create another platform
      CreatePlatform(lastClick\x, lastClick\y, MouseX(), MouseY())
      lastClick\x = MouseX()
      lastClick\y = MouseY()
      MouseClicked = #True
    EndIf
  Else
    MouseClicked = #False
  EndIf
   
  If KeyboardPushed(#PB_Key_Escape)
    quit = #True
  EndIf
 
  If KeyboardPushed(#PB_Key_1 )
    ResizeWindow(0, #PB_Ignore, #PB_Ignore, #SCREEN_WIDTH*2, #SCREEN_HEIGHT*2)
  EndIf
 
  ;- Draw game
  ClearScreen(RGB(0,0,Random(200)))
 
 
  ; Draw mouse
  DisplayTransparentSprite(0,MouseX(),MouseY())
 
  StartDrawing(ScreenOutput())
 
  ForEach platforms()
    platforms()\x1 = platforms()\x1 + 1
    LineXY(platforms()\x1, platforms()\y1, platforms()\x2, platforms()\y2, $FFFFFF) 
  Next
 
  StopDrawing()
 
  FlipBuffers()
 
Until quit = #True

Procedure CreateMouse()
;   CreateImage(0, 32, 32, 24, $000000)
;   StartVectorDrawing(ImageVectorOutput(0))
;   VectorSourceColor($000000)
;   AddPathSegments("M 0 0 L 32 0 L 0 32 Z")
;   FillPath()
;   StopVectorDrawing()

;   StartDrawing(SpriteOutput(0))
;   DrawImage(0,0,0)
;   StopDrawing()
;   FreeImage(0)       
  LoadSprite(0, "assets/cursor_t.png",#PB_Sprite_AlphaBlending)
EndProcedure

Procedure CreatePlatform(x1.f, y1.f, x2.f, y2.f)
  Define *p.Platform = AddElement(platforms())
  With *p
    \x1 = x1
    \y1 = y1
    \x2 = x2
    \y2 = y2
  EndWith
 
  ;Debug("Platform created.")
EndProcedure


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen has no Autostretch
PostPosted: Sat Jun 27, 2020 1:03 am 
Offline
User
User

Joined: Mon Nov 18, 2013 7:24 am
Posts: 17
Playing around with it more: without an external display attached, sometimes the rendering surface appears to be the "correct" size (aka, actually takes up the whole window) and sometimes it appears as "true pixels" I guess, and therefore takes up only a quarter of the window. It varies from run to run which version you will get?

Every time you resize the window via ResizeWindow() though, it returns to being the quarter-window size. Every time you resize the window with the mouse, it corrects itself and stretches to the whole window. Extremely inconsistent.....

Windowed screens are completely unusable on MacOS at this time--at least for recent Macs with Hi-DPI screens.


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenWindowedScreen has no Autostretch
PostPosted: Thu Feb 18, 2021 11:18 am 
Offline
User
User

Joined: Mon Jun 30, 2008 4:36 pm
Posts: 84
Location: UK
I just came across a similar problem on macOS with a 12-inch Retina MacBook from 2016. I would display a sprite at y=0 and it would appear half way down the screen. This bug is from 2012!!! I’m really disappointed in PureBasic. It’s so incredibly buggy and I’m unlikely to use it for any new projects now it’s just a liability.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye