-2

I previously had an issue with OpenGL on Ubuntu using GLFW but managed to solve that by using the glfwWindowHints() method. Link for reference.

Now, I have stumbled upon yet another error, this time related to the fragment shader.

Failed to compile fragment shader!
0:60(12): error: `gl_FragColor' undeclared
0:60(2): error: no matching function for call to `mainImage(error, vec2)'; candidates are:
0:60(2): error:    void mainImage(vec4, vec2)

Here is output of the command glxinfo | grep OpenGL:

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 520 (Skylake GT2) 
OpenGL core profile version string: 4.5 (Core Profile) Mesa 13.1.0-devel - padoka PPA
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 13.1.0-devel - padoka PPA
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 13.1.0-devel - padoka PPA
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

In my shader files I have defined version as #version 450 core.

I read on a forum elsewhere that the (12) in 0:60(12): error: 'gl_FragColor' undeclared represented version 1.2, but I am not sure whether this is correct or not.

shader.frag - PasteBin

shader.vert - PasteBin

genpfault
  • 51,148
  • 11
  • 85
  • 139
Nicolai Prebensen
  • 301
  • 1
  • 4
  • 10

2 Answers2

3

gl_FragColor has been removed since OpenGL 3.3 Core Profile. The modern way to go is to define your own output variables in the fragment shader. You can specify the mapping between shader output variables and framebuffer attachments by either using the glBindFragDataLocation​ method or by using layout qualifiers.

BDL
  • 21,052
  • 22
  • 49
  • 55
0

I found a possible solution to the problem.

  1. Setting glewExperimental = GL_TRUE; before initializing glew
  2. Replaced gl_FragColor with a new out variable out vec4 color; in fragment shader.

My friend did however not need to do this, using a NVIDIA GPU.

Perhaps this is a problem only for the current drivers for Intel Integrated Graphics for Skylake?

Nicolai Prebensen
  • 301
  • 1
  • 4
  • 10