1
0
forked from 0ad/0ad

Moved Xerces initialisation out of CObjectEntry to here (still need to moved GUI and entity XML code at some point). Added simple fixed camera view for basic profiling.

This was SVN commit r409.
This commit is contained in:
notpete 2004-06-07 19:51:52 +00:00
parent 9210297729
commit bd0d3e1c36

View File

@ -40,6 +40,7 @@
#include "EntityHandles.h" #include "EntityHandles.h"
#include "EntityManager.h" #include "EntityManager.h"
#include "PathfindEngine.h" #include "PathfindEngine.h"
#include "XML.h"
#ifndef NO_GUI #ifndef NO_GUI
@ -69,7 +70,9 @@ static bool g_NoGLVBO=false;
// flag to switch on shadows // flag to switch on shadows
static bool g_Shadows=false; static bool g_Shadows=false;
// flag to switch off pbuffers // flag to switch off pbuffers
static bool g_NoPBuffer=false; static bool g_NoPBuffer=true;
// flag to switch on fixed frame timing (RC: I'm using this for profiling purposes)
static bool g_FixedFrameTiming=false;
static bool g_VSync = false; static bool g_VSync = false;
static bool g_EntGraph = false; static bool g_EntGraph = false;
@ -339,7 +342,7 @@ static void Render()
// overlay mode // overlay mode
glPushAttrib(GL_ENABLE_BIT); glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glAlphaFunc(GL_GREATER, 0.5); glAlphaFunc(GL_GREATER, 0.5);
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
@ -438,6 +441,12 @@ void ParseArgs(int argc, char* argv[])
} }
break; break;
case 'f':
if (strncmp(argv[i]+1,"fixedframe",10)==0) {
g_FixedFrameTiming=true;
}
break;
case 's': case 's':
if (strncmp(argv[i]+1,"shadows",7)==0) { if (strncmp(argv[i]+1,"shadows",7)==0) {
g_Shadows=true; g_Shadows=true;
@ -541,6 +550,11 @@ int main(int argc, char* argv[])
debug_warn("SDL_SetGamma failed"); debug_warn("SDL_SetGamma failed");
} }
// start up Xerces - only needs to be done once (unless locale changes mid-game, for
// some reason), not on every XML file load; multiple initialization calls are ok, though,
// provided there are a matching number of XMLPlatformUtils::Terminate calls
XMLPlatformUtils::Initialize();
res_mount("", "mods/official/", 0); res_mount("", "mods/official/", 0);
@ -623,6 +637,22 @@ if(!g_MapFile)
// render everything to a blank frame to force renderer to load everything // render everything to a blank frame to force renderer to load everything
RenderNoCull(); RenderNoCull();
size_t frameCount=0;
if (g_FixedFrameTiming) {
#if 0 // TOPDOWN
g_Camera.SetProjection(1.0f,10000.0f,DEGTORAD(90));
g_Camera.m_Orientation.SetIdentity();
g_Camera.m_Orientation.RotateX(DEGTORAD(90));
g_Camera.m_Orientation.Translate(CELL_SIZE*250*0.5, 250, CELL_SIZE*250*0.5);
#else // std view
g_Camera.SetProjection(1.0f,10000.0f,DEGTORAD(20));
g_Camera.m_Orientation.SetXRotation(DEGTORAD(30));
g_Camera.m_Orientation.RotateY(DEGTORAD(-45));
g_Camera.m_Orientation.Translate(350, 350, -275);
#endif
g_Camera.UpdateFrustum();
}
g_Console->RegisterFunc(Testing, "Testing"); g_Console->RegisterFunc(Testing, "Testing");
@ -662,13 +692,15 @@ g_Console->RegisterFunc(Testing, "Testing");
float TimeSinceLastFrame = (float)(time1-time0); float TimeSinceLastFrame = (float)(time1-time0);
in_get_events(); in_get_events();
UpdateWorld(TimeSinceLastFrame); UpdateWorld(TimeSinceLastFrame);
terr_update(TimeSinceLastFrame); if (!g_FixedFrameTiming) terr_update(float(TimeSinceLastFrame));
g_Console->Update(TimeSinceLastFrame); g_Console->Update(TimeSinceLastFrame);
Render(); Render();
SDL_GL_SwapBuffers(); SDL_GL_SwapBuffers();
calc_fps(); calc_fps();
time0=time1; time0=time1;
frameCount++;
if (g_FixedFrameTiming && frameCount==100) quit=true;
#endif #endif
} }
@ -693,6 +725,9 @@ g_Console->RegisterFunc(Testing, "Testing");
// destroy renderer // destroy renderer
delete CRenderer::GetSingletonPtr(); delete CRenderer::GetSingletonPtr();
// close down Xerces
XMLPlatformUtils::Terminate();
//shut down FMOD - needs adding to the atexit calls above //shut down FMOD - needs adding to the atexit calls above
FSOUND_Close(); FSOUND_Close();