- removed 0 CR characters - removed 21 trailing whitespaces - replaced 42 tabs with spaceslegacy
@@ -60,8 +60,8 @@ private: | |||||
ID3DXConstantTable *vert_table, *frag_table; | ID3DXConstantTable *vert_table, *frag_table; | ||||
#elif !defined __CELLOS_LV2__ | #elif !defined __CELLOS_LV2__ | ||||
GLuint prog_id, vert_id, frag_id; | GLuint prog_id, vert_id, frag_id; | ||||
// Benlitz: using a simple array could be faster since there is never more than a few attribute locations to store | |||||
Map<String, GLint> attrib_locations; | |||||
// Benlitz: using a simple array could be faster since there is never more than a few attribute locations to store | |||||
Map<String, GLint> attrib_locations; | |||||
#else | #else | ||||
CGprogram vert_id, frag_id; | CGprogram vert_id, frag_id; | ||||
#endif | #endif | ||||
@@ -334,21 +334,21 @@ ShaderAttrib Shader::GetAttribLocation(char const *attr, | |||||
ret.m_flags |= (uint64_t)(uint16_t)index; | ret.m_flags |= (uint64_t)(uint16_t)index; | ||||
#if defined USE_D3D9 || defined _XBOX | #if defined USE_D3D9 || defined _XBOX | ||||
#elif !defined __CELLOS_LV2__ | #elif !defined __CELLOS_LV2__ | ||||
GLint l; | |||||
if (!data->attrib_locations.TryGetValue(attr, l)) | |||||
{ | |||||
l = glGetAttribLocation(data->prog_id, attr); | |||||
if (l < 0) | |||||
{ | |||||
Log::Warn("tried to query invalid attribute: %s\n", attr); | |||||
l = 0; | |||||
} | |||||
else | |||||
{ | |||||
data->attrib_locations[String(attr)] = l; | |||||
} | |||||
} | |||||
GLint l; | |||||
if (!data->attrib_locations.TryGetValue(attr, l)) | |||||
{ | |||||
l = glGetAttribLocation(data->prog_id, attr); | |||||
if (l < 0) | |||||
{ | |||||
Log::Warn("tried to query invalid attribute: %s\n", attr); | |||||
l = 0; | |||||
} | |||||
else | |||||
{ | |||||
data->attrib_locations[String(attr)] = l; | |||||
} | |||||
} | |||||
ret.m_flags |= (uint64_t)(uint32_t)l << 32; | ret.m_flags |= (uint64_t)(uint32_t)l << 32; | ||||
#else | #else | ||||
/* FIXME: can we do this at all on the PS3? */ | /* FIXME: can we do this at all on the PS3? */ | ||||
@@ -24,13 +24,13 @@ namespace lol | |||||
template<typename K, typename V> class Map : protected Hash<K> | template<typename K, typename V> class Map : protected Hash<K> | ||||
{ | { | ||||
public: | public: | ||||
/* If E is different from K, Hash<K> must implement operator()(E const&) | |||||
/* If E is different from K, Hash<K> must implement operator()(E const&) | |||||
* and an equality operator between K and E must exist in order to use this method. | * and an equality operator between K and E must exist in order to use this method. | ||||
*/ | */ | ||||
/* I choose to make this inline because passing the key by reference | /* I choose to make this inline because passing the key by reference | ||||
* is usually suboptimal. */ | * is usually suboptimal. */ | ||||
template <typename E> | |||||
template <typename E> | |||||
inline V const& operator[] (E const &key) const | inline V const& operator[] (E const &key) const | ||||
{ | { | ||||
/* Look for the hash in our table and return the value. */ | /* Look for the hash in our table and return the value. */ | ||||
@@ -44,7 +44,7 @@ public: | |||||
return V(); | return V(); | ||||
} | } | ||||
template <typename E> | |||||
template <typename E> | |||||
inline V & operator[] (E const &key) | inline V & operator[] (E const &key) | ||||
{ | { | ||||
/* Look for the hash in our table and return the value if found. */ | /* Look for the hash in our table and return the value if found. */ | ||||
@@ -58,7 +58,7 @@ public: | |||||
return m_array.Last().m3; | return m_array.Last().m3; | ||||
} | } | ||||
template <typename E> | |||||
template <typename E> | |||||
inline void Remove(E const &key) | inline void Remove(E const &key) | ||||
{ | { | ||||
uint32_t hash = ((Hash<K> const &)*this)(key); | uint32_t hash = ((Hash<K> const &)*this)(key); | ||||
@@ -71,7 +71,7 @@ public: | |||||
} | } | ||||
} | } | ||||
template <typename E> | |||||
template <typename E> | |||||
inline bool HasKey(E const &key) | inline bool HasKey(E const &key) | ||||
{ | { | ||||
uint32_t hash = ((Hash<K> const &)*this)(key); | uint32_t hash = ((Hash<K> const &)*this)(key); | ||||
@@ -82,7 +82,7 @@ public: | |||||
return false; | return false; | ||||
} | } | ||||
template <typename E> | |||||
template <typename E> | |||||
inline bool TryGetValue(E const &key, V& value) | inline bool TryGetValue(E const &key, V& value) | ||||
{ | { | ||||
uint32_t hash = ((Hash<K> const &)*this)(key); | uint32_t hash = ((Hash<K> const &)*this)(key); | ||||
@@ -100,7 +100,7 @@ public: | |||||
void SetMagFiltering(TextureMagFilter filter); | void SetMagFiltering(TextureMagFilter filter); | ||||
void SetMinFiltering(TextureMinFilter filter); | void SetMinFiltering(TextureMinFilter filter); | ||||
void GenerateMipmaps(); | |||||
void GenerateMipmaps(); | |||||
ShaderTexture GetTexture() const; | ShaderTexture GetTexture() const; | ||||
@@ -1792,7 +1792,7 @@ template <typename T> struct Mat4 | |||||
static Mat4<T> frustum(T left, T right, T bottom, T top, T near, T far); | static Mat4<T> frustum(T left, T right, T bottom, T top, T near, T far); | ||||
static Mat4<T> perspective(T fov_y, T width, T height, T near, T far); | static Mat4<T> perspective(T fov_y, T width, T height, T near, T far); | ||||
static Mat4<T> shifted_perspective(T fov_y, T screen_size, T screen_ratio_xy, T draw_distance); | static Mat4<T> shifted_perspective(T fov_y, T screen_size, T screen_ratio_xy, T draw_distance); | ||||
void printf() const; | void printf() const; | ||||
template<class U> | template<class U> | ||||
@@ -274,7 +274,7 @@ public: | |||||
cur_cam->SetProjection(mat4::shifted_perspective(m_fov_damp, screen_size * fov_ratio * 1.1f, 1600.f / 600.f, 1000.f)); | cur_cam->SetProjection(mat4::shifted_perspective(m_fov_damp, screen_size * fov_ratio * 1.1f, 1600.f / 600.f, 1000.f)); | ||||
vec3 cam_center = cam_min_max[0] + min_max_diff * .5f; | vec3 cam_center = cam_min_max[0] + min_max_diff * .5f; | ||||
vec4 test = inverse(world_cam) * vec4(.0f,.0f,-1.0f,1.f); | vec4 test = inverse(world_cam) * vec4(.0f,.0f,-1.0f,1.f); | ||||
test = test; | test = test; | ||||
test = inverse(world_cam) * vec4(.0f,.0f,.0f,1.f); | test = inverse(world_cam) * vec4(.0f,.0f,.0f,1.f); | ||||
@@ -123,9 +123,9 @@ LOLUNIT_FIXTURE(StringTest) | |||||
LOLUNIT_ASSERT(!(s1 != s3)); | LOLUNIT_ASSERT(!(s1 != s3)); | ||||
} | } | ||||
LOLUNIT_TEST(StringCharsEqual) | |||||
LOLUNIT_TEST(StringCharsEqual) | |||||
{ | { | ||||
char const* sz = "abc"; | |||||
char const* sz = "abc"; | |||||
String s1("abc"); | String s1("abc"); | ||||
String s2("ab"); | String s2("ab"); | ||||
@@ -135,9 +135,9 @@ LOLUNIT_FIXTURE(StringTest) | |||||
LOLUNIT_ASSERT(!(sz == s2)); | LOLUNIT_ASSERT(!(sz == s2)); | ||||
} | } | ||||
LOLUNIT_TEST(StringCharsDifferent) | |||||
LOLUNIT_TEST(StringCharsDifferent) | |||||
{ | { | ||||
char const* sz = "abc"; | |||||
char const* sz = "abc"; | |||||
String s1("ab"); | String s1("ab"); | ||||
String s2("abc"); | String s2("abc"); | ||||