Tscope5
primitives_internal.c
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // __ ______
4 // / /_______________ ____ ___ / ____/
5 // / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
6 // / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
7 // \__/____/\___/\____/ .___/\___/ /_____/
8 // /_/
9 //
10 /// \file primitives_internal.c
11 /// Definitions of internal primitives drawing functions.
12 ////////////////////////////////////////////////////////////////////////////////
13 
14 #include "../include/tscope5/primitives_internal.h"
15 #include "../include/tscope5/system_internal.h"
16 
17 #include <allegro5/allegro_primitives.h>
18 
19 /// Is the primitives subsystem installed?
21 
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 /// Do some checks at the start of each primitives function.
25 ///
26 /// \param calling_function Name the function that calls
27 /// for this check or installation.
28 ///
29 /// Checks whether the primitives subsystem is installed.
30 /// If not, the primitives subsystem is installed.
31 ///
32 /// Checks whether the drawing target is set. If not, the program is aborted.
33 ////////////////////////////////////////////////////////////////////////////////
34 void ts5_check_primitives(char *calling_function)
35 {
36  ts5_log(TS5_LOGLEVEL_6, "%s: ts5_check_primitives\n", calling_function);
37 
39  ts5_install_primitives(calling_function);
40  }
41 
42  if (!_ts5_data.target) {
43  ts5_fatal("%s: no drawing target specified\n", calling_function);
44  }
45 }
46 
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 /// Install the primitives drawing subsystem.
50 ///
51 /// \param calling_function Name the function that calls
52 /// for this check or installation.
53 ///
54 /// This function is called automatically if necessary.
55 ////////////////////////////////////////////////////////////////////////////////
56 void ts5_install_primitives(char *calling_function)
57 {
59  ts5_install_tscope5(calling_function);
60  }
61 
63 
65  ts5_log(TS5_LOGLEVEL_1, "%s: Installing Tscope5 primitives\n",
66  calling_function);
67 
68  if (!al_init_primitives_addon()) {
69  ts5_fatal("%s: could not install Tscope5 primitives\n",
70  calling_function);
71  }
72 
74  }
75 }
76 
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// Uninstall the primitives drawing subsystem.
80 ///
81 /// This function is called automatically at the end of the program.
82 ////////////////////////////////////////////////////////////////////////////////
84 {
86 
87  ts5_log(TS5_LOGLEVEL_1, "Uninstalling Tscope5 primitives\n");
88 
89  // al_shutdown_primitives_addon();
90 
92  }
93 }
94 
int _ts5_is_tscope5_installed
Is Tscope5 installed?
void ts5_check_primitives(char *calling_function)
Do some checks at the start of each primitives function.
void ts5_install_primitives(char *calling_function)
Install the primitives drawing subsystem.
void ts5_uninstall_primitives()
Uninstall the primitives drawing subsystem.
int _ts5_is_primitives_installed
Is the primitives subsystem installed?
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_fatal(const char *format,...)
Exit safely with an error message.
Definition: system.c:533