[osg-users] OpenGL Shader Compile Problem: repeated #version directive

Elias Tarasov elias.tarasov at gmail.com
Sat Jul 18 07:32:40 PDT 2015


Hello!

GPU: nVidia 540M
Driver: 353.30
OpenGL version: 4.3.
OS Windows 7

I intend to use osgHimmel library in my project.
However, when i run the app, i get the shader's compile error:

Atmopshere Precomputed (took 7.95881 s)
Warning, can't assign attribute binding as no has been array assigned to set binding
PNG lib warning : iCCP: known incorrect sRGB profile
PNG lib warning : iCCP: known incorrect sRGB profile
VERTEX glCompileShader "" FAILED
VERTEX Shader "" infolog:
0(5) : error C0204: version directive must be first statement and may not be repeated

FRAGMENT glCompileShader "" FAILED
FRAGMENT Shader "" infolog:
0(5) : error C0204: version directive must be first statement and may not be repeated

glLinkProgram "" FAILED
Program "" infolog:
Vertex info
-----------
0(5) : error C0204: version directive must be first statement and may not be repeated

Fragment info
-------------
0(5) : error C0204: version directive must be first statement and may not be repeated

VERTEX glCompileShader "" FAILED
VERTEX Shader "" infolog:
0(5) : error C0204: version directive must be first statement and may not be repeated

GEOMETRY glCompileShader "" FAILED
GEOMETRY Shader "" infolog:
0(5) : error C0204: version directive must be first statement and may not be repeated

FRAGMENT glCompileShader "" FAILED
FRAGMENT Shader "" infolog:
0(5) : error C0204: version directive must be first statement and may not be repeated

glLinkProgram "" FAILED
Program "" infolog:
Vertex info
-----------
0(5) : error C0204: version directive must be first statement and may not be repeated

Geometry info
-------------
0(5) : error C0204: version directive must be first statement and may not be repeated

Fragment info
-------------
0(5) : error C0204: version directive must be first statement and may not be repeated

VERTEX glCompileShader "" FAILED
VERTEX Shader "" infolog:
0(5) : error C0204: version directive must be first statement and may not be repeated

FRAGMENT glCompileShader "" FAILED
FRAGMENT Shader "" infolog:
0(5) : error C0204: version directive must be first statement and may not be repeated

glLinkProgram "" FAILED
Program "" infolog:
Vertex info
-----------
0(5) : error C0204: version directive must be first statement and may not be repeated

Fragment info
-------------
0(5) : error C0204: version directive must be first statement and may not be repeated

VERTEX glCompileShader "" FAILED
VERTEX Shader "" infolog:
0(5) : error C0204: version directive must be first statement and may not be repeated

FRAGMENT glCompileShader "" FAILED
FRAGMENT Shader "" infolog:
0(5) : error C0204: version directive must be first statement and may not be repeated

glLinkProgram "" FAILED
Program "" infolog:
Vertex info
-----------
0(5) : error C0204: version directive must be first statement and may not be repeated

Fragment info
-------------
0(5) : error C0204: version directive must be first statement and may not be repeated

Warning: detected OpenGL error 'invalid enumerant' at after RenderBin::draw(..)
Warning: detected OpenGL error 'invalid value' at after RenderBin::draw(..)

I have several objects, each of which uses Vertex, Fragment, and Geometry shaders.
With a help of community's members here, i found the place where the error might be:

const std::string glsl_version_150()
{
	static const std::string source(PRAGMA_ONCE(version,"#version 150 compatibility\n\n"));
	return source;
};

This function is called every time to create any shader. And therefore #version directive is realy called multiple times.
According to OpenGL SL #version must be the first line and cannot be repeated.
However, this definition is unclear: Is #version must be the one and only one for the entire host OpenGL program? For the host object that uses shader? Or for every single main() entry of the shader?

Can anybody pointed out how to solve that issue?

Thank you!

Cheers,
Elias

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=64358#64358








More information about the osg-users mailing list