R6010 -abort() has been called
ChaoticCacti

Now I'm really confused! :P

Things have been going great with Allegro 5, but all of the sudden I've begun to get this message every time I run something.

-----------------------------------------------
Debug Error!

Program: ...visual studio
2010\Projects\UsingTimers\Debug\UsingTimers.exe

R6010
- abort() has been called

(Press Retry to debug the application
-----------------------------------------------

Every time that I click Retry it directs me to a file named crt0msg.c and this code in particular:

#SelectExpand
1if (rterrnum != _RT_CRNL && rterrnum != _RT_BANNER && rterrnum != _RT_CRT_NOTINIT) 2 { 3 switch (_CrtDbgReportW(_CRT_ERROR, NULL, 0, NULL, error_text)) 4 { 5 case 1: _CrtDbgBreak(); msgshown = 1; break; 6 case 0: msgshown = 1; break; 7 } 8 }

Not sure whats going on here. If you need my code just say so.

Trent Gamblin

abort is called by the debug version of Allegro when something catastropic has happened (calling destroy on a NULL bitmap, bitmap width less than zero, stuff like that.) If you're using the Debug libraries that could be the cause.

ChaoticCacti

In that case here's my code, if there's something wrong could you tell me please?

#SelectExpand
1#include <allegro5\allegro.h> 2#include <allegro5\allegro_font.h> 3#include <allegro5\allegro_ttf.h> 4#include <allegro5\allegro_primitives.h> 5 6#define ScreenWidth 800 7#define ScreenHeight 600 8 9enum KEYS{UP, DOWN, LEFT, RIGHT}; 10 11int main() 12{ 13 bool done = false; 14 int x = ScreenWidth / 2; 15 int y = ScreenHeight / 2; 16 int FPS = 60; 17 18 bool keys[4] = {false, false, false, false}; 19 20 if(!al_init()) 21 return -1; 22 23 ALLEGRO_DISPLAY *display = NULL; 24 display = al_create_display(ScreenWidth, ScreenHeight); 25 26 if(!display) 27 return -1; 28 29 ALLEGRO_EVENT_QUEUE *event_queue = NULL; 30 event_queue = al_create_event_queue(); 31 32 ALLEGRO_TIMER *timer = NULL; 33 timer = al_create_timer(1.0 / FPS); 34 35 al_register_event_source(event_queue, al_get_keyboard_event_source()); 36 al_register_event_source(event_queue, al_get_display_event_source(display)); 37 al_register_event_source(event_queue, al_get_timer_event_source(timer)); 38 39 al_start_timer(timer); 40 41 while(!done) 42 { 43 ALLEGRO_EVENT ev; 44 al_wait_for_event(event_queue, &ev); 45 46 if(ev.type == ALLEGRO_EVENT_KEY_DOWN) 47 { 48 switch(ev.keyboard.keycode) 49 { 50 case ALLEGRO_KEY_UP: 51 keys[UP] = true; 52 break; 53 case ALLEGRO_KEY_DOWN: 54 keys[DOWN] = true; 55 break; 56 case ALLEGRO_KEY_RIGHT: 57 keys[RIGHT] = true; 58 break; 59 case ALLEGRO_KEY_LEFT: 60 keys[LEFT] = true; 61 break; 62 } 63 } 64 else if(ev.type == ALLEGRO_EVENT_KEY_UP) 65 { 66 switch(ev.keyboard.keycode) 67 { 68 case ALLEGRO_KEY_UP: 69 keys[UP] = false; 70 break; 71 case ALLEGRO_KEY_DOWN: 72 keys[DOWN] = false; 73 break; 74 case ALLEGRO_KEY_RIGHT: 75 keys[RIGHT] = false; 76 break; 77 case ALLEGRO_KEY_LEFT: 78 keys[LEFT] = false; 79 break; 80 } 81 } 82 else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) 83 { 84 done = true; 85 } 86 else if(ev.type == ALLEGRO_EVENT_TIMER) 87 { 88 y -= keys[UP] * 10; 89 y += keys[DOWN] * 10; 90 x -= keys[LEFT] * 10; 91 x += keys[RIGHT] * 10; 92 } 93 94 al_draw_filled_rectangle(x, y, x + 30, y + 30, al_map_rgb(0, 255, 0)); 95 al_flip_display(); 96 al_clear_to_color(al_map_rgb(0, 0, 0)); 97 } 98 99 al_destroy_display(display); 100 101 return 0; 102}

Matthew Leverton

You didn't call al_init_primitives_addon().

ChaoticCacti

I included the addon into my code and got rid of the 2 includes that I didn't need: '#include <allegro5\allegro_ttf.h>' and '#include <allegro5\allegro_font.h>'
and I STILL get the abort message.

Could it have anything to do with my additional dependencies? I'm pretty sure that this is correct though.

allegro-5.0.6-monolith-md-debug.lib

That's the only thing that I have in it, is there anything wrong?

bamccaig

I can't tell if you understood Matthew Leverton or not, but I suspect not. You're using the primitives addon (i.e., al_draw_filled_rectangle), but you didn't initialize the addon first (i.e., al_init_primitives_addon). If you call that function during your initialization then all should be good (unless there's another problem). Are you doing this now?

Also, read this: http://wiki.allegro.cc/index.php?title=Return_values.

ChaoticCacti

I had that written before.

Now that I read the wiki page that you posted I'm wondering, does that mean that I need to put:

#SelectExpand
1if(!al_init()) 2 exit(1);

or something else? That's the part that's confusing me.

EDIT: Thank you guys for making me look at the return values. Because once I looked at those I looked at the rest of my code and when I did that, I realized that I didn't install the keyboard! Thanks again!

--Cactus

Matthew Leverton
Thread #610141. Printed from Allegro.cc