• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Shaders how can i access some essential things like time passed ? [SOLVED]

K

Kasra

Guest
Hi, i just started to learning shaders (GLSLES)
it need to know how can i get mouse_x/y, time pass after running shader, reselution or etc as a variable or uniform ?
 
N

NeZvers

Guest
current_time
you can save current_time in a variable to hold starting time and compare current_time against the saved variable. Remember it is in 1/1000 seconds.
 
K

Kasra

Guest
no it was not the issue that i try to point at, i just didnt know how to pass variables to shaders[Since the GPU Threads are blind], so that solved.
it is something like this:
Code:
// draw event
shader_set(sh_00);
var uni = shader_get_uniform(sh_00, "u_screen_width");
shader_set_uniform_i(uni, display_get_width());
draw_sprite(spr, 0, 0, 0);
shader_reset();
//end draw event
// now the shader code
uniform int u_screen_width;
void main()
{
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}
 
Top