Browse Source

Reset nanovg context before calling event handlers and step()

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
21c484eabf
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      src/window.cpp

+ 4
- 3
src/window.cpp View File

@@ -301,6 +301,10 @@ void Window::run() {
while(!glfwWindowShouldClose(win)) { while(!glfwWindowShouldClose(win)) {
frameTimeStart = glfwGetTime(); frameTimeStart = glfwGetTime();


// Make event handlers and step() have a clean nanovg context
nvgReset(vg);
bndSetFont(uiFont->handle);

// Poll events // Poll events
glfwPollEvents(); glfwPollEvents();
// In case glfwPollEvents() set another OpenGL context // In case glfwPollEvents() set another OpenGL context
@@ -329,8 +333,6 @@ void Window::run() {
internal->lastWindowTitle = windowTitle; internal->lastWindowTitle = windowTitle;
} }


bndSetFont(uiFont->handle);

// Get desired scaling // Get desired scaling
float pixelRatio; float pixelRatio;
glfwGetWindowContentScale(win, &pixelRatio, NULL); glfwGetWindowContentScale(win, &pixelRatio, NULL);
@@ -359,7 +361,6 @@ void Window::run() {
if (visible) { if (visible) {
// Update and render // Update and render
nvgBeginFrame(vg, fbWidth, fbHeight, pixelRatio); nvgBeginFrame(vg, fbWidth, fbHeight, pixelRatio);
nvgReset(vg);
nvgScale(vg, pixelRatio, pixelRatio); nvgScale(vg, pixelRatio, pixelRatio);


// Draw scene // Draw scene


Loading…
Cancel
Save