Note that there are some explanatory texts on larger screens.

plurals
  1. POGLSL ES local variables crash?
    primarykey
    data
    text
    <p>I'm trying to implement some shaders from online tutorials (lighthouse3d.com) in my OpenGL ES 2.0 engine.</p> <p>The problem is that for some reason, ANY variables declared in the scope of main() causes the entire shader to fail. for example, this fails:</p> <pre><code>void main(){ vec4 color; gl_FragColor = vec4(1.0, 0.5, 0.5, 1.0); } </code></pre> <p>but this works perfectly:</p> <pre><code>void main(){ //vec4 color; gl_FragColor = vec4(1.0, 0.5, 0.5, 1.0); } </code></pre> <p>Same thing happens with my vertex shaders.(<strong>EDIT</strong>:nvm, only seems to happen with fragment shaders) The only way to use any type of non-constant value is to use attributes, varyings, uniforms, etc. for example, this works as you would expect:</p> <pre><code>uniform sampler2D texture; varying lowp vec4 fragcol; varying lowp vec2 texco; void main(){ gl_FragColor = fragcol * texture2D(texture, texco); } </code></pre> <p>Also, I'm having a hell of a lot of trouble trying to find documentation or resources specifically about GLSL ES (or whatever this version is called). All I've been able to find is this: <a href="http://old.siggraph.org/publications/2006cn/course16/KhronosSpecs/ESLanguageSpec1.10.11.pdf" rel="nofollow">http://old.siggraph.org/publications/2006cn/course16/KhronosSpecs/ESLanguageSpec1.10.11.pdf</a></p> <p>This is all I could find related to variable declarations:</p> <blockquote> <p>[snip]There are no default types. All variable and function declarations must have a declared type, and optionally qualifiers. A variable is declared by specifying its type followed by one or more names separated by commas.[snip]</p> </blockquote> <p>And that is exactly what I did:</p> <p>declared type: <strong>vec4</strong></p> <p>followed by one or more names: <strong>color</strong>;</p> <pre><code>vec4 color </code></pre> <p>I'm clueless</p> <p><strong>EDIT:</strong> GLES20.glGetError() gives error 1282</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload