Comment out some debug; change FPS calc; misc changes
This commit is contained in:
24
main.cc
24
main.cc
@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
|
||||
Object pyramid(vboManager, "objects/pyramid.obj", prog);
|
||||
Object plane(vboManager, "objects/plane.obj", prog);
|
||||
|
||||
float px20_width = 2.0f*(20.0f/width);
|
||||
float px20_width = 2.0f*(60.0f/width);
|
||||
float px20_height = 2.0f*(20.0f/height);
|
||||
|
||||
std::vector<ovlVertexAttribs> ovlAttribs{
|
||||
@@ -217,6 +217,9 @@ int main(int argc, char *argv[])
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
bool close = false;
|
||||
|
||||
Texture2D fpsTex{64, 64, true};
|
||||
unsigned fpsTime = 0, fpsCount = 0;
|
||||
|
||||
while (!close) {
|
||||
SDL_Event event;
|
||||
@@ -315,20 +318,19 @@ int main(int argc, char *argv[])
|
||||
glm::rotate(0.35f, glm::vec3(0.0f, 1.0f, 0.0f)));
|
||||
redTex.bind();
|
||||
pyramid.draw(glm::translate(glm::vec3(-2.0f, 0.0f, 0.0f)));
|
||||
|
||||
// glUseProgram(0);
|
||||
// sf::Time now = clock.getElapsedTime();
|
||||
// sf::Time elapsed = now - last;
|
||||
// last = now;
|
||||
// fpsText.setString(std::to_string(static_cast<int>(std::roundf(1.0f/elapsed.asSeconds()))));
|
||||
// fpsText.setPosition({1680-fpsText.getLocalBounds().width, 0});
|
||||
// window.draw(fpsText);
|
||||
|
||||
auto now = SDL_GetTicks();
|
||||
auto elapsed = now - last;
|
||||
last = now;
|
||||
std::string fpsText = std::to_string(static_cast<unsigned>(1000.0/elapsed));
|
||||
auto fpsTex = font.render(fpsText);
|
||||
if (fpsTime+elapsed > 1000) {
|
||||
const std::string fpsText{std::to_string(fpsCount + 1) + " FPS"s};
|
||||
fpsTex = font.render(fpsText);
|
||||
fpsCount = 0;
|
||||
fpsTime = 0;
|
||||
} else {
|
||||
++fpsCount;
|
||||
fpsTime += elapsed;
|
||||
}
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
Reference in New Issue
Block a user