From a0ae785bf7f3cef46c375417f3b0bab89ecf4449 Mon Sep 17 00:00:00 2001 From: Jean Wasilewski Date: Thu, 16 Apr 2015 15:16:18 +0000 Subject: [PATCH] Non working version --- main.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/main.c b/main.c index 649aada..a58113a 100644 --- a/main.c +++ b/main.c @@ -1,49 +1,36 @@ -/* - Remember to compile try: - 1) gcc hi.c -o hi -lX11 - 2) gcc hi.c -I /usr/include/X11 -L /usr/X11/lib -lX11 - 3) gcc hi.c -I /where/ever -L /who/knows/where -l X11 - - Brian Hammond 2/9/96. Feel free to do with this as you will! -*/ - - -/* include the X library headers */ #include #include #include - -/* include some silly stuff */ #include #include -/* here are our X variables */ +#define AWESOME 7 + Display *dis; int screen; Window win; GC gc; int width=320; int height=240; +int i=0; -/* here are our X routines declared! */ void init_x(); void close_x(); void redraw(); -main () { +int main () +{ XEvent event; /* the XEvent declaration !!! */ KeySym key; /* a dealie-bob to handle KeyPress Events */ char text[255]; /* a char buffer for KeyPress Events */ - Pixmap pmap; XColor col; + int initOffsetBMP; init_x(); printf("Patte de canard\n"); Colormap cmap = DefaultColormap(dis, DefaultScreen(dis)); printf("?\n"); - pmap = XCreatePixmap(dis, win, width, height, DefaultDepth(dis, DefaultScreen(dis))); - FILE* home = NULL; char buffer[4]; @@ -57,6 +44,7 @@ main () { buffer[2] = getc(home); buffer[3] = getc(home); printf("Pixel array offset %02x %02x %02x %02x\n", buffer[0], buffer[1], buffer[2], buffer[3]); + initOffsetBMP = buffer[0] + (buffer[1] >> 8) + (buffer[2] >> 16) + (buffer[3] >> 24); fseek(home, 0x12, SEEK_SET); buffer[0] = getc(home); @@ -84,61 +72,72 @@ main () { } + fseek(home, initOffsetBMP, SEEK_SET); - - while(1); - - - /* look for events forever... */ - while(1) { - /* get the next event and stuff it into our event variable. - Note: only events we set the mask for are detected! - */ + while(1) + { XNextEvent(dis, &event); - if (event.type==Expose && event.xexpose.count==0) { - /* the window was exposed redraw it! */ + if (event.type==Expose && event.xexpose.count==0) redraw(); - } - if (event.type==KeyPress&& - XLookupString(&event.xkey,text,255,&key,0)==1) { - /* use the XLookupString routine to convert the invent - KeyPress data into regular text. Weird but necessary... - */ - if (text[0]=='q') { + + if (event.type==KeyPress&& XLookupString(&event.xkey,text,255,&key,0)==1) + { + if (text[0]=='q') close_x(); - } printf("You pressed the %c key!\n",text[0]); } - if (event.type==ButtonPress) { - /* tell where the mouse Button was Pressed */ - int x=event.xbutton.x, - y=event.xbutton.y; + if (event.type==ButtonPress) + { + //int x=event.xbutton.x, + //y=event.xbutton.y; //strcpy(text,"X is FUN!"); //XSetForeground(dis,gc,rand()%event.xbutton.x%255); //XDrawString(dis,win,gc,x,y, text, strlen(text)); + buffer[0] = getc(home); + buffer[1] = getc(home); + buffer[2] = getc(home); + + int j; + + for(j=0; j