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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/*
XBlockOut a 3D Tetris
Copyright (C) 1992,1993,1994 Thierry EXCOFFIER
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Contact: Thierry.EXCOFFIER@ligia.univ-lyon1.fr
*/
#include "opt.h"
#include "x.h"
#include <stdio.h>
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
void initbuffer(opt,x)
struct opt *opt ;
struct x * x ;
{
if ( opt->verbose ) fprintf(stderr,"Start of buffer initialisation\n") ;
if ( x->back )
{
XFreePixmap( x->display,x->back ) ;
x->back = 0 ;
XFreePixmap( x->display,x->work ) ;
x->work = 0 ;
}
switch( opt->buffering )
{
case 2 :
x->back=XCreatePixmap( x->display,x->root,x->dimx,x->dimy,x->depth ) ;
x->work=XCreatePixmap( x->display,x->root,x->dimx,x->dimy,x->depth ) ;
if ( x->back==0 || x->work==0 )
{
fprintf(stderr,"Not enough memory for double buffering\n") ;
fprintf(stderr,"Try to use single buffering\n") ;
fprintf(stderr,"Use option buffering=1 (except for black&white)\n") ;
exit(1) ;
}
break ;
case 1 :
case 5 :
if ( opt->buffering==1 && opt->verbose )
{
fprintf(stderr,"Create buffer windows for debugging\n") ;
x->work = XCreateSimpleWindow(x->display,x->root,0,0,x->dimx,x->dimy,0,0,0);
XMapWindow(x->display,x->work) ;
}
else {
x->work = XCreatePixmap( x->display,x->root,x->dimx,x->dimy,x->depth ) ;
}
if ( x->work==0 )
{
fprintf(stderr,"Not enough memory for buffering\n") ;
fprintf(stderr,"Try to play without buffering\n") ;
fprintf(stderr,"Use option buffering=0\n") ;
exit(1) ;
}
break ;
}
if ( opt->verbose ) fprintf(stderr,"End of buffer initialisation\n") ;
}
|