Reading in files as int/float array or one String/char ( OpenGL Data )
s.d.hammett at gmail.com
Mon Dec 12 07:01:56 PST 2011
On 12/12/2011 09:31, ParticlePeter wrote:
> I read several posts about reading in files, but I can't find the "best" way for my purpose. I am using std.file in the examples bellow.
> 1.) I'm trying to read an OpenGL Vertex and Fragment Shader. The wired thing on my approach is that it works ... sometimes, but sometimes the Shaders cannot be compiled.
> So how should I read a file as one complete char in a safe way ? This is my way:
> auto fileFrag = cast( GLchar )readText( "Shader/Shader_01.frag" ) ;
> const GLchar * fragSource = cast( GLchar * )fileFrag ;
string literals are zero terminated, but strings returned by library
functions may not be.
Try appending a zero to the read string:
string fragString = readText( "Shader.vert" ) ~ "\0";
My enormous talent is exceeded only by my outrageous laziness.
More information about the Digitalmars-d-learn