My Documents/dxframework/dxf/dxf-engine/dxf_model.cpp

Go to the documentation of this file.
00001 /*      DXFramework Copyright (c) 2006, Jonathan Voigt, University of Michigan.
00002         See http://dxframework.sourceforge.net/ for a list of contributors.
00003         All rights reserved.
00004 
00005         Redistribution and use in source and binary forms, with or without modification, 
00006         are permitted provided that the following conditions are met:
00007 
00008                 * Redistributions of source code must retain the above copyright notice, 
00009                 this list of conditions and the following disclaimer.
00010 
00011                 * Redistributions in binary form must reproduce the above copyright notice, 
00012                 this list of conditions and the following disclaimer in the documentation 
00013                 and/or other materials provided with the distribution.
00014 
00015                 * Neither the name of the DXFramework project nor the names of its 
00016                 contributors may be used to endorse or promote products derived from this 
00017                 software without specific prior written permission.
00018 
00019         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
00020         ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
00021         WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00022         DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
00023         ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00024         (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
00025         LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
00026         ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00027         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00028         SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 */
00030 
00031 #include "dxframework.h"
00032 
00033 void CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ) {
00034         return dxf::Model::Instance()->OnFrameMove(pd3dDevice, fTime, fElapsedTime, pUserContext);
00035 }
00036 
00037 namespace dxf {
00038         extern bool gFPS;
00039 
00040         Model::Model() {
00041         }
00042 
00043         Model* const Model::Instance() {
00044                 static Model instance;
00045                 return &instance;
00046         }
00047 
00048         void Model::Load() {
00049                 StateManager::Load();
00050 
00051                 DXUTSetCallbackFrameMove( ::OnFrameMove );
00052         }
00053 
00054         void Model::Unload() {
00055                 StateManager::Unload();
00056         }
00057 
00058         void Model::OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ) {
00059                 DXFPollInput();
00060                 DXFUpdateConsole();
00061                 if (pCurrentState) pCurrentState->Update(fTime, fElapsedTime);
00062                 StateManager::Update();
00063         }
00064 
00065 
00066         void Model::RenderPre2D(double fTime, float fElapsedTime) {
00067                 if (pCurrentState) pCurrentState->RenderPre2D(fTime, fElapsedTime);
00068         }
00069 
00070         void Model::Render3D(double fTime, float fElapsedTime) {
00071                 if (pCurrentState) pCurrentState->Render3D(fTime, fElapsedTime);
00072         }
00073 
00074         void Model::Render2D(double fTime, float fElapsedTime) {
00075                 if (pCurrentState) pCurrentState->Render2D(fTime, fElapsedTime);
00076                 if (gFPS) Console::Instance()->GetFont()->Render2D(DXUTGetFrameStats());
00077         }
00078 
00079         GameState* GetCurrentGameState() { return Model::Instance()->GetCurrentGameState(); }
00080         void DXFRenderPre2D(double fTime, float fElapsedTime) { Model::Instance()->RenderPre2D(fTime, fElapsedTime); }
00081         void DXFRender3D(double fTime, float fElapsedTime) { Model::Instance()->Render3D(fTime, fElapsedTime); }
00082         void DXFRender2D(double fTime, float fElapsedTime) { Model::Instance()->Render2D(fTime, fElapsedTime); }
00083         void DXFChangeState(const std::wstring& name) { Model::Instance()->ChangeState(name); }
00084         void DXFRegisterState(const std::wstring& name, GameState* pState) { Model::Instance()->RegisterState(name, pState); }
00085 } // namespace dxf

Generated on Fri Aug 18 12:01:27 2006 for DXFramework by  doxygen 1.4.7