How to use mouse-click

Started by Stefan, January 23, 2016, 12:51:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Stefan

I found a demo LED scoreboard, that is controlled by mouse-click.
How do i do that in GeeXLab, sth. with gh_input.mouse_get_button_state() ?
EDIT: solution below

As a work-around i replaced mouse-click with mouse-over in the pixel shader

    vec3 col = iMouse.w > 0.5 ? flag( DE ) : flag( RU );
    if ( p.x > 0.5 + halfStripe ){ col = iMouse.w > 0.5 ? flag( RU ) : flag( DE ); }

   
replaced with

    vec3 col = iMouse.x > 0.5*iResolution.x ? flag( DE ) : flag( RU );
    if ( p.x > 0.5 + halfStripe ){ col = iMouse.x > 0.5*iResolution.x ? flag( RU ) : flag( DE ); }


>>>Get ported version here<<<


Stefan

#1
Here is another demo: 2D Radial Repeat : Hex RadClick
Besides mouse i patched other issues.

section id
shifted to bottom left of the screen, away from GeeXLab's overlay

uv.x += iDate.w ; // rotate each radius offset with constant speed
doesn't work, replaced with
uv.x += iGlobalTime ;

mouse click
if(iMouse.z>0.) pos = iMouse.xy;
replaced with mouse over
if(iMouse.x>20.) pos = iMouse.xy;


>>>Get ported version here<<<


Stefan

#2
OK,
got it working now

local mx, my = gh_input.mouse_getpos()
local mz = gh_input.mouse_get_button_state(1)
local mw = mz

gh_gpu_program.uniform4f(shadertoy_prog, "iMouse", mx, -(my - winH), mz, mw)



I will add both mouse-click and mouse-over versions to next demo pack.

JeGX

Indeed I just noticed that there is no a code sample focused on the mouse (while there is a keyboard/ folder in the code sample pack). The mouse is used in many code samples so browsing the code sample pack is a solution. Another faster solution is to look at the libs folder shipped with GeeXLab.

In GeeXLab/libs/lua/ there are several Lua files that use the mouse, like this one: gx_cam_lib_v2.lua

Anyway, you have found the solution and that's the important thing!

Stefan

Here is a pack with mouse-click controlled shaders

I remember to have stumbled over Shadertoy demos with keyboard control, but i passed on them because the keyboard is stuffed in an iChannel

I take another look if i find these demos again...

Stefan

Where the River Goes

>>>ported to GeeXLab<<<

Click mouse to change view

#define ENABLE_ULTRA_QUALITY  to fry your GPU, frame rate drops to 10%