0

我已经起床了 10 个小时试图弄清楚这一点。我尝试了一堆不同的库来尝试让 ogg 或 mp3 文件与 allegro 4 一起播放。我下载了 DUMB 库并将包含和 lib 文件复制到 mingw 各自的位置(我使用代码块)。将库安装到我的编译器的正确方法是什么?到目前为止,这是我的代码..

#include <allegro.h>
#include <iostream>
#include <stdlib.h>
#include <aldumb.h>


#include "CUSTOM_FUNCTIONS_HEADER.h"
#include "status_screen_functions_header.h"

#define WHITE makecol(255,255,255)

//General Game Settings
int volume = 128;
int pan = 128;
int pitch = 1000;

#
int main(int argc, char *argv[]){


    allegro_init();
    atexit(&dumb_exit);//initialize dumb
    dumb_register_stdfiles(); //tELL DUMB HOW TO OPEN FILES

    install_keyboard();
    if(install_sound(DIGI_AUTODETECT, MIDI_NONE, "") != 0){

        allegro_message("error initializing the sound system");

    }


    set_color_depth(16);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1100, 550, 0, 0);

    write_status_screen("Status$>_Allegro Engine Initialization Successfull");
//******************************************************************************//
//*****************************************************************************//
//Write code below this line since allegro has been initialized//
    BITMAP *dragon;
    BITMAP *main_title, *main_menu;
    BITMAP *buffer;

    /*Menu music*/
   // load_sample("OG_MUSIC\\straight_outta_compton_menu.ogg");

    //Setup Audiostream for Main Menu Music//

    write_status_screen("Status$> Loading OG Music Stream: \"Straight Outta Compton.OGG\"");


    DUH *myduh;

    myduh = dumb_load_it_quick("OG_MUSIC\\straight_outta_compton_menu.ogg");

    AL_DUH_PLAYER *dp = al_start_duh(myduh, 2, 0,
                                  volume, 4096, 48000);;

//logg_get_stream("straight_outta_compton_menu.ogg", volume, pan, true);



    SAMPLE *menu_guntrigger = load_sample("OG_MUSIC\\gun_menu_choose.wav");


    /*Menu count*/
    int menct = 0;

    buffer = create_bitmap(1100, 480);

    textprintf_ex(screen, font, 0, 0, WHITE, 0, "Resolution = %ix%i ", SCREEN_W, SCREEN_H);

    dragon = load_bitmap("BITMAPS\\COMPTON_START_MENU_FADED_TWO.bmp", NULL);
    main_title = load_bitmap("BITMAPS\\OGM_TITLE.bmp", NULL);
    main_menu = load_bitmap("BITMAPS\\MAIN_MENU.bmp", NULL);


    write_status_screen("Status$>_Bitmaps loaded into memory!");
    write_status_screen("Status$> Loading OG Sound Effects......:");
    rest(650);



    rest(700);


    int frames_drawn = 0;

    while(!key[KEY_ESC]){



    /*Handle Controls First modulus 2 to make selection easier, every second frame, keypress is captured. DO NOT DO THIS FOR ACTUAL GAMEPLAY*/

        if(key[KEY_UP] && frames_drawn % 2 == 0){
            play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
            menct--;
        } else if (key[KEY_DOWN] && frames_drawn % 3 == 0){
            play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
            menct++;
        }
        if (menct > 3){
            play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
            menct = 0;
        }else if (menct <0){
            play_sample(menu_guntrigger, volume, pan, pitch, FALSE);
            menct = 3;
        }
        rest(10);


        //Erase everything
        clear(buffer);

        //status box
        rectfill(screen, 0, 480, 1100, 483, WHITE);

        /*Draw the frame based on user input*/
        draw_sprite(buffer, dragon, 0, 0);
        draw_sprite(buffer, main_title, 315, 10);
        drawframe(buffer, main_menu, 485, 145, 332, 305, 0, 0, 4, menct);
        //blit(main_title, screen, 0, 0, 50, 50, 540, 96);
        //masked_blit(main_title, screen, 0, 0, 50, 50, 540, 96);

        //masked_blit(source, dest, framex, framey, x, y, width, height);

        textprintf_ex(buffer, font, 900, 470, WHITE, 0, "Written By: Kelvin Silva", bitmap_color_depth(screen));

        textprintf_ex(buffer, font, 0, 470, WHITE, 0, "Frames Drawn: %i", frames_drawn);

        blit(buffer, screen, 0, 0, 0, 0, 1100, 480);

        /*pollduh*/
        al_poll_duh(dp);
        /*Wait for vsync, rest a little, update framecount and prompt for more input*/
        vsync();
        frames_drawn++;
        rest(50);
    }

    write_status_screen("Status$>_Game Loop Ended...");

    clear_status_screen();
//NOTE NEED TO SETUP MEMORY DESTRUCTION


    destroy_bitmap(dragon);
    destroy_bitmap(main_title);
    destroy_bitmap(buffer);

    allegro_exit();

    return 0;
}
END_OF_MAIN()



d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_start_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|48|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|49|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|62|undefined reference to `play_audio_stream'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|69|undefined reference to `voice_set_priority'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|74|undefined reference to `stop_audio_stream'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_stop_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|92|undefined reference to `stop_audio_stream'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_pause_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|103|undefined reference to `voice_stop'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_resume_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|113|undefined reference to `voice_start'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_duh_set_priority':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|123|undefined reference to `voice_set_priority'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_poll_duh':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|156|undefined reference to `get_audio_stream_buffer'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|166|undefined reference to `free_audio_stream_buffer'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|167|undefined reference to `stop_audio_stream'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|179|undefined reference to `free_audio_stream_buffer'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_duh_encapsulate_sigrenderer':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|208|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|209|undefined reference to `al_assert'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|215|undefined reference to `play_audio_stream'|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|222|undefined reference to `voice_set_priority'|
d:\programs\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\..\..\..\libaldmd.a(alplay.o)||In function `al_duh_decompose_to_sigrenderer':|
D:\Users\Kelvin_Silva\Downloads\dumb-0.9.3\dumb-0.9.3\src\allegro\alplay.c|248|undefined reference to `stop_audio_stream'|
||=== Build finished: 18 errors, 0 warnings (0 minutes, 0 seconds) ===|
4

1 回答 1

0

DUMB 要求您链接两个库,即核心 libdumb 和 aldumb “胶水”。看起来你只与后者链接。订单也很重要。

请注意,DUMB 用于播放 MOD 文件(以及各种变体)。如果你想要 ogg 支持,如果你安装了官方的 ogg 库,它会内置在 Allegro 4.4 中。

此外,如果您刚刚开始,那么您应该真正使用 Allegro 5。版本 4 不再受真正支持,并且在现代操作系统上也无法正常工作。

于 2013-08-06T14:33:55.927 回答