|
allegro window |
motyas
Member #16,305
April 2016
|
Hello guys, |
Chris Katko
Member #1,881
January 2002
|
Call: Before you set up the display with: So al_set_new_display_flags(ALLEGRO_WINDOWED || ALLEGRO_RESIZABLE); //shows how to combine flags ALLEGRO_DISPLAY *display = al_create_display(800, 600); You then check if display is valid. Display will be NULL if it cannot apply the flag you requested. There is also: Which works like: al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_REQUIRE); //Display will fail if it can't use this. //or al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST); //Display will still be built even if this doesn't work. al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_DONTCARE); //UNSET any previous requirements you set. (Rarely needed) ALLEGRO_DISPLAY *display = al_create_display(800, 600);
-----sig: |
Elias
Member #358
May 2000
|
Don't use || but use | instead. -- |
Chris Katko
Member #1,881
January 2002
|
Thanks, I wrote that too quickly and didn't notice the typo. -----sig: |
motyas
Member #16,305
April 2016
|
The code will be like this? int main(int argc, char * argv[]) { If its like this how i do to remain the window? (in SDL is with SDL_Display(time);) but i don't know how its with allegro... |
Chris Katko
Member #1,881
January 2002
|
More like this: 1int main(int argc, char * argv[]) {
2
3al_init();
4
5al_set_new_display_flags(ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE);
6al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_REQUIRE);
7
8ALLEGRO_DISPLAY *display = al_create_display(800, 600);
9
10//display = al_create_display(800, 600); // NO NO NO TYPO
11
12main_game_loop();
13
14return 0;
15}
16
17void main_game_loop()
18{
19bool done = false;
20while(!done) //each loop represents one frame of game logic
21 {
22 //do stuff including game logic, drawing a frame, etc
23 //if a key is pressed (like ESCAPE), set done = true, and loop will terminate.
24 }
25}
If you need to know how to do keyboard, start reading the basic Allegro 5 tutorials: https://wiki.allegro.cc/index.php?title=Basic_Keyboard_Example -----sig: |
motyas
Member #16,305
April 2016
|
Thanks very much, works! But why i have two windows? Hahahah |
Chris Katko
Member #1,881
January 2002
|
Whoops, I edited the posted code and left a typo in. There should only be one al_create_display. See the code now, I commented the line out. Also note that those settings function calls (al_set_new_display_flags and al_set_new_display_option) are not required. They're only required if you want their specific change. So you don't need the VSYNC one if you don't care about VSYNC. I only included them to demonstrate how to call them and in what order. (before creating the actual display.) -----sig: |
motyas
Member #16,305
April 2016
|
Hahaha, thanks! The tutorial of the keyboard is amazing! |
|