simple display (from: GUI library for D)

Matthias Pleh jens at konrad.net
Fri Apr 8 19:31:11 PDT 2011


Am 09.04.2011 03:55, schrieb Michel Fortin:
> On 2011-04-08 21:45:20 -0400, Adam D. Ruppe <destructionator at gmail.com>
> said:
>
>> Michel Fortin wrote:
>>> One issue is that different operating system will draw things with
>>> slightly different algorithms, which will result in slightly different
>>> images, which might introduce glitches from platform to platform.
>>
>> I actually hit an even bigger problem... Xlib can't actually draw
>> to XImages, and you don't have direct pixel access to XPixmaps
>> (it's the difference between being on the X Server and the client).
>>
>> So, the lowest common denominator, using only system libraries, is
>> actually to allow *only* pixel access to Image, and move other
>> drawing over to the Window. (Specifically, a Painter struct that
>> ties to the window, so it can manage graphics contexts... yeah,
>> it's starting to get complicated again.)
>>
>> What this means is if we want to draw to images, we've
>> got to spin our own algorithms. Which makes the different OS
>> algorithms moot - the direct screen drawing will be different, but
>> the images will all be the same. The downside is their functions
>> will lag a bit since I can't just wrap some C calls.
>
> Personally, I wouldn't even bother with direct screen drawing in that
> case. Direct screen drawing will need a different implementation for
> each OS, which means a lot of duplicated effort that could be put in
> implementing dependency-less cross-platform drawing primitives instead.
>
> As for text, which library does the X server uses to draw text?
> Freetype? You could link directly to it when you need to draw text...
> and on other OS use similar OS services.
>
>

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.

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.

°Matthias



More information about the Digitalmars-d mailing list