1 #include "mof/Application.hpp"
2 #include "mof/GraphicsDevice.hpp"
3 #include "mof/Window.hpp"
4 #include "mof/ConsoleIO.hpp"
5 #include "mof/Timer.hpp"
7 #include "mof/Captor.hpp"
8 #include "mof/InputDevice.hpp"
9 #include "mof/private/GraphicsDeviceImpl.hpp"
10 #include "mof/utilities.hpp"
11 #include "mof/Finalizer.hpp"
13 #include "mof/sound/SoundDevice.hpp"
17 double frame_interval_;///<
\83t
\83\8c\81[
\83\80\82Ì
\8aÔ
\8au
\81i
\83~
\83\8a\95b
\81j
18 int m_nUpdatingPerFrame;
19 mof::Window* m_pWindow = NULL;
20 bool enable_output_frame_;
21 bool enable_output_audio_;
22 mof::Application::InputMode input_mode_;
27 void Application::initialize
29 const mof::tstring& appname ,
34 int nUpdatingPerFrame,
36 bool enable_output_frame,
37 bool enable_output_audio
40 frame_interval_ = 1.0f / fps * 1000;
41 m_nUpdatingPerFrame = nUpdatingPerFrame;
42 enable_output_frame_ = enable_output_frame;
43 enable_output_audio_ = enable_output_audio;
44 input_mode_ = input_mode;
46 m_pWindow = new mof::Window( appname , width , height , fullscreen );
47 mof::GraphicsDevice::initialize( m_pWindow->getHandler(), 0, width , height , fullscreen );
48 mof::InputDevice::initialize();
49 mof::sound::SoundDevice::initialize(m_pWindow->getHandler(), enable_output_audio_);
53 void Application::finalize( )
55 mof::GraphicsDevice::finalize();
56 mof::InputDevice::finalize();
57 mof::sound::SoundDevice::finalize();
62 void Application::run(scene& s)
65 ZeroMemory( &msg, sizeof(msg) );
70 mof::Captor Captor( _T("output"));
74 while( PeekMessage( &msg, NULL, 0U, 0U, PM_NOREMOVE ) )
76 //
\83^
\83C
\83}
\82ð
\82Æ
\82ß
\82é
79 if( msg.message == WM_QUIT )return;
80 GetMessage( &msg , NULL , 0 , 0 );
81 TranslateMessage( &msg );
82 DispatchMessage( &msg );
84 //
\83^
\83C
\83}
\82ª
\8e~
\82Ü
\82Á
\82Ä
\82¢
\82ê
\82Î
\81A
\8dÄ
\8aJ
88 for( int i = 0 ; i < m_nUpdatingPerFrame ; i++ )s.update();//
\83V
\81[
\83\93\82Ì
\8f\88\97\9d
91 mof::GraphicsDevice::beginScene();
92 s.draw();//
\83V
\81[
\83\93\82Ì
\95`
\89æ
93 if (enable_output_frame_) Captor.capture();
94 mof::GraphicsDevice::endScene();
97 double true_past_time = timer.getTime();
98 double past_time = frame_interval_ * (frameCount + 1);
99 if(past_time > true_past_time) {
100 Sleep(static_cast<int>(past_time - true_past_time));
101 sleepingTime += past_time - true_past_time;
106 if(++frameCount % 500 == 0)
108 float fps = 500.0f / static_cast<float>(fpsTimer.getTime() - sleepingTime) * 1000;
111 DEBUG_PRINT( "FPS --- " << fps );
119 void Application::quit( )
125 Application::InputMode Application::input_mode() {