Dear Sir,
After following suggestions from Maurice and Mariano Sirs, I have the following pascal codes seems to meet my requirements:
TYPE pGrContext=^GrContext; VAR scrgrc,bufgrc:pGrContext; BEGIN GrSetDriver("memory gw 640 gh 400 nc 256"); GrSetMode(GR_default_graphics,2,3,4,5,6); scrgrc:=GrCurrentContext; bufgrc:=GrCreateContext(GrMaxX,GrMaxY,NIL,NIL);
line(GrMaxX,GrMaxY,0,0); line(GrMaxX,0,0,GrMaxY);
{ copy whole screen context to bufgrc } GrBitBltNC(bufgrc,0,0,NIL,0,0,GrMaxX,GrMaxY,GrWRITE); { set new drawings to bufgrc } GrSetContext(bufgrc); line(0,GrMaxY DIV 2,GrMaxX,GrMaxY DIV 2); line(GrMaxX DIV 2,0,GrMaxX DIV 2,GrMaxY);
ClearDevice; GrSetContext(scrgrc); { copy bufgrc back to screen } GrBitBltNC(NIL,0,0,bufgrc,0,0,GrMaxX,GrMaxY,GrWRITE);
CloseGraph; END.
The 3rd and 4th 'line' commands seems to be drew in the memory and then be displayed at the next 'GrSetContext' and 'GrBitBltNC' commands. But the remaining problem is the 'GrBitBltNC' takes about 0.1~0.2 seconds on my Linux system, is there any other alternate method to speed-up this ?
Regards,
JH
----- Original Message ----- From: "Maurice Lombardi" Maurice.Lombardi@ujf-grenoble.fr To: grx@gnu.de Sent: Saturday, December 11, 2010 7:25 PM Subject: Re: Batch drawing to memory only for less screen flickering
Le 10/12/2010 17:56, Mariano a écrit :
El 10/12/10 10:24, Maurice Lombardi escribió:
Le 09/12/2010 08:20, jhliu a écrit :
There is an example of a general solution in the demogrx test program. The running banner is drew in a memory context and them bitblt to the screen (see the paint_animation function).
Indeed, this is the way the "saucer" is drawn in the GetImage / PutImage demo in the bgi/bccbgi program, when multiple paging is not available, i.e. in all cases except some VESA/DJGPP modes. See the sources in src/bgi/getimage.c. I was supposing that the OP had in mind a common practice in slow systems in the old times: There are two pages in memory and the "visual page" is switched between the two nearly instantaneously (in fact at the start of the next refreshing of the screen). This is why it exists only in the old DOS system VESA/DJGPP. In modern times the drawing is made in memory in a minimal rectangle (not the whole screen), and the actual refreshing is deferred to the Windows system through an InvalidateRect() function (or to the X11 system through an PIXEL_CACHE_INVALIDATE() macro). I am not sure there is really an advantage in the old way of doing without availability of the special card function.
Maurice
-- Maurice Lombardi Laboratoire de Spectrometrie Physique, Universite Joseph Fourier de Grenoble, BP87 38402 Saint Martin d'Heres Cedex FRANCE Tel: 33 (0)4 76 51 47 51 Fax: 33 (0)4 76 63 54 95 mailto:Maurice.Lombardi@ujf-grenoble.fr from January 1st, 2011, the Laboratoire de Spectrométrie Physique will become the LABORATOIRE INTERDISCIPLINAIRE DE PHYSIQUE (LIPhy).
Grx mailing list Grx@gnu.de https://www.g-n-u.de/mailman/listinfo/grx