1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
|
#include <stdio.h>
#include "conio.h"
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_primitives.h>
int main(int argc, char **argv){
ALLEGRO_DISPLAY* display = NULL;
ALLEGRO_DISPLAY_MODE display_data;
ALLEGRO_DISPLAY_MODE my_display;
ALLEGRO_EVENT_QUEUE* event_queue=NULL;
ALLEGRO_EVENT ev;
ALLEGRO_TIMEOUT timeout;
ALLEGRO_COLOR color_Red=al_map_rgb(200,0,0);
ALLEGRO_COLOR color_Grey=al_map_rgb(100,100,100);
if(!al_init()) {
fprintf(stdout, "failed to initialize allegro!\n");
return -1;
}
if(!al_init_image_addon()){
fprintf(stdout, "failed to initialize image_addon!\n");
return -1;
}
if(!al_init_primitives_addon()){
fprintf(stdout, "failed to initialize image_primitives!\n");
return -1;
}
al_get_display_mode((al_get_num_display_modes()-1),&display_data);
al_get_display_mode((al_get_num_display_modes()-10),&my_display);
fprintf(stdout,"Ihre momentane Bildschirmauflösung ist: %i x %i",display_data.width,display_data.height);
fprintf(stdout,"Meine Lieblings-Bildschirmauflösung ist: %i x %i\n Daher werden wir auch ein Fenster mit dieser Auflösung erstellen.",my_display.width,my_display.height);
puts("Bitte wählen Sie einen Modus aus, in dem das nächste Fenster erstellt werden soll.");
puts("[1] Vollbildmodus\n[2] Fenstermodus");
char auswahl=_getch();
switch(auswahl){
case '1':
al_set_new_display_flags(ALLEGRO_FULLSCREEN);
break;
case '2':
break;
default:
puts("Sie haben eine ungültige Auswahl getroffen!\nDaher nehme ich den \"Vollbildmodus\" an.");
al_set_new_display_flags(ALLEGRO_FULLSCREEN);
_getch();
}
display = al_create_display(my_display.width,my_display.height);
if(!display) {
fprintf(stdout, "failed to create display!\n");
return -1;
}
al_set_window_title(display,"Testfenster");
event_queue= al_create_event_queue();
if(!event_queue){
fprintf(stdout,"failed to create event queue!\n");
al_destroy_display(display);
return -1;
}
al_register_event_source(event_queue,al_get_display_event_source(display));
al_clear_to_color(al_map_rgb(100,100,100));
al_flip_display();
while(1)
{
al_init_timeout(&timeout,0.06);
bool get_event = al_wait_for_event_until(event_queue,&ev,&timeout);
if(get_event&&ev.type==ALLEGRO_EVENT_DISPLAY_CLOSE){
break;
}
/* UM DIESE BEIDEN ZEILEN HIER GEHT ES!!!!!*/
al_clear_to_color(color_Red);
al_draw_line(0,0,my_display.width,my_display.height,color_Red,10);
//
al_flip_display();
if(auswahl!='2'){
al_rest(25.0);
break;
}
}
al_destroy_event_queue(event_queue);
al_rest(1.0);
al_destroy_display(display);
return 0;
}
|