9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Some libdraw help
@ 2007-06-08 15:19 Anant Narayanan
  2007-06-08 15:37 ` andrey mirtchovski
  2007-06-08 15:37 ` Christian Kellermann
  0 siblings, 2 replies; 4+ messages in thread
From: Anant Narayanan @ 2007-06-08 15:19 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hi All,

I'm a little new to libdraw and need some advice on drawing bitmap data
 onto a window.

I have with me some bitmap data on memory, the address of the first byte
is known. I also know the width of the bitmap data and the total number
of scanlines in it. The number of pixels in each scanline is rounded up
so that each scanline is word-aligned.

I also know the depth, i.e. the number of bits in a pixel. The color
arrangement per pixel depends on the depth. In the case of a 32-bit
depth, the 8 most significant bits are to be ignored, the next 8 bits
represent the red, the next 8 green and the next 8 blue. For a 16 bit
depth, the most significant bit is ignored and the next 15 bits are for
red, green and blue respectively. So on for 8, 4, 2 and 1-bit depths.

The byte order of the data is the same as that of the host CPU.

Finally, I have with me the co-ordinates of a "mask rectangle", i.e. the
portion of the bitmap that needs to updated on the screen. Consequently,
the first time my function is called, the mask rectangle will be the
entire window size; but later calls will contain mask rectangle
co-ordinates for portions of the screen that need updating.

Now for the questions :)

1) What is the best way to draw this bitmap data onto the screen? Note
that the bitmap data on memory will not stick around, I have to copy it.
 I had a look at the Memimage set of methods, but am not sure that it's
the best way to go about it.

2) Do I have to worry about endianness?

3) A general question (un-related to the description above): How can I
create a "full-screen" window? "full-screen" means the application has
the undivided attention of the user, like many games run in other
operating systems. This is different from just resizing the window to
the size of the screen because the window border would still be visible
in this case :)

Help would be most appreciated!

Thank you,

Regards,
--
Anant


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] Some libdraw help
  2007-06-08 15:19 [9fans] Some libdraw help Anant Narayanan
@ 2007-06-08 15:37 ` andrey mirtchovski
  2007-06-08 15:40   ` andrey mirtchovski
  2007-06-08 15:37 ` Christian Kellermann
  1 sibling, 1 reply; 4+ messages in thread
From: andrey mirtchovski @ 2007-06-08 15:37 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

see "loadimage" for the function that creates an Image * from a
bitstream. if you look at the xscreensaves hacks (xscr.tgz in
/contrib/andrey on sources) you'll find a couple that use that hack,
most notably "eruption".

you can fullscreen an application in two ways: use that app instead of
rio (then it'll use the entire screen but you won't be able to resize
it, or run any other draw app); or use a helper function (thanks to
Russ):

    % fullscr=`{echo $vgasize | awk -Fx '{print "0 0 " $1 " " $2}'}
    % window -r $fullscr myapp

cheers!

On 6/8/07, Anant Narayanan <anant@kix.in> wrote:
> Hi All,
>
> I'm a little new to libdraw and need some advice on drawing bitmap data
>  onto a window.
>
> I have with me some bitmap data on memory, the address of the first byte
> is known. I also know the width of the bitmap data and the total number
> of scanlines in it. The number of pixels in each scanline is rounded up
> so that each scanline is word-aligned.
>
> I also know the depth, i.e. the number of bits in a pixel. The color
> arrangement per pixel depends on the depth. In the case of a 32-bit
> depth, the 8 most significant bits are to be ignored, the next 8 bits
> represent the red, the next 8 green and the next 8 blue. For a 16 bit
> depth, the most significant bit is ignored and the next 15 bits are for
> red, green and blue respectively. So on for 8, 4, 2 and 1-bit depths.
>
> The byte order of the data is the same as that of the host CPU.
>
> Finally, I have with me the co-ordinates of a "mask rectangle", i.e. the
> portion of the bitmap that needs to updated on the screen. Consequently,
> the first time my function is called, the mask rectangle will be the
> entire window size; but later calls will contain mask rectangle
> co-ordinates for portions of the screen that need updating.
>
> Now for the questions :)
>
> 1) What is the best way to draw this bitmap data onto the screen? Note
> that the bitmap data on memory will not stick around, I have to copy it.
>  I had a look at the Memimage set of methods, but am not sure that it's
> the best way to go about it.
>
> 2) Do I have to worry about endianness?
>
> 3) A general question (un-related to the description above): How can I
> create a "full-screen" window? "full-screen" means the application has
> the undivided attention of the user, like many games run in other
> operating systems. This is different from just resizing the window to
> the size of the screen because the window border would still be visible
> in this case :)
>
> Help would be most appreciated!
>
> Thank you,
>
> Regards,
> --
> Anant
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] Some libdraw help
  2007-06-08 15:19 [9fans] Some libdraw help Anant Narayanan
  2007-06-08 15:37 ` andrey mirtchovski
@ 2007-06-08 15:37 ` Christian Kellermann
  1 sibling, 0 replies; 4+ messages in thread
From: Christian Kellermann @ 2007-06-08 15:37 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

* Anant Narayanan <anant@kix.in> [070608 17:24]:

> 3) A general question (un-related to the description above): How can I
> create a "full-screen" window? "full-screen" means the application has
> the undivided attention of the user, like many games run in other
> operating systems. This is different from just resizing the window to
> the size of the screen because the window border would still be visible
> in this case :)

To do so you don't use rio as it multiplexes the graphic device as
well as input (keyboard and mouse) to other applications (or even
itself). Just as you can run any libdraw application without rio.


Regards,

Christian

-- 
You may use my gpg key for replies:
pub  1024D/47F79788 2005/02/02 Christian Kellermann (C-Keen)

[-- Attachment #2: Type: application/pgp-signature, Size: 194 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9fans] Some libdraw help
  2007-06-08 15:37 ` andrey mirtchovski
@ 2007-06-08 15:40   ` andrey mirtchovski
  0 siblings, 0 replies; 4+ messages in thread
From: andrey mirtchovski @ 2007-06-08 15:40 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> /contrib/andrey on sources) you'll find a couple that use that hack,
> most notably "eruption".

s/hack/function/


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-08 15:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-08 15:19 [9fans] Some libdraw help Anant Narayanan
2007-06-08 15:37 ` andrey mirtchovski
2007-06-08 15:40   ` andrey mirtchovski
2007-06-08 15:37 ` Christian Kellermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).