1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | * Mupen64plus - oglft_c.cpp * |
3 | * Mupen64Plus homepage: https://mupen64plus.org/ * |
4 | * Copyright (C) 2018 Bobby Smiles * |
5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * |
10 | * * |
11 | * This program is distributed in the hope that it will be useful, * |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
14 | * GNU General Public License for more details. * |
15 | * * |
16 | * You should have received a copy of the GNU General Public License * |
17 | * along with this program; if not, write to the * |
18 | * Free Software Foundation, Inc., * |
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
20 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
21 | |
22 | #include "oglft_c.h" |
23 | |
24 | #include <OGLFT.h> |
25 | |
26 | extern "C" bool OGLFT_Init_FT(void) |
27 | { |
28 | try { |
29 | return OGLFT::Init_FT(); |
30 | } catch(...) { /* swallow error */ } |
31 | |
32 | return false; |
33 | } |
34 | |
35 | extern "C" bool OGLFT_Uninit_FT(void) |
36 | { |
37 | try { |
38 | return OGLFT::Uninit_FT(); |
39 | } catch(...) { /* swallow error */ } |
40 | |
41 | return false; |
42 | } |
43 | |
44 | extern "C" bool OGLFT_Face_isValid(const struct OGLFT_Face* face) |
45 | { |
46 | try { |
47 | return reinterpret_cast<const OGLFT::Face*>(face)->isValid(); |
48 | } catch(...) { /* swallow error */ } |
49 | |
50 | return false; |
51 | } |
52 | |
53 | |
54 | extern "C" void OGLFT_Face_setForegroundColor(struct OGLFT_Face* face, float r, float g, float b, float a) |
55 | { |
56 | try { |
57 | reinterpret_cast<OGLFT::Face*>(face)->setForegroundColor(r, g, b, a); |
58 | } catch(...) { /* swallow error */ } |
59 | } |
60 | |
61 | extern "C" void OGLFT_Face_setBackgroundColor(struct OGLFT_Face* face, float r, float g, float b, float a) |
62 | { |
63 | try { |
64 | reinterpret_cast<OGLFT::Face*>(face)->setBackgroundColor(r, g, b, a); |
65 | } catch(...) { /* swallow error */ } |
66 | } |
67 | |
68 | |
69 | extern "C" void OGLFT_Face_setHorizontalJustification(struct OGLFT_Face* face, enum OGLFT_Face_HorizontalJustification justification) |
70 | { |
71 | try { |
72 | reinterpret_cast<OGLFT::Face*>(face)->setHorizontalJustification(static_cast<OGLFT::Face::HorizontalJustification>(justification)); |
73 | } catch(...) { /* swallow error */ } |
74 | } |
75 | |
76 | extern "C" void OGLFT_Face_setVerticalJustification(struct OGLFT_Face* face, enum OGLFT_Face_VerticalJustification justification) |
77 | { |
78 | try { |
79 | reinterpret_cast<OGLFT::Face*>(face)->setVerticalJustification(static_cast<OGLFT::Face::VerticalJustification>(justification)); |
80 | } catch(...) { /* swallow error */ } |
81 | } |
82 | |
83 | |
84 | extern "C" double OGLFT_Face_height(const struct OGLFT_Face* face) |
85 | { |
86 | try { |
87 | return reinterpret_cast<const OGLFT::Face*>(face)->height(); |
88 | } catch(...) { /* swallow error */ } |
89 | |
90 | return 0.0; |
91 | } |
92 | |
93 | |
94 | extern "C" void OGLFT_Face_measure(struct OGLFT_Face* face, const char* s, float sizebox[4]) |
95 | { |
96 | try { |
97 | OGLFT::BBox bbox = reinterpret_cast<OGLFT::Face*>(face)->measure(s); |
98 | sizebox[0] = bbox.x_min_; |
99 | sizebox[1] = bbox.y_min_; |
100 | sizebox[2] = bbox.x_max_; |
101 | sizebox[3] = bbox.y_max_; |
102 | } catch(...) { memset(sizebox, 0, 4*sizeof sizebox[0]); } |
103 | } |
104 | |
105 | extern "C" void OGLFT_Face_measure_nominal(struct OGLFT_Face* face, const char* s, float sizebox[4]) |
106 | { |
107 | try { |
108 | OGLFT::BBox bbox = reinterpret_cast<OGLFT::Face*>(face)->measure_nominal(s); |
109 | sizebox[0] = bbox.x_min_; |
110 | sizebox[1] = bbox.y_min_; |
111 | sizebox[2] = bbox.x_max_; |
112 | sizebox[3] = bbox.y_max_; |
113 | } catch(...) { memset(sizebox, 0, 4*sizeof sizebox[0]); } |
114 | } |
115 | |
116 | extern "C" void OGLFT_Face_draw(struct OGLFT_Face* face, float x, float y, const char* s, float sizebox[4]) |
117 | { |
118 | try { |
119 | reinterpret_cast<OGLFT::Face*>(face)->draw(x, y, s, sizebox); |
120 | } catch(...) { /* swallow error */ } |
121 | } |
122 | |
123 | |
124 | extern "C" struct OGLFT_Face* OGLFT_Monochrome_create(const char* filename, float point_size) |
125 | { |
126 | try { |
127 | return reinterpret_cast<struct OGLFT_Face*>(new OGLFT::Monochrome(filename, point_size)); |
128 | } catch(...) { /* swallow error */ } |
129 | |
130 | return NULL; |
131 | } |
132 | |
133 | extern "C" void OGLFT_Face_destroy(struct OGLFT_Face* face) |
134 | { |
135 | try { |
136 | delete reinterpret_cast<OGLFT::Face*>(face); |
137 | } catch(...) { /* swallow error */ } |
138 | } |
139 | |