Page 1 of 1

Don't let dpi-awareness influence WindowedScreen...Please.

Posted: Sun Sep 27, 2020 4:41 pm
by DK_PETER
(Windows - dpi settings 125)
Test code with and without dpi-awareness in compiler settings.
It's actually quite annoying, when you're working with 3D, sprites and mouse delta.

Code: Select all

InitSprite()
InitKeyboard()

OpenWindow(0, 0, 0, 800, 600, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)

Repeat : 
  ClearScreen(0)
  Repeat : ev = WindowEvent() : Until ev = 0
  
  
  FlipBuffers()
  
  ExamineKeyboard()
  
Until KeyboardPushed(#PB_Key_Escape)

Re: Don't let dpi-awareness influence WindowedScreen...Pleas

Posted: Sun Sep 27, 2020 6:29 pm
by Saki
This is the normal behavior of a pixel-based output.
The whole DPI aware thing just s.cks.

Code: Select all

InitSprite()
InitKeyboard()

OpenWindow(0, 0, 0, 800, 600, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800*DesktopResolutionX(), 600*DesktopResolutionY())

Repeat :
  ClearScreen(0)
  Repeat : ev = WindowEvent() : Until ev = 0
 
 
  FlipBuffers()
 
  ExamineKeyboard()
 
Until KeyboardPushed(#PB_Key_Escape)

Re: Don't let dpi-awareness influence WindowedScreen...Pleas

Posted: Sun Sep 27, 2020 6:32 pm
by DK_PETER
@Saki
I agree wholeheartedly..

Here's another example: Simple window and canvas (WindowMouseX/Y)
Edit:
For it to work you must use: DesktopUnscaledX(WindowMouseX(0)) and the same for Y.
I just find it extremely tedious to remember to do it like this..

Anyway...I do not expect an automated solution and know it's an annoying Windows feature
which we must live with.

Take the feature request as a rant to let off some steam. :)

Code: Select all

;Switch dpi awareness on/off

Structure Centerpos
  x.i
  y.i
EndStructure

Structure Positions
  c.Centerpos
  w.f
  h.f
EndStructure

Structure Object
  id.i
  pic.i
  pos.Positions
EndStructure
Global NewList o.Object()
  
Declare.i InsertObject()

OpenWindow(0, 0, 0, 1024, 768, "Test", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
BindEvent(#PB_Event_LeftClick, @InsertObject())

Repeat
  
  ev = WaitWindowEvent()
  
Until ev = #PB_Event_CloseWindow

Procedure.i InsertObject()
  AddElement(o())
  o()\pos\c\x = WindowMouseX(0)
  o()\pos\c\y = WindowMouseY(0)
  o()\pos\w   = 200
  o()\pos\h   = 40
  o()\pic = CreateImage(#PB_Any, 512, 128)
  StartDrawing(ImageOutput(o()\pic))
  DrawingMode(#PB_2DDrawing_Gradient)
  FrontColor(0) : BackColor($AAAAAA)
  LinearGradient(0, 0, OutputWidth(), OutputHeight())
  Box(0, 0, OutputWidth(), OutputHeight())
  DrawingMode(#PB_2DDrawing_Default)
  Box(4, 4, OutputWidth()-8, OutputHeight()-8, RGB(Random(255, 20), Random(255, 20), Random(255,20)))
  StopDrawing()
  o()\id = CanvasGadget(#PB_Any, o()\pos\c\x - o()\pos\w / 2, o()\pos\c\y - o()\pos\h / 2, o()\pos\w, o()\pos\h)
  StartDrawing(CanvasOutput(o()\id))
  DrawImage(ImageID(o()\pic), 0, 0, OutputWidth(), OutputHeight())
  StopDrawing()
EndProcedure

Re: Don't let dpi-awareness influence WindowedScreen...Pleas

Posted: Sun Sep 27, 2020 11:15 pm
by Saki
Hi DK_PETER
Yes, it's no fun LOL
I have already tormented myself a lot with it.
In the meantime it works, but it is still extremely annoying.

For Windowed Screen you can also do it the other way round, like this :

Code: Select all

OpenWindow(0, 0, 0, 800/DesktopResolutionX(), 600/DesktopResolutionX(), "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
Best Regards Saki

Re: Don't let dpi-awareness influence WindowedScreen...Pleas

Posted: Mon Sep 28, 2020 5:35 am
by VB6_to_PBx
Saki wrote:Hi DK_PETER
Yes, it's no fun LOL
I have already tormented myself a lot with it.
In the meantime it works, but it is still extremely annoying.

For Windowed Screen you can also do it the other way round, like this :

Code: Select all

OpenWindow(0, 0, 0, 800/DesktopResolutionX(), 600/DesktopResolutionX(), "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
Best Regards Saki
Saki ,
did you really mean for both of them to be :
600/DesktopResolutionX()
??

should it be this instead ? 600/DesktopResolutionY()
OpenWindow(0, 0, 0, 800/DesktopResolutionX(), 600/DesktopResolutionY(), "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

Re: Don't let dpi-awareness influence WindowedScreen...Pleas

Posted: Mon Sep 28, 2020 8:40 am
by Saki
HI VB6_to_PBx
The modern digital monitors all have square pixels, where x and y are always the same.

Best Regards Saki