Re: "Layers" in SVGAlib

Search this archive.

From: Russell Marks (russell.marks@dtn.ntl.com)
Date: Thu 17 Feb 2000 - 17:02:10 IST


> >> I am thinking of seperate levels - like a background
> >> level, a foreground level, another level, and a mouse level,
> >> for example...
> >> And you can write to each level and read from each level -
> 
> > Yes. They're called layers I think. And I don't think svgalib
> > has a supprt for them, though it would be possible in a
> > separate library. If you don't want to support tansparency
> > you could probably do it by build areas in memory as copying
> > the pixels when you want the result displayed.
> 
> I agree. You have gl's framebuffer, as well as the ability to make your
> own (sort of) with gl_getbox(). You can then copy the relevant sections of
> your in-memory "layers" to the physical screen as needed. You won't be
> able to remove these layers in the future, but you can always overwrite
> them, using the info stored in memory.
> 
> This is how I handle pop-up windows, where a temporary message appears,
> and then the background is restored.

<aol>Me too</aol>, with zgv's mouse support (the right-button menu) -
though that may be a bit more complicated/kludgey, as it has to deal
with weird modes like 360x480, and 640x480 16-colour, so I can't just
use gl_* all the time - it's actually a bit of a mess. :-)

Another function handy for `sprite'-type stuff (which may be relevant
here) is gl_putboxmask(). However, this messes up if your sprite
doesn't completely fit onscreen (or it did last time I checked). I ran
into this when implementing zgv's mouse pointer; the vgagl-using
version of that is a bit nasty, but is one way of avoiding this
problem (though this only deals with being partly off the
right/bottom, as that's all that's needed for a mouse pointer):

> /* deal with being near edge of screen */
> if(savex>screen_width-savew)
>   savew=screen_width-savex,small=1;
> if(savey>screen_height-saveh)
>   saveh=screen_height-savey,small=1;
> 
> /* we need to save existing data, then draw the mouse. */
> if(usegl)
>   {
>   /* gl-using 8/15/16/24-bit version */
>   gl_getbox(savex,savey,savew,saveh,mouseptr_save);
>   /* since there's no gl_putboxpartmask, and clipping doesn't work for
>    * gl_putboxmask, we have to do either masking or clipping ourselves.
>    * Hmm. I'll pick clipping, I think...
>    */
>   if(small)
>     /* do it a line at a time */
>     for(y=0;y<saveh;y++)
>       gl_putboxmask(savex,savey+y,savew,1,
>                               mouseptr_pixmap+MOUSECUR_XSIZE*y*screen_bytepp);
>   else
>     /* full size, no problem */
>     gl_putboxmask(savex,savey,savew,saveh,mouseptr_pixmap);
>   }

I notice there's also a gl_putboxmaskcompiled(), which is apparently
faster (after an initial gl_compileboxmask()). Now, either this hasn't
been in svgalib all that long, or I was *particularly* unobservant
when I wrote the above code... :-)


While I'm here, I may as well tackle this from the original post too:

> My second problem is, I don't knwo how to set down the mouse
> sensivity - like in the SVGAlib example 'spin'...

mouse_setscale(). 16 is a pretty reasonable value IMHO. Unfortunately,
I don't think there's a libvga.config setting to set this (corrections
welcome :-)).

-Rus.


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST