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

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
DK_PETER
Addict
Addict
Posts: 898
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

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

Post 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)
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

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

Post 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)
地球上の平和
User avatar
DK_PETER
Addict
Addict
Posts: 898
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

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

Post 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
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

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

Post 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
地球上の平和
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

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

Post 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)
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

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

Post 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
地球上の平和
Post Reply