[PB 4.51RC2] OpenWindowedScreen problem ?
Posted: Fri Aug 27, 2010 6:48 am
				
				Hi.
Seems that is possible use 'OpenWindowedScreen' only the first time for the entire life of the program:
I mean open a normal window ( or a MDI child , is the same),
then use OpenWindowedScreen(), returns 1, OK everything works, but if i close the opened window e recall OpenWindowedScreen this returns 0 and in effect nothing works from now.
Below a modified verson of 'camera.pb', from directory Examples that shows the problem.
I've tried both the subsystems OpenGL e DirectX7, same result.
			Seems that is possible use 'OpenWindowedScreen' only the first time for the entire life of the program:
I mean open a normal window ( or a MDI child , is the same),
then use OpenWindowedScreen(), returns 1, OK everything works, but if i close the opened window e recall OpenWindowedScreen this returns 0 and in effect nothing works from now.
Below a modified verson of 'camera.pb', from directory Examples that shows the problem.
Code: Select all
#CameraSpeed = 10
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
Define.l numtimes=2
If InitEngine3D()
  Add3DArchive("Data", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
redo:  
  OpenWindow(0, 0, 0, 700, 400, "3D Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ;If Screen3DRequester()
  Define free3DThings.l
  Define ows_res.l=OpenWindowedScreen(WindowID(0),10, 0, 400, 300, 0, 0, 0)
  Debug ows_res
  If ows_res
  	free3DThings=1
    AmbientColor(RGB(0,200,0))  ; Green 'HUD' like color 
 
    CreateMaterial(0, LoadTexture(0, "r2skin.jpg"))
    CreateEntity(0, LoadMesh(0, "robot.mesh"), MaterialID(0))
    AnimateEntity(0, "Walk")
    
    CreateCamera(0, 0, 0, 100, 50)  ; Front camera
    CameraLocate(0,0,0,100)
    
    CreateCamera(1, 0, 50, 100, 50) ; Back camera
    CameraLocate(1,0,0,-100)
    RotateCamera(1,180,0,0)
    
    CameraRenderMode(1, #PB_Camera_Textured)  ; Wireframe for this camera
 
    Repeat
      Screen3DEvents()
      
      ClearScreen(RGB(0, 0, 0))
            
      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
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
        MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
      EndIf
      
      RotateEntity(0, 0, 0.1, 0, #PB_Relative)
      
      RotateCamera(0, MouseY, MouseX, RollZ, #PB_Relative)
      MoveCamera  (0, KeyX, 0, KeyY)
      
      RotateCamera(1, MouseY, MouseX, RollZ, #PB_Relative)
      MoveCamera  (1, KeyX, 0, KeyY)
      
      RenderWorld()
      Screen3DStats()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  Else
  	free3DThings=0
  EndIf
    
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
If free3DThings
	FreeEntity(0)
	FreeMesh(8)
	FreeMaterial(0)
	FreeTexture(0)
	FreeCamera(0)
	FreeCamera(1)
	CloseScreen()
EndIf  
CloseWindow(0)
numtimes-1
If numtimes>0
	Goto redo
EndIf