forked from vreemdelabs/Scoreview-Base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
136 lines (116 loc) · 2.63 KB
/
main.cpp
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
Scoreview (R)
Copyright (C) 2015 Patrick Areny
All Rights Reserved.
Scoreview is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <malloc.h>
#include <memory.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <iterator>
#include <list>
#include <vector>
#include <tinyxml.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "audiodata.h"
#include "audioapi.h"
#include "shared.h"
#include "gfxareas.h"
#include "mesh.h"
#include "gl2Dprimitives.h"
#include "cfgfile.h"
#include "score.h"
#include "f2n.h"
#include "pictures.h"
#include "keypress.h"
#include "instrumenthand.h"
#include "scoreplacement.h"
#include "scoreplacement_violin.h"
#include "scoreplacement_piano.h"
#include "scoreplacement_guitar.h"
#include "scoreedit.h"
#include "scorerenderer.h"
#include "card.h"
#include "messages.h"
#include "messages_network.h"
#include "app.h"
#include "sdlcalls.h"
#include "threads.h"
#ifndef _DEBUG
#define USE_LOG_FILE
#endif
void main_loop(Cappdata *app)
{
bool must_quit = false;
while (!must_quit)
{
handle_input_events(&must_quit, app);
app->timed_events();
app->render_gui();
usleep(7000);
}
}
#ifdef USE_LOG_FILE
void open_log_file()
{
Cxml_cfg_file_decoder cfgfile;
string user_home;
user_home = cfgfile.get_user_config_path() + string("applog.txt");
freopen(user_home.c_str(), "w", stdout);
}
void close_log_file()
{
#ifndef __LINUX
freopen("CON", "w", stdout);
#else
fclose(stdout);
#endif
}
#else
void open_log_file()
{
}
void close_log_file()
{
}
#endif
int main(int argc, char **argv)
{
int width;
int height;
Cappdata *app;
width = 1024 + 12;
height = 512 + 256 + 64;
open_log_file();
// Central class
app = new Cappdata(width, height);
if (app->init_the_network_messaging() == 0)
{
// Create threads
if (create_threads(app) == 0)
{
// Just loop
main_loop(app);
// Destroy threads
release_threads(app);
}
}
delete app;
close_log_file();
return 0;
}