GLchar** problem
torhu
no at spam.invalid
Thu Oct 30 13:08:21 PDT 2008
Saaa wrote:
> glshaderSource needs a GLchar** and all I get from cast(char[])
> read(filename) is a single *
>
> How do I get this extra pointer ? :D
>
> The C code is:
>
> char *file;
> shader = glCreateShader(GL_FRAGMENT_SHADER);
> file = textFileRead("program.frag");
> const char * filep = file;
> glShaderSource(f, 1, &filep,NULL);
> free(filep);
>
> my D attempt:
>
> char[] file;
> GLuint shader;
> shader=glCreateShader(GL_FRAGMENT_SHADER);
> file=cast(char[])read(`program.frag`);
> glShaderSource(f, 1, cast(char **) toStringz(file),null);
> //let gc collect file
>
> Error: Access Violation :)
>
>
Assuming the C code works, here's what you do in D.
GLuint shader;
shader=glCreateShader(GL_FRAGMENT_SHADER);
char[] file=cast(char[])read(`program.frag`);
char* filep = toStringz(file);
glShaderSource(f, 1, &filep,null);
More information about the Digitalmars-d-learn
mailing list