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

snippet-grids example does not work #33

Closed
rossant opened this issue Mar 20, 2015 · 18 comments
Closed

snippet-grids example does not work #33

rossant opened this issue Mar 20, 2015 · 18 comments

Comments

@rossant
Copy link

rossant commented Mar 20, 2015

Intel GPU:

[i] Using GLFW (GL 3.0)
[i] Running at 60 frames/second
error: fragment shader varying v_index_4 not written by vertex shader
.error: fragment shader varying v_x_4 not written by vertex shader
.
Traceback (most recent call last):
  File "examples/snippet-grids.py", line 106, in <module>
    app.run()
  File "/data/git/glumpy/glumpy/app/__init__.py", line 301, in run
    clock = __init__(clock=clock, framerate=framerate, backend=__backend__)
  File "/data/git/glumpy/glumpy/app/__init__.py", line 261, in __init__
    window.dispatch_event('on_resize', window._width, window._height)
  File "/data/git/glumpy/glumpy/app/window/event.py", line 375, in dispatch_event
    if getattr(self, event_type)(*args):
  File "/data/git/glumpy/glumpy/app/window/window.py", line 193, in on_resize
    self.dispatch_event('on_draw', 0.0)
  File "/data/git/glumpy/glumpy/app/window/event.py", line 365, in dispatch_event
    if handler(*args):
  File "examples/snippet-grids.py", line 82, in on_draw
    program.draw(gl.GL_LINE_STRIP)
  File "/data/git/glumpy/glumpy/gloo/program.py", line 499, in draw
    self.activate()
  File "/data/git/glumpy/glumpy/gloo/globject.py", line 87, in activate
    self._create()
  File "/data/git/glumpy/glumpy/gloo/program.py", line 155, in _create
    raise ValueError('Linking error')
ValueError: Linking error

NVIDIA GPU:
image

and scrolling =>

Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 314, in 'calling callback function'
  File "/data/git/glumpy/glumpy/app/window/backends/backend_glfw.py", line 288, in on_scroll
    self.dispatch_event('on_mouse_scroll', x, y, xoffset, yoffset)
  File "/data/git/glumpy/glumpy/app/window/event.py", line 365, in dispatch_event
    if handler(*args):
  File "examples/snippet-grids.py", line 90, in on_mouse_scroll
    program['xscale'] *= np.exp(2.5*dx)
  File "/data/git/glumpy/glumpy/gloo/program.py", line 333, in __getitem__
    raise IndexError("Unknown item (no corresponding hook, uniform or attribute)")
IndexError: Unknown item (no corresponding hook, uniform or attribute)
@rougier
Copy link
Member

rougier commented Mar 20, 2015

Yes, this one is broken. You might prefer to test collection-update.py

@rossant
Copy link
Author

rossant commented Mar 20, 2015

You might prefer to test collection-update.py

Nice. However the mouse wheel doesn't do anything.

@rougier
Copy link
Member

rougier commented Mar 20, 2015

Weird, this should scale the signal when you're over it.
Does the signal under the mouse become white ?
If you write a print "toto" within the on_mouse_scroll event, does it get printed ?

@rossant
Copy link
Author

rossant commented Mar 20, 2015

Weird, this should scale the signal when you're over it.

it doesn't

Does the signal under the mouse become white ?

yes

If you write a print "toto" within the on_mouse_scroll event, does it get printed ?

yes

@rougier
Copy link
Member

rougier commented Mar 21, 2015

So do all signals have different scales at start ?
Can you print lines["xscale"][index]in the on_scroll_event and check if it get changed ?

@rossant
Copy link
Author

rossant commented Mar 21, 2015 via email

@rougier
Copy link
Member

rougier commented Mar 21, 2015

Can you add (after if selected > 0.0)

v_color=vec4(vec3(1.0-xscale/100.0),color.a*id);

The signal should change color (black to white) with mouse scroll.

@rossant
Copy link
Author

rossant commented Mar 21, 2015

no change...

@rougier
Copy link
Member

rougier commented Mar 21, 2015

