Allegro and OpenGL fullscreen problem
Kamil Biały

Hi!

While i'm trying to set window in fullscreen mode, it flush me blank screen. I have no idea what it could be.

My main.c function:

#SelectExpand
1 2#include <stdio.h> 3#include <math.h> 4#include <allegro5/allegro.h> 5#include <allegro5/allegro_opengl.h> 6#include <GL/glu.h> 7#include "constants.h" 8#include "terrain.h" 9#include "camera.h" 10 11 12/// MAIN /////////////////////////////////////////////////////////////////////////// 13 14int main( int argc, char **argv ) 15{ 16 // Zmienne allegro 17 ALLEGRO_DISPLAY *display = NULL; 18 ALLEGRO_EVENT_QUEUE *event_queue = NULL; 19 ALLEGRO_TIMER *timer = NULL; 20 21 // Główne zmienne 22 T_TERRAIN *terrain = NULL; 23 T_CAMERA *camera = NULL; 24 25 // Pozostałe zmienne 26 bool runapp = true; 27 bool redraw = true; 28 29 // Inicjalizacja 30 al_init( ); 31 al_install_keyboard( ); 32 al_install_mouse( ); 33 34 // Okienko aplikacji 35 al_set_new_display_flags( ALLEGRO_OPENGL ); 36 al_set_new_display_flags( ALLEGRO_FULLSCREEN ); 37 display = al_create_display( 800, 600 ); 38 al_set_current_opengl_context( display ); 39 40 // Uzupełnianie głównych zmiennych 41 terrain = t_terrain_create( "map.tga" ); 42 t_terrain_scale( terrain, 3.0, 1.0, 1.0 ); 43 t_terrain_render( terrain, 0, 0, 0 ); 44 camera = t_camera_create( 0, 20, -1, 0, 0, 800, 600 ); 45 46 // Ustawienia OpenGL 47 glEnable(GL_DEPTH_TEST); 48 glShadeModel(GL_SMOOTH); 49 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); 50 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 51 glDisable(GL_CULL_FACE); 52 glViewport( 0, 0, 800, 600 ); 53 54 // Kolejka i czasomierz 55 event_queue = al_create_event_queue( ); 56 timer = al_create_timer( 1.0 / 50 ); 57 58 // Kolejka zdarzeń 59 al_register_event_source( event_queue, al_get_display_event_source( display ) ); 60 al_register_event_source( event_queue, al_get_keyboard_event_source( ) ); 61 al_register_event_source( event_queue, al_get_mouse_event_source( ) ); 62 al_register_event_source( event_queue, al_get_timer_event_source( timer ) ); 63 64 // Pętla główna 65 al_start_timer( timer ); 66 while( runapp ) 67 { 68 // Pobieranie i rozpoznawanie zdarzeń 69 ALLEGRO_EVENT event; 70 al_wait_for_event( event_queue, &event ); 71 72 switch( event.type ) 73 { 74 case ALLEGRO_EVENT_DISPLAY_CLOSE: runapp = false; break; 75 case ALLEGRO_EVENT_TIMER: redraw = true; break; 76 case ALLEGRO_EVENT_KEY_DOWN: 77 switch( event.keyboard.keycode ) 78 { 79 case ALLEGRO_KEY_W: t_camera_move( camera, T_CAMERA_MOVE_FORWARD, true ); break; 80 case ALLEGRO_KEY_S: t_camera_move( camera, T_CAMERA_MOVE_BACKWARD, true ); break; 81 case ALLEGRO_KEY_A: t_camera_move( camera, T_CAMERA_MOVE_LEFT, true ); break; 82 case ALLEGRO_KEY_D: t_camera_move( camera, T_CAMERA_MOVE_RIGHT, true ); break; 83 } 84 break; 85 case ALLEGRO_EVENT_KEY_UP: 86 switch( event.keyboard.keycode ) 87 { 88 case ALLEGRO_KEY_W: t_camera_move( camera, T_CAMERA_MOVE_FORWARD, false ); break; 89 case ALLEGRO_KEY_S: t_camera_move( camera, T_CAMERA_MOVE_BACKWARD, false ); break; 90 case ALLEGRO_KEY_A: t_camera_move( camera, T_CAMERA_MOVE_LEFT, false ); break; 91 case ALLEGRO_KEY_D: t_camera_move( camera, T_CAMERA_MOVE_RIGHT, false ); break; 92 } 93 break; 94 case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN: 95 t_camera_move( camera, T_CAMERA_ROTATE, true ); 96 t_camera_motion( camera, event.mouse.x, event.mouse.y, true ); 97 break; 98 case ALLEGRO_EVENT_MOUSE_BUTTON_UP: 99 t_camera_move( camera, T_CAMERA_ROTATE, false ); 100 break; 101 case ALLEGRO_EVENT_MOUSE_AXES: 102 t_camera_motion( camera, event.mouse.x, event.mouse.y, false ); 103 break; 104 } 105 106 // Renderowanie otoczenia 107 if( redraw && al_is_event_queue_empty( event_queue ) ) 108 { 109 redraw = false; 110 t_camera_display( camera ); 111 112 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 113 glCallList( terrain->glList ); 114 al_flip_display( ); 115 } 116 } 117 al_stop_timer( timer ); 118 119 // Destruktory allegro 120 al_destroy_display( display ); 121 al_destroy_event_queue( event_queue ); 122 al_destroy_timer( timer ); 123 124 // Destruktory główne 125 t_terrain_destroy( terrain ); 126 t_camera_destroy( camera ); 127 128 return 0; 129}

If you are interessed in, what is this - it's a terrain generator - http://www.aculo.pl/allegro - terrain_generator.rar file

Please, help :)

Jeff Bernard

al_set_new_display_flags expects a bitfield, so you need to pass all the options you want at once. Since you're calling it twice, it's only using the second call, which doesn't have OpenGL.

al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_FULLSCREEN);

Kamil Biały

Wow... I had no idea about it...
Thanks :)

Thread #612473. Printed from Allegro.cc