[5.60/x64]3DEngine, MouseDeltaXY and Windows-Scaling <>100%

All bugs related to the 3D engine
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

[5.60/x64]3DEngine, MouseDeltaXY and Windows-Scaling <>100%

Post by GPI »

When in in the Windows-Settings the Scaling is set to a diffrent Value than 100%, the MouseDeltaX/Y() return complete to high values. But only when the 3DEngine is activ.

(Win10, Surface4 Pro, Scaling to 200%, setting is under "win10-Einstellungen / System / Bildschirm/ Skalierung und Anordnung", should be "win10 Settings/Preferences / System/ Screen / Scaling")

edit: And MouseX/Y() return after a small movement always the maximal screen values.

for example (form the manual): Even small movement (dy <10) will return values over 700.

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Material
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

#CameraSpeed = 1

IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()

  Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Models", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    AmbientColor(RGB(255,255,255))
    
    LoadMesh   (0, "robot.mesh")
    CreateMaterial(0, LoadTexture(0, "r2skin.jpg"))

    CreateMaterial(1, LoadTexture(1, "clouds.jpg"))
    MaterialBlendingMode(1, #PB_Material_AlphaBlend)  ; Alphablending for this texture
    
    CreateEntity  (0, MeshID(0), MaterialID(1))
    CreateEntity  (1, MeshID(0), MaterialID(0))
 
    MoveEntity(1, 60, 0, 0)
    
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, 0, 40, 150, #PB_Absolute)
      
    Repeat
      Screen3DEvents()
      
      If ExamineMouse()
        Debug ""+MouseDeltaX()+" "+MouseDeltaY()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed 
        Else
          KeyX = 0
        EndIf
                  
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed 
        Else
          KeyY = 0
        EndIf

      EndIf
          
      RotateEntity(0, 0, -0.5, 0, #PB_Relative)
      RotateEntity(1, 0, 0.5, 0, #PB_Relative)
      
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera  (0, KeyX, 0, KeyY)
      
      RenderWorld()
      Screen3DStats()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
    
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
  
End
Without 3DEngine, everything works fine:

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Mouse example file
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

If InitMouse() = 0 Or InitSprite() = 0 Or InitKeyboard() = 0
  MessageRequester("Error", "Can't open DirectX", 0)
  End
EndIf

;
;-------- MessageReq and OpenScreen --------
;

MessageRequester("Information", "This will test the fast mouse access..."+Chr(10)+"Press any mouse button to quit!", 0)


OpenWindow(0,0,0,600,800,"test",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,600,800)

Repeat
  If WindowEvent()=#PB_Event_CloseWindow
    Break
  EndIf
  
  FlipBuffers()
  ClearScreen(#Black)
  ExamineKeyboard()
  ExamineMouse()                      
          
  x = MouseX()                         ; Returns actual x pos of our mouse
  y = MouseY()                         ; Returns actual y pos of our mouse
  dx=MouseDeltaX()
  dy=MouseDeltaY()
  
  StartDrawing(ScreenOutput())
  DrawText(0,100,"x:"+x+" y:"+y)
  DrawText(0,200,"dx:"+dx+" dy:"+dy)
  
  StopDrawing()
  

Until MouseButton(#PB_MouseButton_Left) Or MouseButton(#PB_MouseButton_Right)

End    
Last edited by GPI on Thu Aug 24, 2017 4:10 pm, edited 1 time in total.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: 3DEngine, MouseDeltaXY and Windows-Scaling <>100%

Post by GPI »

And important information: Only happend with OpenWindowScreen()...
Post Reply