On Thu, 30 Oct 2008 20:44:06 +0100, Saaa <[EMAIL PROTECTED]> 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 :)

I believe this should work:

        char[] file;
        file = toStringz(read("program.frag"));
        glShaderSource(f, 1, &file, null);

What your program does, is treat the first chars of toStringz(file)
as a pointer, then wander off wildly in that direction.

A more D-like way of doing it would possibly be:

        char[] file;
        file = read("program.frag");
        glShaderSource(f, 1, &file.ptr, &file.length);

--
Simen

Reply via email to