Mathias Weiss <[EMAIL PROTECTED]> writes:
> I have to questions, both concerning the direct buffer.
>
> First I'd like to know how to write in a ggi_directbuffer.
> How do I decide what type has to be asigned to the dbuf->write element??
>
> In the slimy.c demo there is first the asignment
>
> uint8 *fbptr;
> fbptr = dbuf->write;
>
> and then it is writen to *fbptr.
>
> I think I understand that for 8 bit color depth you have to use uint8. But
> what if I want to use truecolor, or what if I first check what color depth
> my system provides me??
You can assign dbuf->write to whatever you want, regardless of the
pixelsize or color depth (which need not be the same), and you
don't have to write exactly one pixel at a time if you don't want
to.
The format of the direct buffer is specified by the 'layout' and 'buffer'
fields in the ggi_directbuffer struct.
In most cases you can access the framebuffer in whatever way you want,
but check the 'noaccess' and 'align' members of ggi_directbuffer to be
sure. Also note that 'align' only tells you about restrictions the
graphics card may impose, modern CPUs will take a large performance
hit if you do unaligned 16-, 32-, or 64-bit accesses, and many of
them does not allow it at all.
> And how can I asign a ggi_color or ggi_pixel element to the direct buffer?
You probably don't want to assign a ggi_color struct to a directbuffer
directly, but you can get the corresponding pixel value with
ggiMapColor(). A ggi_pixel is just an integer large enough to hold a
pixelvalue for any mode. You assign it just like you asign any other
integer:
void *pointer = dbuf->write;
ggi_pixel pix;
*(uint8*)pointer = pix;
*(uint16*)pointer = pix;
*(uint32*)pointer = pix;
for 8, 16 and 32 bit pixel-sizes respectively.
> The second question regards flushing. When I finshed writing in the
> directbuffer I do a ggiFlush.
>
> Is it possible/does improve speed to do a flushing of just a part of the
> buffer?
>
> If yes, how can I do that?
Yes, flushing only part of the visual may improve performance, you
can do that with ggiFlushRegion().
> I looked for documentation on the ggi home page but found nothing. If I
> have missed some please let me know.
You missed the documentation page?
For docs on LibGGI see:
http://www.ggi-project.org/docs/libggi/book1.html
and also the man-pages that comes with LibGGI.
//Marcus
--
-------------------------------+------------------------------------
Marcus Sundberg | http://www.stacken.kth.se/~mackan
Royal Institute of Technology | Phone: +46 707 295404
Stockholm, Sweden | E-Mail: [EMAIL PROTECTED]