Hello guys,
someone can explain me how to use the void al_set_new_display_flags(int flags) function?
because i put it in the main, and when i wanted to enter the parameters (ALLEGRO_WINDOWED), gives me an error (i thing because in the main i can't put a function...) and when i put it out of the main gave me another error... Hahahah, anyway, thanks!
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);
Don't use || but use | instead.
Thanks, I wrote that too quickly and didn't notice the typo.
The code will be like this?
int main(int argc, char * argv[]) {
al_init();
al_create_display;
al_set_new_display_flags(ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE); //shows how to combine flags
ALLEGRO_DISPLAY *display = al_create_display(800, 600);
al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_REQUIRE);
display = al_create_display(800, 600);
al_set_new_display_option;
return 0;
}
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...
Thanks!
More like this:
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
Thanks very much, works! But why i have two windows? Hahahah
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.)
Hahaha, thanks! The tutorial of the keyboard is amazing!