简体   繁体   English

Allegro draw_sprite()

[英]Allegro draw_sprite()

I have a 114x114 bitmap called "x.bmp" in my debug folder and this simple code 我的调试文件夹中有一个114x114位图,称为“ x.bmp”,此简单代码

#include <allegro.h>

BITMAP *Sprite;

int main(){
    allegro_init();
    install_keyboard();
    set_color_depth(16);
    set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);

    Sprite = load_bitmap( "x.bmp", NULL);

    acquire_screen();
    draw_sprite(screen, Sprite, 50, 50);
    release_screen();

    readkey();

    return 0;

}   
END_OF_MAIN();

But it freezes up and looks like this 但是它冻结了,看起来像这样 冻结屏幕

But when I just run the AllegroTest.exe file via windows explorer it works... 但是当我只是通过Windows资源管理器运行AllegroTest.exe文件时, 它可以工作...

I am using Allegro 4.2.3 and MSVC++ 2008 我正在使用Allegro 4.2.3和MSVC ++ 2008

Edit: here's something interesting I get in my debug output window: 编辑:这是我在调试输出窗口中得到的一些有趣的东西:

al-gfx INFO: The driver will wait for vsync.
al-gfx INFO: set_gfx_card success for 640x480x16.
Assert failed at line 250 of c:\users\matthew\desktop\allegro\4.2\include\allegro\inline\draw.inlThe thread 'Win32 Thread' (0x137c) has exited with code -805306369 (0xcfffffff).
The thread 'Win32 Thread' (0x25b8) has exited with code -805306369 (0xcfffffff).

c:\\users\\matthew doesn't exist!!! c:\\ users \\ matthew不存在!!! I have no user named matthew? 我没有名为matthew的用户吗?

The bitmap most likely can't be loaded. 位图很可能无法加载。

When you start an application from the Visual Studio debugger, the default working directory is the project directory . 从Visual Studio调试器启动应用程序时,默认的工作目录是项目目录 When you start an application via explorer, the working directory is the directory the executable is in. Normally, the project directory will be ...\\SolutionName\\ProjectName\\ . 通过资源管理器启动应用程序时,工作目录是可执行文件所在的目录。通常,项目目录为... \\ SolutionName \\ ProjectName \\

When you provide a relative path, ie x.bmp , the application will search the working directory for it, followed by some other directories, such as those listed in the PATH environment variable. 当您提供相对路径(即x.bmp ,应用程序将在工作目录中搜索它,然后在其他目录中进行搜索,例如PATH环境变量中列出的目录。 It's usually preferable to give an absolute path, if possible. 如果可能的话,通常最好给出一个绝对路径。

Most likely your image file is in the same directory as the executable, but this directory isn't the project directory. 您的图像文件很可能与可执行文件位于同一目录中,但是此目录不是项目目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM