Code Monkey home page Code Monkey logo

Comments (6)

almarklein avatar almarklein commented on August 25, 2024 1

Good question. The GUI toolkit will indeed request a new draw when it knows that the visualization needs to be refreshed. Like when the window is resized, and om some systems when part of the window was hidden by another window and is now shown again. This was already the case before #78. What was added was the possibility for the user to request a draw. E.g. in cases that the visualization itself has changed.

This works somewhat different for Qt and glfw. In Qt the former already works automatically, and requesting a draw is done simply by calling update(). In both cases this will at some point result in a draw event.

For glfw you have to bring your own event loop. So this draw event ... we have to do that ourselves. The simplest way I could find to realize this is by adding a single function (update_glfw_canvasses) that you call on each iteration, and which draws any windows that have requested (manually or via e.g. a resize) to be redrawn.

In both cases, the window will not be redrawn continuously, unless you keep requesting redraws.

from wgpu-py.

almarklein avatar almarklein commented on August 25, 2024 1

Haha, now I'm not sure if I understand your question correctly :)

So, indeed Qt by itself only generates a new draw event when the window is somehow invalid (e.g. on resize). This means that our users need to call request_draw() when the viz needs an update. The request_draw() function for the Qt canvas simply calls .update().

(In theory our users could just as well call update(), except that request_draw() is the generic function that also works on the glfw canvas.)

from wgpu-py.

Korijn avatar Korijn commented on August 25, 2024

I'm wondering if we should just leave this up to the application developer by providing an API that allows them to do it.

from wgpu-py.

Korijn avatar Korijn commented on August 25, 2024

Nice work on the docs! The GUI API page's examples left me a little confused though; where are the calls to request_draw?

Looking at the Qt canvas a little better, it appears that Qt is making the calls, rather than the python code. I guess my expectations were somewhat different here.

I understand that Qt will trigger a draw when the window is resized for example, or opened for the first time. Does Qt also continuously trigger drawing when there is no interaction, or does the user then need to use request_draw to achieve that?

from wgpu-py.

Korijn avatar Korijn commented on August 25, 2024

Ok, great, that's perfect!

Qt the former already works automatically, and requesting a draw is done simply by calling update(). In both cases this will at some point result in a draw event.

Just to make sure I fully understand the details here: so Qt does not continuously call update() when only the visualization changes? Meaning that the user needs to call request_draw().

from wgpu-py.

Korijn avatar Korijn commented on August 25, 2024

Got it! Thanks

from wgpu-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.