This following code works fine. A triangle is displayed.

        GLfloat[6] verts = [  0.0,  1.0,
                             -1.0, -1.0,
                              1.0, -1.0 ];

        glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo); // Some of the types are:

glBufferData(GL_ARRAY_BUFFER, verts.sizeof, &verts, GL_STATIC_DRAW);



Then, all I do is take out the 6 so that the static array becomes a dynamic one. It compiles fine.

         GLfloat[] verts = [  0.0,  1.0,
                             -1.0, -1.0,
                              1.0, -1.0 ];

However, when I run it, the triangle disappears.

According to OpenGL, glBufferData shows: void glBufferData( ignore, GLsizeiptr size, const GLvoid * data, ignore);

So I thought the best solution would be to simply cast the dynamic array to a pointer?

So I tried:
glBufferData(GL_ARRAY_BUFFER, verts.sizeof, cast(const GLvoid *) &verts, GL_STATIC_DRAW);
and
glBufferData(GL_ARRAY_BUFFER, verts.sizeof, cast(const GLvoid *) verts, GL_STATIC_DRAW);
and
glBufferData(GL_ARRAY_BUFFER, verts.sizeof, verts.ptr, GL_STATIC_DRAW);
and
glBufferData(GL_ARRAY_BUFFER, verts.sizeof, cast(const GLvoid *) verts.ptr, GL_STATIC_DRAW);
and
nothing but more blank screens.

Any ideas?  Thanks.


Reply via email to