Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL Shader ERROR: 0:1: '' : syntax error #version
    text
    copied!<p>I'm using xcode to make a game with OpenGL. I have used GLUT to initialise a window. I have shaders that I wish to implement but when I try to compile them, I get two compile errors in the info log. My shaders look like this:</p> <pre><code>//FirstShader.vsh #version 150 core in vec3 position; void main() { gl_Position = vec4(position, 1.0); } //FirstShader.fsh #version 150 core out vec4 fragData; void main() { fragData = vec4(0.0, 0.0, 1.0, 1.0); } </code></pre> <p>I'm reading the file and compiling it with this code:</p> <pre><code>GLuint createShaderFromFile(const GLchar *path, GLenum shaderType){ GLuint shaderID = glCreateShader(shaderType); std::ifstream fin; fin.open(path); if(!fin.is_open()){ fin.close(); std::cout &lt;&lt; "Shader Not Found" &lt;&lt; std:: endl; return 0; } std::string source((std::istreambuf_iterator&lt;GLchar&gt;(fin)),std::istreambuf_iterator&lt;GLchar&gt; ()); fin.close(); const GLchar* shaderSource = source.c_str(); glShaderSource(shaderID, 1, &amp;shaderSource, NULL); glCompileShader(shaderID); GLint compileStatus; glGetShaderiv(shaderID, GL_COMPILE_STATUS, &amp;compileStatus); if (compileStatus != GL_TRUE) { std::cout &lt;&lt; "Shader failed to compile" &lt;&lt; std::endl; GLint infoLoglength; glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &amp;infoLoglength); GLchar* infoLog = new GLchar[infoLoglength + 1]; glGetShaderInfoLog(shaderID, infoLoglength, NULL, infoLog); std::cout &lt;&lt; infoLog &lt;&lt; std::endl; delete infoLog; return 0; } return shaderID; } </code></pre> <p>Im getting these errors:</p> <pre><code>ERROR: 0:1: '' : version '150' is not supported ERROR: 0:1: '' : syntax error #version </code></pre> <p>My OpenGL version is 2.1 and my glsl version is 1.20. Does anybody know how I can fix this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload