// Example 'showres'
// Tommy Grandefors
// 2D32 Graphic library
// Beta v1.0
// January 1997

#include <graphix.hh>
#include <videodef.hh>

#include <iostream.h>
#include <conio.h>

#define NO_TRANSPARENCY	0 //We don't want a transparent bitmap

void UserText(void);

void main(void)
{
   UserText();
   
   Graphix myGfx; //Instantiate the main object
   Bitmap myBmp; //This object will hold the PCX picture
   Palette myPal; //Will hold the picture's palette
   
   //Set the lowest possible resolution
   if( myGfx.SetVideoMode(VGA256x224x256) < 0)
   {
      cout << "Can't initiate video mode" << endl;
      return;
   }
   
   myGfx.ClearVideoMemory(0);//Fill videomemory (all pages) with color black.
   
   if(myGfx.LoadPCX("picture.pcx", myBmp, myPal, NO_TRANSPARENCY,0) == -1) //Get picture
   {
      myGfx.SetVideoMode(TEXT);
      cout << "Can't find the file 'picture.pcx'" << endl;
      return;
   }
   
   myGfx.SetDrawPage(0);
   myGfx.SetVisiblePage(0);

   //See the file 'videodef.hh' for the different resolutions and read the '2D32 Programmer's Reference Guide'
   for(int i = 1; i < 22; i++) //Toggle through 21 different video modes
   { //I'm skipping the highest resolutions (1024x768 and 1280x1024)
      //Set the wanted resolution
      if( myGfx.SetVideoMode(i, 0) < 0 )
      {
	 myGfx.SetVideoMode(TEXT, 0);
	 cout << "Can't initiate video mode" << endl;
	 return;
      }

      myGfx.SetPalette(myPal); //Set active palette again every time you change mode.
      myGfx.DrawBitmap(0, 0, myBmp); //Draw bitmap on screen (at upper left corner)
      getch();
   }
   
   myGfx.SetVideoMode(TEXT); //Go back to text mode.
} //That's all folks!

void UserText(void)
{
   cout << "This example will show you some of the VGA/SVGA resolutions available." << endl;
   cout << "Some of the resolutions contains some bugs, but it won't kill your" << endl;
   cout << "computer." << endl;
   cout << "I have chosen not to show the two highest resolutiond (1024x768 and\n1280x1024 since your monitor may not support it!" << endl;
   cout << "\nPress a key to toggle between 21 different resolutions." << endl;
   getch();
}


