Tscope5
Main Page
Related Pages
Files
Examples
File List
Globals
tscope5-0.2
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?
20
int
_ts5_is_primitives_installed
= 0;
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
38
if
(!
_ts5_is_primitives_installed
) {
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
{
58
if
(!
_ts5_is_tscope5_installed
) {
59
ts5_install_tscope5
(calling_function);
60
}
61
62
if
(!
_ts5_is_primitives_installed
) {
63
64
_ts5_is_primitives_installed
= 1;
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
73
atexit(
ts5_uninstall_primitives
);
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
////////////////////////////////////////////////////////////////////////////////
83
void
ts5_uninstall_primitives
()
84
{
85
if
(
_ts5_is_primitives_installed
) {
86
87
ts5_log
(TS5_LOGLEVEL_1,
"Uninstalling Tscope5 primitives\n"
);
88
89
// al_shutdown_primitives_addon();
90
91
_ts5_is_primitives_installed
= 0;
92
}
93
}
94