Javascript Text Input Editing: How To Turn Multiple String Text Shader In One Text Input Into Another Representation?
So I want to have 2 input feilds, one editable. I need some script that would turn such shader text input: #ifdef GL_ES precision highp float; #endif varying vec4
Solution 1:
try regular expressions.
html:
<textarea id="text1">#ifdef GL_ES
precision highp float;
#endif
varying vec4 v_color;
void main (void)
{
gl_FragColor = v_color;
}
</textarea>
<textarea id="text2"></textarea>
javascript:
var text = document.getElementById("text1").value;
text = text.replace(/\n/g, "\\n\"\n\"");
document.getElementById("text2").value = "\""+text+"\\n\"";
Post a Comment for "Javascript Text Input Editing: How To Turn Multiple String Text Shader In One Text Input Into Another Representation?"