I am a newcomer to the grx (246) library for C and not a professional programmer. I am working on a Linux red hat 9 machine, under X11.
The routines look fine and the demo programs works well. I would highly wellcome a more extensive documentation though!
I want to write a program for a very simple animation: a filled circle should move horizontally from the left to the right margin of the screen, speed about 7 cm /s (that is important, very slow movement is much simpler), the movements should be soft and natural. (Some other moving objects will follow)
Here are the critical lines of my program:
... GrSetMode(GR_width_height_bpp_graphics, 1000, 400, 1); pContext = GrCreateFrameContext(GR_frameRAM1, sizex, sizey, NULL, NULL); GrSetContext(pContext); GrClearContext( GrWhite() ); GrFilledCircle(sizex/2, sizey/2, r, red); // red etc. defined previously GrSetContext(NULL); y = GrMaxY()/2; right = GrMaxX() - 2*r;
for (x = 0; x < right; x++) { GrBitBlt1bpp(NULL, x, y, pContext, 0, 0, sizex, sizey, black, red); GrSleep(3 or whatever); GrBitBlt1bpp(NULL, x, y, pContext, 0, 0, sizex, sizey, black,black); }
The Sleep command and the output on the screen do not seem to synchronize.
It helps a lot if I repeat the plotting of the circle, say 50 times, putting it into a (silly) loop, omitting the sleep, but then I get black horizontally blinking stripes in the circle and it is difficult to obtain a reasonable time control.
REMARK
Trying to make the library for the Linux console version I get the error message: in function 'drawline': fdrivers/svga.c: 257, can't find a register in class 'AD_REGS' while reloading 'asm'.
Who can help me?
Gernot Kleiter Dept. of Psychology Univ. Salzburg, Austria
Gernot D. Kleiter escribió:
I am a newcomer to the grx (246) library for C and not a professional programmer. I am working on a Linux red hat 9 machine, under X11.
You are welcome
The routines look fine and the demo programs works well. I would highly wellcome a more extensive documentation though!
I want to write a program for a very simple animation: a filled circle should move horizontally from the left to the right margin of the screen, speed about 7 cm /s (that is important, very slow movement is much simpler), the movements should be soft and natural. (Some other moving objects will follow)
Here are the critical lines of my program:
... GrSetMode(GR_width_height_bpp_graphics, 1000, 400, 1); pContext = GrCreateFrameContext(GR_frameRAM1, sizex, sizey, NULL, NULL); GrSetContext(pContext); GrClearContext( GrWhite() ); GrFilledCircle(sizex/2, sizey/2, r, red); // red etc. defined previously GrSetContext(NULL); y = GrMaxY()/2; right = GrMaxX() - 2*r;
for (x = 0; x < right; x++) { GrBitBlt1bpp(NULL, x, y, pContext, 0, 0, sizex, sizey, black, red); GrSleep(3 or whatever); GrBitBlt1bpp(NULL, x, y, pContext, 0, 0, sizex, sizey, black,black); }
The Sleep command and the output on the screen do not seem to synchronize.
It helps a lot if I repeat the plotting of the circle, say 50 times, putting it into a (silly) loop, omitting the sleep, but then I get black horizontally blinking stripes in the circle and it is difficult to obtain a reasonable time control.
If you don't want to see blinkings you need to use a double buffer, make a memory context, do the drawing in it and them bitblt to the screen context. You have an example in the demogrx.c program, see the "paint_animation" function.
REMARK
Trying to make the library for the Linux console version I get the error message: in function 'drawline': fdrivers/svga.c: 257, can't find a register in class 'AD_REGS' while reloading 'asm'.
It is a problem with the newest gcc compilers. Workaround: change "-O2" to "-O1" in makedefs.grx
Greetings, M.Alvarez