Tscope5
bitmaps_internal.c
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // __ ______
4 // / /_______________ ____ ___ / ____/
5 // / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
6 // / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
7 // \__/____/\___/\____/ .___/\___/ /_____/
8 // /_/
9 //
10 /// \file bitmaps_internal.c
11 /// Definitions of internal bitmap functions.
12 ////////////////////////////////////////////////////////////////////////////////
13 
14 
15 #include "../include/tscope5/bitmaps_internal.h"
16 #include "../include/tscope5/system_internal.h"
17 
18 #include <allegro5/allegro_image.h>
19 
20 /// Is the bitmaps subsystem installed?
22 
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 /// Do some checks at the start of each bitmap function.
26 ///
27 /// \param calling_function Name the function that calls for
28 /// this check or installation.
29 ///
30 /// Checks whether the bitmaps subsystem is installed.
31 /// If not, the bitmaps subsystem is installed.
32 ////////////////////////////////////////////////////////////////////////////////
33 void ts5_check_bitmaps(char *calling_function)
34 {
35  ts5_log(TS5_LOGLEVEL_6, "%s: ts5_check_bitmaps\n", calling_function);
37  ts5_install_bitmaps(calling_function);
38  }
39 }
40 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Do some checks at the start of each bitmap function.
44 ///
45 /// \param calling_function Name the function that calls for
46 /// this check or installation.
47 ///
48 /// \param map The bitmap that has to be checked.
49 ///
50 /// Checks whether the source and target bitmap are not NULL or equal.
51 /// Aborts if necessary.
52 ////////////////////////////////////////////////////////////////////////////////
53 void ts5_check_bitmaps2(char *calling_function, TS5_BITMAP *map)
54 {
55  ts5_check_bitmaps(calling_function);
56  ts5_log(TS5_LOGLEVEL_6, "%s: ts5_check_bitmaps2\n", calling_function);
57 
58  if (!_ts5_data.target) {
59  ts5_fatal("%s: no drawing target specified\n", calling_function);
60  }
61 
62  if (!map) {
63  ts5_fatal("%s: bitmap pointer is null\n", calling_function);
64  }
65 
66  if (_ts5_data.target == map) {
67  ts5_fatal("%s: source and target are the same\n", calling_function);
68  }
69 }
70 
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Install the bitmaps subsystem.
74 ///
75 /// \param calling_function Name the function that calls for
76 /// this check or installation.
77 ///
78 /// This function is called automatically if necessary.
79 ////////////////////////////////////////////////////////////////////////////////
80 void ts5_install_bitmaps(char *calling_function)
81 {
83  ts5_install_tscope5(calling_function);
84  }
85 
87 
89  ts5_log(TS5_LOGLEVEL_1, "%s: Installing Tscope5 bitmaps\n",
90  calling_function);
91 
92  if (!al_init_image_addon()) {
93  ts5_fatal("%s: could not install Tscope5 bitmaps\n",
94  calling_function);
95  }
96 
97  atexit(ts5_uninstall_bitmaps);
98  }
99 }
100 
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// Close the bitmaps subsystem.
104 ///
105 /// This function is called automatically at the end of the program.
106 ////////////////////////////////////////////////////////////////////////////////
108 {
110 
111  ts5_log(TS5_LOGLEVEL_1, "Uninstalling Tscope5 bitmaps\n");
112  al_shutdown_image_addon();
114  }
115 }
116 
int _ts5_is_tscope5_installed
Is Tscope5 installed?
void ts5_install_bitmaps(char *calling_function)
Install the bitmaps subsystem.
void ts5_check_bitmaps(char *calling_function)
Do some checks at the start of each bitmap function.
void ts5_log(const unsigned int level, const char *format,...)
Send info to a logging window.
Definition: system.c:45
void ts5_install_tscope5(char *calling_function)
Install Tscope5.
void ts5_check_bitmaps2(char *calling_function, TS5_BITMAP *map)
Do some checks at the start of each bitmap function.
void ts5_uninstall_bitmaps()
Close the bitmaps subsystem.
int _ts5_is_bitmaps_installed
Is the bitmaps subsystem installed?
void ts5_fatal(const char *format,...)
Exit safely with an error message.
Definition: system.c:533