| 336 | } |
| 337 | |
| 338 | void render() override |
| 339 | { |
| 340 | if (mSynth.IsLoadingState()) |
| 341 | return; |
| 342 | |
| 343 | mSynth.LockRender(true); |
| 344 | |
| 345 | if (UserPrefs.LastTargetFramerate != UserPrefs.target_framerate.Get()) |
| 346 | { |
| 347 | stopTimer(); |
| 348 | UserPrefs.LastTargetFramerate = UserPrefs.target_framerate.Get(); |
| 349 | startTimerHz(UserPrefs.target_framerate.Get()); |
| 350 | } |
| 351 | |
| 352 | juce::Point<int> mouse = Desktop::getMousePosition(); |
| 353 | mouse -= mScreenPosition; |
| 354 | mSynth.MouseMoved(mouse.x, mouse.y); |
| 355 | |
| 356 | float width = getWidth(); |
| 357 | float height = getHeight(); |
| 358 | |
| 359 | static float kMotionTrails = .4f; |
| 360 | |
| 361 | ofVec3f bgColor(ModularSynth::sBackgroundR, ModularSynth::sBackgroundG, ModularSynth::sBackgroundB); |
| 362 | glViewport(0, 0, width * mPixelRatio, height * mPixelRatio); |
| 363 | glClearColor(bgColor.x, bgColor.y, bgColor.z, 0); |
| 364 | if (UserPrefs.motion_trails.Get() <= 0) |
| 365 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 366 | |
| 367 | nvgBeginFrame(mVG, width, height, mPixelRatio); |
| 368 | |
| 369 | if (UserPrefs.motion_trails.Get() > 0) |
| 370 | { |
| 371 | ofSetColor(bgColor.x * 255, bgColor.y * 255, bgColor.z * 255, (1 - (UserPrefs.motion_trails.Get() * kMotionTrails) * (ofGetFrameRate() / 60.0f)) * 255); |
| 372 | ofFill(); |
| 373 | ofRect(0, 0, width, height); |
| 374 | } |
| 375 | |
| 376 | nvgLineCap(mVG, NVG_ROUND); |
| 377 | nvgLineJoin(mVG, NVG_ROUND); |
| 378 | static float sSpacing = -.3f; |
| 379 | nvgTextLetterSpacing(mVG, sSpacing); |
| 380 | nvgTextLetterSpacing(mFontBoundsVG, sSpacing); |
| 381 | |
| 382 | mSynth.Draw(mVG); |
| 383 | |
| 384 | nvgEndFrame(mVG); |
| 385 | |
| 386 | mSynth.PostRender(); |
| 387 | |
| 388 | mSynth.LockRender(false); |
| 389 | |
| 390 | ++mFrameCountAccum; |
| 391 | int64 time = Time::currentTimeMillis(); |
| 392 | |
| 393 | const int64 kCalcFpsIntervalMs = 1000; |
| 394 | if (time - mLastFpsUpdateTime >= kCalcFpsIntervalMs) |
| 395 | { |
nothing calls this directly
no test coverage detected