Should OpenWindowedScreen() crash this code?

Everything related to 3D programming
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Should OpenWindowedScreen() crash this code?

Post 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
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Should OpenWindowedScreen() crash this code?

Post by J. Baker »

Haven't tried it but I wouldn't put CloseScreen or CloseWindow within the Procedure. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Should OpenWindowedScreen() crash this code?

Post 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
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Should OpenWindowedScreen() crash this code?

Post by Samuel »

I just tried both of your samples and neither of them crashed. Both windows opened and closed without a problem.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Should OpenWindowedScreen() crash this code?

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Should OpenWindowedScreen() crash this code?

Post 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.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Should OpenWindowedScreen() crash this code?

Post by rsts »

Runs fine here.

Win 8 64: PB 32 bit
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Should OpenWindowedScreen() crash this code?

Post 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.....
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: Should OpenWindowedScreen() crash this code?

Post 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
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Should OpenWindowedScreen() crash this code?

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Should OpenWindowedScreen() crash this code?

Post 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
Post Reply