Author Topic: How to use mouse-click  (Read 6288 times)

0 Members and 1 Guest are viewing this topic.

Stefan

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4345
    • View Profile
How to use mouse-click
« on: January 23, 2016, 12:51:10 AM »
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<<<

« Last Edit: January 25, 2016, 02:17:02 AM by Stefan »


Stefan

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4345
    • View Profile
Re: How to use mouse-click
« Reply #1 on: January 24, 2016, 10:44:01 PM »
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<<<

« Last Edit: January 24, 2016, 10:53:40 PM by Stefan »

Stefan

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4345
    • View Profile
Re: How to use mouse-click
« Reply #2 on: January 25, 2016, 02:15:40 AM »
OK,
got it working now

Code: [Select]
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.
« Last Edit: January 25, 2016, 02:55:58 AM by Stefan »

JeGX

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1893
    • View Profile
    • Geeks3D.com
Re: How to use mouse-click
« Reply #3 on: January 25, 2016, 08:36:52 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4345
    • View Profile
Re: How to use mouse-click
« Reply #4 on: January 26, 2016, 06:19:43 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4345
    • View Profile
Where the River Goes - yet another GPU burner
« Reply #5 on: January 29, 2016, 08:58:55 PM »
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%