标题说明了一切。我正在(尝试)在Allegro 5中加载字体。运行此帖子底部的代码会导致打开一个空白的白色窗口(需要),但崩溃时“TSAGAME.EXE已停止工作”(不需要)。命令提示符返回一个随机的负数
“问题详情”对话位于:http://pastebin.com/Vc89wfwy
我测试了“font”变量(在第24行和第25行之间)。它不是空的。
C:\Users\Andrew\Desktop\TSAGAME>tree /F
C:.
│ allegro.log
│ main.cpp
│ Orbitron Black.ttf
│ pirulen.ttf
│ TSAGAME.cbp
│ TSAGAME.depend
│ TSAGAME.layout
│
├───bin
│ │ Orbitron Black.ttf
│ │
│ └───Debug
│ allegro-5.0.10-monolith-mt-debug.dll
│ Orbitron Black.ttf
│ TSAGAME.exe
│
└───obj
│ Orbitron Black.ttf
│
└───Debug
main.o
Orbitron Black.ttf
C:\Users\Andrew\Documents\GitHub\Game4TSA\allegro\allegro-5.0.10-mingw-4.5.0\lib\liballegro-5.0.10-monolith-mt-debug.a
C:\Users\Andrew\Documents\GitHub\Game4TSA\allegro\allegro-5.0.10-mingw-4.5.0\include
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <windowsx.h>
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_primitives.h>
#define ScreenWidth 800
#define ScreenHeight 600
int main()
{
al_init();
al_set_new_display_flags(ALLEGRO_WINDOWED);
ALLEGRO_DISPLAY *display = al_create_display(ScreenWidth, ScreenHeight);
al_set_window_position(display, 200, 100);
al_set_window_title(display, "Neat a demo");
al_init_font_addon();
al_init_ttf_addon();
ALLEGRO_FONT *font = al_load_font("C:/Users/Andrew/Desktop/TSAGAME/Orbitron Black.ttf", 10, 0);
al_draw_text(font, al_map_rgb(44, 117, 255), 0, 0, NULL, "www");
al_flip_display();
al_rest(10.0);
al_destroy_font(font);
al_destroy_display(display);
return 0;
}
想法?我已经挖了一段时间了。简而言之: xkcd, #979