   [GLSL] ERROR: 2:1: 'gl_Position' : undeclared identifier
  I get the following errors when compiling two simple shaders:ERROR: 2:1: 'gl_Position' : undeclared identifier ERROR: 2:1: 'ftransform' : no matching overloaded function found ERROR:  compilation errors.  No code generated.ERROR: 2:1: 'gl_Position' : undeclared identifier ERROR: 2:1: 'ftransform' : no matching overloaded function found ERROR:  compilation errors.  No code generated.vertex:void main(void){    gl_Position = ftransform();}fragment:void main(void){    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);}OpenGL version is 2.1.8664I tried adding "#version 100" to 150 because I've read that ftransform is deprecated from 140 upwards but that didn't work either:ERROR: 1:1: '' : syntax error #versionthe shaders are created with the following two functions:void mSHADER::init(string const& Shader_Vertex, string const& Shader_Fragment){handle_program = glCreateProgram();if (handle_program == SHADER_INVALID_HANDLE){log_shader.log << "Can't create shader for: \"" << Shader_Vertex << " and \"" << Shader_Fragment << endl;}handle_vertex = glCreateShader( GL_VERTEX_SHADER );if(handle_vertex == SHADER_INVALID_HANDLE){log_shader.log << "Can't create shader for: \"" << Shader_Vertex << endl;}fromFile(handle_vertex, (/*directory*/SHADER_DEFAULT_DIRECTORY + Shader_Vertex));glCompileShader(handle_vertex);glAttachShader(handle_program, handle_vertex);handle_fragment = glCreateShader(GL_FRAGMENT_SHADER);if(handle_fragment == SHADER_INVALID_HANDLE){log_shader.log << "Can't create shader for: \"" << Shader_Fragment << endl;}fromFile(handle_fragment, (/*directory*/SHADER_DEFAULT_DIRECTORY + Shader_Vertex));glCompileShader(handle_fragment);glAttachShader(handle_program, handle_fragment);glLinkProgram(handle_program);GLint status_compile;GLint status_link;glGetObjectParameterivARB(handle_program, GL_OBJECT_COMPILE_STATUS_ARB, &status_compile);glGetObjectParameterivARB(handle_program, GL_OBJECT_LINK_STATUS_ARB, &status_link);if(status_compile == SHADER_INVALID_HANDLE){log_shader.log << "Can't compile shader for: \"" << Shader_Vertex << " and \"" << Shader_Fragment << endl;}if(status_link == SHADER_INVALID_HANDLE){log_shader.log << "Can't link shader for: \"" << Shader_Vertex << " and \"" << Shader_Fragment << endl;}}void mSHADER::fromFile(GLuint Handle, string const& Filename){ifstream file(Filename.c_str());if(!file.good()){log_shader.log << "Can't read shader source: " << Filename << endl;return;}string line;vector<string> lines;vector<const char*> shader;vector<GLint> lengths;while(getline(file,line)){if((!line.empty())&&(line.at(0) != '/')){lines.push_back(line);}}shader.reserve( lines.size() );for(int i = 0; i < lines.size(); i++){shader.push_back( lines.at(i).c_str() );lengths.push_back( lines.at(i).length() );}glShaderSource(Handle, shader.size(), &shader.front(), &lengths.front());file.close();}
  I think you might need to add newlines to the end of your lines. Its been a while since I looked at my shader source code, but it looks like this:char ** cstrings = new char*[numstrings];for(unsigned int i=0;i<numstrings;i++){cstrings = new char[strings.size()+2];strcpy_s(cstrings,strings.size()+1,strings.c_str());cstrings[strings.size()] = '\n';cstrings[strings.size()+1] = '\0';}unsigned int hShader = glCreateShader(GLtype);glShaderSource(hShader,numstrings,(const GLchar**)cstrings,NULL);You don't need to have the null character if you're counting the line lengths yourself, but I think you might need newlines.   ;  I tried adding newlines to my code(see first post) and I tried copying your code but neither worked. It may doing something awful to the line endings but Im not sure how to change them or how to convert them properly... I tried my shaders in  AMD's rendermonkey and in another opengl demo and they run properly so it must be my file loading. This is what my code looks like now:string line;vector<string> lines;vector<const char*> shader;vector<GLint> lengths;while(getline(file,line)){if((!line.empty())&&(line.at(0) != '/')){   // skip empty lines and commentslines.push_back(line + '\n');}}shader.reserve( lines.size() );for(int i = 0; i < lines.size(); i++){shader.push_back( lines.at(i).c_str() );lengths.push_back( lines.at(i).length() );}glShaderSource(Handle, shader.size(), &shader[0], &lengths[0]);;  Hmm I'm not sure. Maybe check your glsl version? glGetString(GL_SHADING_LANGUAGE_VERSION)   ;  cout << glGetString(GL_SHADING_LANGUAGE_VERSION)  << endl;crashes my application (I even made a new application to test it). It crashes because something in ostream receives a NULL pointer. After that I get all kinds of undefined behaviour--------------------------------------------------Checking supported libraries and extensions:--------------------------------------------------OpenGL Version: 2.1.8664GLEW Version: 1.5.4Glut Version: 20600--------------------------------------------------I'm on a toshiba laptop and these are the 'latest' vendor drivers for this setup...   ;  Can you see the value returned in the debugger if your ostream is crashing?Make sure you're calling this after you initialize the context. Also, what hardware are you using?   ;  ahh it returns " 1.30 "(casted it then sent it to a file)ati mobility radeon hd4500 windows vista x32   ;  You may want to try #version 110 instead of #version 100, the spec sounds like it might only accept 110 or 120. That might explain your version error.Quote:This document specifies only version 1.30 of the OpenGL Shading Language. It requires __VERSION__to substitute 130, and requires #version to accept only 130. If #version is declared with 110 or 120, thelanguage accepted is a previous version of the shading language, which will be supported depending onthe version and type of context in the OpenGL API.;  I tried 100 - 110 - 120 - 130 but no luck. They all report:ERROR: 3:1: 'gl_Position' : undeclared identifier ERROR: 3:1: 'ftransform' : no matching overloaded function found ;fromFile(handle_fragment, (/*directory*/SHADER_DEFAULT_DIRECTORY + Shader_Vertex));Notice anything wrong here?Might want to have your debug output report which shader is reporting the errors, might save you a lot of trouble next time :)   