CCCPaste

tffFileRead.cpp

#include 
#include 
#include "tff.h"
 #include 
 #include 
 #include 
#include 

int main(int argc, char* args[]){

    if(SDL_Init(SDL_INIT_EVERYTHING) < 0){
        printf("Failed to initialize SDL!\n");
        return 0;
    }


    Backbuffer = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE);
    if(TTF_Init() == -1)
        return 0;

    Font = TTF_OpenFont("fonts/Gothikka-bold.ttf", FS());
    if(Font == NULL){
        printf("Failed to load font!\n");
        TTF_CloseFont(Font);
        TTF_Quit();
        SDL_Quit();

        return 0;
    }

    SDL_WM_SetCaption("Outline Font", NULL);

 //   int counter = 1000;

    while(ProgramIsRunning()){
        SDL_FillRect(Backbuffer, NULL, 0);

   //     counter--;
   //     if(counter < 0){
           // counter = 1000;
   //            TTF_CloseFont(Font);
    //           TTF_Quit();
    //           SDL_Quit();
   //         }
    //    char buffer[64];
   //     const char *x="This program will explode in: %d ";
  //      sprintf(buffer, x , counter);
 //char *R="Raster Fonts Suck";
 //char *W="Outline Fonts FTW";
//	  char *text="who knows";
std::string text;
 	  std::fstream newfile;
 	     newfile.open("text.txt",std::ios::in); 
 	
   if (newfile.is_open()){   
      std::string tp;
           int count=0;
      while(getline(newfile, tp)){ 
		  text=tp;
		  char* f = const_cast(text.c_str());

		  DrawTTFFonts(f,count);
		  SDL_Delay(2000);
          SDL_Flip(Backbuffer);
 count++;
      }
      		  SDL_Delay(2000);
      newfile.close(); //close the file object.
   }
// DrawTTFFonts(text,count);

        //DrawOutlineText(Backbuffer, R, 100, 100, Font, 255, 0, 0);
      //  DrawOutlineText(Backbuffer, W, 100,150, Font, 0, 255, 0);
      //  DrawOutlineText(Backbuffer, buffer, 100, 200, Font, 0, 0, 255);

       // SDL_Delay(20);
     //   SDL_Flip(Backbuffer);
    }

    TTF_CloseFont(Font);
    TTF_Quit();
    SDL_Quit();

    return 0;
}