Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » [A5] Game's Window not Showing

This thread is locked; no one can reply to it. rss feed Print
[A5] Game's Window not Showing
Franc[e]sco
Member #12,605
February 2011

Hi, I have just set up allegro5 with codeblocks by compiing it myself and tried to compile an example to see if it worked. The generated program works fine for my friends, but on my computer the game window is always minimized and can't be maximized. I have no idea why I'm getting this weird bug.

I am running Windows 7 x64, if that helps.

KeithS
Member #11,950
May 2010

Franc[e]sco,

I cannot promise to be of much assistance tracking the root of the problem, but I think anyone is going to want the following to be specified before they can help you;

1. Is the build of the program that works on your friends' computer an executable, compiled on your computer, that you have given them? Or is it your code compiled on their respective computers with their own installations of A5?

2. Are they all using Win 7 x64?

3. Post the code, and perhaps an executable compiled on your comp, too, if the site allows that.

I have Win 7 / x64 as an alternate OS on my second computer. Don't use it much at all (Win 7 or the other computer) but if you do as point (3) above I can at least start to help you trouble shoot, and then maybe someone who can really help you might take an interest in your problem.:)

* * * * * * * * * * *

My Noobish Blog

Franc[e]sco
Member #12,605
February 2011

We were both using win7 x64, and the executable i sent to my friend was compiled on my pc. The sourcecode is the bouncer example from the wiki:

#SelectExpand
1#include <stdio.h> 2#include <allegro5/allegro.h> 3 4const float FPS = 60; 5const int SCREEN_W = 640; 6const int SCREEN_H = 480; 7const int BOUNCER_SIZE = 32; 8 9int main(int argc, char **argv) 10{ 11 ALLEGRO_DISPLAY *display = NULL; 12 ALLEGRO_EVENT_QUEUE *event_queue = NULL; 13 ALLEGRO_TIMER *timer = NULL; 14 ALLEGRO_BITMAP *bouncer = NULL; 15 float bouncer_x = SCREEN_W / 2.0 - BOUNCER_SIZE / 2.0; 16 float bouncer_y = SCREEN_H / 2.0 - BOUNCER_SIZE / 2.0; 17 float bouncer_dx = -4.0, bouncer_dy = 4.0; 18 bool redraw = true; 19 20 if(!al_init()) { 21 fprintf(stderr, "failed to initialize allegro!\n"); 22 return -1; 23 } 24 25 timer = al_create_timer(1.0 / FPS); 26 if(!timer) { 27 fprintf(stderr, "failed to create timer!\n"); 28 return -1; 29 } 30 31 display = al_create_display(SCREEN_W, SCREEN_H); 32 if(!display) { 33 fprintf(stderr, "failed to create display!\n"); 34 al_destroy_timer(timer); 35 return -1; 36 } 37 38 bouncer = al_create_bitmap(BOUNCER_SIZE, BOUNCER_SIZE); 39 if(!bouncer) { 40 fprintf(stderr, "failed to create bouncer bitmap!\n"); 41 al_destroy_display(display); 42 al_destroy_timer(timer); 43 return -1; 44 } 45 46 al_set_target_bitmap(bouncer); 47 48 al_clear_to_color(al_map_rgb(255, 0, 255)); 49 50 al_set_target_bitmap(al_get_backbuffer(display)); 51 52 event_queue = al_create_event_queue(); 53 if(!event_queue) { 54 fprintf(stderr, "failed to create event_queue!\n"); 55 al_destroy_bitmap(bouncer); 56 al_destroy_display(display); 57 al_destroy_timer(timer); 58 return -1; 59 } 60 61 al_register_event_source(event_queue, al_get_display_event_source(display)); 62 63 al_register_event_source(event_queue, al_get_timer_event_source(timer)); 64 65 al_clear_to_color(al_map_rgb(0,0,0)); 66 67 al_flip_display(); 68 69 al_start_timer(timer); 70 71 while(1) 72 { 73 ALLEGRO_EVENT ev; 74 al_wait_for_event(event_queue, &ev); 75 76 if(ev.type == ALLEGRO_EVENT_TIMER) { 77 if(bouncer_x < 0 || bouncer_x > SCREEN_W - BOUNCER_SIZE) { 78 bouncer_dx = -bouncer_dx; 79 } 80 81 if(bouncer_y < 0 || bouncer_y > SCREEN_H - BOUNCER_SIZE) { 82 bouncer_dy = -bouncer_dy; 83 } 84 85 bouncer_x += bouncer_dx; 86 bouncer_y += bouncer_dy; 87 88 redraw = true; 89 } 90 else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { 91 break; 92 } 93 94 if(redraw && al_is_event_queue_empty(event_queue)) { 95 redraw = false; 96 97 al_clear_to_color(al_map_rgb(0,0,0)); 98 99 al_draw_bitmap(bouncer, bouncer_x, bouncer_y, 0); 100 101 al_flip_display(); 102 } 103 } 104 105 al_destroy_bitmap(bouncer); 106 al_destroy_timer(timer); 107 al_destroy_display(display); 108 al_destroy_event_queue(event_queue); 109 110 return 0; 111}

Here's an executable compiled on my pc ---> http://localhostr.com/file/OHvcjz9/allegro5_test.exe

It works for all my friends, but on my pc the window is like, stuck minimized. If i move the mouse over the task bar icon i can see the program working corretly in the preview thing :/.

Ikkarub
Member #12,637
March 2011

I've just had the same symptoms on the same OS - turned out the display window was being created off the visible screen area by default. Specifying a position with al_set_new_window_position sorted it.

cgman24
Member #12,536
February 2011
avatar

In your Display Settings, do you have multiple monitors enabled? On a recent install to another computer, a second monitor was enabled by default for some reason, even though there wasn't one. It caused some weird problems similar to this one.

Franc[e]sco
Member #12,605
February 2011

@Ikkarub:
THANKS! It worked! al_set_new_window_position(0,0); before initializing allegro fixes it!

Matthew Leverton
Supreme Loser
January 1999
avatar

Do you have two display adapters? What does Windows control panel show for enabled monitors? What does al_get_new_window_position(&x, &y) report if you do not call set window position?

Franc[e]sco
Member #12,605
February 2011

No, this computer is a laptop and it doesnt have multiple displays or settings for muultiple displays.
Getting the window position returns max positive signed int for both X and Y (2147483650).
It's pretty weird. I guess it's a problem with this particular machine. I'll just make sure i set the window position manually :)

Peter Wang
Member #23
April 2000

This may or may not be fixed in 5.0 SVN. It would be nice if you checked and tell us the result.

Go to: