From 8797569d33c4917eb8f8a1dc2341aac7b5815315 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 22 Jul 2012 22:05:12 +0200 Subject: Texture & mouse functions; refactoring & fixes - cleaned up and added documentation to engine.h - refactored CEngine interface and associated structs - added mouse handling functions in CApplication & CEngine - fixed bugs in projection matrix setting - changed texture loading & handling - added const-values in CDevice & CGLDevice - changed event management in CApplication - other minor changes & bugfixes --- src/common/event.h | 7 ++++++- src/common/key.h | 4 ++-- src/common/singleton.h | 10 +++++----- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/common') diff --git a/src/common/event.h b/src/common/event.h index 70b110d..6ce1a79 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -36,6 +36,7 @@ enum EventType // TODO: document the meaning of each value + //! Invalid event / no event EVENT_NULL = 0, //! Event sent on user or system quit request @@ -638,6 +639,9 @@ struct Event //! Type of event (EVENT_*) EventType type; + //! If true, the event was produced by system (SDL); else, it has come from user interface + bool systemEvent; + //! Additional data for EVENT_KEY_DOWN and EVENT_KEY_UP KeyEventData key; //! Additional data for EVENT_MOUSE_BUTTON_DOWN and EVENT_MOUSE_BUTTON_UP @@ -657,7 +661,8 @@ struct Event //? short keyState; // state of the keyboard (KS_ *) //? float rTime; // relative time - Event(EventType aType = EVENT_NULL) : type(aType) {} + Event(EventType aType = EVENT_NULL) + : type(aType), systemEvent(false) {} }; diff --git a/src/common/key.h b/src/common/key.h index 0ed6b54..de31c09 100644 --- a/src/common/key.h +++ b/src/common/key.h @@ -27,8 +27,8 @@ // Key symbol defined as concatenation to SDLK_... // If need arises, it can be changed to custom function or anything else -#define KEY(x) SDLK_ # x +#define KEY(x) SDLK_ ## x // Key modifier defined as concatenation to KMOD_... // If need arises, it can be changed to custom function or anything else -#define KEY_MOD(x) KMOD_ # x +#define KEY_MOD(x) KMOD_ ## x diff --git a/src/common/singleton.h b/src/common/singleton.h index ee01b24..4df7878 100644 --- a/src/common/singleton.h +++ b/src/common/singleton.h @@ -29,21 +29,21 @@ template class CSingleton public: static T& GetInstance() { - aserrt(mInstance); + assert(mInstance != NULL); return *mInstance; } - static T& GetInstancePointer() { - aserrt(mInstance); + static T* GetInstancePointer() { + assert(mInstance != NULL); return mInstance; } static bool IsCreated() { - return mInstance != NULL; + return mInstance != NULL; } CSingleton() { - assert(!mInstance); + assert(mInstance == NULL); mInstance = static_cast(this); } -- cgit v1.2.3-1-g7c22