Hi Peter
I will speak about mgrx, I don't use grx anymore, not sure if the workaround I will discuss apply to grx.
The graphics output of a X program is buffered, and you need to flush the buffer to see the graphic output on the screen. The mgrx input api takes care of this in the shadow, but because you don't use it no flush is done. As a workaround you can use GrSleep to flush the buffer. Another thing that the input api does is to manage the X espose events (when you minimize and them restore the window or if another window obscure it), I have no workaround for this.
I attach your program with the workaround:
#include <stdio.h> #include <stdlib.h> #include <mgrx.h> int main() { int choice = 1; GrSetMode(GR_width_height_graphics,500,500); GrSleep(100); // wait all X things are ready GrClearScreen(GrWhite()); GrSetWindowTitle("IO"); GrSleep(1); // flush the X queue
while(choice != 0)
{ printf("Menu : \n Quit (0) \n Square (1) \n Circle (2)\n"); printf("Choice ?"); scanf("%d",&choice); GrClearScreen(GrWhite()); switch(choice) { case 0 : return 0; case 1 : GrFilledBox(20,20,60,60,GrBlack()); GrSleep(1); break; case 2 : GrFilledCircle(40,40,20,GrBlack()); GrSleep(1); break; } } system("PAUSE"); return 0; }
Greetings Mariano
El 8/9/20 a las 21:17, Peter Williams escribió:
Hi Mariano
I am having difficulty with a simple test program running with GRX2.4.9. It will run successfully on Windows10 but not on Linux Mint 20 Cinnamon edition. It is called IO.c: #include <stdio.h> #include <stdlib.h> #include <grx20.h> int main() { int choice = 1; GrSetMode(GR_width_height_graphics,500,500); GrClearScreen(GrWhite()); GrSetWindowTitle("IO");
while(choice != 0)
{
printf("Menu : \n Quit (0) \n Square (1) \n Circle (2)\n"); printf("Choice ?"); scanf("%d",&choice); GrClearScreen(GrWhite()); switch(choice) { case 0 : return 0; case 1 : GrFilledBox(20,20,60,60,GrBlack()); break; case 2 : GrFilledCircle(40,40,20,GrBlack()); break; } } system("PAUSE"); return 0; } compiled as gcc -c IO.c gcc -o IO.exe IO.o -lgrx20X -lX11 -lm
When executed the display window is black and no output appears.No title “IO” appears, only “grx 500 x5 00 x 32”.
I attach a screenshot.
I have the same problem when running this program using MGRX134 (with mgrx.h and slightly different compiler instruction). It fails under Linux but works under Windows10.
This problem has also occurred in a more complex and useful program. However, GRX and MGRX do not fail in all my programs! Can you advise?
Best Wishes, Peter Williams
-- Peter Williams petesweet27rr@gmail.com mailto:petesweet27rr@gmail.com St. Albans, AL1 1SN, UK