Hello.
basically I need draw my DIALOG on a specific BITMAP but this is not working.
Here is the code:
1 | /**\file SprEdit.c |
2 | * |
3 | * SprEdit Main Program |
4 | * |
5 | *\author Castagnier Mickaƫl |
6 | * |
7 | *\version 1.0 |
8 | * |
9 | *\date 24/03/07 |
10 | * |
11 | */ |
12 | |
13 | |
14 | |
15 | #include <nilorea.h> |
16 | |
17 | |
18 | DIALOG MainGui[] = |
19 | { |
20 | /* (proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ |
21 | { d_radio_proc, 16, 696, 16, 16, 0, 0, 0, 0, 0, 0, "Full", NULL, NULL }, |
22 | { d_radio_proc, 16, 712, 16, 16, 0, 0, 0, 0, 0, 0, "Masked", NULL, NULL }, |
23 | { d_radio_proc, 16, 728, 16, 16, 0, 0, 0, 0, 0, 0, "Transparent", NULL, NULL }, |
24 | { d_button_proc, 216, 704, 120, 16, 0, 0, 0, 0, 0, 0, "Set Hot Point", NULL, NULL }, |
25 | { d_button_proc, 352, 704, 128, 16, 0, 0, 0, 0, 0, 0, "Set frame Delay", NULL, NULL }, |
26 | { d_button_proc, 496, 704, 144, 16, 0, 0, 0, 0, 0, 0, "Next in Batch", NULL, NULL }, |
27 | { d_button_proc, 352, 728, 128, 16, 0, 0, 0, 0, 0, 0, "Apply To All", NULL, NULL }, |
28 | { d_button_proc, 216, 728, 120, 16, 0, 0, 0, 0, 0, 0, "Apply To All", NULL, NULL }, |
29 | { d_button_proc, 496, 728, 144, 16, 0, 0, 0, 0, 0, 0, "Previous in Batch", NULL, NULL }, |
30 | { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } |
31 | }; |
32 | |
33 | DIALOG_PLAYER *gui; |
34 | |
35 | int DONE = 0 ; |
36 | |
37 | |
38 | |
39 | BITMAP *buf; |
40 | |
41 | |
42 | |
43 | int main (int argc, char *argv[]) |
44 | { |
45 | |
46 | allegro_init(); |
47 | install_timer(); |
48 | install_mouse(); |
49 | install_keyboard(); |
50 | |
51 | gfx_mode( GFX_DIRECTX_WIN , 1024 , 768 , 0 , 0 , 32 , 0 , 0 , 0 , 0 ); |
52 | |
53 | buf = create_bitmap( SCREEN_W , SCREEN_H ); |
54 | clear( buf ); |
55 | |
56 | gui_set_screen(buf); |
57 | |
58 | gui=init_dialog(MainGui,-1); |
59 | |
60 | |
61 | while( !DONE ) |
62 | { |
63 | |
64 | clear_to_color( buf , makecol( 255,255,255 ) ); |
65 | update_dialog(gui); |
66 | |
67 | |
68 | circle( buf , mouse_x , mouse_y , 5 , makecol( 255 , 255 , 0 ) ); |
69 | |
70 | line( buf , mouse_x - 10 , mouse_y , mouse_x + 10 , mouse_y , makecol( 255 , 255 , 255 ) ); |
71 | line( buf , mouse_x , mouse_y - 10 , mouse_x , mouse_y +10 , makecol( 255 , 255 , 255 ) ); |
72 | |
73 | |
74 | blit( buf , screen , 0 , 0 , 0 , 0 , buf -> w , buf -> h ); |
75 | |
76 | if( key[ KEY_ESC ] ) |
77 | DONE = 1 ; |
78 | } |
79 | |
80 | }END_OF_MAIN() |
Where do am I wrong ?
_
I think I tried to do the same thing a while ago and came to the conclusion that it could be broken. I switched my program to OpenLayer (for other reasons) and promptly forgot about it before following it up any further. (I could have been doing something wrong too though...)
Matt Weir.
A dialog uses a dirty rectangles-like system. So when you clear the bitmap, the dialog has no idea it needs to redraw itself, and thus doesn't, leaving your bitmap blank. Either don't clear the bitmap, or tell the dialog to redraw all of itself:
dialog_message(MainGui, MSG_DRAW, NULL);
You needed to set the gui objects colors set_dialog_color() and broadcast_dialog_message() telling it needs to be redrawn
1 | #include <allegro.h> |
2 | |
3 | |
4 | DIALOG MainGui[] = |
5 | { |
6 | /* (proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ |
7 | { d_radio_proc, 16, 696, 16, 16, 0, 0, 0, 0, 0, 0, "Full", NULL, NULL }, |
8 | { d_radio_proc, 16, 712, 16, 16, 0, 0, 0, 0, 0, 0, "Masked", NULL, NULL }, |
9 | { d_radio_proc, 16, 728, 16, 16, 0, 0, 0, 0, 0, 0, "Transparent", NULL, NULL }, |
10 | { d_button_proc, 216, 704, 120, 16, 0, 0, 0, 0, 0, 0, "Set Hot Point", NULL, NULL }, |
11 | { d_button_proc, 352, 704, 128, 16, 0, 0, 0, 0, 0, 0, "Set frame Delay", NULL, NULL }, |
12 | { d_button_proc, 496, 704, 144, 16, 0, 0, 0, 0, 0, 0, "Next in Batch", NULL, NULL }, |
13 | { d_button_proc, 352, 728, 128, 16, 0, 0, 0, 0, 0, 0, "Apply To All", NULL, NULL }, |
14 | { d_button_proc, 216, 728, 120, 16, 0, 0, 0, 0, 0, 0, "Apply To All", NULL, NULL }, |
15 | { d_button_proc, 496, 728, 144, 16, 0, 0, 0, 0, 0, 0, "Previous in Batch", NULL, NULL }, |
16 | { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } |
17 | }; |
18 | |
19 | DIALOG_PLAYER *gui; |
20 | |
21 | int DONE = 0 ; |
22 | |
23 | |
24 | |
25 | BITMAP *buf; |
26 | |
27 | |
28 | |
29 | int main (int argc, char *argv[]) |
30 | { |
31 | |
32 | allegro_init(); |
33 | install_timer(); |
34 | install_mouse(); |
35 | install_keyboard(); |
36 | |
37 | set_color_depth(32); |
38 | set_gfx_mode( GFX_DIRECTX_WIN , 1024 , 768 , 0 , 0); |
39 | |
40 | buf = create_bitmap( SCREEN_W , SCREEN_H ); |
41 | clear( buf ); |
42 | |
43 | |
44 | |
45 | gui_set_screen(buf); |
46 | show_mouse(buf); |
47 | set_dialog_color(MainGui, makecol(0,0,0), makecol(255,255,255)); |
48 | |
49 | gui=init_dialog(MainGui,-1); |
50 | |
51 | while( !DONE ) |
52 | { |
53 | |
54 | show_mouse(NULL); |
55 | |
56 | clear_to_color( buf , makecol( 255,255,255 ) ); |
57 | |
58 | broadcast_dialog_message(MSG_DRAW, 0); |
59 | update_dialog(gui); |
60 | |
61 | |
62 | circle( buf , mouse_x , mouse_y , 5 , makecol( 255 , 255 , 0 ) ); |
63 | |
64 | line( buf , mouse_x - 10 , mouse_y , mouse_x + 10 , mouse_y , makecol( 255 , 255 , 255 ) ); |
65 | line( buf , mouse_x , mouse_y - 10 , mouse_x , mouse_y +10 , makecol( 255 , 255 , 255 ) ); |
66 | |
67 | show_mouse(gui_get_screen()); |
68 | |
69 | |
70 | blit( buf , screen , 0 , 0 , 0 , 0 , buf -> w , buf -> h ); |
71 | |
72 | if( key[ KEY_ESC ] ) |
73 | DONE = 1 ; |
74 | } |
75 | |
76 | }END_OF_MAIN() |
That solves my problem, thanks.