Dynamic array and OpenGL problem
Matti Niemenmaa
see_signature at for.real.address
Mon Jan 14 04:26:56 PST 2008
Mikko Ronkainen wrote:
> Now when I got it working I'm thinking about speeding things up a bit. Few questions:
>
> ubyte[] getFramebuffer() { return framebuffer; }
>
> Does D pass it around as a reference?
Yes. ubyte[] is essentially:
struct ubyte_array {
size_t length;
ubyte* ptr;
}
And that's what gets passed around, so 8 bytes of data on a 32-bit system,
regardless of the size of the array.
> And now I'm zeroing the framebuffer like this:
>
> for(int i=0; i<(width*height*3); ++i)
> framebuffer[i] = 0;
>
> Is there more speedier way to just zero the memory? This takes most of the time in the rendering loop...
There's:
framebuffer[] = 0;
But I don't know if it's faster. Theoretically it should use memset, but if it
doesn't, you can do it manually:
import std.c.string; // or if using Tango, import tango.stdc.string;
...
// going from memory here, check the docs to be sure of the parameter order
memset(framebuffer.ptr, 0, framebuffer.length);
--
E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
More information about the Digitalmars-d-learn
mailing list