Bug 1282 - "'gl_FragColor' : undeclared identifier" thrown during fragment shader compilation with GL2ES2
Summary: "'gl_FragColor' : undeclared identifier" thrown during fragment shader compil...
Status: RESOLVED INVALID
Alias: None
Product: Jogl
Classification: JogAmp
Component: awt (show other bugs)
Version: 2.4.0
Hardware: pc_x86_64 windows
: P4 normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2016-01-10 14:04 CET by webermax2004
Modified: 2019-03-29 14:19 CET (History)
0 users

See Also:
Type: FEATURE
SCM Refs:
Workaround: ---


Attachments
Source file (1.75 KB, text/plain)
2016-01-10 14:04 CET, webermax2004
Details

Note You need to log in before you can comment on or make changes to this bug.
Description webermax2004 2016-01-10 14:04:49 CET
Created attachment 769 [details]
Source file

Noticed using 2.3.2. as available on http://jogamp.org/deployment/jogamp-current/archive/.

The following code in a GLEventListener produces an error :

public class MyGLEventListener implements GLEventListener {
public void display (GLAutoDrawable drawable) {
GL2ES2 gl = drawable.getGL ().getGL2ES2();
ShaderCode fs;
String[][] fsCode = {{"void main (void) { gl_FragColor = vec4 (1.0, 0.0, 0.0, 1.0); }"}}; 
fs = new ShaderCode (GL2ES2.GL_FRAGMENT_SHADER, 1, fsCode);
fs.compile (gl, System.out);
}
//...
}

The error message is :

Shader status invalid:
ERROR: 0:1: 'gl_FragColor' : undeclared identifier
ERROR: 0:1: 'assign' :  cannot convert from 'const 4-component vector of float' to 'float'

But it works fine when using GL2 instead of GL2ES2 :

public class MyGLEventListener implements GLEventListener {
public void display (GLAutoDrawable drawable) {
GL2 gl = drawable.getGL ().getGL2();
ShaderCode fs;
String[][] fsCode = {{"void main (void) { gl_FragColor = vec4 (1.0, 0.0, 0.0, 1.0); }"}}; 
fs = new ShaderCode (GL2.GL_FRAGMENT_SHADER, 1, fsCode);
fs.compile (gl, System.out);
}
//...
}

Full code attached.
Comment 1 webermax2004 2016-01-10 20:37:56 CET
Problem is not with JOGL, but with the driver which doesn't consider using GLSL 1.0 by default even if the GLSL #version directive is not used in the fragment shader code.