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

[Hydra] WEBGL mode in P5js #277

Open
aaronsherwood opened this issue Apr 15, 2024 · 3 comments
Open

[Hydra] WEBGL mode in P5js #277

aaronsherwood opened this issue Apr 15, 2024 · 3 comments
Assignees
Labels
bug Something isn't working hydra Related to Hydra
Milestone

Comments

@aaronsherwood
Copy link

Can't seem to get webgl mode to work when using p5js shaders in Hydra: Uncaught Error: shader() is only supported in WEBGL mode. Here is the code:

p5 = new P5({width: window.innerWidth, height:window.innerHeight, mode: 'WEBGL'})
shader = p5.loadShader("https://raw.githubusercontent.com/aaronsherwood/liveCoding/main/Class_Examples/shaders/basic.vert", "https://raw.githubusercontent.com/aaronsherwood/liveCoding/main/Class_Examples/shaders/ocean.frag");

p5.pixelDensity(1);
p5.draw = () => {
  shader.setUniform("time", time * 0.3);
  shader.setUniform("resolution", [width, height]);
  shader.setUniform("mouse", [p5.mouseX, p5.mouseY]);
  p5.shader(shader);
  p5.rect(0, 0, width, height);
}
p5.hide();
s0.init({
  src: p5.canvas
})
src(s0).out()

This works fine in normal hydra, see here.

@aaronsherwood
Copy link
Author

PS I had a version of flok-web 0.4.12 on my computer and in that version it works.

@munshkr munshkr self-assigned this Apr 15, 2024
@munshkr munshkr added bug Something isn't working hydra Related to Hydra labels Apr 15, 2024
@munshkr munshkr added this to the Version 1.2 milestone Apr 15, 2024
@AakSin
Copy link

AakSin commented Apr 23, 2024

Typing "WEBGL" as "webgl" in lowercase seemed to fix the issue on my end. The type definitions for p5 seem to all be using lowercase values.

image

@munshkr
Copy link
Owner

munshkr commented Apr 26, 2024

Thanks for reporting this. That's weird, maybe the bundled version of P5 that flok uses is different from the one Hydra uses. I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hydra Related to Hydra
Projects
Status: Todo
Development

No branches or pull requests

3 participants