Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add interactivity to openSeadragonGL #6

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

thejohnhoffer
Copy link
Owner

We now copy the rendered canvas before any application of shaders. Then, all shaders take the original rendered canvas as input for every subsequent update to the tiles. This allows interactive updating of parameters passed to the shaders.

Additionally, the world is updating on init of openSeadragonGL. Previously, one could only observe the effect of the shaders if the openseadragon world happened to update after the init of openSeadragonGL due to interaction or loading of tiles.

@thejohnhoffer thejohnhoffer force-pushed the interactive branch 2 times, most recently from f120224 to 2954386 Compare May 15, 2018 18:42
@yellowtailfan
Copy link

yellowtailfan commented May 9, 2019

I tried this but found the GLSL updates were not being rendered. To fix it, I changed tools/openSeadragonGL.js to make sure GLSL is called on every tile draw (instead of only the first time each tile is drawn):

         'tile-drawing': function(callback, e) {
-            if (e.tile.loaded !==1) {
+            // if (e.tile.loaded !==1) {
+            if (true) {
                 e.tile.loaded = 1;
                 callback(e);
             }

In the gamma change handler in my top-level script that calls OpenSeadragonGL, I set the gamma to a new value and then add a call to forceRedraw():

    var forceRedraw = function () {
        for (var i = 0; i < viewer.world.getItemCount(); i++) {
            var tiled_image = viewer.world.getItemAt(i);
            tiled_image._needsDraw = true;
        }
        viewer.world.update();
    }

Now changing the gamma updates the display instantly, which is lovely.

As a further improvement, it would be good to flag when the input parameters to GLSL change, so that the tile-drawing callback only invokes GLSL when required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants