author | alfadur |
Mon, 26 Nov 2018 02:50:54 +0300 | |
changeset 14300 | fd8e0e52d5bd |
parent 14299 | 21be7838a127 |
child 14375 | ef2fc0210362 |
permissions | -rw-r--r-- |
14159
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
1 |
#include <QDebug> |
12859 | 2 |
#include <QGuiApplication> |
14159
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
3 |
#include <QLibrary> |
12859 | 4 |
#include <QQmlApplicationEngine> |
5 |
||
14159
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
6 |
#include "engine_interface.h" |
14148 | 7 |
#include "hwengine.h" |
8 |
||
14159
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
9 |
namespace Engine { |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
10 |
protocol_version_t* protocol_version; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
11 |
start_engine_t* start_engine; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
12 |
generate_preview_t* generate_preview; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
13 |
cleanup_t* cleanup; |
14276
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14159
diff
changeset
|
14 |
send_ipc_t* send_ipc; |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14159
diff
changeset
|
15 |
read_ipc_t* read_ipc; |
14299
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
16 |
setup_current_gl_context_t* setup_current_gl_context; |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
17 |
render_frame_t* render_frame; |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
18 |
advance_simulation_t* advance_simulation; |
14159
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
19 |
}; // namespace Engine |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
20 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
21 |
void loadEngineLibrary() { |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
22 |
#ifdef Q_OS_WIN |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
23 |
QLibrary hwlib("./libhedgewars_engine.dll"); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
24 |
#else |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
25 |
QLibrary hwlib("./libhedgewars_engine.so"); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
26 |
#endif |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
27 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
28 |
if (!hwlib.load()) |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
29 |
qWarning() << "Engine library not found" << hwlib.errorString(); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
30 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
31 |
Engine::protocol_version = reinterpret_cast<Engine::protocol_version_t*>( |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
32 |
hwlib.resolve("protocol_version")); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
33 |
Engine::start_engine = |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
34 |
reinterpret_cast<Engine::start_engine_t*>(hwlib.resolve("start_engine")); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
35 |
Engine::generate_preview = reinterpret_cast<Engine::generate_preview_t*>( |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
36 |
hwlib.resolve("generate_preview")); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
37 |
Engine::cleanup = |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
38 |
reinterpret_cast<Engine::cleanup_t*>(hwlib.resolve("cleanup")); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
39 |
|
14276
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14159
diff
changeset
|
40 |
Engine::send_ipc = |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14159
diff
changeset
|
41 |
reinterpret_cast<Engine::send_ipc_t*>(hwlib.resolve("send_ipc")); |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14159
diff
changeset
|
42 |
Engine::read_ipc = |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14159
diff
changeset
|
43 |
reinterpret_cast<Engine::read_ipc_t*>(hwlib.resolve("read_ipc")); |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14159
diff
changeset
|
44 |
|
14299
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
45 |
Engine::setup_current_gl_context = |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
46 |
reinterpret_cast<Engine::setup_current_gl_context_t*>( |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
47 |
hwlib.resolve("setup_current_gl_context")); |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
48 |
Engine::render_frame = |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
49 |
reinterpret_cast<Engine::render_frame_t*>(hwlib.resolve("render_frame")); |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
50 |
Engine::advance_simulation = reinterpret_cast<Engine::advance_simulation_t*>( |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
51 |
hwlib.resolve("advance_simulation")); |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14276
diff
changeset
|
52 |
|
14159
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
53 |
if (Engine::protocol_version) |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
54 |
qDebug() << "Loaded engine library with protocol version" |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
55 |
<< Engine::protocol_version(); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
56 |
} |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
57 |
|
14148 | 58 |
int main(int argc, char* argv[]) { |
12859 | 59 |
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |
60 |
QGuiApplication app(argc, argv); |
|
61 |
||
14159
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
62 |
loadEngineLibrary(); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
14148
diff
changeset
|
63 |
|
12859 | 64 |
QQmlApplicationEngine engine; |
14148 | 65 |
|
66 |
HWEngine::exposeToQML(); |
|
67 |
||
12859 | 68 |
engine.load(QUrl(QLatin1String("qrc:/main.qml"))); |
14148 | 69 |
if (engine.rootObjects().isEmpty()) return -1; |
12859 | 70 |
|
71 |
return app.exec(); |
|
72 |
} |