Page 1 of 1

Can a windowed 3D world be resized automatically

Posted: Sun Dec 11, 2016 8:28 am
by coco2
I have tried to do this with the following code but it doesn't seem to work. When I try to resize it bigger the black 3D world doesn't seem to stretch.

Code: Select all

Procedure Init()
  If Not InitEngine3D()
    Debug "Could not initialise 3D engine"
    MessageRequester("Error", "Could not initialize 3D engine",0)
    ProcedureReturn 0
  EndIf
  
  InitSprite()
  InitKeyboard()
  InitMouse()  
  
  ExamineDesktops()
  
  DesktopW = DesktopWidth(0)
  DesktopH = DesktopHeight(0)
  
  If Not OpenWindow(0, 0, 0, DesktopW/2, DesktopH/2, "Description", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
    Debug "Could not initialise window"
    MessageRequester("Error", "Could not initialize window",0)
    ProcedureReturn 0
  EndIf
  
  If Not OpenWindowedScreen(WindowID(0), 0, 0, DesktopW/2, DesktopH/2, #True, 0, 0, #PB_Screen_SmartSynchronization)
    Debug "Could not initialise windowed screen"
    MessageRequester("Error", "Could not initialise windowed screen",0)
    ProcedureReturn 0
  EndIf
  ProcedureReturn 1
EndProcedure

Procedure Main()
  
  Quit = 0
  
  Repeat ; main loop
    
    Repeat ; process all events
      Event = WindowEvent()
      Select Event
        Case #PB_Event_CloseWindow
          Quit = 1
      EndSelect
    Until Event = 0
    
    If MouseControl ; only check mouse if the player is controlling with it
      If ExamineMouse()
        ; do mouse
      EndIf
    EndIf
    
    If ExamineKeyboard()
      ; Do keyboard
    EndIf
    
    RenderWorld()
    FlipBuffers()
    
  Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  
EndProcedure

If Init()
  Main()
EndIf


Re: Can a windowed 3D world be resized automatically

Posted: Thu Dec 15, 2016 2:13 pm
by wombats
It didn't work for me in my own code. It's disappointing, for sure. There have been numerous posts about it, and I haven't come across any official word on the matter.

Re: Can a windowed 3D world be resized automatically

Posted: Thu Dec 15, 2016 8:11 pm
by Mistrel
This would require handling the invalid direct3d device callback which I don't think PureBasic supports.

Re: Can a windowed 3D world be resized automatically

Posted: Thu Dec 15, 2016 8:30 pm
by wombats
Mistrel wrote:This would require handling the invalid direct3d device callback which I don't think PureBasic supports.
That's a shame.

Are you still developing and supporting DarkGDK?

Re: Can a windowed 3D world be resized automatically

Posted: Fri Dec 16, 2016 1:51 am
by Mistrel
wombats wrote:Are you still developing and supporting DarkGDK?
I still support it but it never gained much traction as a product so I don't spend much time improving it. It's been stable for years and I still use it as my go-to for adding any kind of 3D to my projects while using PureBasic.

The website is still available and the product comes with an SDK. You're welcome to try it if you like.

Also; yes. DarkGDK 2.0 supports D3D callbacks for DeviceLost/DeviceNotReset/DeviceReset. ;)