![]() |
|
[Allegro 5][Mac OS X]invalid fullscreen drawable |
•Kyhel•
Member #14,403
June 2012
|
Hi everybody. I've started playing with allegro for a few days now, and i must say i enjoyed it, even if i had to spend 10 hours to build the frameworks and everything ^^ I have done a little program for fun, but i can't get it to work in fullscreen mode. Here is my code : 1#include <iostream>
2#include <allegro5/allegro.h>
3#include "allegro5/allegro_image.h"
4#include "allegro5/allegro_opengl.h"
5#include "allegro5/allegro_audio.h"
6#include "allegro5/allegro_acodec.h"
7
8
9int main(int argc, char **argv) {
10
11 ALLEGRO_DISPLAY *display = NULL;
12 ALLEGRO_BITMAP *imageDragon = NULL, *imagePomme = NULL;
13 ALLEGRO_EVENT_QUEUE *eventQueue = NULL;
14 ALLEGRO_SAMPLE *sample=NULL;
15 ALLEGRO_SAMPLE_INSTANCE *sampleInstance = NULL;
16 float gainSample = 0.5;
17 float panSample = 0;
18 int curseurSample = 0;
19 int pommeX = 0, pommeY = 0;
20
21 bool continuer = true;
22
23 if(!al_init())
24 std::cout<<"impossible d'initialiser Allegro";
25 if(!al_init_image_addon())
26 std::cout<<"impossible d'initialiser AllegroImage";;
27 if(!al_install_keyboard())
28 std::cout<<"impossible d'initialiser le clavier";
29 if(!al_install_mouse())
30 std::cout<<"impossible d'initialiser la souris";
31 if(!al_install_audio())
32 std::cout<<"impossible d'initialiser le son";
33 if(!al_init_acodec_addon())
34 std::cout<<"impossible d'initialiser AllegroAcodec";
35
36 if(!al_reserve_samples(1))
37 std::cout<<"impossible de réserver un emplacement pour le son";
38
39 al_set_new_display_flags(ALLEGRO_FULLSCREEN);
40 display = al_create_display(1280,800);
41
42 al_set_mouse_xy(display, al_get_display_width(display)/2, al_get_display_height(display)/2);
43 al_hide_mouse_cursor(display);
44
45 ALLEGRO_MOUSE_STATE mouseState;
46 al_get_mouse_state(&mouseState);
47
48 pommeX = mouseState.x;
49 pommeY = mouseState.y;
50
51 imageDragon = al_load_bitmap("dragon.png");
52 if (imageDragon == NULL) {
53 std::cout<<"dragon.png n'a pas pu être chargé";
54 return -1;
55 }
56
57 imagePomme = al_load_bitmap("pomme.png");
58 if (imagePomme == NULL) {
59 std::cout<<"pomme.png n'a pas pu être chargé";
60 return -1;
61 }
62
63 sample = al_load_sample("Line Up The Stars.ogg");
64 if (sample == NULL) {
65 std::cout<<"Line Up The Stars.ogg n'a pas pu être chargé";
66 return -1;
67 }
68
69 sampleInstance = al_create_sample_instance(sample);
70 al_attach_sample_instance_to_mixer(sampleInstance, al_get_default_mixer());
71 al_set_sample_instance_playmode(sampleInstance, ALLEGRO_PLAYMODE_LOOP);
72 al_set_sample_instance_gain(sampleInstance, gainSample);
73
74 eventQueue = al_create_event_queue();
75
76 al_register_event_source(eventQueue, al_get_mouse_event_source());
77 al_register_event_source(eventQueue, al_get_keyboard_event_source());
78
79 al_draw_scaled_bitmap(imageDragon, 0, 0, al_get_bitmap_width(imageDragon), al_get_bitmap_height(imageDragon), 0, 0, al_get_display_width(display), al_get_display_height(display), 0);
80 al_draw_bitmap(imagePomme, pommeX - al_get_bitmap_width(imagePomme)/2, pommeY - al_get_bitmap_height(imagePomme)/2, 0);
81 al_flip_display();
82
83 al_play_sample_instance(sampleInstance);
84
85 while(continuer){
86
87 ALLEGRO_EVENT ev;
88
89 al_wait_for_event(eventQueue, &ev);
90
91 if(ev.type == ALLEGRO_EVENT_MOUSE_AXES){
92 pommeX = ev.mouse.x;
93 pommeY = ev.mouse.y;
94
95 gainSample = (float)(al_get_display_height(display)-ev.mouse.y)/(float)al_get_display_height(display);
96 al_set_sample_instance_gain(sampleInstance, gainSample);
97
98 panSample = (float)2*(ev.mouse.x - al_get_display_width(display)/2)/(float)al_get_display_width(display);
99 al_set_sample_instance_pan(sampleInstance, panSample);
100 }
101
102 else if (ev.type == ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY) {
103 al_show_mouse_cursor(display);
104 curseurSample = al_get_sample_instance_position(sampleInstance);
105 al_set_sample_instance_playing(sampleInstance, false);
106 }
107
108 else if (ev.type == ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY) {
109 al_hide_mouse_cursor(display);
110 al_set_sample_instance_playing(sampleInstance, true);
111 al_set_sample_instance_position(sampleInstance, curseurSample);
112 }
113
114 else if (ev.type == ALLEGRO_EVENT_KEY_DOWN){
115 switch (ev.keyboard.keycode) {
116 case ALLEGRO_KEY_ESCAPE:
117 continuer = false;
118 break;
119
120 default:
121 break;
122 }
123 }
124
125 al_draw_scaled_bitmap(imageDragon, 0, 0, al_get_bitmap_width(imageDragon), al_get_bitmap_height(imageDragon), 0, 0, al_get_display_width(display), al_get_display_height(display), 0);
126 al_draw_bitmap(imagePomme, pommeX - al_get_bitmap_width(imagePomme)/2, pommeY - al_get_bitmap_height(imagePomme)/2, 0);
127 al_flip_display();
128
129 }
130
131 al_destroy_display(display);
132 al_destroy_bitmap(imageDragon);
133
134 return 0;
135}
And here is the error i get : 2012-06-26 22:27:43.111 Allegro Project[40388:6607] invalid fullscreen drawable 1280x800 is my native screen resolution, so i really don't understand why it doesn't work Thanks for reading this, i hope someone has fixes this and can tell me how to do it |
Elias
Member #358
May 2000
|
Yes, both fullscreen as well as fullscreen-window are broken right now (under OSX 10.7). The SVN version has a fullscreen-icon on all resizable windows which you can use to switch to fullscreen - it's the only working way for now. I have investigating whether that can be used to fix fullscreen-window (by automatically triggering it somehow) on my todo list, but might be a while so hopefully someone beats me to it. -- |
•Kyhel•
Member #14,403
June 2012
|
I'm glad i made you remember this, i'm going to try to build the svn source then, just to try fullscreen more because it's so much more fun with it ^^ And thanks for your quick answer, i won't spend the night trying to figure this out then |
|