mirror of
https://github.com/rwengine/openrw.git
synced 2025-04-28 21:08:05 +03:00
Added Benchmark mode (--benchmark file)
This commit is contained in:
parent
aecc43c75b
commit
74f0e7f67c
4 changed files with 34 additions and 4 deletions
|
@ -10,6 +10,7 @@ add_executable(rwgame
|
||||||
pausestate.cpp
|
pausestate.cpp
|
||||||
menustate.cpp
|
menustate.cpp
|
||||||
debugstate.cpp
|
debugstate.cpp
|
||||||
|
benchmarkstate.cpp
|
||||||
|
|
||||||
DrawUI.cpp
|
DrawUI.cpp
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "DrawUI.hpp"
|
#include "DrawUI.hpp"
|
||||||
#include "ingamestate.hpp"
|
#include "ingamestate.hpp"
|
||||||
#include "menustate.hpp"
|
#include "menustate.hpp"
|
||||||
|
#include "benchmarkstate.hpp"
|
||||||
#include "debug/HttpServer.hpp"
|
#include "debug/HttpServer.hpp"
|
||||||
|
|
||||||
#include <objects/GameObject.hpp>
|
#include <objects/GameObject.hpp>
|
||||||
|
@ -38,6 +39,7 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
|
||||||
bool newgame = false;
|
bool newgame = false;
|
||||||
bool test = false;
|
bool test = false;
|
||||||
std::string startSave;
|
std::string startSave;
|
||||||
|
std::string benchFile;
|
||||||
|
|
||||||
for( int i = 1; i < argc; ++i )
|
for( int i = 1; i < argc; ++i )
|
||||||
{
|
{
|
||||||
|
@ -69,6 +71,10 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
|
||||||
{
|
{
|
||||||
startSave = argv[i+1];
|
startSave = argv[i+1];
|
||||||
}
|
}
|
||||||
|
if( strcmp( "--benchmark", argv[i]) == 0 && i+1 < argc )
|
||||||
|
{
|
||||||
|
benchFile = argv[i+1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +87,6 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
|
||||||
sf::ContextSettings cs;
|
sf::ContextSettings cs;
|
||||||
cs.depthBits = 32;
|
cs.depthBits = 32;
|
||||||
window.create(sf::VideoMode(w, h), "", style, cs);
|
window.create(sf::VideoMode(w, h), "", style, cs);
|
||||||
window.setVerticalSyncEnabled(true);
|
|
||||||
window.setMouseCursorVisible(false);
|
window.setMouseCursorVisible(false);
|
||||||
|
|
||||||
log.addReciever(&logPrinter);
|
log.addReciever(&logPrinter);
|
||||||
|
@ -130,7 +135,11 @@ RWGame::RWGame(const std::string& gamepath, int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
auto loading = new LoadingState(this);
|
auto loading = new LoadingState(this);
|
||||||
if( newgame )
|
if (! benchFile.empty())
|
||||||
|
{
|
||||||
|
loading->setNextState(new BenchmarkState(this, benchFile));
|
||||||
|
}
|
||||||
|
else if( newgame )
|
||||||
{
|
{
|
||||||
if( test )
|
if( test )
|
||||||
{
|
{
|
||||||
|
@ -171,7 +180,7 @@ void RWGame::newGame()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state = new GameState;
|
state = new GameState();
|
||||||
world = new GameWorld(&log, &work, data);
|
world = new GameWorld(&log, &work, data);
|
||||||
world->dynamicsWorld->setDebugDrawer(debug);
|
world->dynamicsWorld->setDebugDrawer(debug);
|
||||||
|
|
||||||
|
@ -317,6 +326,9 @@ int RWGame::run()
|
||||||
|
|
||||||
while ( accum >= GAME_TIMESTEP ) {
|
while ( accum >= GAME_TIMESTEP ) {
|
||||||
StateManager::get().tick(GAME_TIMESTEP);
|
StateManager::get().tick(GAME_TIMESTEP);
|
||||||
|
if (StateManager::get().states.size() == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
tick(GAME_TIMESTEP);
|
tick(GAME_TIMESTEP);
|
||||||
|
|
||||||
|
@ -337,7 +349,9 @@ int RWGame::run()
|
||||||
|
|
||||||
render(alpha, timer);
|
render(alpha, timer);
|
||||||
|
|
||||||
StateManager::get().draw(renderer);
|
if (StateManager::get().states.size() > 0) {
|
||||||
|
StateManager::get().draw(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
window.display();
|
window.display();
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,9 @@ DebugState::DebugState(RWGame* game, const glm::vec3& vp, const glm::quat& vd)
|
||||||
m->addEntry(Menu::lambda("Full Armour", [=] {
|
m->addEntry(Menu::lambda("Full Armour", [=] {
|
||||||
game->getPlayer()->getCharacter()->getCurrentState().armour = 100.f;
|
game->getPlayer()->getCharacter()->getCurrentState().armour = 100.f;
|
||||||
}, entryHeight));
|
}, entryHeight));
|
||||||
|
m->addEntry(Menu::lambda("Cull Here", [=] {
|
||||||
|
game->getRenderer()->setCullOverride(true, _debugCam);
|
||||||
|
}, entryHeight));
|
||||||
|
|
||||||
this->enterMenu(m);
|
this->enterMenu(m);
|
||||||
|
|
||||||
|
@ -224,6 +227,9 @@ void DebugState::handleEvent(const sf::Event &e)
|
||||||
case sf::Keyboard::LShift:
|
case sf::Keyboard::LShift:
|
||||||
_sonicMode = true;
|
_sonicMode = true;
|
||||||
break;
|
break;
|
||||||
|
case sf::Keyboard::P:
|
||||||
|
printCameraDetails();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case sf::Event::KeyReleased:
|
case sf::Event::KeyReleased:
|
||||||
|
@ -246,6 +252,13 @@ void DebugState::handleEvent(const sf::Event &e)
|
||||||
State::handleEvent(e);
|
State::handleEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebugState::printCameraDetails()
|
||||||
|
{
|
||||||
|
std::cout << " " << _debugCam.position.x << " " << _debugCam.position.y << " " << _debugCam.position.z
|
||||||
|
<< " " << _debugCam.rotation.x << " " << _debugCam.rotation.y << " " << _debugCam.rotation.z
|
||||||
|
<< " " << _debugCam.rotation.w << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
void DebugState::spawnVehicle(unsigned int id)
|
void DebugState::spawnVehicle(unsigned int id)
|
||||||
{
|
{
|
||||||
auto ch = game->getPlayer()->getCharacter();
|
auto ch = game->getPlayer()->getCharacter();
|
||||||
|
|
|
@ -21,6 +21,8 @@ public:
|
||||||
|
|
||||||
virtual void handleEvent(const sf::Event& event);
|
virtual void handleEvent(const sf::Event& event);
|
||||||
|
|
||||||
|
void printCameraDetails();
|
||||||
|
|
||||||
void spawnVehicle(unsigned int id);
|
void spawnVehicle(unsigned int id);
|
||||||
|
|
||||||
const ViewCamera& getCamera();
|
const ViewCamera& getCamera();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue