Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

allegro + iostream???

Ostatnio zmodyfikowano 2009-02-17 22:05
Autor Wiadomość
maro
Temat założony przez niniejszego użytkownika
allegro + iostream???
» 2009-02-17 13:55:27
Witam jestem tu nowy, i wczoraj zacząłem zabawę z C++.

Mianowicie chodzi mi o używanie Allegro z iostream...
Chcę wyświetlić pole do wpisania nazwy usera, a tu błąd...
C/C++
#include <allegro.h>
#include <iostream>

using namespace std;

int main() {
    char user_name;
    allegro_init();
    install_keyboard();
    set_color_depth( 32 );
    set_gfx_mode( GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0 );
    set_palette( default_palette );
    clear_to_color( screen, makecol( 128, 128, 128 ) );
    BITMAP * bg = NULL;
    bg = load_bmp( "bg.bmp", default_palette );
    if( !bg ) {
        set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 );
        allegro_message( "ERROR: Can't open a bg!!!" );
        allegro_exit();
        return 0;
    }
    blit( bg, screen, 0, 0, 0, 0, bg->w, bg->h );
    textout_ex( screen, font, "Witaj w miniTeacher!", 20, 20, makecol( 255, 255, 255 ), - 1 );
    textout_ex( screen, font, "Podaj twoje imie:", 20, 50, makecol( 255, 255, 180 ), - 1 );
    textout_ex( screen, font, cin >> user_name, 20, 100, makecol( 255, 255, 180 ), - 1 );
   
    //dalsza część kodu...
   
    readkey();
   
    allegro_exit();
    return 0;
}
END_OF_MAIN();
log:

Kompilator: Default compiler
Building Makefile: "C: \Documents and Settings\Robert\Moje dokumenty\programy\miniTeacher\Makefile.win"
Wykonywanie  make...
make.exe -f "C: \Documents and Settings\Robert\Moje dokumenty\programy\miniTeacher\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"D:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"D:/Dev-Cpp/include/c++/3.4.2/backward"  -I"D:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"D:/Dev-Cpp/include/c++/3.4.2"  -I"D:/Dev-Cpp/include"  -DALLEGRO_STATICLINK

main.cpp: In function `int _mangled_main()':
main.cpp:25: error: invalid conversion from `void*' to `const char*'
main.cpp:25: error:   initializing argument 3 of `void textout_ex(BITMAP*, const FONT*, const char*, int, int, int, int)'

make.exe: *** [main.o] Error 1

Wykonanie zakończone
P-4270
maro
Temat założony przez niniejszego użytkownika
thx
» 2009-02-17 15:57:24
dzięki, tylko jeden problem... czemu nie mogę wpisać po kompilacji tekstu do tego pola???
P-4271
DeBugger
» 2009-02-17 16:59:17
Bo jest to program okienkowy(prawie okienkowy).
Chyba można było włączyć jakoś konsolę, ale siedzę na Linuxie, więc mnie ten problem nie dotyczy.
P-4272
DejaVu
» 2009-02-17 19:58:06
Nie można łączyć cin/cout'a z allegro.
P-4277
Skala
» 2009-02-18 12:44:00
ha haha :D jaka wojna na forum :)
przyczyny nie znam kasowania postów ale myślę że Pan Piotr powinien dać szanse na wypowiedzenie się innym osobom :)

//JCJ pisze: Proszę nie offtopować. I nie używać wulgaryzmów w postach(choć sam nie moderuje postów manfreda). Od teraz nie piszemy słowa(wulgaryzmu) zaczynającego się na `ch` i kończącego się na `a`, bo to też przeklenśtwo. xD :)
P-4282
pekfos
» 2009-02-18 16:55:17
Temat już chyba został wyczerpany: można łączyć allegro z konsolą i zostało podane jak to zrobić. teraz niech autor tematu powie czy ma jakieś błędy przy łączeniu.

//do JCJ: chańba, chmara to też wulgaryzmy?
lepiej by było to trochę sprecyzować
//JCJ pisze: Sprecyzowałem w tamtym poście(od Skali). I nie chwytać mnie za słówka. :)
P-4291
manfred
» 2009-02-17 14:36:17
C/C++
#include <iostream>
#include <string>
#include <allegro.h>

using namespace std;

int main()
{
    allegro_init();
    install_keyboard();
    set_color_depth( 32 );
    set_gfx_mode( GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0 );
    set_palette( default_palette );
    clear_to_color( screen, makecol( 128, 128, 128 ) );
    BITMAP * bg = 0;
    bg = load_bmp( "bg.bmp", default_palette );
    if( !bg )
    {
        set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 );
        allegro_message( "ERROR: Can't open a bg!!!" );
        allegro_exit();
        return 0;
    }
    blit( bg, screen, 0, 0, 0, 0, bg->w, bg->h );
    textout_ex( screen, font, "Witaj w miniTeacher!", 20, 20, makecol( 255, 255, 255 ), - 1 );
    textout_ex( screen, font, "Podaj twoje imie:", 20, 50, makecol( 255, 255, 180 ), - 1 );
    string user_name;
    getline( cin, user_name );
    textout_ex( screen, font, user_name.c_str(), 20, 100, makecol( 255, 255, 180 ), - 1 );
   
    //dalsza część kodu...
   
    readkey();
   
    allegro_exit();
    return 0;
}
END_OF_MAIN();
P-18747
manfred
» 2009-02-17 22:04:25
>>dubla<<
P-18749
« 1 » 2
  Strona 1 z 2 Następna strona