Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kimkulling/vcpkg integration #204

Merged
merged 10 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "imgui"]
path = contrib/imgui
url = https://github.com/ocornut/imgui.git
[submodule "contrib/vcpkg"]
path = contrib/vcpkg
url = https://github.com/microsoft/vcpkg.git
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ENDIF()

#ADD_DEFINITIONS( -DGLM_ENABLE_EXPERIMENTAL )

# Include all sub directories of the engine code component
# Include all sub-directories of the engine code component
ADD_SUBDIRECTORY( src/Engine )
if (OSRE_BUILD_PLAYER)
ADD_SUBDIRECTORY( src/Player )
Expand Down Expand Up @@ -132,7 +132,7 @@ IF( OSRE_BUILD_DOC )
COMMENT "Generating OSRE-API documentation with Doxygen" VERBATIM
)
else (DOXYGEN_FOUND)
MESSAGE("Doxygen need to be installed to generate the doxygen documentation")
MESSAGE("Doxygen needs to be installed to generate the doxygen documentation")
ENDIF ( DOXYGEN_FOUND )
ENDIF( OSRE_BUILD_DOC )

Expand Down
13 changes: 13 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 3,
"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}

2 changes: 1 addition & 1 deletion contrib/assimp
Submodule assimp updated 1272 files
1 change: 1 addition & 0 deletions contrib/vcpkg
Submodule vcpkg added at 52b52b
35 changes: 18 additions & 17 deletions include/osre/Common/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <osre/Common/StringUtils.h>
#include <osre/Common/TFunctor.h>

// Container
#include <cppcore/Container/TArray.h>
#include <cppcore/Container/TList.h>

Expand All @@ -38,23 +39,22 @@ struct Event;
struct EventData;

//-------------------------------------------------------------------------------------------------
/// @ingroup Engine
///
/// @brief Event type declaration helper macro. This is a shortcut to define global events like
/// windows messages.
/// @brief Event type declaration helper macro.
///
/// This is a shortcut to define global events like Windows messages.
//-------------------------------------------------------------------------------------------------
#define DECL_EVENT(NAME) const Common::Event NAME(#NAME)

//-------------------------------------------------------------------------------------------------
/// @ingroup Engine
///
/// @brief The base class of osre-events, describes type of an event. To create your own events
/// it is possible to build derives from the base class.
/// @brief The base class of osre-events.
///
/// Describes the type of an event. To create your events it is possible to build derives
/// from the base class.
//-------------------------------------------------------------------------------------------------
struct OSRE_EXPORT Event {
friend class EventTriggerer;

/// @brief the class constructor with description id.
/// @brief The class constructor with description id.
/// @param id Id description, will be used to describe the event type.
Event(const c8 *id);

Expand Down Expand Up @@ -90,10 +90,10 @@ struct OSRE_EXPORT Event {
Event(const Event &) = delete;
Event &operator=(const Event &) = delete;

ui32 m_numRefs;
HashId m_hash;
ui32 mNumRefs;
HashId mHash;
const c8 *mId;
const EventData *m_eventData;
const EventData *mEventData;
};

//--------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -141,14 +141,15 @@ struct OSRE_EXPORT EventData {
EventData &operator=(const EventData &) = delete;

private:
const Event &m_Event;
EventTriggerer *m_Source;
d32 m_timestamp;
ui32 m_numRefs;
const Event &mEvent;
EventTriggerer *mSource;
d32 mTimestamp;
ui32 mNumRefs;
void *mPayload;
};

/// Base event functor.
typedef Functor<void, const Event &, const EventData *> EventFunctor;
using EventFunctor = Functor<void, const Event &, const EventData *>;

