|
al_create_display crash |
shadyvillian
Member #12,426
December 2010
|
When I create display a for the second time i keep getting a seg fault(note: this is a secondary window created on a mouse click). when the user exits the window i call al_destroy_display() then recreate it when they want to open it. what causes a a program to crash on al_create_display other than not calling al_init()? heres the call stack: #0 77450475 ntdll!TpWaitForAlpcCompletion() (C:\Windows\system32\ntdll.dll:??) heres the function: 1int _StatisticsModule::Initialize()
2{
3 Screen = NULL;
4 EventQueue = NULL;
5
6 int xpos = (al_get_display_width(al_get_current_display())/2)-272, ypos = (al_get_display_height(al_get_current_display())/2)-295;
7 int x = 0, y = 0;
8 al_get_window_position(al_get_current_display(), &x, &y);
9
10 Screen = al_create_display(545, 590); //crash on this line
11 if(!Screen)
12 {
13 return ShowMessageBox(al_get_current_display(), "Error", "Failed to create screen", ALLEGRO_MESSAGEBOX_ERROR);
14 }
15
16 al_set_window_position(Screen, x+xpos, y+ypos);
17 al_set_window_title(Screen, "Statistics");
18 al_set_target_backbuffer(Screen);
19
20 EventQueue = al_create_event_queue();
21 RedrawTimer = al_create_timer(1.0 / 60);
22
23 al_register_event_source(EventQueue, al_get_keyboard_event_source());
24 al_register_event_source(EventQueue, al_get_mouse_event_source());
25 al_register_event_source(EventQueue, al_get_display_event_source(Screen));
26 al_register_event_source(EventQueue, al_get_timer_event_source(RedrawTimer));
27
28 if(LoadContent() == -1)
29 {
30 return -1;
31 }
32
33 return 0;
34}
Software Engineer by day, hacker by night. |
|