Add FPS counter and unlock webcam framerate
Maybe disable webcam view altogether and make it a compiler flag?
This commit is contained in:
parent
3220795821
commit
ed6323d7e5
|
@ -131,5 +131,5 @@ void cvFrame() {
|
|||
|
||||
void cvShowFrame() {
|
||||
cv::imshow("Video Input", frame);
|
||||
cv::waitKey(32);
|
||||
cv::waitKey(1);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,10 @@
|
|||
|
||||
#include <webp/decode.h>
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
|
||||
#include <graphics.hpp>
|
||||
#include <modelpart.hpp>
|
||||
|
@ -26,6 +29,9 @@ GLuint transUniform; //location of the "transMatrix" transformation matrix unifo
|
|||
|
||||
float windowAspectRatio;
|
||||
|
||||
int frameCount;
|
||||
std::chrono::high_resolution_clock::time_point secondStart;
|
||||
|
||||
//parts of the model (see modelpart.hpp)
|
||||
Model* model;
|
||||
|
||||
|
@ -76,6 +82,13 @@ void initBuffers (GLuint* vaoNum) {
|
|||
glEnableVertexAttribArray(uvAttr);
|
||||
}
|
||||
|
||||
void fpsCounterReset() {
|
||||
glutSetWindowTitle(fmt::format("{0} - {1} @ {2} FPS", PROJECT_NAME, model->getName(), frameCount).c_str());
|
||||
|
||||
secondStart = std::chrono::high_resolution_clock::now();
|
||||
frameCount = 0;
|
||||
}
|
||||
|
||||
void initGraphics () {
|
||||
int argc = 1;
|
||||
char *argv[1] = {(char*)"fc2d"};
|
||||
|
@ -91,7 +104,7 @@ void initGraphics () {
|
|||
|
||||
model = new Model(resolvePath(("models/"+optData.model+".fma").c_str()).c_str());
|
||||
|
||||
glutSetWindowTitle((PROJECT_NAME " - " + model->getName()).c_str());
|
||||
fpsCounterReset();
|
||||
|
||||
//enable blending for alpha textures
|
||||
glEnable(GL_BLEND);
|
||||
|
@ -191,6 +204,14 @@ void initShader() {
|
|||
|
||||
void graphicsFrame () {
|
||||
glutMainLoopEvent();
|
||||
|
||||
auto timeSinceSecondStart = std::chrono::high_resolution_clock::now() - secondStart;
|
||||
frameCount++;
|
||||
long usSinceSecondStart = std::chrono::duration_cast<std::chrono::microseconds>(timeSinceSecondStart).count();
|
||||
|
||||
if (usSinceSecondStart >= 1000000) {
|
||||
fpsCounterReset();
|
||||
}
|
||||
}
|
||||
|
||||
void printShaderCompileLog(GLuint shader) {
|
||||
|
|
Loading…
Reference in a new issue