using EventDataList = cppcore::TList<Common::EventData *>;
using EventPtrArray = cppcore::TArray<const Common::Event *>;
Expand Down
4 changes: 2 additions & 2 deletions include/osre/Platform/PlatformInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class WindowsMoveEventData : public Common::EventData {
///
/// @brief This class stores window-resizing events.
//-------------------------------------------------------------------------------------------------
class WindowsResizeEventData : public Common::EventData {
class WindowsResizeEventData : public Common::EventData{
public:
/// @brief The class constructor.
/// @param c The event trigger.
Expand Down Expand Up @@ -120,7 +120,7 @@ class OSRE_EXPORT KeyboardButtonEventData : public Common::EventData {
//-------------------------------------------------------------------------------------------------
class OSRE_EXPORT MouseButtonEventData : public Common::EventData {
public:
/// @brief An enum to descripe the button state.
/// @brief An enum to describe the button state.
enum ButtonType {
LeftButton = 0,
MiddleButton,
Expand Down
1 change: 1 addition & 0 deletions src/Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}/contrib/glm/
${PROJECT_SOURCE_DIR}/contrib/unzip/
${PROJECT_SOURCE_DIR}/contrib/zlib/
${CMAKE_CURRENT_BINARY_DIR}//contrib/zlib/
${PROJECT_SOURCE_DIR}/contrib/assimp/include
)

Expand Down
42 changes: 21 additions & 21 deletions src/Engine/Common/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ namespace OSRE {
namespace Common {

Event::Event(const c8 *id) :
m_numRefs(1),
m_hash(StringUtils::hashName(id)),
mNumRefs(1),
mHash(StringUtils::hashName(id)),
mId(id),
m_eventData(nullptr) {
mEventData(nullptr) {
// empty
}

void Event::setEventData(const EventData *pData) {
m_eventData = pData;
mEventData = pData;
}

const EventData *Event::getEventData() const {
return m_eventData;
return mEventData;
}

HashId Event::getHash() const {
return m_hash;
return mHash;
}

const String Event::getId() const {
Expand All @@ -52,51 +52,51 @@ const String Event::getId() const {
}

void Event::get() {
++m_numRefs;
++mNumRefs;
}

void Event::release() {
--m_numRefs;
if (0 == m_numRefs) {
--mNumRefs;
if (0 == mNumRefs) {
delete this;
}
}

bool Event::operator == (const Event &rhs) const {
return (m_hash == rhs.m_hash);
return (mHash == rhs.mHash);
}

EventData::EventData(const Event &e, EventTriggerer *c) :
m_Event(e),
m_Source(c),
m_timestamp(0.0),
m_numRefs(1) {
mEvent(e),
mSource(c),
mTimestamp(0.0),
mNumRefs(1) {
// empty
}

const Event &EventData::getEvent() const {
return m_Event;
return mEvent;
}

EventTriggerer *EventData::getEventSender() const {
return m_Source;
return mSource;
}

void EventData::get() {
++m_numRefs;
++mNumRefs;
}

void EventData::release() {
if (m_numRefs) {
--m_numRefs;
if (0 == m_numRefs) {
if (mNumRefs) {
--mNumRefs;
if (mNumRefs == 0) {
delete this;
}
}
}

bool EventData::operator==(const EventData &other) const {
return (m_Event == other.m_Event && m_Source == other.m_Source);
return (mEvent == other.mEvent && mSource == other.mSource);
}

} // Namespace Common
Expand Down
13 changes: 2 additions & 11 deletions src/Engine/Platform/sdl2/SDL2EventQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,8 @@ bool SDL2EventHandler::update() {
case SDL_KEYDOWN:
case SDL_KEYUP: {
KeyboardButtonEventData *data = new KeyboardButtonEventData(SDL_KEYDOWN == ev.type, m_eventTriggerer);
if (ev.key.keysym.sym == SDLK_RCTRL) {
data->m_key = KEY_RCTRL;
} else if (ev.key.keysym.sym == SDLK_LCTRL) {
data->m_key = KEY_LCTRL;
} else if (ev.key.keysym.sym == SDLK_LSHIFT){
data->m_key = KEY_LSHIFT;
} else if (ev.key.keysym.sym == SDLK_RSHIFT){
data->m_key = KEY_RSHIFT;
} else {
data->m_key = (Key)ev.key.keysym.sym;
}
const char *c = SDL_GetKeyName(ev.key.keysym.sym);
data->m_key = (Key) *c;
activeEventQueue->addBack(data);
} break;

Expand Down
5 changes: 5 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": [
"sdl2"
]
}
Loading