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

Request: add a createShader( String [] vertSrc, String [] fragSrc ) function like p5.js has #397

Open
processing-bot opened this issue Feb 8, 2022 · 2 comments
Labels
core enhancement New feature or request help wanted Extra attention is needed opengl

Comments

@processing-bot
Copy link
Collaborator

Created by: scudly

Now that we have multi-line strings, it is practical to include shader code directly in sketches (or even to construct them programmatically) rather than reading from an external file. The current publicly supported and documented loadShader() API only cleanly supports reading shaders from files. Ideally, we would also have a createShader( String[] fragSrc ) that infers the type and provides a vertex shader as the current loadShader() does.

Passing the source as an array of strings seems more general than taking it as a single, multi-line string and is trivial enough to express in code. It also matches the existing PShader constructors.

@processing-bot
Copy link
Collaborator Author

Created by: codeanticode

Yes, this would be a nice enhancement, thanks for suggesting!

@processing-bot
Copy link
Collaborator Author

Created by: codeanticode

@scudly the PShader class already has a public constructor that takes string arrays as inputs:

https://github.com/processing/processing4/blob/master/core/src/processing/opengl/PShader.java#L285

So you could use that for the time being.

@benfry In order for this functionality to be properly incorporated into the API we could need to add a a a couple of createShader() methods to PApplet, as @scudly suggested. Those should be pretty straightforward to implement, I can create a PR for inclusion in the next beta.

@Stefterv Stefterv added help wanted Extra attention is needed core labels Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request help wanted Extra attention is needed opengl
Projects
None yet
Development

No branches or pull requests

2 participants