コード例 #1
0
ファイル: testgl.c プロジェクト: carlosphp/svgalib-1
int main(int argc, char *argv[])
{
    vga_init();
    
    if(argc>=2) {
        timescale=atoi(argv[1]);
        if(timescale<1)timescale=1;
    }

    VGAMODE = vga_getdefaultmode();
    if (VGAMODE == -1)
	VGAMODE = G320x200x256;	/* Default mode. */

    if (!vga_hasmode(VGAMODE)) {
	printf("Mode not available.\n");
	exit(-1);
    }
    VIRTUAL = 0;		/* No virtual screen. */
    if (vga_getmodeinfo(VGAMODE)->colors == 16 ||
	(vga_getmodeinfo(VGAMODE)->flags & IS_MODEX))
	/* These modes are supported indirectly by vgagl. */
	VIRTUAL = 1;

    if (VIRTUAL) {
	/* Create virtual screen. */
	gl_setcontextvgavirtual(VGAMODE);
	backscreen = gl_allocatecontext();
	gl_getcontext(backscreen);
    }
    vga_setmode(VGAMODE);
    gl_setcontextvga(VGAMODE);	/* Physical screen context. */
    physicalscreen = gl_allocatecontext();
    gl_getcontext(physicalscreen);
    if (COLORS == 256)
	gl_setrgbpalette();

	if(argc==3)sleep(2);

    test();

    /* Now do the same with clipping enabled. */
    gl_clearscreen(0);
    gl_setclippingwindow(WIDTH / 4, HEIGHT / 4, WIDTH - WIDTH / 4 - 1,
			 HEIGHT - HEIGHT / 4 - 1);

    test();

    gl_disableclipping();
    if (COLORS == 256)
	/* Show the logo if using 256 color mode. */
	logotest();

    getchar();

    if (VIRTUAL)
	gl_freecontext(backscreen);
    vga_setmode(TEXT);
    exit(0);
}
コード例 #2
0
ファイル: main-lsl.c プロジェクト: AmyBSOD/ToME-SX
/*
 * Term hook
 * Initialize a new term
 */
