The following program doesn't work:
#include <grx20.h> #include <grxkeys.h>
#include <stdio.h>
int GRXMain( int argc, char **argv ) { int x, y; int maxX, maxY;
GrColor color; GrContext *context;
GrSetMode( GR_biggest_graphics ); GrSetRGBcolorMode(); GrClearScreen( GrBlack() );
maxX = GrScreenX(); maxY = GrScreenY();
printf("%d %d\n", maxX, maxY );
context = GrCreateContext( maxX, maxY, 0, 0 ); if ( context == 0 ) { printf("Error creating context\n"); exit(0); }
GrSetContext( context );
color = GrAllocCell();
for( y=0; y<maxY; y++ ) { for( x=0; x<maxX; x++ ) { GrSetColor( color, x, y, 0 ); GrPlot( x, y, color ); } }
GrBitBlt( 0, 0, 0, context, 0, 0 ,maxX, maxY, GrWRITE ); GrDestroyContext( context ); GrFreeColor( color ); GrKeyRead(); return 0; }
Please tell me why?
The following program doesn't work: ... GrSetRGBcolorMode(); ... color = GrAllocCell(); ... Please tell me why?
"In the RGB model GrNumFreeColors returns 0 and GrAllocCell always returns GrNOCOLOR, as colors returned by GrAllocCell are meant to be changed - what is not supposed to be done in RGB mode."
(GRX's users manual), see also test/colorops.c
Use color = GrAllocColor(). In RGB mode you don't need to GrFreeColor().
E-gards: Jimmy