Mail Archives: djgpp/1996/03/21/17:54:53
I posted this message a few weeks ago directly to csaba, but
didn't have any answer. Perhaps someone else could have
answers. Thanks !
----
I have some questions about strange behaviour of your libgrx
library.
At the end of this message you will find a sample program that
will show you those problems. Try it. Compile with commands :
GNU 1 & GRX 1 : gcc graph.cc -lgrx -o graph
GNU 2 & GRX20 : gcc graph.cc -D_V2_ -lgrx20 -o graph
Problem in both Grx1 and Grx20 versions : As you can see in the middle
of the code, I tried to hide the mouse cursor and to wait for any
user action (in fact the goal of that is to build a screen saver in
my GUI). So I called GrMouseEraseCursor to hide the cursor. Indeed
it deseapear from the screen, but each time I ask libgrx for an
user action (GrMouseGetEvent), the cursor come back to the screen and
then go away again. The result is that the cursor is 'flashing' during
the waiting loop... Are there other ways to hide the cursor ? Am I
doing something wrong ?
Problem in Grx20 only : As you can see at the end of the code, I want to
show some message when my application come back in text mode. With
LibGrx1, no problem, but with grx20, the application terminate
without troubles, but there is nothing on the text screen ! Do you
have a hint for this ?
Problem in Grx20 only (possibly corrected in more recent versions)
(not in the sample program) : When I try to draw XORed lines on the
screen, simply adding the constant Gr_XOR to the color, everything
works fine with grx1, but with grx20 nothing appears on the screen.
Is there another way to draw XORed lines with grx20 ? Or is this
feature still not implemented ?
I have been using libgrx for so much time that I thought I never could
find a bug ! well, finally I did :-)
Thanks a lot for your (coming...) answers.
----- Sample program "graph.cc" begin here -----------------------------------
#include <conio.h>
#include <stdio.h>
#ifdef _V2_
#include <grx20.h>
typedef long color;
#else
#include <grx.h>
#include <mousex.h>
#define GrMouseEvent MouseEvent
#define GrMouseGetEvent MouseGetEvent
#define GrMouseSetCursor MouseSetCursor
#define GrMouseEraseCursor MouseEraseCursor
#define GrMouseDisplayCursor MouseDisplayCursor
#define GrMouseDetect MouseDetect
#define GrMouseEventMode MouseEventMode
#define GrMouseEventEnable MouseEventEnable
#define GrMouseInit MouseInit
#define GrMouseUnInit MouseUnInit
#define GR_M_KEYPRESS M_KEYPRESS
#define GR_M_POLL M_POLL
#define GR_M_EVENT M_EVENT
typedef int color;
#endif
char MouseArrow[16*12] =
{ 1, 1, 1,00,00,00,00,00,00,00,00,00 ,
1, 4, 1, 1,00,00,00,00,00,00,00,00 ,
1, 4, 5, 1, 1,00,00,00,00,00,00,00 ,
1, 4, 5, 5, 1, 1,00,00,00,00,00,00 ,
1, 4, 4, 5, 5, 1, 1,00,00,00,00,00 ,
1, 4, 4, 5, 5, 5, 1, 1,00,00,00,00 ,
1, 4, 4, 4, 5, 5, 5, 1, 1,00,00,00 ,
1, 4, 4, 4, 5, 5, 5, 5, 1, 1,00,00 ,
1, 4, 4, 4, 5, 5, 5, 5, 5, 1, 1,00 ,
1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 1, 1 ,
1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 1 ,
1, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1 ,
1, 4, 4, 4, 1, 1,00,00,00,00,00,00 ,
1, 4, 4, 1, 1,00,00,00,00,00,00,00 ,
1, 4, 1, 1,00,00,00,00,00,00,00,00 ,
1, 1, 1,00,00,00,00,00,00,00,00,00 };
int main()
{ GrCursor *CurMouse;
GrMouseEvent evt;
int i;
// Init Graphic mode
GrSetMode(GR_width_height_color_graphics,640,480,16);
// Init Colors
color ColorTable[6];
color NoSysColor[5];
ColorTable[0]=5;
for(i=0;i<5;i++)
{ NoSysColor[i] =GrAllocColor(i*255/4,i*255/4,i*255/4);
ColorTable[i+1]=NoSysColor[i];
}
// Init Mouse
#ifdef _V2_
CurMouse=GrBuildCursor(MouseArrow,12,12,16, 1, 1,ColorTable);
#else
CurMouse=GrBuildCursor(MouseArrow,12,16, 1, 1,ColorTable);
#endif
if (!GrMouseDetect())
{ GrSetMode(GR_80_25_text);
return 1;
}
GrMouseEventMode(1);
GrMouseEventEnable(1,1);
GrMouseInit();
GrMouseSetCursor(CurMouse);
GrMouseDisplayCursor();
// Message loop : Wait for a key hit
do
{ GrMouseGetEvent(GR_M_EVENT | GR_M_POLL,&evt);
} while (!(evt.flags & GR_M_KEYPRESS));
// Hide cursor test
// :: 1 Hide cursor
GrMouseEraseCursor();
// :: 2 Wait for an action
do
{ GrMouseGetEvent(GR_M_EVENT | GR_M_POLL,&evt);
} while (!(evt.flags & GR_M_EVENT));
// :: 3 Show cursor
GrMouseDisplayCursor();
// Destroy mouse cursor
GrMouseUnInit();
GrDestroyCursor(CurMouse);
// Close Graphic mode
GrSetMode(GR_80_25_text);
printf("Back to text mode !\n");
return 0;
}
--
Eric Nicolas <nicolas AT dsys DOT ceng DOT cea DOT fr>
- Raw text -