Page 1 of 1

Should OpenWindowedScreen() crash this code?

Posted: Tue Feb 19, 2013 11:53 pm
by IdeasVacuum
I am using an alternative method, which is to manage the host Window with HideWindow(), but I don't see why CloseScreen() + CloseWindow() does not ensure that a new OpenWindowedScreen() can be created:

Code: Select all

Procedure ScreenCrash()
;---------------------

         If OpenWindow(0,0,0,800,600,"Test CloseScreen()")

                        OpenWindowedScreen(WindowID(0),0,0,800,600)
                              CreateCamera(0,0,0,800,600)

                      Repeat

                              RenderWorld()

                                   Repeat
                                                Event = WindowEvent()
                                             If(Event = #PB_Event_CloseWindow) : Exit = #True : EndIf

                                   Until Event = #False

                      Until Exit = #True

                      CloseScreen()
                      CloseWindow(0)
         EndIf

EndProcedure

If InitEngine3D()

        igInitEngineOK = #True
          InitSprite()
        InitKeyboard()
Else
        igInitEngineOK = #False
        MessageRequester("InitEngine3D", "3D Engine initialisation failure", #MB_ICONERROR)
EndIf

If igInitEngineOK = #True

        MessageRequester("1st run", "1st Run", 0)
        ScreenCrash()

        MessageRequester("2nd run", "2nd Run", 0)
        ScreenCrash()

EndIf

Re: Should OpenWindowedScreen() crash this code?

Posted: Wed Feb 20, 2013 12:00 am
by J. Baker
Haven't tried it but I wouldn't put CloseScreen or CloseWindow within the Procedure. ;)

Re: Should OpenWindowedScreen() crash this code?

Posted: Wed Feb 20, 2013 12:10 am
by IdeasVacuum
Well, its good to have CloseWindow() in the If of OpenWindow(), since it can only be closed if successfully opened - but why not have CloseScreen() and CloseWindow() within the Procedure?

Calling them outside of the Procedure does not prevent the crash:

Code: Select all

Procedure ScreenCrash()
;---------------------

         If OpenWindow(0,0,0,800,600,"Test CloseScreen()")

                        OpenWindowedScreen(WindowID(0),0,0,800,600)
                              CreateCamera(0,0,0,800,600)

                      Repeat

                              RenderWorld()

                                   Repeat
                                                Event = WindowEvent()
                                             If(Event = #PB_Event_CloseWindow) : Exit = #True : EndIf

                                   Until Event = #False

                      Until Exit = #True

         EndIf

EndProcedure

If InitEngine3D()

        igInitEngineOK = #True
          InitSprite()
        InitKeyboard()
Else
        igInitEngineOK = #False
        MessageRequester("InitEngine3D", "3D Engine initialisation failure", #MB_ICONERROR)
EndIf

If igInitEngineOK = #True

        MessageRequester("1st run", "1st Run", 0)
        ScreenCrash()

        CloseScreen()
        CloseWindow(0)

        MessageRequester("2nd run", "2nd Run", 0)
        ScreenCrash()

        CloseScreen()
        CloseWindow(0)

EndIf

Re: Should OpenWindowedScreen() crash this code?

Posted: Wed Feb 20, 2013 1:52 am
by Samuel
I just tried both of your samples and neither of them crashed. Both windows opened and closed without a problem.

Re: Should OpenWindowedScreen() crash this code?

Posted: Wed Feb 20, 2013 3:24 am
by IdeasVacuum
Hi Samuel - that is a surprise because the crash is reliable on my machine, WinXP x86. Various compiler settings, same result.

So, need more people to give the code a quick test please! Let us know your OS/bits too.

Re: Should OpenWindowedScreen() crash this code?

Posted: Wed Feb 20, 2013 4:21 am
by Samuel
I'm running off of windows7 x64. I tried the code using the 64 and 86 bit compilers. They both seem to run smoothly.

Re: Should OpenWindowedScreen() crash this code?

Posted: Wed Feb 20, 2013 8:28 am
by rsts
Runs fine here.

Win 8 64: PB 32 bit

Re: Should OpenWindowedScreen() crash this code?

Posted: Wed Feb 20, 2013 2:02 pm
by IdeasVacuum
Thanks rsts - potentially then, it's a compatibility problem with WinXP x86. Hopefully there is someone else out there using XP that cn run the test.....

Re: Should OpenWindowedScreen() crash this code?

Posted: Wed Feb 20, 2013 6:03 pm
by LuCiFeR[SD]
this crashes for me with an IMA. Windows7 64bit (Nvidia GTS450 1GB). PB 5.10 in 32 and 64bit.

@IdeasVacuum This is the bug I thought you were experiencing to begin with in this post.

but the bug you are experiencing here has been reported here and here

This is not Just a windows XP problem. Without using any 3D commands (Sprite3D not affected) the windowed screen will open and close all day long.

press enter to close and reopen screen

Code: Select all

InitEngine3D()
InitSprite()
InitSprite3D()
InitKeyboard()
InitMouse()

OpenWindow(0,0,0,800,600,"Test windowed Screen")
OpenWindowedScreen(WindowID(0),0,0,800,600)
CreateCamera(0,0,0,800,600)


Repeat
  RenderWorld()
  FlipBuffers()
  ClearScreen($000000)
  Repeat
    Event= WindowEvent()
    Select event           
      Case #PB_Event_CloseWindow
        Exit=#True       
    EndSelect   
  Until Event=#False
  
  If ExamineKeyboard()
    If KeyboardReleased(#PB_Key_Return)
      FreeCamera(0)
      CloseScreen()
      CloseWindow(0)
      OpenWindow(0,0,0,800,600,"Test windowed Screen")
      OpenWindowedScreen(WindowID(0),0,0,800,600) ;- IMA happens here
      CreateCamera(0,0,0,800,600)
    EndIf
  EndIf
  
  
Until Exit=#True
End
same code with 3D stuff commented out

Code: Select all

;InitEngine3D()
InitSprite()
InitSprite3D()
InitKeyboard()
InitMouse()

OpenWindow(0,0,0,800,600,"Test windowed Screen")
OpenWindowedScreen(WindowID(0),0,0,800,600)
;CreateCamera(0,0,0,800,600)


Repeat
  ;RenderWorld()
  FlipBuffers()
  ClearScreen($000000)
  Repeat
    Event= WindowEvent()
    Select event           
      Case #PB_Event_CloseWindow
        Exit=#True       
    EndSelect   
  Until Event=#False
  
  If ExamineKeyboard()
    If KeyboardReleased(#PB_Key_Return)
      ;FreeCamera(0)
      CloseScreen()
      CloseWindow(0)
      OpenWindow(0,0,0,800,600,"Test windowed Screen")
      OpenWindowedScreen(WindowID(0),0,0,800,600)
      ;CreateCamera(0,0,0,800,600)
    EndIf
  EndIf
  
  
Until Exit=#True
End

Re: Should OpenWindowedScreen() crash this code?

Posted: Wed Feb 20, 2013 7:09 pm
by IdeasVacuum
I believe there is a problem with the way PB is handling its screens when using ogre, be it fullscreen or windowedscreens
I think you are right LuCiFeR[SD] :cry:

I believe it could be related to dragging a WindowedScreen form one Monitor to another too:
http://www.purebasic.fr/english/viewtop ... 36&t=53586

I have hit more issue these past few days than I did before in a whole year. Some of it is down to my lack of experience with the new PB 3D stuff, but nonetheless, it seems a bit fragile.

Re: Should OpenWindowedScreen() crash this code?

Posted: Thu Feb 21, 2013 11:08 am
by PMV
IdeasVacuum wrote:I have hit more issue these past few days than I did before in a whole year. Some of it is down to my lack of experience with the new PB 3D stuff, but nonetheless, it seems a bit fragile.
The 3D stuff is one of the "newes" features from PB, so it is not just
you ... it is because it is just used by a few people, especially
because 3D needs a long experience. Just go one, report everything
that feels strange and help by evolving this topic to something perfect.
:D

MFG PMV