Can you try this:

    print lines._vertices_buffer._pending_data
    lines["xscale"][index] *= np.exp(2.5*dx)
    lines["xscale"][index] = min(max(1.0, lines["xscale"][index]),100)
    print lines._vertices_buffer._pending_data

@rossant
Copy link
Author

rossant commented Mar 21, 2015

None
(0, 6412800)

@rougier
Copy link
Member

rougier commented Mar 22, 2015

You get only two lines ?
First mean buffer do not need upload, second tells the area to be uploaded. Each time you scroll, you should get these two lines (or twice the last if mouse scroll is too fast), indicating the buffer has been uploaded.

@rossant
Copy link
Author

rossant commented Mar 22, 2015

Here is a more complete output with

@window.event
def on_mouse_scroll(x, y, dx, dy):
    index = get_index(x,y)
    dx = -np.sign(dy) * .05
    # lines["xscale"][index] *= np.exp(2.5*dx)
    # lines["xscale"][index] = min(max(1.0, lines["xscale"][index]),100)

    print '--------'
    print lines._vertices_buffer._pending_data
    lines["xscale"][index] *= np.exp(2.5*dx)
    lines["xscale"][index] = min(max(1.0, lines["xscale"][index]),100)
    print lines._vertices_buffer._pending_data
    print
(py27)cyrille@gigabyte:~/git/glumpy$ python examples/collection-update.py 
[i] Using GLFW (GL 3.0)
[i] Running at 60 frames/second
--------
(0, 6412800)
(0, 6412800)

--------
None
(0, 6412800)

--------
None
(0, 6412800)

--------
None
(0, 6412800)

--------
(0, 6412800)
(0, 6412800)

--------
None
(0, 6412800)

--------
None
(0, 6412800)

--------
(0, 6412800)
(0, 6412800)

--------
None
(0, 6412800)

--------
None
(0, 6412800)

--------
(0, 6412800)
(0, 6412800)

@rougier
Copy link
Member

rougier commented Mar 22, 2015

Another idea to test (should scale all signals at once)

@window.event
def on_mouse_scroll(x, y, dx, dy):
    index = get_index(x,y)
    dx = -np.sign(dy) * .05
    lines["xscale"] *= np.exp(2.5*dx)
    lines["xscale"] = min(max(1.0, lines["xscale"]),100)

@rossant
Copy link
Author

rossant commented Mar 22, 2015

[i] Using GLFW (GL 3.0)
[i] Running at 60 frames/second
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 314, in 'calling callback function'
  File "/data/git/glumpy/glumpy/app/window/backends/backend_glfw.py", line 288, in on_scroll
    self.dispatch_event('on_mouse_scroll', x, y, xoffset, yoffset)
  File "/data/git/glumpy/glumpy/app/window/event.py", line 365, in dispatch_event
    if handler(*args):
  File "examples/collection-update.py", line 127, in on_mouse_scroll
    lines["xscale"] = min(max(1.0, lines["xscale"]),100)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

image

@rougier
Copy link
Member

rougier commented Mar 22, 2015

Dams. Can you comment the line (or replae with minimum/maximum instead of min/max) ?

@rossant
Copy link
Author

rossant commented Mar 22, 2015

Commenting the line = no more error messages, but the screenshot is the same.

@rougier
Copy link
Member

rougier commented Mar 22, 2015

I think I have found. your texture is most probably clamped between 0 and 1 by the GPU. Since xscale is between 0 and 100, it does not work. Can you try to add xscale*100 in the shader where necessary, and use:

@window.event
def on_mouse_scroll(x, y, dx, dy):
    index = get_index(x,y)
    dx = -np.sign(dy) * .005
    lines["xscale"][index] *= np.exp(2.5*dx)
    lines["xscale"][index] = min(max(0.01, lines["xscale"][index]),1.0)

@rossant
Copy link
Author

rossant commented Mar 22, 2015

Yep that was the problem!

@rougier rougier closed this as completed Aug 18, 2015
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

No branches or pull requests

2 participants