Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Error unning test code after installing allegro

This thread is locked; no one can reply to it. rss feed Print
Error unning test code after installing allegro
PamperBoy
Member #15,477
January 2014

Hi

I'm trying to get my test code to work. But get the following error:

Assertion failed!

Program: D:\Game Assignment\Game\Release\Game.exe File: allegro-git\addons\primitives\primitives.c Line: 76

Expression: addon_initialized

For information on blablablabla...

This is my code:

#SelectExpand
1// C++ ALLEGRO 5 MADE EASY TUTORIAL 6 - DRAWING PRIMITIVES 2// CODINGMADEEASY 3 4#include<allegro5/allegro.h> 5#include<allegro5/allegro_native_dialog.h> 6#include<allegro5/allegro_primitives.h> 7 8#define ALLEGRO_STATICLINK 9#define ScreenWidth 800 10#define ScreenHeight 600 11 12int main() 13{ 14 ALLEGRO_DISPLAY *display; 15 16 if(!al_init()) 17 { 18 al_show_native_message_box(NULL, NULL, "Error", "Could not initialize Allegro 5", NULL, ALLEGRO_MESSAGEBOX_ERROR); 19 return -1; 20 } 21 display = al_create_display(ScreenWidth, ScreenHeight); 22 23 if(!display) 24 { 25 al_show_native_message_box(NULL, NULL, "Error", "Could not create Allegro 5 display", NULL, ALLEGRO_MESSAGEBOX_ERROR); 26 return -1; 27 } 28 29 // You generally want to do this after you check to see if the display was created. If the display wasn't created then there's 30 // no point in calling this function 31 al_set_new_display_flags(ALLEGRO_WINDOWED); 32 al_set_window_position(display, 200, 100); 33 al_set_window_title(display, "CodingMadeEasy"); 34 35 ALLEGRO_COLOR electricBlue = al_map_rgb(44, 117, 255); 36 37 float points[8] = { 0, 0, 400, 100, 50, 200, ScreenWidth, ScreenHeight }; 38 39 al_draw_triangle(10, 10, 20, 10, 25, 50, al_map_rgb(255, 0, 0), 1.0); 40 //al_draw_filled_triangle(10, 10, 20, 10, 25, 50, al_map_rgb(255, 0, 0), 1.0); 41 42 al_draw_rounded_rectangle(10, 10, 100, 100, 5, 5, al_map_rgb(0, 255, 0), 3); 43 //al_draw_filled_rounded_rectangle(10, 10, 100, 100, 5, 5, al_map_rgb(0, 255, 0), 3); 44 45 al_draw_rectangle(400, 400, 450, 500, al_map_rgb(255, 98, 100), 9.0); 46 //al_draw_filled_rectangle(400, 400, 450, 500, al_map_rgb(255, 98, 100), 9.0); 47 48 al_draw_circle(ScreenWidth / 2, ScreenHeight / 2, 10, al_map_rgb(255, 255, 0), 3.0); 49 //al_draw_filled_circle(ScreenWidth / 2, ScreenHeight / 2, 10, al_map_rgb(255, 255, 0), 3.0); 50 51 al_draw_ellipse(ScreenWidth / 2, ScreenHeight - 100, 10, 5, al_map_rgb(255, 0, 255), 4.0); 52 //al_draw_filled_ellipse(ScreenWidth / 2, ScreenHeight - 100, 10, 5, al_map_rgb(255, 0, 255), 4.0); 53 54 al_draw_arc(10, ScreenHeight - 100, 10, 0, 4.0, al_map_rgb(255, 0, 0), 2.0); 55 56 al_draw_line(100, 500, 300, 500, electricBlue, 6.0); 57 58 al_draw_pixel(500, 500, electricBlue); 59 60 al_draw_spline(points, electricBlue, 1.0); 61 62 al_flip_display(); 63 al_rest(5.0); 64 al_destroy_display(display); 65 66 return 0; 67}

Does anyone know how to solve this?:-/

EDIT

i just google some more. After a while i found that i have to call al_init_primitives_addon. So i added this code just to check if it's there.

#SelectExpand
1if(!al_init_primitives_addon()) 2 { 3 al_show_native_message_box(NULL, NULL, "Error", "shit just got real", NULL, ALLEGRO_MESSAGEBOX_ERROR); 4 return -1; 5 }

So helpfull when they dont put this in the tutorials....

l j
Member #10,584
January 2009
avatar

Yes you require a call to al_init_primitives_addon() before using primitives drawing operations.

PamperBoy
Member #15,477
January 2014

Hahaha you posted just when i fixed that. But thanks anyway! ;D

Go to: