switch between full and windowed 3D screen

Just starting out? Need help? Post your questions and find answers here.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

switch between full and windowed 3D screen

Post by Psychophanta »

I have a tip to switch between standard 2D graphics full screen to windowed one, and viceversa and it works nicely.
But when try to do it using Engine3D, then it does not work.
Is there a way to do it for 3D screen ?

Code: Select all

Macro initsprograma()
  CreateLight(0,$EEEEEE,4,4,2,#PB_Light_Point)
  CreateCamera(0,0,0,100,100)
  MoveCamera(0,0,0,3,#PB_Absolute)
  LoadTexture(0,"soil_wall.jpg")
  CreateMaterial(0,TextureID(0))
  CreateCube(0,1)
  CreateEntity(0,MeshID(0),MaterialID(0),0,0,0)
EndMacro

If InitEngine3D()=0
  MessageRequester("Error","The 3D Engine can't be initialized",0):End
EndIf
If InitSprite()=0 Or InitKeyboard()=0 Or InitMouse()=0
  MessageRequester("Error","The graphics Engine can't be initialized",0):End
EndIf
Add3DArchive(#PB_Compiler_Home+"examples/3D/Data/Textures",#PB_3DArchive_FileSystem)

If ExamineDesktops()=0
  MessageRequester("Error","Can not examine desktops",0):End
EndIf
Global pantallacompleta.b=0,bitplanes.a=DesktopDepth(0),FRX.u=DesktopWidth(0),FRY.u=DesktopHeight(0),RX.u,RY.u,FrecuenciadeMuestreo.u=60
If FRX<1280 Or FRY<720:RX=FRX*2/3:RY=FRY*2/3:Else:RX=1280:RY=720:EndIf
OpenWindow(0,0,0,RX,RY,"switch screen size",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,RX,RY,1,0,0,#PB_Screen_WaitSynchronization)
initsprograma()

Macro cambiarpantalla()
  CloseScreen()
  If IsWindow(0):CloseWindow(0):EndIf
  pantallacompleta.b!1
  If pantallacompleta.b
    RX=FRX:RY=FRY
    OpenScreen(RX,RY,bitplanes.a,"cuerpo TID",#PB_Screen_WaitSynchronization,FrecuenciadeMuestreo.u)
  Else
    If FRX<1280 Or FRY<720:RX=FRX*2/3:RY=FRY*2/3:Else:RX=1280:RY=720:EndIf
    OpenWindow(0,0,0,RX,RY,"switch screen size",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
    OpenWindowedScreen(WindowID(0),0,0,RX,RY,1,0,0,#PB_Screen_WaitSynchronization)
  EndIf
  initsprograma()
EndMacro

Repeat
  ExamineKeyboard()
  If pantallacompleta.b=0
    WaitWindowEvent()
  EndIf
  RenderWorld()
  FlipBuffers()
  If KeyboardReleased(#PB_Key_C)
    cambiarpantalla()
  EndIf
Until KeyboardPushed(#PB_Key_Escape)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: switch between full and windowed 3D screen

Post by Psychophanta »

The issue continues in the PB 6.03b6 win64. :(
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: switch between full and windowed 3D screen

Post by Psychophanta »

Looks like it is fixed in the PB5.21 beta 5.
However we can notice that CloseScreen() continues without closing the 3D engine.
Is the CloseEngine3D() function necessary? Or should CloseScreen() be responsible for shutting down the 3D engine? :?:

The same issue aplies to InitSprite(), InitKeyboard(), InitMouse(). So CloseScreen() function does not close none of them:
Is there CloseMouse(), CloseKeyboard() and CloseSprite() function necessary to really close all its stuff?

Code: Select all

ExamineDesktops()
Global bitplanes.a=DesktopDepth(0),FRX.u=DesktopWidth(0),FRY.u=DesktopHeight(0),RX.u=FRX*2/3,RY.u=FRY*2/3
InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll")
InitSprite():InitKeyboard():InitMouse()

Procedure completa()
  Protected evento.i
  OpenScreen(FRX,FRY,bitplanes,"cambio modo pantalla",#PB_Screen_WaitSynchronization)
  CreateLight(0,$EEEEEE,4,4,2,#PB_Light_Point)
  CreateCamera(0,0,0,100,100)
  MoveCamera(0,0,0,5,#PB_Absolute)
  CreateMaterial(0,0,$aaeecc)
  CreateCube(0,1)
  CreateEntity(0,MeshID(0),MaterialID(0))
  Repeat
    ExamineKeyboard():ExamineMouse()
    If KeyboardReleased(#PB_Key_C)
      ReleaseMouse(1):CloseScreen()
      ProcedureReturn
    EndIf
    MoveEntity(0,MouseDeltaX()/300,-MouseDeltaY()/300,0,#PB_Relative|#PB_World)
    RotateEntity(0,-0.5,0.2,0.3,#PB_Relative)
    RenderWorld(50)
    FlipBuffers():Delay(11)
  Until KeyboardPushed(#PB_Key_Escape)
  End
EndProcedure
Procedure ventana()
  Protected evento.i
  OpenWindow(0,0,0,RX,RY,"cambio modo pantalla",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(0),0,0,RX,RY,1,0,0,#PB_Screen_WaitSynchronization)
  SetActiveWindow(0)
  CreateLight(0,$EEEEEE,4,4,2,#PB_Light_Point)
  CreateCamera(0,0,0,100,100)
  MoveCamera(0,0,0,5,#PB_Absolute)
  CreateMaterial(0,0,$aaeecc)
  CreateCube(0,1)
  CreateEntity(0,MeshID(0),MaterialID(0))
  Repeat:Repeat:evento.i=WindowEvent():Until evento=#PB_Event_None
    ExamineKeyboard():ExamineMouse()
    If KeyboardReleased(#PB_Key_C)
      CloseScreen():CloseWindow(0)
      ProcedureReturn
    EndIf
    MoveEntity(0,MouseDeltaX()/300,-MouseDeltaY()/300,0,#PB_Relative|#PB_World)
    RotateEntity(0,-0.5,0.2,0.3,#PB_Relative)
    RenderWorld(50)
    FlipBuffers():Delay(11)
  Until KeyboardPushed(#PB_Key_Escape)
  End
EndProcedure
Repeat
  completa()
  ventana()
Forever
(Release the "C" key to switch between full screen or windowed)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply