Working on new gui for testbed application
This commit is contained in:
parent
e29794d24f
commit
abe178fa1d
|
@ -79,22 +79,22 @@ void Gui::init() {
|
|||
// Update the GUI
|
||||
void Gui::update() {
|
||||
|
||||
double currentTime = glfwGetTime();
|
||||
if ((currentTime - mTimeSinceLastProfilingDisplay) > TIME_INTERVAL_DISPLAY_PROFILING_INFO) {
|
||||
mTimeSinceLastProfilingDisplay = currentTime;
|
||||
// Update Profiling GUI every seconds
|
||||
if ((mApp->mCurrentTime - mTimeSinceLastProfilingDisplay) > TIME_INTERVAL_DISPLAY_PROFILING_INFO) {
|
||||
mTimeSinceLastProfilingDisplay = mApp->mCurrentTime;
|
||||
mCachedFPS = mApp->mFPS;
|
||||
mCachedUpdateTime = mApp->mUpdateTime;
|
||||
mCachedPhysicsUpdateTime = mApp->mPhysicsUpdateTime;
|
||||
mCachedUpdateTime = mApp->mFrameTime;
|
||||
mCachedPhysicsUpdateTime = mApp->mPhysicsTime;
|
||||
}
|
||||
|
||||
// Framerate (FPS)
|
||||
mFPSLabel->setCaption(std::string("FPS : ") + floatToString(mCachedFPS, 0));
|
||||
|
||||
// Update time
|
||||
mUpdateTimeLabel->setCaption(std::string("Update time (ms) : ") + floatToString(mCachedUpdateTime * 1000.0, 1));
|
||||
// Frame time
|
||||
mFrameTimeLabel->setCaption(std::string("Frame time (ms) : ") + floatToString(mCachedUpdateTime * 1000.0, 1));
|
||||
|
||||
// Update time
|
||||
mUpdatePhysicsTimeLabel->setCaption("Update physics time (ms) : " + floatToString(mCachedPhysicsUpdateTime * 1000.0, 1));
|
||||
// Physics time
|
||||
mPhysicsTimeLabel->setCaption("Physics time (ms) : " + floatToString(mCachedPhysicsUpdateTime * 1000.0, 1));
|
||||
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ void Gui::createSettingsPanel() {
|
|||
CheckBox* checkboxVSync = new CheckBox(mRenderingPanel, "V-Sync");
|
||||
checkboxVSync->setChecked(mApp->mIsVSyncEnabled);
|
||||
checkboxVSync->setCallback([&](bool value) {
|
||||
mApp->mIsVSyncEnabled = value;
|
||||
mApp->enableVSync(value);
|
||||
});
|
||||
|
||||
// Enabled/Disable Shadows
|
||||
|
@ -426,10 +426,10 @@ void Gui::createProfilingPanel() {
|
|||
mFPSLabel = new Label(profilingPanel, std::string("FPS : ") + floatToString(mCachedFPS, 0),"sans-bold");
|
||||
|
||||
// Update time
|
||||
mUpdateTimeLabel = new Label(profilingPanel, std::string("Update time (ms) : ") + floatToString(mCachedUpdateTime * 1000.0, 1),"sans-bold");
|
||||
mFrameTimeLabel = new Label(profilingPanel, std::string("Frame time (ms) : ") + floatToString(mCachedUpdateTime * 1000.0, 1),"sans-bold");
|
||||
|
||||
// Update time
|
||||
mUpdatePhysicsTimeLabel = new Label(profilingPanel, "Update physics time (ms) : " + floatToString(mCachedPhysicsUpdateTime * 1000.0, 1),"sans-bold");
|
||||
mPhysicsTimeLabel = new Label(profilingPanel, "Physics time (ms) : " + floatToString(mCachedPhysicsUpdateTime * 1000.0, 1),"sans-bold");
|
||||
|
||||
profilingPanel->setVisible(true);
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ class Gui {
|
|||
|
||||
// Profiling panel
|
||||
Label* mFPSLabel;
|
||||
Label* mUpdateTimeLabel;
|
||||
Label* mUpdatePhysicsTimeLabel;
|
||||
Label* mFrameTimeLabel;
|
||||
Label* mPhysicsTimeLabel;
|
||||
|
||||
std::vector<CheckBox*> mCheckboxesScenes;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ const float TestbedApplication::SCROLL_SENSITIVITY = 0.02f;
|
|||
TestbedApplication::TestbedApplication(bool isFullscreen)
|
||||
: Screen(Vector2i(1280, 760), "Testbed ReactPhysics3D", true, isFullscreen),
|
||||
mIsInitialized(false), mFPS(0), mNbFrames(0), mPreviousTime(0),
|
||||
mUpdateTime(0), mPhysicsUpdateTime(0), mGui(this) {
|
||||
mLastTimeComputedFPS(0), mFrameTime(0), mPhysicsTime(0), mGui(this) {
|
||||
|
||||
mCurrentScene = NULL;
|
||||
mIsMultisamplingActive = true;
|
||||
|
@ -61,10 +61,12 @@ TestbedApplication::TestbedApplication(bool isFullscreen)
|
|||
mSinglePhysicsStepDone = false;
|
||||
mWindowToFramebufferRatio = Vector2(1, 1);
|
||||
mIsShadowMappingEnabled = true;
|
||||
mIsVSyncEnabled = true;
|
||||
mIsVSyncEnabled = false;
|
||||
mIsContactPointsDisplayed = false;
|
||||
|
||||
init();
|
||||
|
||||
resizeEvent(Vector2i(0, 0));
|
||||
}
|
||||
|
||||
// Destructor
|
||||
|
@ -72,12 +74,6 @@ TestbedApplication::~TestbedApplication() {
|
|||
|
||||
// Destroy all the scenes
|
||||
destroyScenes();
|
||||
|
||||
// Destroy the window
|
||||
//glfwDestroyWindow(mWindow);
|
||||
|
||||
// Terminate GLFW
|
||||
//glfwTerminate();
|
||||
}
|
||||
|
||||
// Initialize the viewer
|
||||
|
@ -184,7 +180,7 @@ void TestbedApplication::update() {
|
|||
}
|
||||
|
||||
// Compute the physics update time
|
||||
mPhysicsUpdateTime = glfwGetTime() - currentTime;
|
||||
mPhysicsTime = glfwGetTime() - currentTime;
|
||||
|
||||
// Compute the interpolation factor
|
||||
float factor = mTimer.computeInterpolationFactor(mEngineSettings.timeStep);
|
||||
|
@ -205,8 +201,6 @@ void TestbedApplication::update() {
|
|||
|
||||
void TestbedApplication::drawContents() {
|
||||
|
||||
resizeEvent(Vector2i(0, 0));
|
||||
|
||||
update();
|
||||
|
||||
int bufferWidth, bufferHeight;
|
||||
|
@ -219,16 +213,13 @@ void TestbedApplication::drawContents() {
|
|||
// Render the scene
|
||||
mCurrentScene->render();
|
||||
|
||||
// Display the GUI
|
||||
//Gui::getInstance().render();
|
||||
|
||||
// Compute the current framerate
|
||||
computeFPS();
|
||||
|
||||
mGui.update();
|
||||
|
||||
// Check the OpenGL errors
|
||||
checkOpenGLErrors();
|
||||
|
||||
// Compute the current framerate
|
||||
computeFPS();
|
||||
}
|
||||
|
||||
/// Window resize event handler
|
||||
|
@ -251,12 +242,6 @@ bool TestbedApplication::resizeEvent(const Vector2i& size) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Set the dimension of the camera viewport
|
||||
void TestbedApplication::reshape() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Change the current scene
|
||||
void TestbedApplication::switchScene(Scene* newScene) {
|
||||
|
||||
|
@ -271,6 +256,8 @@ void TestbedApplication::switchScene(Scene* newScene) {
|
|||
|
||||
// Reset the scene
|
||||
mCurrentScene->reset();
|
||||
|
||||
resizeEvent(Vector2i(0, 0));
|
||||
}
|
||||
|
||||
// Check the OpenGL errors
|
||||
|
@ -310,22 +297,24 @@ void TestbedApplication::computeFPS() {
|
|||
mCurrentTime = glfwGetTime();
|
||||
|
||||
// Calculate time passed
|
||||
mUpdateTime = mCurrentTime - mPreviousTime;
|
||||
double timeInterval = mUpdateTime * 1000.0;
|
||||
mFrameTime = mCurrentTime - mPreviousTime;
|
||||
double timeInterval = (mCurrentTime - mLastTimeComputedFPS) * 1000.0;
|
||||
|
||||
// Update the FPS counter each second
|
||||
if(timeInterval > 0.0001) {
|
||||
if(timeInterval > 1000) {
|
||||
|
||||
// calculate the number of frames per second
|
||||
mFPS = static_cast<double>(mNbFrames) / timeInterval;
|
||||
mFPS *= 1000.0;
|
||||
|
||||
// Set time
|
||||
mPreviousTime = mCurrentTime;
|
||||
|
||||
// Reset frame count
|
||||
mNbFrames = 0;
|
||||
|
||||
mLastTimeComputedFPS = mCurrentTime;
|
||||
}
|
||||
|
||||
// Set time
|
||||
mPreviousTime = mCurrentTime;
|
||||
}
|
||||
|
||||
// GLFW error callback method
|
||||
|
|
|
@ -80,11 +80,14 @@ class TestbedApplication : public Screen {
|
|||
/// Previous time for fps computation (in seconds)
|
||||
double mPreviousTime;
|
||||
|
||||
/// Last time the FPS have been computed
|
||||
double mLastTimeComputedFPS;
|
||||
|
||||
/// Update time (in seconds)
|
||||
double mUpdateTime;
|
||||
double mFrameTime;
|
||||
|
||||
/// Physics update time (in seconds)
|
||||
double mPhysicsUpdateTime;
|
||||
double mPhysicsTime;
|
||||
|
||||
/// True if multisampling is active
|
||||
bool mIsMultisamplingActive;
|
||||
|
@ -126,9 +129,6 @@ class TestbedApplication : public Screen {
|
|||
/// Update the simulation by taking a single physics step
|
||||
void updateSinglePhysicsStep();
|
||||
|
||||
/// Called when the windows is reshaped
|
||||
void reshape();
|
||||
|
||||
/// Check the OpenGL errors
|
||||
static void checkOpenGLErrorsInternal(const char* file, int line);
|
||||
|
||||
|
@ -275,13 +275,13 @@ inline void TestbedApplication::displayContactPoints(bool display) {
|
|||
|
||||
// Enable/Disable Vertical synchronization
|
||||
inline void TestbedApplication::enableVSync(bool enable) {
|
||||
mIsVSyncEnabled = enable;
|
||||
/*mIsVSyncEnabled = enable;
|
||||
if (mIsVSyncEnabled) {
|
||||
glfwSwapInterval(1);
|
||||
}
|
||||
else {
|
||||
glfwSwapInterval(0);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user