We are using QNX message passing from computer “A” to drive events on the
screen of computer “B”
In principle, Computer B is in a wait state until it receives the first
message from computer “A” and then depending upon the message draws a
different image on the screen. All of the draw functions work (both
before messages are received, and during the message passing routines,
however one image that renders instanteously before the message loop is
initiated (initiated by computer “A’s” first message) takes literally
seconds to render if called by a message.
The code for the image in question is
/*
- prob will be probability that each dot is shown
- 10 => pitch black, 1 => very white
/
void draw_square(int prob)
{
/ might be cleaner w/o widgets, but docs discourage this. - i break up drawing the random dots into 64 element rows
- because the pixel widget has a limit on the number of
- elements it will draw at once.
*/
PtWidget_t* pixel;
PtArg_t args[3];
PhPoint_t points[SQUARE_LENGTH * SQUARE_LENGTH];
PhPoint_t origin = { SQUARE_ORIGIN_X, SQUARE_ORIGIN_Y};
int i, j, row;
/* note: this will always set upper left pixel */
memset(&points, 0, 64 * 64 * sizeof(PhPoint_t));
for (i = 0; i < SQUARE_LENGTH; i++) {
for (j = 0; j < SQUARE_LENGTH; j++) {
if( !((rand() % 10) < prob)) {
points[i + j * SQUARE_LENGTH].x = i;
points[i + j * SQUARE_LENGTH].y = j;
}
}
}
PtSetArg(&args[0], Pt_ARG_ORIGIN, &origin, 0);
PtSetArg(&args[1], Pt_ARG_COLOR, Pg_WHITE, 0);
for (row = 0; row < 64; row++) {
PtSetArg(&args[2], Pt_ARG_POINTS, &points[SQUARE_LENGTH *
row], 64);
pixel = PtCreateWidget(PtPixel, NULL, 3, args);
PtRealizeWidget(pixel);
}
}
The image is a 64 X 64 pixel array. It is designed to alter the intensity
drawn depending upon the input given, for example, if given an inout of 1,
then 10% of the dots should be black, if 9 then 90% should be black. This
code works fine, the only poblem is the image is rendered in seconds
(literally) if done during the message passing loop, but rendered
instantaeously if done by itself (ie before message passing begins.
Any thoughts on this would be greatly appreciated.
Sincerely
Anil Cherian