@@ -364,7 +364,7 @@ Shader::Shader(char const *vert, char const *frag) | |||
glGetActiveAttrib(data->prog_id, i, max_len, &attrib_len, (GLint*)&attrib_size, (GLenum*)&attrib_type, name_buffer); | |||
String name(name_buffer); | |||
int index = 0; | |||
int index = -1; | |||
VertexUsage usage = VertexUsage::Max; | |||
for (int j = 0; j < VertexUsage::Max; ++j) | |||
{ | |||
@@ -377,9 +377,10 @@ Shader::Shader(char const *vert, char const *frag) | |||
} | |||
} | |||
if (usage == VertexUsage::Max || index == LONG_MIN || index == LONG_MAX) | |||
if (usage == VertexUsage::Max || index == -1) | |||
{ | |||
Log::Error("unable to parse attribute sementic from name: %s", name_buffer); | |||
Log::Error("unable to parse attribute semantic from name: %s", | |||
name_buffer); | |||
} | |||
else | |||
{ | |||
@@ -390,7 +391,7 @@ Shader::Shader(char const *vert, char const *frag) | |||
#ifdef _DEBUG | |||
if (data->attrib_locations.HasKey(flags)) | |||
{ | |||
Log::Error("an error occured while parsing attribute sementics"); | |||
Log::Error("an error occured while parsing attribute semantics"); | |||
} | |||
#endif | |||
data->attrib_locations[flags] = location; | |||
@@ -19,7 +19,12 @@ namespace lol | |||
class KeyBinding | |||
{ | |||
public: | |||
KeyBinding() : m_device(nullptr), m_current(false), m_previous(false), m_keyindex(-1) {} | |||
KeyBinding() | |||
: m_device(nullptr), | |||
m_keyindex(-1), | |||
m_current(false), | |||
m_previous(false) | |||
{} | |||
/** Indicate wheither the key is currently down */ | |||
bool IsDown() const { return m_current; } | |||
@@ -52,7 +57,14 @@ protected: | |||
class AxisBinding | |||
{ | |||
public: | |||
AxisBinding() : m_device(nullptr), m_current(0.0f), m_previous(0.0f), m_axisindex(-1), m_minkeyindex(-1), m_maxkeyindex(-1) {} | |||
AxisBinding() | |||
: m_device(nullptr), | |||
m_axisindex(-1), | |||
m_minkeyindex(-1), | |||
m_maxkeyindex(-1), | |||
m_current(0.0f), | |||
m_previous(0.0f) | |||
{} | |||
/** Gets the current absolute value of this axis */ | |||
float GetValue() const { return m_current; } | |||
@@ -69,7 +81,8 @@ public: | |||
void ClearBinding(); | |||
/** Indicate wheither a physical device and axis has been bound */ | |||
bool IsBound() { return m_device && m_axisindex != -1 || m_maxkeyindex != -1; } | |||
bool IsBound() { return m_device && | |||
(m_axisindex != -1 || m_maxkeyindex != -1); } | |||
protected: | |||
void Update() { m_previous = m_current; m_current = IsBound() ? RetrieveCurrentValue() : 0.0f; } | |||
@@ -171,20 +171,27 @@ static inline ldouble ceil(ldouble x) { return std::ceil(x); } | |||
static inline T fract(T x) { return x - lol::floor(x); } \ | |||
static inline T min(T x, T y) { return std::min(x, y); } \ | |||
static inline T max(T x, T y) { return std::max(x, y); } \ | |||
static inline T clamp(T x, T y, T z) { return min(max(x, y), z); } \ | |||
static inline T clamp(T x, T y, T z) { return min(max(x, y), z); } | |||
#define LOL_GENERIC_FUNC_SIGNED(T) \ | |||
LOL_GENERIC_FUNC(T) \ | |||
static inline T sign(T x) { return (T)(((T)0 < x) - (x < (T)0)); } | |||
LOL_GENERIC_FUNC(uint8_t) | |||
LOL_GENERIC_FUNC(int8_t) | |||
LOL_GENERIC_FUNC(uint16_t) | |||
LOL_GENERIC_FUNC(int16_t) | |||
LOL_GENERIC_FUNC(uint32_t) | |||
LOL_GENERIC_FUNC(int32_t) | |||
LOL_GENERIC_FUNC(uint64_t) | |||
LOL_GENERIC_FUNC(int64_t) | |||
LOL_GENERIC_FUNC(float) | |||
LOL_GENERIC_FUNC(double) | |||
LOL_GENERIC_FUNC(ldouble) | |||
#define LOL_GENERIC_FUNC_UNSIGNED(T) \ | |||
LOL_GENERIC_FUNC(T) \ | |||
static inline T sign(T x) { return (T)((T)0 < x); } | |||
LOL_GENERIC_FUNC_UNSIGNED(uint8_t) | |||
LOL_GENERIC_FUNC_SIGNED(int8_t) | |||
LOL_GENERIC_FUNC_UNSIGNED(uint16_t) | |||
LOL_GENERIC_FUNC_SIGNED(int16_t) | |||
LOL_GENERIC_FUNC_UNSIGNED(uint32_t) | |||
LOL_GENERIC_FUNC_SIGNED(int32_t) | |||
LOL_GENERIC_FUNC_UNSIGNED(uint64_t) | |||
LOL_GENERIC_FUNC_SIGNED(int64_t) | |||
LOL_GENERIC_FUNC_SIGNED(float) | |||
LOL_GENERIC_FUNC_SIGNED(double) | |||
LOL_GENERIC_FUNC_SIGNED(ldouble) | |||
#undef LOL_GENERIC_FUNC | |||
} /* namespace lol */ | |||