File: buffer.c

package info (click to toggle)
xgalaga 2.0.34-41
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,568 kB
  • ctags: 1,222
  • sloc: ansic: 15,819; sh: 2,634; perl: 816; makefile: 155
file content (60 lines) | stat: -rw-r--r-- 1,504 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "allincludes.h"

#ifdef BUFFERING
/* clears the buffer [BDyess] */
void
W_ClearBuffer(window)
    W_Window window;
{
  struct window * win = W_Void2Window(window);

  if(!win->isbuffered) return;
  XFillRectangle(W_Display, win->drawable, colortable[backColor].contexts[0],
		 0, 0, win->width, win->height);
}

int
W_IsBuffered(window)
    W_Window window;
{
  return W_Void2Window(window)->isbuffered;
}

/* turns on buffering, reduces flicker [BDyess] */
/* on is a flag: 1 turns on buffering, 0 turns it off */
void
W_Buffer(window, on)
    W_Window window;
    int on;
{
  struct window * win = W_Void2Window(window);

  if(on) {	/* turn buffering on [BDyess] */
    win->isbuffered = 1;
    if(win->buffer == 0) {  /* create a new pixmap for the buffer [BDyess] */
      win->buffer = XCreatePixmap(W_Display, W_Root, win->width,
				win->height, 
				(unsigned)DefaultDepth(W_Display, W_Screen));
    }
    win->drawable = win->buffer;
    /* clear the buffer to start with (can contain garbage) [BDyess] */
    W_ClearBuffer(window);
  } else { /* turn it off [BDyess] */
    win->drawable = win->window;
    win->isbuffered = 0;
  }
}

/* draws the buffer onto the screen [BDyess] */
void
W_DisplayBuffer(window)
    W_Window window;
{
  struct window * win = W_Void2Window(window);

  if(!win->isbuffered) return;
  XCopyArea(W_Display, win->buffer, win->window, 
            colortable[W_Black].contexts[0], 0, 0, win->width, 
	    win->height, 0, 0);
}
#endif /*BUFFERING [BDyess]*/