difference between renderoneframe and startrendering

feanor91

08-08-2008 06:43:53

Hello

I have a question about this 2 functions, because their behaviour is strange.

If I put a timer that is fire every 1 milliseconds and put renderoneframe in it, I have a 60FPS on my scene.

If I use startrendering instead after all is initialisez, I have 900 more FPS...

Of course, it's the same scene in the same computer. So, why a such difference?

lilljohan

08-08-2008 10:44:03

If you're using Forms.Timer then that is the problem. It is a low resolution timer so it won't fire once every ms.

Use something like this instead while (Running) {
root.RenderOneFrame();
Application.DoEvents();
}

feanor91

08-08-2008 11:07:32

Hi

Thanks for answer...It works. But I get a NullReferenceExeption when I quit my application. Execption that I haven't if I use Timer our StartRendering.

I am on VB 2008 Express And I put the while loop at the end of my formload event.

lilljohan

08-08-2008 12:03:25

Are you disposing your Mogre.Root?


....
Disposed += Form_Disposed
....
Sub Form_Disposed(ByVal sender As Object, ByVal e As EventArgs)
Mogre.Root.Dispose()
End Sub

feanor91

08-08-2008 12:12:15

Euh...No

But I added that en the result is the same

look :


"Before, all my init"

'myRoot.StartRendering()

While RenduEnCours
My.Application.DoEvents()
If Not RenduEnCours Then
Exit While
End If
'Affichage des infos de rendu
Try
lblAvg.Text = "FPS moyennes: " & Mogre.StringConverter.ToString(MyWindow.AverageFPS, 3)
lblCurr.Text = "FPS courantes: " & Mogre.StringConverter.ToString(MyWindow.LastFPS, 3)
lblBest.Text = "Meilleures FPS: " & Mogre.StringConverter.ToString(MyWindow.BestFPS, 3)
lblWorst.Text = "Pires FPS: " & Mogre.StringConverter.ToString(MyWindow.WorstFPS, 3)
lblNumTris.Text = "Triangles: " & Mogre.StringConverter.ToString(MyWindow.TriangleCount)
lblNumBatches.Text = "Nombre de Batch: " & Mogre.StringConverter.ToString(MyWindow.BatchCount)
Catch ex As Exception

End Try

'et on rend une frame
myRoot.RenderOneFrame()

'Update du monde physique
If mnuDetectionDeCollision.Checked Then
Dim stepPhysics As Single = 0.1
myWorld.Update(stepPhysics)
End If


If SceneNodeSelected Is Nothing Then
'si un objet est sélectionné ou pas, on active ou désactive le panneau de paramètre
grpParamObjet.Enabled = False
cmdResetEtat.Enabled = False
Else
grpParamObjet.Enabled = True
cmdResetEtat.Enabled = True
End If
End While

DisposeNewton()
DisposeOgre()


End Sub <---PROBLEM IS HERE


The 2 Dispose sub :

Private Sub DisposeOgre()
'Pemet de nettoyer les instances OGRES en cas de rechargement de la scène ou de l'ouverture d'une nouvelle
'en gros, on réinitialise toutes les instances Ogre

SceneNodeSelected = Nothing
MObjectSelected = Nothing

myCamera = Nothing
Scene = Nothing
ResourceGroupManager.Singleton.DestroyResourceGroup("General")
MyWindow.RemoveAllViewports()
MyWindow.Dispose()
myRoot.DestroySceneManager(mySceneManager)
myRoot.DetachRenderTarget(MyWindow)
myRoot.Dispose()
MyWindow = Nothing
mySceneManager = Nothing

End Sub

Private Sub DisposeNewton()

'Permet de liberer les instances Newton, mais ça ne marche pas top, à paufiner....
'Ainsi, si on recharge la scène ou si on en charge une autre, tout marche sauf que l'on a pas de mouvement sur X.
'A l'heure qu'il est, je ne sais pas pourquoi

RemoveHandler Me.CamBody.ForceCallback, AddressOf camera_force_callback
myWorld.DestroyAllBodies()
myWorld.Dispose()
myWorld = Nothing

End Sub


If The same thing is in timer, it's ok, if I use startrendering, it's ok too...It's so strange but, if I run appli out the IDE, I get no errors.