more correct nanovg rendering

pull/3471/head
kallaballa 2 years ago
parent 469df5e773
commit cbe9139b49
  1. 8
      src/common/detail/nanovgcontext.cpp
  2. 3
      src/common/viz2d.cpp
  3. 2
      src/font/font-demo.cpp

@ -46,12 +46,16 @@ void pop() {
void NanoVGContext::begin() {
push();
float w = v2d_.getVideoFrameSize().width;
float h = v2d_.getVideoFrameSize().height;
float w = v2d_.getFrameBufferSize().width;
float h = v2d_.getFrameBufferSize().height;
float r = v2d_.getXPixelRatio();
nvgSave(context_);
nvgBeginFrame(context_, w, h, r);
//FIXME mirroring with text somehow doesn't work
// nvgTranslate(context_, 0, h);
// nvgScale(context_, 1, -1);
GL_CHECK(glViewport(0, 0, w, h));
}

@ -30,6 +30,7 @@ cv::Scalar color_convert(const cv::Scalar& src, cv::ColorConversionCodes code) {
cv::Scalar dst(vdst[0],vdst[1],vdst[2], src[3]);
return dst;
}
std::function<bool(Viz2DWindow*, Viz2DWindow*)> Viz2DWindow::viz2DWin_Xcomparator([](Viz2DWindow* lhs, Viz2DWindow* rhs){ return lhs->position()[0] < rhs->position()[0]; });
std::set<Viz2DWindow*, decltype(Viz2DWindow::viz2DWin_Xcomparator)> Viz2DWindow::all_windows_xsorted_(viz2DWin_Xcomparator);
@ -218,7 +219,7 @@ void Viz2D::initialize() {
glfwSetMouseButtonCallback(getGLFWWindow(), [](GLFWwindow *glfwWin, int button, int action, int modifiers) {
Viz2D* v2d = reinterpret_cast<Viz2D*>(glfwGetWindowUserPointer(glfwWin));
v2d->screen().mouse_button_callback_event(button, action, modifiers);
if (button == GLFW_MOUSE_BUTTON_LEFT) {
if (button == GLFW_MOUSE_BUTTON_RIGHT) {
v2d->setMouseDrag(action == GLFW_PRESS);
}
}

@ -94,7 +94,7 @@ int main(int argc, char **argv) {
v2d->nanovg([&](const cv::Size& sz) {
using namespace kb;
v2d->clear();
nvg::beginPath();
nvg::fontSize(FONT_SIZE);
nvg::fontFace("libertine");
nvg::fillColor(color_convert(cv::Scalar(0.15 * 180.0, 128, 255, 255), cv::COLOR_HLS2BGR));

Loading…
Cancel
Save