June 24, 2011
Jimmy Cao Wrote:

> No, it writes to stdout which (in this case) is line-buffered.  Whenever there's a newline character, it is supposed to flush.

There're no characters in binary data. This is low-level API. If you want the library to care about characters and do various things, maybe you need a high-level text API like printf or even better phobos std.stdio.write?
June 24, 2011
On Fri, Jun 24, 2011 at 3:03 PM, Kagamin <spam@here.lot> wrote:

> Jimmy Cao Wrote:
>
> > No, it writes to stdout which (in this case) is line-buffered.  Whenever there's a newline character, it is supposed to flush.
>
> There're no characters in binary data. This is low-level API. If you want the library to care about characters and do various things, maybe you need a high-level text API like printf or even better phobos std.stdio.write?
>

Actually, low-level is like using cputs from conio.h. http://www.digitalmars.com/rtl/conio.html

> "They bypass the stdin and stdout buffers and access the console directly."


Anyways, I was using to write an array of characters to stdout.  Since
stdout was buffered, when the newline character was encountered, flushing
should have occured.
Also, you do realize that std.stdio.write uses fwrite, right?  It's the same
thing, except when writing wider chars or when fwide doesn't return 0, in
that case something else is used.


June 25, 2011
I've added description for the modules, so users don't get lost in wondering what each module does. I still need to fill it for Chapter 18 though. (I kind of skimmed that chapter, brrr).
July 05, 2011
Behold this glorious GUI with a rounded rectangle: http://i.imgur.com/Yszgd.png

Okay, so that's actually Cairo with the win32 back-end. Surprisingly, using the two together is quite simple. I had to convert the cairo headers, do a little tweaks to help HTOD out, used implib with /s on the DLL, grabbed two other dependencies and ported a Python example to D.

And it runs! Pretty cool having native windows controls and Cairo for smooth antialised graphics (with no flicker!).

FWIW there's an object-oriented D1 wrapper for Cairo called CairOO, but it's severely outdated and the old dependencies don't even exist anymore.
July 08, 2011
I don't know where to post these things, so I'm putting it here.

So here I have a screenshot of an app that reads MIDI control changes in realtime, and uses Cairo which draws into a GDI backbuffer to make a visual output of the changes over time: http://i.imgur.com/klwTa.png

The realtime MIDI input is stored as an array of values, and then Cairo draws them by using straight lines.

Note how the lines are a little jagged? That's not because of Cairo, it's due to my MIDI hardware which has a very low update rate. But Cairo actually did a good job, it antialiased the points between the changes and made the lines appear nicer. The result is a hell of a lot better than what GDI can do.

Switching from pure win32 drawing to Cairo is a *breeze*. It's really damn simple to use it. I do want to give Cairo's new OpenGL a try though.
July 08, 2011
Here's one using randomly picked colors (this was also pretty simple to do): http://i.imgur.com/mbf1R.png
July 08, 2011
New one:
http://i.imgur.com/R5OHu.png

I should probably open up a blog for these things. :p

It seems I've run into some glitch though, some values tend to jump to 0 arbitrarily. I think it could be caused by array reallocations, and I'm using some globals as well.. Still it mostly works. :)
July 08, 2011
Andrej Mitrovic wrote:
>Behold this glorious GUI with a rounded rectangle: http://i.imgur.com/Yszgd.png
>
>Okay, so that's actually Cairo with the win32 back-end. Surprisingly, using the two together is quite simple. I had to convert the cairo headers, do a little tweaks to help HTOD out, used implib with /s on the DLL, grabbed two other dependencies and ported a Python example to D.
>
>And it runs! Pretty cool having native windows controls and Cairo for smooth antialised graphics (with no flicker!).
>
>FWIW there's an object-oriented D1 wrapper for Cairo called CairOO, but it's severely outdated and the old dependencies don't even exist anymore.

Hi Andrej,

I'm currently writing a cairo wrapper for D2. The source code is located here: https://github.com/jpf91/cairoD

There's no API documentation yet, but I try to keep a consistent naming scheme (phobos like) and the naming follows cairo's names, so it shouldn't be too bad. Documentation is probably what should be done next, but there are some more things to be done (see the TODO list).

A word on memory management, as that's a little different from cairo:
All structs are either POD or ref-counted.
For classes, .dispose should be called when the class is no longer
needed. (The gc also calls dispose automatically to prevent memory
leaks, but that's not good enough for some use cases)

The Win32Surface hasn't been tested yet, so reports on that are welcome. And if you want to help with the wrapper, just let me know.

-- 
Johannes Pfau

July 08, 2011
What's the license on the bindings?
July 08, 2011
Andrej Mitrovic wrote:
>What's the license on the bindings?

Have not thought about that yet, but I think I'll use the boost
license. (I'm not sure if that's possible, as
cairo is LGPL, maybe I'll have to release the binding part at least as
LGPL, as that's based on the cairo headers? Stupid licensing stuff... )

-- 
Johannes Pfau