X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fivac.git;a=blobdiff_plain;f=webcam.c;h=7b4be7e7e50bfcb1a7ab9f132103b9d24972b568;hp=3c5e7a8c50c25df77b8d64af73857ef3bede6b94;hb=041c97e2ca46c5cb594123faf5b124b34993d83b;hpb=b69fb509a515d69f1da0655866dff2c37a3a34cb diff --git a/webcam.c b/webcam.c index 3c5e7a8..7b4be7e 100644 --- a/webcam.c +++ b/webcam.c @@ -5,30 +5,68 @@ * */ -include -include -include - -include - -include "minirgb.h" +/* includes */ +#include +#include +#include +#include +#include +#include "minirgb.h" +/* variables */ Display *display; +/* main routine */ int main(int argc,char **argv) { - XEvent xevent; - char *image, *device=VIDEO_DEV; + /* local variables */ + int screen_id,screen_width,screen_height; + Window root_window,win; + unsigned long white_pixel,black_pixel; - display=XOpenDisplay(NULL); - if(!display) { - printf("cannot open display\n"); - exit(1); + /* opening display */ + display=XOpenDisplay(NULL); /* connect on local display :0 */ + if(display==NULL) { + printf("cannot connect to xserver!\n"); + exit(EXIT_FAILURE); } - if (minirg_init(display)) { - printf("minirg init process failed\n"); - exit(1); - } + /* getting basic xserver information */ + // our screen id + screen_id=DefaultScreen(display); + // dimensions of screen + screen_width=DisplayWidth(display,screen_id); + screen_height=DisplayHeight(display,screen_id); + // how to draw white/black pixels */ + white_pixel=WhitePixel(display,screen_id); + black_pixel=BlackPixel(display,screen_id); + // the screen's root window id + root_window=RootWindow(display,screen_id); + + /* print basic xserver settings */ + printf("screen ID: %d\n",screen_id); + printf("dimensions: %d x %d\n",screen_width,screen_height); + printf("white color -> %d\n",white_pixel); + printf("black color -> %d\n",black_pixel); + /* open a window */ + win=XCreateSimpleWindow(display, + root_window, + 0,0, // coordinates + screen_width/3,screen_height/3, + 500,black_pixel,white_pixel); + /* map the window */ + XMapWindow(display,win); + + /* flush */ + XFlush(display); + + /* wait a bit */ + sleep(5); + printf("blabla ....\n"); + + /* close display */ + XCloseDisplay(display); + +}