Bug 1282

Summary: "'gl_FragColor' : undeclared identifier" thrown during fragment shader compilation with GL2ES2
Product: [JogAmp] Jogl Reporter: webermax2004
Component: awtAssignee: Sven Gothel <sgothel>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P4    
Version: 2.4.0   
Hardware: pc_x86_64   
OS: windows   
Type: FEATURE SCM Refs:
Workaround: ---
Attachments: Source file

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.