|
1 #include <QDebug> |
1 #include <QGuiApplication> |
2 #include <QGuiApplication> |
|
3 #include <QLibrary> |
2 #include <QQmlApplicationEngine> |
4 #include <QQmlApplicationEngine> |
3 |
5 |
|
6 #include "engine_interface.h" |
4 #include "hwengine.h" |
7 #include "hwengine.h" |
|
8 |
|
9 namespace Engine { |
|
10 protocol_version_t* protocol_version; |
|
11 start_engine_t* start_engine; |
|
12 generate_preview_t* generate_preview; |
|
13 cleanup_t* cleanup; |
|
14 }; // namespace Engine |
|
15 |
|
16 void loadEngineLibrary() { |
|
17 #ifdef Q_OS_WIN |
|
18 QLibrary hwlib("./libhedgewars_engine.dll"); |
|
19 #else |
|
20 QLibrary hwlib("./libhedgewars_engine.so"); |
|
21 #endif |
|
22 |
|
23 if (!hwlib.load()) |
|
24 qWarning() << "Engine library not found" << hwlib.errorString(); |
|
25 |
|
26 Engine::protocol_version = reinterpret_cast<Engine::protocol_version_t*>( |
|
27 hwlib.resolve("protocol_version")); |
|
28 Engine::start_engine = |
|
29 reinterpret_cast<Engine::start_engine_t*>(hwlib.resolve("start_engine")); |
|
30 Engine::generate_preview = reinterpret_cast<Engine::generate_preview_t*>( |
|
31 hwlib.resolve("generate_preview")); |
|
32 Engine::cleanup = |
|
33 reinterpret_cast<Engine::cleanup_t*>(hwlib.resolve("cleanup")); |
|
34 |
|
35 if (Engine::protocol_version) |
|
36 qDebug() << "Loaded engine library with protocol version" |
|
37 << Engine::protocol_version(); |
|
38 } |
5 |
39 |
6 int main(int argc, char* argv[]) { |
40 int main(int argc, char* argv[]) { |
7 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |
41 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |
8 QGuiApplication app(argc, argv); |
42 QGuiApplication app(argc, argv); |
|
43 |
|
44 loadEngineLibrary(); |
9 |
45 |
10 QQmlApplicationEngine engine; |
46 QQmlApplicationEngine engine; |
11 |
47 |
12 HWEngine::exposeToQML(); |
48 HWEngine::exposeToQML(); |
13 |
49 |