error kurde biblioteka allegro

0

próbuję skąpilować kod w C++ ze strony
http://www.gamedev.net/page/resources/_/technical/game-programming/text-input-in-an-allegro-game-r2130

pozmieniałm tak, że kompiluje ale niestety nie wyświetla takie błędy:
[Linker error] undefined reference to `WinMain@16'
ld returned 1 exit status
[Build Error] [Projekt1.exe] Error 1
oto kod

#include <allegro.h>
#include <string>

using namespace std;

#define WHITE makecol(255, 255, 255)

int main()
{
   // typical Allegro initialization
   allegro_init();
   install_keyboard();
   set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0);

   // all variables are here
   BITMAP* buffer = create_bitmap(320, 240); // initialize the double buffer
   string  edittext;                         // an empty string for editting
   string::iterator iter = edittext.begin(); // string iterator
   int     caret  = 0;                       // tracks the text caret
   bool    insert = true;                    // true if text should be inserted
   
   // the game loop
   do
   {
      while(keypressed())
      {
         int  newkey   = readkey();
         char ASCII    = newkey & 0xff;
         char scancode = newkey >> 8;

         // a character key was pressed; add it to the string
         if(ASCII >= 32 && ASCII <= 126)
         {
            // add the new char, inserting or replacing as need be
            if(insert || iter == edittext.end())
               iter = edittext.insert(iter, ASCII);
            else
               edittext.replace(caret, 1, 1, ASCII);

            // increment both the caret and the iterator
            caret++;
            iter++;
         }
         // some other, "special" key was pressed; handle it here
         else
            switch(scancode)
            {
               case KEY_DEL:
                  if(iter != edittext.end()) iter = edittext.erase(iter);
               break;

               case KEY_BACKSPACE:
                  if(iter != edittext.begin())
                  {
                     caret--;
                     iter--;
                     iter = edittext.erase(iter);
                  }
               break;
            
               case KEY_RIGHT:
                  if(iter != edittext.end())   caret++, iter++;
               break;
            
               case KEY_LEFT:
                  if(iter != edittext.begin()) caret--, iter--;
               break;
            
               case KEY_INSERT:
                  insert = !insert;
               break;

               default:

               break;
            }
      }
      
      // clear screen
      clear(buffer);

      // output the string to the screen
      textout_ex(buffer, font, edittext.c_str(), 10, 10, makecol(0, 0, 255), -1);

      // output some stats using Allegro's printf functions
      
      // draw the caret
      vline(buffer, caret * 8, 8, 18, WHITE);

      // blit to screen
      blit(buffer, screen, 0, 0, 0, 0, 320, 240);

   }while(!key[KEY_ESC]); // end of game loop
   
   // clean up
   destroy_bitmap(buffer);
   set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);   
   allegro_exit();
   
   
   return 0;
}

pozdrawiam

0

Najprawdopodobniej masz błędnie ustawione opcje linkera / źle utworzony projekt. Możesz też spróbować umieścić makro na koncu (za koncowa klamra main) END_OF_MAIN() .

0

dzięki teraz kompiluje,
możesz mi tylko jeszcze powiedzieć dlaczego ten program działa strasznie wolno?
mam namyśli to że od naciśnięcia klawiatury do wyświetlenia się na ekranie mija trochę czasu??
i jeszcze jedna sprawa
za każdym razem jak to odpalam to mi nie wiem jak to opisać dokładnie ale na sekundę całe moja kochane 17,3 cala staje się czarne, a dopiero potem się otwiera okno normalnie. O co cho?? to ja nie wiem:)

0

wy do czegoś takiego macie jakieś debugery czy to po prostu wiecie, że tam czegoś nie ma??

1 użytkowników online, w tym zalogowanych: 0, gości: 1