home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_02 / 1n02010a < prev    next >
Text File  |  1990-07-09  |  2KB  |  72 lines

  1.  
  2. ==============================================================================
  3.     Listing 1. Hello World
  4. ==============================================================================
  5.  
  6.  
  7. /*File:┐      D:\TIGAPGMS\HELLO\HELLO.CPP      04/21/1990  08:48:34
  8. *-----------------------------------------------------------------------
  9. *-----------------------------------------------------------------------*/
  10.  
  11.  
  12.     #include <stdio.h>
  13.     
  14.     #include <typedefs.hpp>
  15. extern "C"
  16. {
  17.     #include <tiga.h>
  18.     #include <extend.h>
  19. }
  20.  
  21.  
  22. #define XSIZE    (config.mode.disp_hres)
  23. #define YSIZE    (config.mode.disp_vres)
  24. #define    XOR    10
  25.  
  26. CONFIG config;
  27.  
  28. int        main( int argc, char argv[ ] )
  29. {
  30.   
  31.   if( set_videomode( TIGA, INIT | CLR_SCREEN ) )
  32.   { 
  33.     if( install_primitives( ) >= 0 )
  34.     {
  35.  
  36.         //Get display size
  37.       get_config( &config );
  38.       set_fcolor( WHITE );
  39.       set_bcolor( BLACK );
  40.  
  41.         //Center message on screen
  42.       char* hello = "   H e l l o   W o r l d   ";
  43.       int tw = text_width( hello );
  44.       text_out( (XSIZE-tw)/2, YSIZE/2, hello );
  45.  
  46.         //Draw 10 surrounding boxes
  47.       set_ppop( XOR );
  48.       for( int i = 1; i <= 10; i++ )
  49.       {
  50.         int w = tw + (XSIZE-tw) * i / 10;
  51.         int h = YSIZE * i / 10;
  52.         fill_rect( w, h, (XSIZE-w)/2, (YSIZE-h)/2 );
  53.       }
  54.     }
  55.     else
  56.     {
  57.       printf( "ERROR: Can not load TIGA primitives.\n" );
  58.       return 1;
  59.     }
  60.     set_videomode( PREVIOUS, NO_INIT );
  61.   }
  62.   else
  63.   {
  64.     printf( "ERROR: Please install TIGA and try again.\n" );
  65.     return 2;
  66.   }
  67.   return 0;
  68. }
  69.  
  70. ==============================================================================
  71.  
  72.