   GLSL - Loading from file?
  Hi there!I'm just getting into GLSL and having some trouble.In all resources I can find "glShaderSourceARB" is used (of course). The third parameter seems to be a pointer to some shader-code-text.Isn't there a way to pass a pointer to the file containing the source?Or do I have to load the whole file into memory before I can call glShaderSourceARB??And how would I read afile into memory if I don't know the file's size?Thank's for your help!   
  check this source file "textfile.cpp" in this GlutGLSLtaken from lighthouse3Dalso take a look a their tutorial list:Ligthhouse3D[Edited by - frecco2k on January 2, 2006 1:18:26 PM];  are you using c++? if so just use a std::string.bool Shader::LoadSrc(string filename){ifstream instream;instream.open(filename.c_str(),ios::in);if (instream.is_open()){//using the null character as a delimeter should get the whole filegetline(instream,src,'\0');//close the fileinstream.close();return true;}return false;}src is just a member std::string   ;  There's a more generic (doesn't depend on a delimiter) c++ file to memory example Here. Note that the example has a memory leak, but it's just to show how to copy a file into memory.glShaderSource can take source code that has been allocated in pieces. The third parameter is an array of pointers to strings that make up the source. So you can read and allocate it in chunks, if you want.   ;  Well, since I pass null as the length parameter to glShaderSource it expects null terminated strings, which is what string::c_str() provides. In that case the delimiter is implicit, since if the string contains a null character, glShaderSource will ignore everything after it anyway.It just seemed the simplest way to do it to me, and it avoids having to seek through the file to find the length yourself.Cocalus is absolutely right though.   ;  I've been slowly working on a tutorial explaining basic GLSL loading stuff... I might have it finished in a week or two. In the mean time, you might look at this source, it shows a simple way to load the text from a file and load/compile/link it.http://www.leecbaker.com/coding/glsl/main.cpp   