File:  [UNIX Amiga Emulator] / uae / xwin.cc
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:37:52 2018 UTC (8 years, 3 months ago) by root
Branches: MAIN, BSchmidt
CVS tags: uae001, HEAD
uae-0.1

 /* 
  * UAE - The Unusable Amiga Emulator
  * 
  * X interface v0.0
  * v0.0: 950305: black and white window
  * 
  * (c) 1995 Bernd Schmidt
  */

#include <stdio.h>
#include <X11/Xlib.h>

#include "xwin.h"

Display *display;
int screen;
Window rootwin, mywin;
GC whitegc,blackgc;
XColor black,white;
Colormap cmap;

void InitX()
{
   char *display_name = 0;
   XSetWindowAttributes wattr;
   
   display = XOpenDisplay(display_name);
   if (display == 0)  {
      printf("Can't connect to X server %s\n",XDisplayName(display_name));
      exit(-1);
   }
   screen = XDefaultScreen(display);
   rootwin = XRootWindow(display,screen);
/*   wattr.backing_store = Always;*/
  /* dimensions are not exact */
   mywin = XCreateWindow(display,rootwin,0,0,800,400,0,
			 CopyFromParent,CopyFromParent,CopyFromParent,
			 0,&wattr);
   XMapWindow(display,mywin);
   
   whitegc = XCreateGC(display,mywin,0,0);
   blackgc = XCreateGC(display,mywin,0,0);
   cmap = XDefaultColormap(display,screen);
   
   XParseColor(display,cmap,"#000000",&black);
   if (!XAllocColor(display,cmap,&black)) printf("Fehlschlag\n");
   XParseColor(display,cmap,"#ffffff",&white);
   if (!XAllocColor(display,cmap,&white)) printf("Fehlschlag 2\n");
   XSetForeground(display,blackgc,black.pixel);
   XSetForeground(display,whitegc,white.pixel);
}

void DrawPixel(int x,int y,int col)
{
  if (col){
    XDrawPoint(display,mywin,blackgc,x,y);
  } else {
    XDrawPoint(display,mywin,whitegc,x,y);
  }
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.