InitEngine3d() -> ReInitEngine3d() ?
InitEngine3d() -> ReInitEngine3d() ?
hi
i would like to know if there is a way to re initialise the 3d engine
because as soon as a fullscreen 3d app is minimised and thereafter reactivated the app crashes
first i thougt there is a way to reload resources or such like the problem with reactivating fullscreen apps using sprites
but i havent foundt a solution/workaround for the problem with initengine3d()
i would like to know if there is a way to re initialise the 3d engine
because as soon as a fullscreen 3d app is minimised and thereafter reactivated the app crashes
first i thougt there is a way to reload resources or such like the problem with reactivating fullscreen apps using sprites
but i havent foundt a solution/workaround for the problem with initengine3d()
sorry but that hasnt worked
i tried with
and some delay functions but the result is always the same
crash on return to the app
i tried with
Code: Select all
Repeat
WaitWindowEvent()
Until IsScreenActive()<>0
crash on return to the app
May be that works
cya dige
Code: Select all
#hWnd = 0
InitSprite()
OpenWindow(#hWnd, 10, 10, 800, 600, #PB_Window_SystemMenu, "Test")
OpenWindowedScreen(WindowID(), 200, 200, 400, 300, 0, 0, 0)
Repeat
If IsScreenActive() And GetActiveWindow_() = WindowID(#hWnd)
FlipBuffers()
ClearScreen(0,0,0)
EndIf
Until WindowEvent() = #PB_EventCloseWindow
Re: InitEngine3d() -> ReInitEngine3d() ?
thx but that is not the kind of solution im serchin for
because as soon as a fullscreen 3d app is minimised and thereafter reactivated the app crashes
here is the code
i tried to pause the app while the window isnt active but that didnt solve the problem
Code: Select all
InitEngine3D()
InitSprite()
InitKeyboard()
#CameraSpeed = 5
DefType.f KeyX, KeyY
Add3DArchive("Data\" , #PB_3DArchive_FileSystem)
If OpenScreen(1024, 768, 16, "Test") <> 0
AmbientColor(RGB(255,255,255))
CreateMaterial (0, LoadTexture(0, "Terrain_Texture.jpg"))
AddMaterialLayer(0, LoadTexture(1, "Terrain_Detail.jpg"), 1)
CreateTerrain("Terrain.png", MaterialID(0), 4, 0.6, 4, 4)
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0, 128, 25, 128)
Repeat
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
Height.f = TerrainHeight(CameraX(0), CameraZ(0))
RotateCamera(0, MouseX, MouseY, RollZ)
MoveCamera (0, KeyX, -CameraY(0)+Height+8, KeyY)
RenderWorld()
If StartDrawing(ScreenOutput())
FrontColor(255, 255, 255)
DrawingMode(1)
Locate(50, 50) : DrawText(StrF(Engine3DFrameRate(0),1)+" FPS")
Locate(50, 70) : DrawText(Str(CountRenderedTriangles())+" Triangles")
StopDrawing()
EndIf
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
End
First of all, I never really used OGRE but on the other hand it also
shouldn't be different than anything else because due to the nature
of multitasking enviornments like Windows, you should always check
whether your window receives messages or not.
I think you'll have to check if your application is 'active' at all.
Dige already suggested you to do it like this:
Did you try that?
shouldn't be different than anything else because due to the nature
of multitasking enviornments like Windows, you should always check
whether your window receives messages or not.
I think you'll have to check if your application is 'active' at all.
Dige already suggested you to do it like this:
Code: Select all
If IsScreenActive() And GetActiveWindow_() = WindowID(#hWnd)
[...]
Good programmers don't comment their code. It was hard to write, should be hard to read.
Well, now I tried it myself...
Using IsScreenActive() helps to prevent the app from crashing
but I just didn't manage to get the app on focus again...
I searched this and the german forum seeing that quite a lot of people
reported this behaviour. (I even found another thread of yours
)
Either we all don't understand the concept or there's a bug somewhere.
Seems like Fred has already been informed but didn't answer so far.
Using plain Direct3D (ie no OGRE) I'd do it like this:
But AFAIK there's no PB-command that returns the necessary deviceinfo.
Fred? Can you shed light on this?
Using IsScreenActive() helps to prevent the app from crashing
but I just didn't manage to get the app on focus again...
I searched this and the german forum seeing that quite a lot of people
reported this behaviour. (I even found another thread of yours

Either we all don't understand the concept or there's a bug somewhere.
Seems like Fred has already been informed but didn't answer so far.
Using plain Direct3D (ie no OGRE) I'd do it like this:
Code: Select all
procedure IsDeviceActive()
select d3dDevice\TestCooperativeLevel()
case #D3DERR_DEVICELOST
procedurereturn #FALSE
case #D3DERR_DEVICENOTRESET
if d3dDevice\Reset(@PresentParameters) <> #D3D_OK
procedurereturn #FALSE
else
; re-init scene here
; (ie. re-create all textures, vertex or index buffers
; initially created with #D3DPOOL_DEFAULT.
; We also lost the projection matrix and renderstates)
;
; done re-init
procedurereturn #TRUE
endif
default
procedurereturn #TRUE
endselect
endprocedure
Fred? Can you shed light on this?
Good programmers don't comment their code. It was hard to write, should be hard to read.