|
A5 Daul screen |
carlo starsk
Member #6,250
September 2005
|
Having problems with daul screen A5, VC2010, Windows xp.. After setup both screens show image but the FPS is very slow.. Settings Thanks 1al_get_new_display_adapter();
2al_set_new_display_adapter(0);
3al_set_new_display_flags(ALLEGRO_WINDOWED);
4display1 = al_create_display(WIDTH, HEIGHT);
5
6 al_get_new_display_adapter();
7 al_set_new_display_adapter(1);
8 al_set_new_display_flags(ALLEGRO_WINDOWED );
9 display2 = al_create_display(WIDTH, HEIGHT);
10
11 if(redraw && al_is_event_queue_empty(event_queue)){
12
13 redraw = false;
14 al_set_new_display_adapter(0);
15 al_set_target_backbuffer(display1);
16 DrawBackGround(BG);
17 al_flip_display();
18 al_clear_to_color(al_map_rgb(0,0,0));
19
20 al_set_target_backbuffer(display2);
21 DrawBackGround2(BG2);
22 al_flip_display();
23 al_clear_to_color(al_map_rgb(0,0,0));
|
Ashteth
Member #3,310
March 2003
|
Are you using the same bitmaps (sprites) on both displays? A5 Manual said: Unless you set the ALLEGRO_MEMORY_BITMAP flag, the bitmap is created for the current display. Blitting to another display may be slow You may need to load your bitmaps as video bitmaps on both displays if this is the case.
|
carlo starsk
Member #6,250
September 2005
|
Ashteth. |
SiegeLord
Member #7,827
October 2006
|
carlo starsk said: will test this evening with ALLEGRO_MEMORY_BITMAP flag. That's not what Asteth meant. What he meant is this: 1al_set_new_display_adapter(0);
2al_set_new_display_flags(ALLEGRO_WINDOWED);
3display1 = al_create_display(WIDTH, HEIGHT);
5
6al_set_new_display_adapter(1);
7al_set_new_display_flags(ALLEGRO_WINDOWED);
8display2 = al_create_display(WIDTH, HEIGHT);
10
11if(redraw && al_is_event_queue_empty(event_queue)){
12
13redraw = false;
14al_set_target_backbuffer(display1);
15DrawBackGround(BG);
16al_flip_display();
17al_clear_to_color(al_map_rgb(0,0,0));
18
19al_set_target_backbuffer(display2);
20DrawBackGround2(BG2);
21al_flip_display();
22al_clear_to_color(al_map_rgb(0,0,0));
I.e. you need to duplicate all your images that you want to blit on both displays using al_clone_bitmap. Note how I clone the bitmap after creating the second display ( al_create_display calls al_set_target_backbuffer on the newly created display). Also, those al_get_new_display_adapter calls are unnecessary, and you only need to call al_set_new_display_adapter when creating displays, not drawing to them. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
carlo starsk
Member #6,250
September 2005
|
Thanks I did try the orignal code with two diffrent images both display's The Orignal Code. 1#include <allegro5\allegro.h>
2#include <allegro5\allegro_primitives.h>
3#include <allegro5\allegro_font.h>
4#include <allegro5\allegro_ttf.h>
5#include <allegro5\allegro_image.h>
6#include <allegro5\allegro_audio.h>
7#include <allegro5\allegro_acodec.h>
8//#include <allegro5/allegro_opengl.h>
9//#include "DaulScreen.h"
10
11// Test Header Code
12
13struct BackGround
14{
15 float x;
16 float y;
17
18 ALLEGRO_BITMAP *image;
19};
20
21struct BackGround2
22{
23 float x;
24 float y;
25
26 ALLEGRO_BITMAP *image;
27};
28
29//...........
30
31//GLOBALS==============================
32const int WIDTH = 1024;
33const int HEIGHT = 768;
34int FPS;
35
36
37ALLEGRO_SAMPLE_INSTANCE *songInstance = NULL;
38ALLEGRO_SAMPLE *music = NULL;
39
40ALLEGRO_BITMAP *BGimage;
41ALLEGRO_BITMAP *BGimage2;
42
43//prototypes functions daul screen test
44
45void InitBG(BackGround &BG, ALLEGRO_BITMAP *image);
46void DrawBackGround(BackGround &BG);
47
48void InitBG2(BackGround2 &BG2, ALLEGRO_BITMAP *image);
49void DrawBackGround2(BackGround2 &BG2);
50
51//===================================
52void get_desktop_resolution(int adapter, int *w, int *h)
53 {
54 ALLEGRO_MONITOR_INFO info;
55 al_get_monitor_info(adapter, &info);
56
57 *w = info.x2 - info.x1;
58 *h = info.y2 - info.y1;
59 }
60int desktop_width, desktop_height;
61int testtimer=0; //..
62//=====================================
63
64int main(void)
65{
66 //primitive variable
67 bool done = false;
68 bool redraw = true;
69 int pos_x;
70 int pos_y;
71 const int FPS = 60;
72 //object variables
73
74 BackGround BG;
75 BackGround2 BG2;
76
77 //Allegro variables
78 ALLEGRO_DISPLAY *display1 = NULL;
79 ALLEGRO_DISPLAY *display2 = NULL;
80 ALLEGRO_EVENT_QUEUE *event_queue = NULL;
81 ALLEGRO_TIMER *timer = NULL;
82 ALLEGRO_FONT *font18 = NULL;
83 //ALLEGRO_DISPLAY_MODE disp_data;
84
85 //Initialization Functions
86 if(!al_init()) //initialize Allegro
87 return -1;
88
89 //int mon=al_get_num_video_adapters(); //returns 2
90 //al_get_display_mode(al_get_num_display_modes() - 1, &disp_data);
91
92 al_get_new_display_adapter();
93 al_set_new_display_adapter(0);
94 al_set_new_display_flags(ALLEGRO_WINDOWED);
95 display1 = al_create_display(WIDTH, HEIGHT/*disp_data.width, disp_data.height*/);
96
97 al_get_new_display_adapter();
98 al_set_new_display_adapter(1);
99 al_set_new_display_flags(ALLEGRO_WINDOWED );
100 display2 = al_create_display(WIDTH, HEIGHT/*disp_data.width, disp_data.height*/);
101
102
103 if(!display1)
104 return -1;
105 if(!display2)
106 return -1;
107
108 // Allegro addon
109 al_init_primitives_addon();
110 al_install_keyboard();
111 al_install_mouse();
112 al_init_font_addon();
113 al_init_ttf_addon();
114 al_init_image_addon();
115 al_install_audio();
116 al_init_acodec_addon();
117
118 event_queue = al_create_event_queue();
119 timer = al_create_timer(1.0 / FPS);
120
121 //load images
122 BGimage = al_load_bitmap("test.png");
123 BGimage2 = al_load_bitmap("test2.png");
124 al_convert_mask_to_alpha(BGimage, al_map_rgb(255, 0, 255));
125 al_convert_mask_to_alpha(BGimage2, al_map_rgb(255, 0, 255));
126
127 al_reserve_samples(10);
128
129 music= al_load_sample("test.ogg");
130
131 songInstance = al_create_sample_instance(music);
132 al_set_sample_instance_playmode(songInstance, ALLEGRO_PLAYMODE_LOOP);
133
134 al_attach_sample_instance_to_mixer(songInstance, al_get_default_mixer());
135
136 srand(time(NULL));
137
138 InitBG(BG,BGimage);
139 InitBG2(BG2,BGimage2);
140
141 font18 = al_load_font("arial.ttf", 18, 0);
142
143 al_register_event_source(event_queue, al_get_mouse_event_source());
144 al_register_event_source(event_queue, al_get_keyboard_event_source());
145 al_register_event_source(event_queue, al_get_timer_event_source(timer));
146 al_register_event_source(event_queue, al_get_display_event_source(display1));
147 al_register_event_source(event_queue, al_get_display_event_source(display2));
148
149 //al_hide_mouse_cursor(display);
150
151
152 al_start_timer(timer);
153
154 while(!done)
155 {
156
157 ALLEGRO_EVENT ev;
158 al_wait_for_event(event_queue, &ev);
159
160 if(ev.type == ALLEGRO_EVENT_TIMER){
161
162 redraw = true;
163 dis=~dis;
164 }
165
166 else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE){
167
168 done = true;
169 }
170
171 else if(ev.type == ALLEGRO_EVENT_KEY_DOWN){
172
173 switch(ev.keyboard.keycode){
174
175 case ALLEGRO_KEY_ESCAPE: done = true;
176 break;
177 }
178 }
179
180 else if(ev.type == ALLEGRO_EVENT_KEY_UP){
181
182 switch(ev.keyboard.keycode){
183
184 case ALLEGRO_KEY_ESCAPE:done = true;
185 break;
186
187 }
188 }
189
190 if(ev.type==ALLEGRO_EVENT_MOUSE_AXES){
191
192 pos_x= ev.mouse.x;
193 pos_y= ev.mouse.y;
194 }
195
196
197 if(redraw && al_is_event_queue_empty(event_queue)){
198
199 redraw = false;
200 al_set_target_backbuffer(display1);
201 DrawBackGround(BG);
202 al_draw_textf(font18, al_map_rgb(255, 0, 255), 200, 60, 0, "SCREEN 1 %i ", testtimer);
203
204 al_flip_display();
205 al_clear_to_color(al_map_rgb(0,0,0));
206
207 al_set_target_backbuffer(display2);
208 DrawBackGround2(BG2);
209 al_draw_textf(font18, al_map_rgb(255, 0, 255),200, 100, 0, "SCREEEN 2 %i ", testtimer);
210 al_flip_display();
211 al_clear_to_color(al_map_rgb(0,0,0));
212
213 testtimer++;
214
215 }
216 }
217
218
219 al_destroy_sample(music);
220 al_destroy_sample_instance(songInstance);
221 al_destroy_bitmap(BGimage);
222 al_destroy_bitmap(BGimage2);
223 al_destroy_event_queue(event_queue);
224 al_destroy_timer(timer);
225 al_destroy_font(font18);
226 al_destroy_display(display1); //destroy our display object
227 al_destroy_display(display2);
228 return 0;
229}
230
231//================Monitor 1========
232void InitBG(BackGround &BG, ALLEGRO_BITMAP *image = NULL)
233{
234
235 BG.x = 0;
236 BG.y = 0;
237
238 if(image != NULL)
239 BG.image = image;
240}
241void DrawBackGround(BackGround &BG)
242{
243
244 al_draw_bitmap(BG.image, BG.x, BG.y, 0);
245
246}
247
248//============== Monitor 2 ========
249
250void InitBG2(BackGround2 &BG2, ALLEGRO_BITMAP *image = NULL)
251{
252
253 BG2.x = 0;
254 BG2.y = 0;
255
256 if(image != NULL)
257 BG2.image = image;
258}
259
260void DrawBackGround2(BackGround2 &BG2)
261{
262
263 al_draw_bitmap(BG2.image, BG2.x, BG2.y, 0);
264
265}
|
Thomas Fjellstrom
Member #476
June 2000
|
When loading images for the second display, you have to change that display to the current display, otherwise both bitmaps will be attached to the display that was created last. So, when loading for the first display make sure you call set_target_backbuffer(display1); easiest is to probably load for display2 first, then set the target backbuffer to display1 and load all the images for that. And now the current display is display1 as you'd probably expect. -- |
carlo starsk
Member #6,250
September 2005
|
Thanks to |
Johan Halmén
Member #1,550
September 2001
|
carlo starsk said: What am i missing or doing wrong. Dual screen. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
|