It is currently Wed Oct 21, 2020 2:44 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Don't let dpi-awareness influence WindowedScreen...Please.
PostPosted: Sun Sep 27, 2020 4:41 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 870
Location: Denmark
(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:
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)

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 10, Intel 6800K, GeForce Gtx 1060, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: Don't let dpi-awareness influence WindowedScreen...Pleas
PostPosted: Sun Sep 27, 2020 6:29 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 265
Location: Pandora
This is the normal behavior of a pixel-based output.
The whole DPI aware thing just s.cks.

Code:
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)

_________________
地球上の平和


Top
 Profile  
Reply with quote  
 Post subject: Re: Don't let dpi-awareness influence WindowedScreen...Pleas
PostPosted: Sun Sep 27, 2020 6:32 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 870
Location: Denmark
@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:
;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

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 10, Intel 6800K, GeForce Gtx 1060, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: Don't let dpi-awareness influence WindowedScreen...Pleas
PostPosted: Sun Sep 27, 2020 11:15 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 265
Location: Pandora
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:
OpenWindow(0, 0, 0, 800/DesktopResolutionX(), 600/DesktopResolutionX(), "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)


Best Regards Saki

_________________
地球上の平和


Top
 Profile  
Reply with quote  
 Post subject: Re: Don't let dpi-awareness influence WindowedScreen...Pleas
PostPosted: Mon Sep 28, 2020 5:35 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon May 09, 2011 9:36 am
Posts: 535
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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Don't let dpi-awareness influence WindowedScreen...Pleas
PostPosted: Mon Sep 28, 2020 8:40 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 265
Location: Pandora
HI VB6_to_PBx
The modern digital monitors all have square pixels, where x and y are always the same.

Best Regards Saki

_________________
地球上の平和


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 guests


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