We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I just try to see this work into my processing.
https://www.openprocessing.org/sketch/502316
var gl,noctaves,c;
function setup() {
createCanvas(windowWidth, windowHeight,WEBGL);
gl=this.canvas.getContext('webgl');
gl.disable(gl.DEPTH_TEST);
noctaves=1;
initc();
test=new p5.Shader(this._renderer,vert,frag);//shaders are loaded
shader(test);//shaders are applied
}
function draw() {
test.setUniform("iResolution", [width,height]);//pass some values to the shader
test.setUniform("iTime", millis()*.001);
test.setUniform('iMouse',[mouseX,mouseY]);
test.setUniform("noctaves",noctaves);
test.setUniform("c",c);
shader(test);
box(width/2);
}
function mouseReleased(){
noctaves=noctaves==6?1:noctaves+1;
if(noctaves==1)initc();
}
function initc(){
c=[];
for(var i=0;i<22;i++){
if(i<19)c[i]=random(-10,10);
else c[i]=random(-1,1);
}
}
but when I paste that code and press launch, I meet this message with fail
Badly formed character constant (expection quote. got e)
processing.app.SketchException: Badly formed character constant (expecting quote, got e) at processing.mode.java.preproc.PdePreprocessor.checkForUnterminatedMultilineComment(PdePreprocessor.java:888) at processing.mode.java.preproc.PdePreprocessor.write(PdePreprocessor.java:925) at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:253) at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:156) at processing.mode.java.JavaBuild.build(JavaBuild.java:123) at processing.mode.java.JavaBuild.build(JavaBuild.java:105) at processing.mode.java.JavaMode.handleLaunch(JavaMode.java:122) at processing.mode.java.JavaEditor.lambda$0(JavaEditor.java:1097) at java.lang.Thread.run(Thread.java:748)
what can I do?
Answers
Can you please format your code?
@KevinWorkman I'm not sure what you asking exactly. but
If you ask my processing version, I'm using 3.3.6 32bit version.
If you ask what I type more. I just copying as ctrl+a and ctrl+v
We can't really read your code. Please format the code in the editor. There's a code button, or look at how other posters have formatted their code.
@KevinWorkman Thanks. I edit it.
When I try to run your code, I get an error on this line:
The error says that
vert
is not defined.Thanks Kevin. I think I just need to learn more..
Do you need to use double quotes on line 4?
In Java, single quotes are generally used for a single character, so it's expecting another quote after the w but getting e instead. That would explain the message. JavaScript might be different though.
JavaScript is different. You can use either a single quote or a double quote to use a string literal.
hence my proviso at the end there.
and that's no reason to mix them willy-nilly in the code though.
(i'm also not entirely convinced the error in the first post is a javascript error what with all the processing.mode.java.JavaEditor.* stuff)
(which you can verify by pasting the above into the pde in java mode)
there's a second tab in the openprocessing page
Thank @koogs I was think all code in openprocessing is working without mistake. I think it's bit hard to understand your advise.. now I learning hard with book to understand more.. thanks :(
1. The openprocessing sketch has two tabs.
2. Did you copy the contents of both tabs (
mySketch
andshaders
) into your desktop sketch?3. A missing tab of code might be one reason why you are getting an error.
No, my last message was quoting Kevin who appears to have missed the second tab when trying to reproduce the problem
YunJae's problem appears to be trying to use the code from openprocessing in Java mode.
I think its worth pointing out that this sketch i not written in java, but in javascript. The two languages are similair, but different.
For example while processing/java uses
void setup(){}
andvoid draw(){}
etc, openprocessing/javascript usesfunction setup(){}
andfunction draw(){}
etc.You can't run javascript in an editor that expects java and vise versa. As @koogs points out, that is probably the source of your problem.
As you learn more programming, these differences will become more obvious to you and it might be possible for you to translate the code from one language to another or just rewrite the sketch.
Good luck :)
@jeremydouglass , @koogs , @Eyeorelife
Thanks guys. I think i can understand little bit more. I didn't know about second tab and I didn't know about different modes. I was find some more codes that didnt work in sketch from openprocessing and that moment I realize what you guys says.. because, these codes can't find from my books.
Thank you guys and I hope I understand well for this time..