Browse Source

Add NanoVG::beginFrame(Widget*) for convenience

gh-pages
falkTX 8 years ago
parent
commit
8d8af85953
2 changed files with 14 additions and 0 deletions
  1. +5
    -0
      dgl/NanoVG.hpp
  2. +9
    -0
      dgl/src/NanoVG.cpp

+ 5
- 0
dgl/NanoVG.hpp View File

@@ -298,6 +298,11 @@ public:
*/
void beginFrame(int width, int height, float scaleFactor = 1.0f, Alpha alpha = PREMULTIPLIED_ALPHA);

/**
Begin drawing a new frame inside a widget.
*/
void beginFrame(Widget* widget);

/**
Ends drawing flushing remaining render state.
*/


+ 9
- 0
dgl/src/NanoVG.cpp View File

@@ -15,6 +15,7 @@
*/

#include "../NanoVG.hpp"
#include "../Window.hpp"

// -----------------------------------------------------------------------

@@ -182,6 +183,14 @@ void NanoVG::beginFrame(int width, int height, float scaleFactor, Alpha alpha)
nvgBeginFrame(fContext, width, height, scaleFactor, static_cast<NVGalpha>(alpha));
}

void NanoVG::beginFrame(Widget* widget)
{
DISTRHO_SAFE_ASSERT_RETURN(widget != nullptr,);

Window& window(widget->getParentWindow());
nvgBeginFrame(fContext, window.getWidth(), window.getHeight(), 1.0f, NVG_PREMULTIPLIED_ALPHA);
}

void NanoVG::endFrame()
{
nvgEndFrame(fContext);


Loading…
Cancel
Save