Dynamic array and OpenGL problem

Mikko Ronkainen mikoro at iki.fi
Sun Jan 13 13:18:20 PST 2008


Hello, Iäm playing around a little with OpenGL and I'm drawing trying to draw raw pixels from memory to the screen. This is the function:

void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);

Now I have a buffer with rgb data:

ubyte[3][1024][1280] framebuffer;

If I fill it and pass it to the opengl, everything works fine. But if I create it dynamically:

ubyte[][][] framebuffer;
framebuffer = new ubyte[][][](3, height, width);

Now even after filling it I get some random garbage when rendering. Program doesn't segfault though, so I assume memory is correctly allocated and written - opengl just doesn't read it right. What am I doing wrong?


More information about the Digitalmars-d-learn mailing list