qmlfrontend/engine_instance.h
author Simon McVittie <smcv@debian.org>
Mon, 12 Sep 2022 10:40:53 -0400
branch1.0.0
changeset 15859 7b1d6dfa3173
parent 15217 b32c52c76977
child 15891 d52f5d8e75e6
permissions -rw-r--r--
Remove FindSDL2 find-module, use sdl2-config.cmake instead This requires SDL >= 2.0.4. Since <https://bugzilla.libsdl.org/show_bug.cgi?id=2464> was fixed in SDL 2.0.4, SDL behaves as a CMake "config-file package", even if it was not itself built using CMake: it installs a sdl2-config.cmake file to ${libdir}/cmake/SDL2, which tells CMake where to find SDL's headers and library, analogous to a pkg-config .pc file. As a result, we no longer need to copy/paste a "find-module package" to be able to find a system copy of SDL >= 2.0.4 with find_package(SDL2). Find-module packages are now discouraged by the CMake developers, in favour of having upstream projects behave as config-file packages. This results in a small API change: FindSDL2 used to set SDL2_INCLUDE_DIR and SDL2_LIBRARY, but the standard behaviour for config-file packages is to set <name>_INCLUDE_DIRS and <name>_LIBRARIES. Use the CONFIG keyword to make sure we search in config-file package mode, and will not find a FindSDL2.cmake in some other directory that implements the old interface. In addition to deleting redundant code, this avoids some assumptions in FindSDL2 about the layout of a SDL installation. The current libsdl2-dev package in Debian breaks those assumptions; this is considered a bug and will hopefully be fixed soon, but it illustrates how fragile these assumptions can be. We can be more robust against different installation layouts by relying on SDL's own CMake integration. When linking to a copy of CMake in a non-standard location, users can now set the SDL2_DIR or CMAKE_PREFIX_PATH environment variable to point to it; previously, these users would have used the SDL2DIR environment variable. This continues to be unnecessary if using matching system-wide installations of CMake and SDL2, for example both from Debian.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
     1
#ifndef ENGINEINSTANCE_H
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
     2
#define ENGINEINSTANCE_H
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
     3
14373
4409344db447 Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents: 14372
diff changeset
     4
#include <QImage>
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
     5
#include <QObject>
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14271
diff changeset
     6
#include <QOpenGLContext>
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
     7
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
     8
#include "engine_interface.h"
14271
1aac8a62be6f Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents: 14154
diff changeset
     9
#include "game_config.h"
1aac8a62be6f Implement send_ipc and read_ipc in engine lib, send_ipc in frontend
unC0Rr
parents: 14154
diff changeset
    10
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    11
class EngineInstance : public QObject {
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    12
  Q_OBJECT
14854
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14842
diff changeset
    13
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    14
 public:
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    15
  explicit EngineInstance(const QString& libraryPath,
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    16
                          QObject* parent = nullptr);
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    17
  ~EngineInstance();
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    18
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    19
  Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged)
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    20
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14271
diff changeset
    21
  void sendConfig(const GameConfig& config);
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14271
diff changeset
    22
  void renderFrame();
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14271
diff changeset
    23
  void setOpenGLContext(QOpenGLContext* context);
14373
4409344db447 Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents: 14372
diff changeset
    24
  QImage generatePreview();
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    25
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    26
  bool isValid() const;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    27
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    28
 signals:
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    29
  void isValidChanged(bool isValid);
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    30
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    31
 public slots:
14842
ef9630519491 Fix some minor problems with new frontend code
unc0rr
parents: 14713
diff changeset
    32
  void advance(quint32 ticks);
ef9630519491 Fix some minor problems with new frontend code
unc0rr
parents: 14713
diff changeset
    33
  void moveCamera(const QPoint& delta);
15217
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    34
  void simpleEvent(Engine::SimpleEventType event_type);
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    35
  void longEvent(Engine::LongEventType event_type,
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    36
                 Engine::LongEventState state);
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    37
  void positionedEvent(Engine::PositionedEventType event_type, qint32 x,
b32c52c76977 Marry C enums, Qt's metaobject system and QML
unc0rr
parents: 14854
diff changeset
    38
                       qint32 y);
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    39
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    40
 private:
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14271
diff changeset
    41
  Engine::EngineInstance* m_instance;
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    42
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    43
  Engine::hedgewars_engine_protocol_version_t*
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    44
      hedgewars_engine_protocol_version;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    45
  Engine::start_engine_t* start_engine;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    46
  Engine::generate_preview_t* generate_preview;
14373
4409344db447 Rework EngineInstance::generatePreview, add preview cleanup function in enginelib
unC0Rr
parents: 14372
diff changeset
    47
  Engine::dispose_preview_t* dispose_preview;
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    48
  Engine::cleanup_t* cleanup;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    49
  Engine::send_ipc_t* send_ipc;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    50
  Engine::read_ipc_t* read_ipc;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    51
  Engine::setup_current_gl_context_t* setup_current_gl_context;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    52
  Engine::render_frame_t* render_frame;
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    53
  Engine::advance_simulation_t* advance_simulation;
14713
cc6ab1e3f7d5 Allow to move camera around
unc0rr
parents: 14373
diff changeset
    54
  Engine::move_camera_t* move_camera;
14854
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14842
diff changeset
    55
  Engine::simple_event_t* simple_event;
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14842
diff changeset
    56
  Engine::long_event_t* long_event;
aed75d439027 Implement external events approach to input user actions into engine.
unc0rr
parents: 14842
diff changeset
    57
  Engine::positioned_event_t* positioned_event;
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14290
diff changeset
    58
  bool m_isValid;
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    59
};
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    60
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents:
diff changeset
    61
#endif  // ENGINEINSTANCE_H