Hi,
For that purpose I'm using the function GrBitBlt.
GrContext *pPic; int w = x2 - x1 + 1; int h = y2 - y1 + 1; // Create a context in memory pPic = GrCreateContext(w, h, NULL, NULL); // Save the on-screen rectangle if(pPic != NULL) GrBitBlt(pPic, 0, 0, NULL, x1, y1, x2, y2, GrWRITE);
// ... overwrite the screen
// Restore the rectangle if(pPic != NULL) GrBitBlt(NULL, x1, y1, pPic, 0, 0, w, h, GrWRITE); // And release the memory GrDestroyContext(pPic);
This works fine for me. Hope that helps. Josu Onandia
-----Mensaje original----- De: J-P [SMTP:jstacey@plato.wadham.ox.ac.uk] Enviado el: viernes 12 de mayo de 2000 15:59 Para: grx@gnu.de Asunto: Contexts and saving bits of the screen
Hi,
I am trying to implement rather basic "sprites" in GRX (not so complicated that I want to proceed to e.g. Allegro). To this end I'd like to write over, but then *retrieve*, bits of graphics on the screen.
Essentially, I would like a filled box to be drawn on existing screen content, but the existing content to be "saved" somehow and put back on the screen (analogous to conio.h's puttext() and gettext() functions) once the filled box is no longer necessary.
I was hoping perhaps to use GrContexts and GetImageFromContext() for this, but I'm not entirely sure how to go about it. My first few attempts resulted in seg-faults. What is the name of the "default context" that GrSetMode() sets up?
Just a routine that buffers the screen content of the box (x1,y1,x2,y2) would help.
Any help gratefully received.
J-P Stacey
On Mon, 15 May 2000, Josu Onandia wrote:
For that purpose I'm using the function GrBitBlt.
Thankyou :) There was only a two-line note to it in the documentation, which wasn't obvious in the printouts I'd made. Is it a known bug in the documentation, by the way, that lots of the Mouse functions and #defines are missing the "GR_" or "Gr" prefix in the docs?
If anyone's interested, I now have a fairly stable, fast, OO C++, low-graphics menu system written using GRX functions. Blitting was my main problem.
Many thanks to all who replied.
J-P Stacey.