My system configuration is as follows: SDL2, Fedora 21, Nvidia GTX Drivers.
[mhoggan@localhost build]$ glxinfo | grep version
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL core profile version string: 4.4.0 NVIDIA 346.47
OpenGL core profile shading language version string: 4.40 NVIDIA via Cg compiler
OpenGL version string: 4.5.0 NVIDIA 346.47
OpenGL shading language version string: 4.50 NVIDIA
OpenGL ES profile version string: OpenGL ES 3.1 NVIDIA 346.47
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
GL_EXT_shader_implicit_conversions, GL_EXT_shader_integer_mix,
[mhoggan@localhost build]$ uname -a
Linux localhost.san.rr.com 3.19.3-200.fc21.x86_64 #1 SMP Thu Mar 26 21:39:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
After the shader is created with glCreateShader
and the following sources are passed into glCompileShader
I am getting the same error for both vertex and fragment shaders:
Going to compile vertex source:
attribute vec3 position;attribute vec4 color;varying frag_color;void main() { gl_Position = vec4(position, 1.0); frag_color = color;}
Going to compile fragment source:
varying vec4 frag_color;void main() { gl_FragColor = frag_color;}
Where the error I am getting is:
Vertex shader compilation: 0(1) : error C0000: syntax error, unexpected identifier, expecting "::" at token "frag_color"
Frament shader compilation: 0(1) : error C0000: syntax error, unexpected identifier, expecting "::" at token "frag_color"
The code that leads up to this error is identical between the two classes, but the sequence of calls that produce the output below are:
// Note that after each opengl call I call glError thorugh the macro
// GL_CALL. I have verified there are no errors from glError.
_fragment_shader_id = glCreateShader(GL_FRAGMENT_SHADER); GL_CALL
if(_fragment_shader_id == 0) {
compiler_errors = "ERROR: Error to get fragment shader id.";
return compiler_errors;
}
const GLchar *source = _fragment_shader_code.data();
printf("Going to compile fragment source: %s\n", source);
GLint source_cnt = 0;
glShaderSource(_fragment_shader_id, 1, &source, source_cnt);
GL_CALL
glCompileShader(_fragment_shader_id); GL_CALL
To see if it might be a version issue I have tried to change the context creation to various versions, using SDL2's API.
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 4);
//Create window
gWindow = SDL_CreateWindow("Project", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN |
SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
if(gWindow == NULL) {
printf("Window could not be created! SDL Error: %s\n", SDL_GetError());
assert(false);
} else {
gContext = SDL_GL_CreateContext(gWindow);
if(gContext == NULL) {
printf("OpenGL 2.1 context could not be created! SDL Error: %s\n",
SDL_GetError());
assert(false);
You haven't specified a type for "varying frag_color" in the Vertex shader. I assume you meant "varying vec4 frag_color".