author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 26 Nov 2018 01:13:10 +0100 | |
changeset 14296 | 0855344f54a7 |
parent 14294 | 21be7838a127 |
child 14298 | 00b56ec8b7df |
permissions | -rw-r--r-- |
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
1 |
#include "engine_instance.h" |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
2 |
|
14294
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14290
diff
changeset
|
3 |
extern "C" void (*getProcAddress())(const char* fn) { return nullptr; } |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14290
diff
changeset
|
4 |
|
14290
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14271
diff
changeset
|
5 |
EngineInstance::EngineInstance(QObject* parent) |
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
6 |
: QObject(parent), m_instance(Engine::start_engine()) {} |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
7 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
8 |
EngineInstance::~EngineInstance() { Engine::cleanup(m_instance); } |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
9 |
|
14290
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14271
diff
changeset
|
10 |
void EngineInstance::sendConfig(const GameConfig& config) { |
14271
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
11 |
for (auto b : config.config()) { |
14290
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14271
diff
changeset
|
12 |
Engine::send_ipc(m_instance, reinterpret_cast<uint8_t*>(b.data()), |
14271
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
13 |
static_cast<size_t>(b.size())); |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
14 |
} |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
15 |
} |
1aac8a62be6f
Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents:
14154
diff
changeset
|
16 |
|
14290
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14271
diff
changeset
|
17 |
void EngineInstance::advance(quint32 ticks) {} |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14271
diff
changeset
|
18 |
|
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14271
diff
changeset
|
19 |
void EngineInstance::renderFrame() {} |
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14271
diff
changeset
|
20 |
|
14294
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14290
diff
changeset
|
21 |
void EngineInstance::setOpenGLContext(QOpenGLContext* context) { |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14290
diff
changeset
|
22 |
Engine::setup_current_gl_context(m_instance, 0, 0, &getProcAddress); |
21be7838a127
Add advance_simulation() function to engine lib, some WIP on frontend
unc0rr
parents:
14290
diff
changeset
|
23 |
} |
14290
92e5682810d4
Prepare to have possibility to pass opengl context to engine
unc0rr
parents:
14271
diff
changeset
|
24 |
|
14154
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
25 |
Engine::PreviewInfo EngineInstance::generatePreview() { |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
26 |
Engine::PreviewInfo pinfo; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
27 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
28 |
Engine::generate_preview(m_instance, &pinfo); |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
29 |
|
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
30 |
return pinfo; |
8354b390f1a2
Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff
changeset
|
31 |
} |