01.
void
Director::drawScene()
02.
{
03.
// calculate "global" dt
04.
calculateDeltaTime();
05.
06.
// skip one flame when _deltaTime equal to zero.
07.
if
(_deltaTime < FLT_EPSILON)
08.
{
09.
return
;
10.
}
11.
12.
if
(_openGLView)
13.
{
14.
_openGLView->pollInputEvents();
15.
}
16.
17.
//tick before glClear: issue #533
18.
if
(! _paused)
19.
{
20.
_scheduler->update(_deltaTime);
21.
_eventDispatcher->dispatchEvent(_eventAfterUpdate);
22.
}
23.
24.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
25.
26.
/* to avoid flickr, nextScene MUST be here: after tick and before draw.
27.
XXX: Which bug is this one. It seems that it can't be reproduced with v0.9 */
28.
if
(_nextScene)
29.
{
30.
setNextScene();
31.
}
32.
33.
pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
34.
35.
// draw the scene
36.
if
(_runningScene)
37.
{
38.
_runningScene->visit(_renderer, Mat4::IDENTITY,
false
);
39.
_eventDispatcher->dispatchEvent(_eventAfterVisit);
40.
}
41.
42.
// draw the notifications node
43.
if
(_notificationNode)
44.
{
45.
_notificationNode->visit(_renderer, Mat4::IDENTITY,
false
);
46.
}
47.
48.
if
(_displayStats)
49.
{
50.
showStats();
51.
}
52.
53.
_renderer->render();
54.
_eventDispatcher->dispatchEvent(_eventAfterDraw);
55.
56.
popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
57.
58.
_totalFrames++;
59.
60.
// swap buffers
61.
if
(_openGLView)
62.
{
63.
_openGLView->swapBuffers();
64.
}
65.
66.
if
(_displayStats)
67.
{
68.
calculateMPF();
69.
}
70.
}