ginit.cpp

/**********************************************************/
/* Author....... Todd A. Miller                           */
/* Dialect...... Turbo C++ 3.0                            */
/* Description.. This file is the GR_INIT unit.           */
/**********************************************************/
#ifndef GR_INIT
#define GR_INIT

#include <stdio.h>
#include <graphics.h>
#include <stdlib.h>

void ABORT(char*);
void initialize_drivers_and_fonts();

void ABORT(char *msg)
{
int error = graphresult();
   printf("%s: %s\n", msg, grapherrormsg(error));
   exit(error);
}

void initialize_drivers_and_fonts()
{
int driver, mode, error;
   if (registerfarbgidriver(CGA_driver_far) < 0)
      ABORT("CGA");
   if (registerfarbgidriver(EGAVGA_driver_far) < 0)
      ABORT("EGA\VGA");
   if (registerfarbgidriver(Herc_driver_far) < 0)
      ABORT("Herc");
   if (registerfarbgidriver(ATT_driver_far) < 0)
      ABORT("AT&T");
   if (registerfarbgidriver(PC3270_driver_far) < 0)
      ABORT("PC 3270");
   if (registerfarbgifont(gothic_font_far) < 0)
      ABORT("Gothic");
   if (registerfarbgifont(sansserif_font_far) < 0)
      ABORT("SansSerif");
   if (registerfarbgifont(small_font_far) < 0)
      ABORT("Small");
   if (registerfarbgifont(triplex_font_far) < 0)
      ABORT("Triplex");
   driver = DETECT;
   initgraph(&driver, &mode, "c:\\tc\\BGI");
   error = graphresult();
   if (error != grOk)
   {
      printf("Graphics error: %s\n", grapherrormsg(error));
      exit(error);
   }
}

#endif GR_INIT