X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2Fapp.cpp;h=b111402e4809fca4bc8bb10db79b2f90da476213;hb=e245d91528b1447cd1649533c587aebe278c3a53;hp=dc4869a46191417735b008b9faf95a66a79a09d0;hpb=ed3bdc028edc0ecb5835d1c0bf18dbc59b342daf;p=blank.git diff --git a/src/app/app.cpp b/src/app/app.cpp index dc4869a..b111402 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -28,8 +28,7 @@ #include #include -using std::runtime_error; -using std::string; +using namespace std; namespace blank { @@ -80,11 +79,11 @@ void HeadlessApplication::RunT(size_t t) { void HeadlessApplication::RunS(size_t n, size_t t) { for (size_t i = 0; HasState() && i < n; ++i) { Loop(t); - std::cout << '.'; - if (i % 16 == 15) { - std::cout << std::setfill(' ') << std::setw(5) << std::right << (i + 1) << std::endl; + cout << '.'; + if (i % 32 == 31) { + cout << setfill(' ') << setw(5) << right << (i + 1) << endl; } else { - std::cout << std::flush; + cout << flush; } } } @@ -316,19 +315,24 @@ void AssetLoader::LoadBlockTypes( const ShapeRegistry &shapes ) const { string full = data + set_name + ".types"; - std::ifstream file(full); + ifstream file(full); if (!file) { - throw std::runtime_error("failed to open block type file " + full); + throw runtime_error("failed to open block type file " + full); } TokenStreamReader in(file); - string name; + string proto; while (in.HasMore()) { - in.ReadIdentifier(name); - in.Skip(Token::EQUALS); BlockType type; + in.ReadIdentifier(type.name); + in.Skip(Token::EQUALS); + if (in.Peek().type == Token::IDENTIFIER) { + // prototype + in.ReadIdentifier(proto); + type.Copy(reg.Get(proto)); + } type.Read(in, snd_index, tex_index, shapes); in.Skip(Token::SEMICOLON); - reg.Add(std::move(type)); + reg.Add(move(type)); } } @@ -417,9 +421,9 @@ void AssetLoader::LoadModels( const ShapeRegistry &shapes ) const { string full = data + set_name + ".models"; - std::ifstream file(full); + ifstream file(full); if (!file) { - throw std::runtime_error("failed to open model file " + full); + throw runtime_error("failed to open model file " + full); } TokenStreamReader in(file); string model_name; @@ -453,9 +457,9 @@ void AssetLoader::LoadModels( void AssetLoader::LoadShapes(const string &set_name, ShapeRegistry &shapes) const { string full = data + set_name + ".shapes"; - std::ifstream file(full); + ifstream file(full); if (!file) { - throw std::runtime_error("failed to open shape file " + full); + throw runtime_error("failed to open shape file " + full); } TokenStreamReader in(file); string shape_name; @@ -591,8 +595,28 @@ void FrameCounter::Push() noexcept { avg.waiting = sum.waiting * factor; avg.total = sum.total * factor; + //Print(cout); + sum = Frame(); max = Frame(); } +void FrameCounter::Print(ostream &out) const { + out << fixed << right << setprecision(2) << setfill(' ') + << "PEAK handle: " << setw(2) << peak.handle + << ".00ms, update: " << setw(2) << peak.update + << ".00ms, render: " << setw(2) << peak.render + << ".00ms, running: " << setw(2) << peak.running + << ".00ms, waiting: " << setw(2) << peak.waiting + << ".00ms, total: " << setw(2) << peak.total + << ".00ms" << endl + << " AVG handle: " << setw(5) << avg.handle + << "ms, update: " << setw(5) << avg.update + << "ms, render: " << setw(5) << avg.render + << "ms, running: " << setw(5) << avg.running + << "ms, waiting: " << setw(5) << avg.waiting + << "ms, total: " << setw(5) << avg.total + << "ms" << endl; +} + }