Browse Source

Add Engine > Frame rate menu bar item.

tags/v1.1.5
Andrew Belt 5 years ago
parent
commit
7b0ce97406
4 changed files with 36 additions and 12 deletions
  1. +4
    -3
      CHANGELOG.md
  2. +28
    -0
      src/app/MenuBar.cpp
  3. +0
    -5
      src/app/Scene.cpp
  4. +4
    -4
      src/window.cpp

+ 4
- 3
CHANGELOG.md View File

@@ -4,13 +4,14 @@ In this document, Mod is Ctrl on Windows/Linux and Cmd on Mac.


### 1.1.5 (in development) ### 1.1.5 (in development)
- Swap order of tags and brands in Module Browser. - Swap order of tags and brands in Module Browser.
- Disable smoothing for MIDI CC buttons in MIDI-Map.
- Automatically unzip update on Mac.
- Stop worker threads when engine is paused to save CPU.
- Add Engine > Frame rate menu bar item.
- Hide menu and scrollbars when fullscreen. - Hide menu and scrollbars when fullscreen.
- Add key command (F3) for engine CPU meter. - Add key command (F3) for engine CPU meter.
- Add numpad key commands. - Add numpad key commands.
- Automatically unzip update on Mac.
- Stop worker threads when engine is paused to save CPU.
- Core - Core
- Disable smoothing for MIDI CC buttons in MIDI-Map.
- Fix sustain pedal release bug when using polyphonic mode in MIDI-CV. - Fix sustain pedal release bug when using polyphonic mode in MIDI-CV.
- API - API
- Add libsamplerate library. - Add libsamplerate library.


+ 28
- 0
src/app/MenuBar.cpp View File

@@ -327,6 +327,30 @@ struct CursorLockItem : ui::MenuItem {
} }
}; };


struct FrameRateValueItem : ui::MenuItem {
int frameSwapInterval;
void onAction(const event::Action& e) override {
settings::frameSwapInterval = frameSwapInterval;
}
};

struct FrameRateItem : ui::MenuItem {
ui::Menu* createChildMenu() override {
ui::Menu* menu = new ui::Menu;

for (int i = 1; i <= 6; i++) {
float frameRate = 60.f / i;

FrameRateValueItem* item = new FrameRateValueItem;
item->frameSwapInterval = i;
item->text = string::f("%.0f Hz", frameRate);
item->rightText += CHECKMARK(settings::frameSwapInterval == i);
menu->addChild(item);
}
return menu;
}
};

struct FullscreenItem : ui::MenuItem { struct FullscreenItem : ui::MenuItem {
void onAction(const event::Action& e) override { void onAction(const event::Action& e) override {
APP->window->setFullScreen(!APP->window->isFullScreen()); APP->window->setFullScreen(!APP->window->isFullScreen());
@@ -366,6 +390,10 @@ struct ViewButton : MenuButton {
cableTensionSlider->box.size.x = 200.0; cableTensionSlider->box.size.x = 200.0;
menu->addChild(cableTensionSlider); menu->addChild(cableTensionSlider);


FrameRateItem* frameRateItem = new FrameRateItem;
frameRateItem->text = "Frame rate";
menu->addChild(frameRateItem);

FullscreenItem* fullscreenItem = new FullscreenItem; FullscreenItem* fullscreenItem = new FullscreenItem;
fullscreenItem->text = "Fullscreen"; fullscreenItem->text = "Fullscreen";
fullscreenItem->rightText = "F11"; fullscreenItem->rightText = "F11";


+ 0
- 5
src/app/Scene.cpp View File

@@ -56,11 +56,6 @@ void Scene::step() {


void Scene::draw(const DrawArgs& args) { void Scene::draw(const DrawArgs& args) {
Widget::draw(args); Widget::draw(args);

// nvgBeginPath(args.vg);
// nvgRect(args.vg, 0, 0, box.size.x, box.size.y);
// nvgFillColor(args.vg, color::mult(color::WHITE, APP->window->frame % 2));
// nvgFill(args.vg);
} }


void Scene::onHoverKey(const event::HoverKey& e) { void Scene::onHoverKey(const event::HoverKey& e) {


+ 4
- 4
src/window.cpp View File

@@ -325,7 +325,10 @@ Window::~Window() {
void Window::run() { void Window::run() {
frame = 0; frame = 0;
while (!glfwWindowShouldClose(win)) { while (!glfwWindowShouldClose(win)) {
frameTimeStart = glfwGetTime();
double frameTime = glfwGetTime();
// double frameRate = 1.0 / (frameTime - frameTimeStart);
// DEBUG("%g fps", frameRate);
frameTimeStart = frameTime;


// Make event handlers and step() have a clean nanovg context // Make event handlers and step() have a clean nanovg context
nvgReset(vg); nvgReset(vg);
@@ -406,9 +409,6 @@ void Window::run() {


glfwSwapBuffers(win); glfwSwapBuffers(win);


// Compute actual frame rate
double frameTimeEnd = glfwGetTime();
DEBUG("%g fps", 1 / (frameTimeEnd - frameTimeStart));
frame++; frame++;
} }
} }


Loading…
Cancel
Save