It is currently Tue Nov 12, 2019 3:09 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: [PB5.10b5 x86] CloseScreen = GetScriptParticleEmitter crash
PostPosted: Fri Jan 25, 2013 3:12 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Apr 01, 2008 3:23 pm
Posts: 151
Hi,

Closing and reopening the screen (to change the screen resolution, for example) prevents particle emitters created with "GetScriptParticleEmitter" to initialize properly.

=> After closing + reopening then screen, "GetScriptParticleEmitter(...)" doesn't display anything, and "ParticleEmitterID(...)" crashes with "Specified #ParticleEmitter is not initialised".

Code:
; Bug description:
;------------------
; Closing and reopening the screen (to change the screen resolution, for example)
; prevents particle emitters created with "GetScriptParticleEmitter" to initialize.
;
; NB: Run this source from PB's "Examples/3D" directory.
;     Press [Space] to close/reopen the screen.

Global numParticleEmitter.i

; This proc opens a windowed screen, creates the camera and a particle emitter
Procedure initScreenAnd3D()
  ;- Window
  OpenWindow(0, 0, 0, 800, 600, "CloseScreen causes particle emitters bug", #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
  OpenWindowedScreen(WindowID(0), 0, 0, 800,600, 0, 0, 0,#PB_Screen_SmartSynchronization)
 
  ;- Camera
  CreateCamera(0,0,0,100,100)
  MoveCamera(0,0,-100,200,#PB_Absolute)
  CameraLookAt(0,0,-100,0)
  RotateCamera(0,0,0,45)
   
  ;- Particle emitter
  Parse3DScripts()
  numParticleEmitter = GetScriptParticleEmitter(#PB_Any, "Examples/JetEngine1")
 
EndProcedure


;- Initialization
InitEngine3D()
InitSprite()
InitKeyboard()

Add3DArchive("Data/Textures" , #PB_3DArchive_FileSystem)
Add3DArchive("Data/Scripts"  , #PB_3DArchive_FileSystem)
Add3DArchive("Data/Particles", #PB_3DArchive_FileSystem)

; Initialize screen and 3D elements
initScreenAnd3D()
Debug "First time: emitter ID = " + Str(ParticleEmitterID(numParticleEmitter))

;- Main loop
KeyboardMode(#PB_Keyboard_International)

Repeat
  While WindowEvent() : Wend
  ExamineKeyboard()
 
  ;- Press [Space] to close and reopen screen
  If KeyboardReleased(#PB_Key_Space)
    ; Free all and close screen
    FreeCamera(0)
    FreeParticleEmitter(numParticleEmitter)
    CloseScreen()
    CloseWindow(0)
   
    ; Reopen
    initScreenAnd3D()
    Debug "After CloseScreen: emitter ID = " + Str(ParticleEmitterID(numParticleEmitter))
   
  EndIf
 
  ; Render
  RenderWorld()
  FlipBuffers()
 
Until KeyboardPushed(#PB_Key_Escape)

End


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB5.10b5 x86] CloseScreen = GetScriptParticleEmitter cr
PostPosted: Fri Jan 25, 2013 4:13 pm 
Offline
666
666

Joined: Mon Sep 01, 2003 2:33 pm
Posts: 1033
I reported this to fred a while ago. If you edit your code like this:

Code:
Procedure initScreenAnd3D()
  ;- Window
  OpenWindow(0, 0, 0, 800, 600, "CloseScreen causes particle emitters bug", #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
  OpenWindowedScreen(WindowID(0), 0, 0, 800,600, 0, 0, 0,#PB_Screen_SmartSynchronization)
 
  ;- Camera
  CreateCamera(0,0,0,100,100)
  MoveCamera(0,0,-100,200,#PB_Absolute)
  CameraLookAt(0,0,-100,0)
  RotateCamera(0,0,0,45)
 
EndProcedure


;- Initialization
InitEngine3D()
InitSprite()
InitKeyboard()

initScreenAnd3D()


;- Main loop
KeyboardMode(#PB_Keyboard_International)
Repeat
  While WindowEvent() : Wend
  ExamineKeyboard()
 
  ;- Press [Space] to close and reopen screen
  If KeyboardReleased(#PB_Key_Space)
    ; Free all and close screen
    FreeCamera(0)
    CloseScreen()
    CloseWindow(0)
    ; Reopen
    initScreenAnd3D()
 
  EndIf
Until KeyboardPushed(#PB_Key_Escape)

  ; Render
  RenderWorld()
  FlipBuffers()
 
End


I get an IMA on OpenWindowedScreen() whenever you press space

(Edit: Added the camera stuff back into the example)


Last edited by LuCiFeR[SD] on Fri Jan 25, 2013 6:15 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [PB5.10b5 x86] CloseScreen = GetScriptParticleEmitter cr
PostPosted: Fri Jan 25, 2013 5:52 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Apr 01, 2008 3:23 pm
Posts: 151
Hmm... Not the same problem, I think.

In your version, there's no camera: I don't see why you expect it to work at all (lucky it runs the first time without crashing). :?

My problem is that "CloseScreen" seems to wipe out some resources from memory (not only the sprites, as said in the doc), and as far as I know, only Particle Emitters cannot be reloaded (Materials can be reloaded with "GetScriptMaterial", etc.).


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB5.10b5 x86] CloseScreen = GetScriptParticleEmitter cr
PostPosted: Fri Jan 25, 2013 6:08 pm 
Offline
666
666

Joined: Mon Sep 01, 2003 2:33 pm
Posts: 1033
even if you create the camera... it still IMA's when you swich screen. It makes no difference at all.

what I am trying to say is that I don't believe the problem is with the commands you think it is.

I believe there is a problem with the way PB is handling its screens when using ogre, be it fullscreen or windowedscreens


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB5.10b5 x86] CloseScreen = GetScriptParticleEmitter cr
PostPosted: Fri Jan 25, 2013 6:39 pm 
Offline
666
666

Joined: Mon Sep 01, 2003 2:33 pm
Posts: 1033
and just to add to this..... your original code with OnError support added (enable in compiler options and disable the debugger)

PNG image of error

Code:
Declare ErrorHandler()
Declare initScreenAnd3D()
OnErrorCall(@ErrorHandler())

Global numParticleEmitter.i

; This proc opens a windowed screen, creates the camera and a particle emitter
Procedure initScreenAnd3D()
  ;- Window
  OpenWindow(0, 0, 0, 800, 600, "CloseScreen causes particle emitters bug", #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
  OpenWindowedScreen(WindowID(0), 0, 0, 800,600, 0, 0, 0,#PB_Screen_SmartSynchronization)
 
  ;- Camera
  CreateCamera(0,0,0,100,100)
  MoveCamera(0,0,-100,200,#PB_Absolute)
  CameraLookAt(0,0,-100,0)
  RotateCamera(0,0,0,45)
   
  ;- Particle emitter
  Parse3DScripts()
  numParticleEmitter = GetScriptParticleEmitter(#PB_Any, "Examples/JetEngine1")
 
EndProcedure


;- Initialization
InitEngine3D()
InitSprite()
InitKeyboard()

Add3DArchive("Data/Textures" , #PB_3DArchive_FileSystem)
Add3DArchive("Data/Scripts"  , #PB_3DArchive_FileSystem)
Add3DArchive("Data/Particles", #PB_3DArchive_FileSystem)

; Initialize screen and 3D elements
initScreenAnd3D()
Debug "First time: emitter ID = " + Str(ParticleEmitterID(numParticleEmitter))

;- Main loop
KeyboardMode(#PB_Keyboard_International)

Repeat
  While WindowEvent() : Wend
  ExamineKeyboard()
 
  ;- Press [Space] to close and reopen screen
  If KeyboardReleased(#PB_Key_Space)
    ; Free all and close screen
    FreeCamera(0)
    FreeParticleEmitter(numParticleEmitter)
    CloseScreen()
    CloseWindow(0)
   
    ; Reopen
    initScreenAnd3D()
    Debug "After CloseScreen: emitter ID = " + Str(ParticleEmitterID(numParticleEmitter))
   
  EndIf
 
  ; Render
  RenderWorld()
  FlipBuffers()
 
Until KeyboardPushed(#PB_Key_Escape)

End
Procedure ErrorHandler()
 
  ErrorMessage$ = "A program error was detected:" + Chr(13)
  ErrorMessage$ + Chr(13)
  ErrorMessage$ + "Error Message:   " + ErrorMessage()      + Chr(13)
  ErrorMessage$ + "Error Code:      " + Str(ErrorCode())    + Chr(13) 
  ErrorMessage$ + "Code Address:    " + Str(ErrorAddress()) + Chr(13)
 
  If ErrorCode() = #PB_OnError_InvalidMemory   
    ErrorMessage$ + "Target Address:  " + Str(ErrorTargetAddress()) + Chr(13)
  EndIf
 
  If ErrorLine() = -1
    ErrorMessage$ + "Sourcecode line: Enable OnError lines support to get code line information." + Chr(13)
  Else
    ErrorMessage$ + "Sourcecode line: " + Str(ErrorLine()) + Chr(13)
    ErrorMessage$ + "Sourcecode file: " + GetFilePart(ErrorFile()) + Chr(13)
  EndIf
 
  ErrorMessage$ + Chr(13)
  ErrorMessage$ + "Register content:" + Chr(13)
 
  CompilerSelect #PB_Compiler_Processor
    CompilerCase #PB_Processor_x86
      ErrorMessage$ + "EAX = " + Str(ErrorRegister(#PB_OnError_EAX)) + Chr(13)
      ErrorMessage$ + "EBX = " + Str(ErrorRegister(#PB_OnError_EBX)) + Chr(13)
      ErrorMessage$ + "ECX = " + Str(ErrorRegister(#PB_OnError_ECX)) + Chr(13)
      ErrorMessage$ + "EDX = " + Str(ErrorRegister(#PB_OnError_EDX)) + Chr(13)
      ErrorMessage$ + "EBP = " + Str(ErrorRegister(#PB_OnError_EBP)) + Chr(13)
      ErrorMessage$ + "ESI = " + Str(ErrorRegister(#PB_OnError_ESI)) + Chr(13)
      ErrorMessage$ + "EDI = " + Str(ErrorRegister(#PB_OnError_EDI)) + Chr(13)
      ErrorMessage$ + "ESP = " + Str(ErrorRegister(#PB_OnError_ESP)) + Chr(13)
 
    CompilerCase #PB_Processor_x64
      ErrorMessage$ + "RAX = " + Str(ErrorRegister(#PB_OnError_RAX)) + Chr(13)
      ErrorMessage$ + "RBX = " + Str(ErrorRegister(#PB_OnError_RBX)) + Chr(13)
      ErrorMessage$ + "RCX = " + Str(ErrorRegister(#PB_OnError_RCX)) + Chr(13)
      ErrorMessage$ + "RDX = " + Str(ErrorRegister(#PB_OnError_RDX)) + Chr(13)
      ErrorMessage$ + "RBP = " + Str(ErrorRegister(#PB_OnError_RBP)) + Chr(13)
      ErrorMessage$ + "RSI = " + Str(ErrorRegister(#PB_OnError_RSI)) + Chr(13)
      ErrorMessage$ + "RDI = " + Str(ErrorRegister(#PB_OnError_RDI)) + Chr(13)
      ErrorMessage$ + "RSP = " + Str(ErrorRegister(#PB_OnError_RSP)) + Chr(13)
      ErrorMessage$ + "Display of registers R8-R15 skipped."         + Chr(13)
 
    CompilerCase #PB_Processor_PowerPC
      ErrorMessage$ + "r0 = " + Str(ErrorRegister(#PB_OnError_r0)) + Chr(13)
      ErrorMessage$ + "r1 = " + Str(ErrorRegister(#PB_OnError_r1)) + Chr(13)
      ErrorMessage$ + "r2 = " + Str(ErrorRegister(#PB_OnError_r2)) + Chr(13)
      ErrorMessage$ + "r3 = " + Str(ErrorRegister(#PB_OnError_r3)) + Chr(13)
      ErrorMessage$ + "r4 = " + Str(ErrorRegister(#PB_OnError_r4)) + Chr(13)
      ErrorMessage$ + "r5 = " + Str(ErrorRegister(#PB_OnError_r5)) + Chr(13)
      ErrorMessage$ + "r6 = " + Str(ErrorRegister(#PB_OnError_r6)) + Chr(13)
      ErrorMessage$ + "r7 = " + Str(ErrorRegister(#PB_OnError_r7)) + Chr(13)
      ErrorMessage$ + "Display of registers r8-R31 skipped."       + Chr(13)
 
  CompilerEndSelect
 
  MessageRequester("Guru Meditation"+ Str(ErrorCode())+"."+Str(ErrorAddress()), ErrorMessage$)
  End
 
EndProcedure


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB5.10b5 x86] CloseScreen = GetScriptParticleEmitter cr
PostPosted: Tue Feb 05, 2013 10:01 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Apr 01, 2008 3:23 pm
Posts: 151
Ok, I see what you mean.

(Also: "Guru meditation", heh? It brings back good memories...)


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB5.10b5 x86] CloseScreen = GetScriptParticleEmitter cr
PostPosted: Tue Feb 05, 2013 3:00 pm 
Offline
666
666

Joined: Mon Sep 01, 2003 2:33 pm
Posts: 1033
Kelebrindae wrote:
Ok, I see what you mean.

(Also: "Guru meditation", heh? It brings back good memories...)


Kelebrindae,I am happy that we finally understand each other :).

As for the "Guru Meditation" thing hehe, I have very good memories of those days too :). And Ironically if this bug didn't exist, you would have been even more amused by the way I display it normally LOL


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye