Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Fullscreen

This thread is locked; no one can reply to it. rss feed Print
Fullscreen
godzilla69
Member #15,495
February 2014
avatar

if (value == 1)
al_set_new_display_flags(ALLEGRO_FULLSCREEN);

Why doesn't this work?

I'm trying to do messagebox asking for fullscreen (yes/no)

torhu
Member #2,727
September 2002
avatar

You have to call al_create_display too ;)

godzilla69
Member #15,495
February 2014
avatar

so here is my source code:

The program is in progress as you can see.:) I'm beginner and just training.

#include<allegro5\allegro.h>
#include<allegro5\allegro_native_dialog.h>
#include<iostream>
#include<allegro5\allegro_ttf.h>
#include<allegro5\allegro_font.h>

#define ScreenWidth 800
#define ScreenHeight 600

int main ()
{

ALLEGRO_DISPLAY *display;

if(!al_init())
{
al_show_native_message_box(NULL, NULL,NULL, "Could not initialize Allegro 5", NULL, NULL);
}

display = al_create_display(800, 600);
al_set_window_title(display, "Test");
if(!display)
{
al_show_native_message_box(display, "Title", "plaa", "Could not create Allegro window", NULL, ALLEGRO_MESSAGEBOX_QUESTION);
}


int value = al_show_native_message_box(display, "Fullscreen?", "", "Do you want to go fullscreen?(This feature is unavailable at the moment)", NULL, ALLEGRO_MESSAGEBOX_YES_NO);

std::cout << value << std::endl;
if (value == 1)
al_set_new_display_flags(ALLEGRO_FULLSCREEN);

al_init_font_addon();
al_init_ttf_addon();

ALLEGRO_FONT *font = al_load_font("COMICATE.TTF", 48, NULL);
al_draw_text(font, al_map_rgb(44, 117, 255), ScreenWidth / 2, ScreenHeight/2, ALLEGRO_ALIGN_CENTRE, "MADE BY GODZILLA69");

al_rest(3.0);
al_destroy_display(display);
return 0;
}

Listopad
Member #15,486
February 2014

#SelectExpand
1... 2if (value == 1) 3{ 4al_set_new_display_flags(ALLEGRO_FULLSCREEN); 5ALLEGRO_DISPLAY_MODE disp_data; 6al_get_display_mode(N, &disp_data); 7display = al_create_display(disp_data.width, disp_data.height); 8} 9...

al_get_display_mode:
Retrieves a display mode. Display parameters should not be changed between a call of al_get_num_display_modes and al_get_display_mode. index must be between 0 and the number returned from al_get_num_display_modes-1. mode must be an allocated ALLEGRO_DISPLAY_MODE structure. This function will return NULL on failure, and the mode parameter that was passed in on success.
source: https://www.allegro.cc/manual/5/al_get_display_mode

godzilla69
Member #15,495
February 2014
avatar

nvm i got it working

Thanks for helping! :)

BTW, what does that number mean(N)?

al_get_display_mode(N, &disp_data);

jmasterx
Member #11,410
October 2009

It is the index. There are many display modes. You need to fetch them 1 at a time.

godzilla69
Member #15,495
February 2014
avatar

Alright, Thank you very much ;)

Go to: