simple display (from: GUI library for D)

Matthias Pleh jens at konrad.net
Sat Apr 9 05:07:41 PDT 2011


Am 09.04.2011 13:11, schrieb Michel Fortin:
> On 2011-04-08 22:31:11 -0400, Matthias Pleh <jens at konrad.net> said:
>
>> For the drawingt part. I'm currently working on a rednerer with
>> scanline algorithm. This will be completly OS-independent. It's in a
>> single file with 2kLOC, and rather low level drawing. I just render on
>> a simple ubyte-array, but it already support polygon-rendering,
>> antialiasing and different color-structs.
>
> Oh! really nice.
>
>
>> This is how it looks like for now:
>> http://img683.imageshack.us/i/testawa.jpg/
>> this takes currently 62ms to render, don't know if this is fast enough,
>> but can definitley improved.
>
> The important thing is to have an API. Once it works we can concern
> ourselves with speed. What's the API like?
>
>


Currntly, it's rather low level API.
It looks like this:

void draw()
{
     buf = new ubyte[width * height * 3];
     // create render buffer, just a ubyte-arrray (no color info)
     PixelBuffer pixBuff = new PixelBuffer(buf, width, height, width*3);

     auto ren= new Renderer!(Rgb24)(pixBuff);  // -> Rgb24
  	                              // manages the correct Color
     Rasterizer ras = new Rasterizer;

     // create the path
     // per primitive min. 3 vertexes needed
     ras.movTo(20,40);  // -> moves the point without drawing
     ras.lineTo(30,80); // -> moves the point with drawing
     [...snip...]

     // finally render it to the PixelBuffer
     ras.render(ren, Color(255,0,0));
}

on this we could add more abstraction to directly render lines, 
rectangles and circles ... (the posted image is completly renderd
whit the API above)

I hope, I will find time this weekend, clean it up and post it here.
Maybe Adam then could add it to his source.


°Matthias


More information about the Digitalmars-d mailing list