static void term_init_svgalib(term *t)
{
	int vgamode;

	/* Only one term */
	(void) t;

	vga_init();

	/* The palette is 256x3 bytes big (RGB). */
	C_MAKE(pal, 768, byte);

#ifdef USE_GRAPHICS

	/* Hardwire this mode in for now */
	vgamode = G1024x768x256;

	/* Set up the bitmap buffer context */
	gl_setcontextvgavirtual(vgamode);
	buffer = gl_allocatecontext();
	gl_getcontext(buffer);

	/* Load bitmap into virtual screen */
	term_load_bitmap();

#endif /* USE_GRAPHICS */

	/* Hardwire this mode in for now */
	vgamode = G640x480x256;

	/* Set up the physical screen context */
	if (vga_setmode(vgamode) < 0)
	{
		quit("Graphics mode not available!");
	}

	gl_setcontextvga(vgamode);
	screen = gl_allocatecontext();
	gl_getcontext(screen);

	/* Is this needed? */
	gl_enablepageflipping(screen);

	/* Set up palette colors */
	setpal();

	/* Load the character font data */
	initfont();

	/* Color 0 isn't transparent */
	gl_setwritemode(WRITEMODE_OVERWRITE);
}
コード例 #3
0
ファイル: draw.c プロジェクト: descent/jmcce
bool screen_init (void)
{
#ifdef LINUXFB
  use_fb = 1;
  if (fb_init ()) 
  {
    use_fb = 0;
    return false;
  }
#endif

#ifdef VGALIB
  use_fb = 0;
  vga_init ();
  vga_setmode(DEFAULT_VGA_MODE);
  gl_setcontextvga(DEFAULT_VGA_MODE);
  physical_screen = gl_allocatecontext();
  gl_getcontext(physical_screen);

  gl_setcontextvgavirtual(DEFAULT_VGA_MODE);
  virtual_screen = gl_allocatecontext();
  gl_getcontext(virtual_screen);

  gl_setcontext(virtual_screen);
  //vga_ext_set(VGA_EXT_SET,  VGA_CLUT8);

// color table:
// http://en.wikipedia.org/wiki/ANSI_escape_code#Colors 

  gl_setpalettecolor(BLUE, 0, 0, 63); // blue
  gl_setpalettecolor(BLACK, 0, 0, 0); // black
  gl_setpalettecolor(GREEN, 0, 63, 0); 
  gl_setpalettecolor(RED, 63, 0, 0); 
  gl_setpalettecolor(BROWN, 170/4, 85/4, 0);
  gl_setpalettecolor(MAGENTA, 170/4, 0, 170/4);
  gl_setpalettecolor(CYAN, 0, 170/4, 170/4); 
  gl_setpalettecolor(GRAY, 48, 48, 48);

  gl_setpalettecolor(LIGHTBLACK, 85/4, 85/4, 85/4); 
  gl_setpalettecolor(LIGHTBLUE, 85/4, 85/4, 255/4); 
  gl_setpalettecolor(LIGHTGREEN, 85/4, 255/4, 85/4); 
  gl_setpalettecolor(LIGHTCYAN, 85/4, 255/4, 255/4); 
  gl_setpalettecolor(LIGHTRED, 25/45/4, 85/4, 85/4); 
  gl_setpalettecolor(LIGHTMAGENTA, 255/4, 85/4, 255/4); 
  gl_setpalettecolor(LIGHTBROWN, 255/4, 255/4, 85/4); 

#endif

  active_console = 1;
  return true;
}
コード例 #4
0
ファイル: smode2.c プロジェクト: TryndamereStark/lirc
void initscreen(void)
{
	int vgamode;

	vga_init();

	vgamode = G640x480x16;

	if (!vga_hasmode(vgamode)) {
		printf("Mode not available.\n");
		exit(-1);
	}
	vga_setmode(vgamode);

	/* Create virtual screen. */
	gl_setcontextvgavirtual(vgamode);
	backscreen = gl_allocatecontext();
	gl_getcontext(backscreen);

	/* Physical screen context. */
	vga_setmode(vgamode);
	gl_setcontextvga(vgamode);
	physicalscreen = gl_allocatecontext();
	gl_getcontext(physicalscreen);

	gl_setcontext(backscreen);
	/*drawgraypalette(); */

	gl_clearscreen(0);

//    gl_setcontextvga(vgamode);
	gl_enableclipping();
	gl_setclippingwindow(0, 0, 639, 479);
	gl_setwritemode(WRITEMODE_OVERWRITE | FONT_COMPRESSED);
	gl_setfont(8, 8, gl_font8x8);
	gl_setfontcolors(0, 1);
}
コード例 #5
0
ファイル: mandel-svga.c プロジェクト: palmerc/lab
int main() {
   int maxCols = 1024;
   int maxRows = 768;
   int maxIterations = 2048;
   int maxSize = 4;
   float Xmin = -2.0;
   float Xmax = 1.2;
   float Ymin = -1.2;
   float Ymax = 1.2;
 
   double X, Y;
   double Xsquare, Ysquare;
   double currentP;
   double currentQ[767];
   double deltaP, deltaQ;
   int color;
   int currentRow, currentCol;
 
   deltaP = (Xmax - Xmin)/(double)maxCols;
 
   deltaQ = (Ymax - Ymin)/(double)maxRows;
 
   currentQ[0] = Ymax;
   for (currentRow = 1; currentRow < maxRows; currentRow++) {
      currentQ[currentRow] = currentQ[currentRow-1] - deltaQ;
   }
   currentP = Xmin;
 
   vga_init();
   vga_setmode(G1024x768x256);
   gl_setcontextvga(G1024x768x256);
   physicalscreen = gl_allocatecontext();
   gl_getcontext(physicalscreen);
   gl_setcontextvgavirtual(G1024x768x256);
   virtualscreen = gl_allocatecontext();
   gl_getcontext(virtualscreen);
   gl_setcontext(virtualscreen);
 
   for (currentCol = 0; currentCol < maxCols; currentCol++) {
      for (currentRow = 0; currentRow < maxRows; currentRow++) {
         X = 0.0;
         Y = 0.0;
         Xsquare = 0.0;
         Ysquare = 0.0;
         color = 0;
         while ((color <= maxIterations) && (Xsquare + Ysquare <= maxSize)) {
            Xsquare = X * X;
            Ysquare = Y * Y;
            Y = (2*X*Y) + currentQ[currentRow];
            X = (Xsquare - Ysquare) + currentP;
            color++;
         }
             gl_setpixel(currentCol, currentRow, color % 256);
      }
      currentP = currentP + deltaP;
      gl_copyscreen(physicalscreen);
   }
   vga_getch();
   gl_clearscreen(0);
   vga_setmode(TEXT);
 
   return 0;
}
コード例 #6
0
ファイル: gr.c プロジェクト: Ringdingcoder/d1x
int gr_set_mode(u_int32_t mode)
{
	unsigned int w, h;
	char vgamode[16];
	vga_modeinfo *modeinfo;
	int modenum, rowsize;
	void *framebuffer;
	
#ifdef NOGRAPH
	return 0;
#endif
	if (mode<=0)
		return 0;

	w=SM_W(mode);
	h=SM_H(mode);

	gr_palette_clear();

	sprintf(vgamode, "G%dx%dx256", w, h);
	modenum = vga_getmodenumber(vgamode);	
	vga_setmode(modenum);
#ifdef SVGALIB_INPUT
	mouse_seteventhandler(mouse_handler);
#endif
	modeinfo = vga_getmodeinfo(modenum);

	if (modeinfo->flags & CAPABLE_LINEAR)
	{
		usebuffer = 0;

		vga_setlinearaddressing();

		// Set up physical screen only
		gl_setcontextvga(modenum);
		physicalscreen = gl_allocatecontext();
		gl_getcontext(physicalscreen);
		screenbuffer = physicalscreen;

		framebuffer = physicalscreen->vbuf;
		rowsize = physicalscreen->bytewidth;
	}
	else
	{
		usebuffer = 1;

		// Set up the physical screen
		gl_setcontextvga(modenum);
		physicalscreen = gl_allocatecontext();
		gl_getcontext(physicalscreen);

		// Set up the virtual screen
		gl_setcontextvgavirtual(modenum);
		screenbuffer = gl_allocatecontext();
		gl_getcontext(screenbuffer);

		framebuffer = screenbuffer->vbuf;
		rowsize = screenbuffer->bytewidth;
	}

	memset(grd_curscreen, 0, sizeof(grs_screen));
	grd_curscreen->sc_mode = mode;
	grd_curscreen->sc_w = w;
	grd_curscreen->sc_h = h;
	grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*3,grd_curscreen->sc_h*4);
	grd_curscreen->sc_canvas.cv_bitmap.bm_x = 0;
	grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0;
	grd_curscreen->sc_canvas.cv_bitmap.bm_w = w;
	grd_curscreen->sc_canvas.cv_bitmap.bm_h = h;
	grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = rowsize;
	grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_LINEAR;
	grd_curscreen->sc_canvas.cv_bitmap.bm_data = framebuffer;
	gr_set_current_canvas(NULL);
	
	gamefont_choose_game_font(w,h);
	
	return 0;
}