Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » text giving error

This thread is locked; no one can reply to it. rss feed Print
text giving error
heet shah
Member #15,908
March 2015

#include<allegro5/allegro.h>
#include<allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_primitives.h>
#include<allegro5/allegro_ttf.h>
#include<allegro5/allegro_font.h>
#include <iostream>
#include<stdlib.h>
using namespace std;

int main()
{
ALLEGRO_DISPLAY *display;
al_init();

al_init_font_addon();
al_init_ttf_addon();

display = al_create_display(900,600);
al_clear_to_color(al_map_rgb(0,0,0));
al_init_primitives_addon();
ALLEGRO_COLOR electricblue = al_map_rgb(44,100,255);
al_draw_line(300,0,300,600,electricblue,3.0);
al_draw_line(600,0,600,600,electricblue,3.0);
al_draw_line(900,0,900,600,electricblue,3.0);

ALLEGRO_FONT *font= al_load_font("A little sunshine.ttf",50,NULL);
al_draw_text(font,al_map_rgb(44,255,0),450,300,ALLEGRO_ALIGN_CENTRE,"game");

al_flip_display();
al_rest(3);

al_destroy_font(font);
al_destroy_display(display);
return 0;
}

the following code is giving error and the screen is not displayed but without text the screen is being displayed

StevenVI
Member #562
July 2000
avatar

Do you have any additional details on the error?
Add in some error checking to make sure that the font loaded successfully by the al_load_font call. My theory is that it is not, and you're passing a null font into the al_draw_text call.

__________________________________________________
Skoobalon Software
[ Lander! v2.5 ] [ Zonic the Hog v1.1 ] [ Raid 2 v1.0 ]

Go to: