@@ -1,7 +1,7 @@ | |||||
// | // | ||||
// Lol Engine — Sample math program: check trigonometric functions | |||||
// Lol Engine — Sample math program: polynomials | |||||
// | // | ||||
// Copyright © 2005—2011 Sam Hocevar <sam@hocevar.net> | |||||
// Copyright © 2005—2017 Sam Hocevar <sam@hocevar.net> | |||||
// | // | ||||
// This program is free software. It comes without any warranty, to | // This program is free software. It comes without any warranty, to | ||||
// the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
@@ -20,28 +20,11 @@ | |||||
using namespace lol; | using namespace lol; | ||||
mat4 multiply_copy(mat4 m1, mat4 m2, mat4 m3) | |||||
{ | |||||
return m1 * m2 * m3; | |||||
} | |||||
mat4 multiply_ref(mat4 const &m1, mat4 const &m2, mat4 const &m3) | |||||
{ | |||||
return m1 * m2 * m3; | |||||
} | |||||
int main(int argc, char **argv) | int main(int argc, char **argv) | ||||
{ | { | ||||
UNUSED(argc, argv); | UNUSED(argc, argv); | ||||
mat4 a = mat4::rotate(0.1f, vec3(1.f, 1.f, 0.f)); | |||||
mat4 b = mat4::rotate(0.1f, vec3(0.f, 0.f, 1.f)); | |||||
mat4 m = mat4(1.f); | |||||
for (int i = 0; i < 40000000; ++i) | |||||
//m = multiply_copy(a, m, b); | |||||
m = multiply_ref(a, m, b); | |||||
m.printf(); | |||||
polynomial<polynomial<float>> p; | |||||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||||
} | } | ||||
@@ -64,9 +64,9 @@ void audio::set_channels(int channels) | |||||
void audio::set_volume(int channel, int volume) | void audio::set_volume(int channel, int volume) | ||||
{ | { | ||||
#if defined LOL_USE_SDL_MIXER | #if defined LOL_USE_SDL_MIXER | ||||
Mix_Volume(channel,volume); | |||||
Mix_Volume(channel, volume); | |||||
#else | #else | ||||
UNUSED(channel); | |||||
UNUSED(channel, volume); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -220,7 +220,6 @@ void Debug::DrawBox(vec2 a, vec2 b, mat2 transform, DCD data) | |||||
v[2] = b; | v[2] = b; | ||||
v[3] = vec2(b.x, a.y); | v[3] = vec2(b.x, a.y); | ||||
int i = 0; | |||||
Debug::DrawLine((transform * v[0]).xy, (transform * v[1]).xy, data); | Debug::DrawLine((transform * v[0]).xy, (transform * v[1]).xy, data); | ||||
Debug::DrawLine((transform * v[1]).xy, (transform * v[2]).xy, data); | Debug::DrawLine((transform * v[1]).xy, (transform * v[2]).xy, data); | ||||
Debug::DrawLine((transform * v[2]).xy, (transform * v[3]).xy, data); | Debug::DrawLine((transform * v[2]).xy, (transform * v[3]).xy, data); | ||||
@@ -253,7 +252,6 @@ void Debug::DrawCircle(vec2 a, vec2 s, DCD data) | |||||
//-- | //-- | ||||
void Debug::DrawCircle(vec3 a, vec3 x, vec3 y, DCD data) | void Debug::DrawCircle(vec3 a, vec3 x, vec3 y, DCD data) | ||||
{ | { | ||||
Scene& scene = Scene::GetScene(); | |||||
float size = F_PI * 2.f * lol::max(length(x), length(y)); | float size = F_PI * 2.f * lol::max(length(x), length(y)); | ||||
int segment_nb = lol::max(1, (int)((size * .25f) / data.m_segment_size)); | int segment_nb = lol::max(1, (int)((size * .25f) / data.m_segment_size)); | ||||
for (int i = 0; i < segment_nb; i++) | for (int i = 0; i < segment_nb; i++) | ||||
@@ -272,7 +270,6 @@ void Debug::DrawCircle(vec3 a, vec3 x, vec3 y, DCD data) | |||||
//-- | //-- | ||||
void Debug::DrawCircle(vec2 a, vec2 x, vec2 y, DCD data) | void Debug::DrawCircle(vec2 a, vec2 x, vec2 y, DCD data) | ||||
{ | { | ||||
Scene& scene = Scene::GetScene(); | |||||
float size = F_PI * 2.f * lol::max(length(x), length(y)); | float size = F_PI * 2.f * lol::max(length(x), length(y)); | ||||
int segment_nb = lol::max(1, (int)((size * .25f) / data.m_segment_size)); | int segment_nb = lol::max(1, (int)((size * .25f) / data.m_segment_size)); | ||||
for (int i = 0; i < segment_nb; i++) | for (int i = 0; i < segment_nb; i++) | ||||
@@ -318,7 +315,6 @@ void Debug::DrawCapsule(vec3 a, float s, vec3 h, DCD data) | |||||
//-- | //-- | ||||
void Debug::DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h, DCD data) | void Debug::DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h, DCD data) | ||||
{ | { | ||||
Scene& scene = Scene::GetScene(); | |||||
float size = F_PI * 2.f * lol::max(length(x), length(y)); | float size = F_PI * 2.f * lol::max(length(x), length(y)); | ||||
int segment_nb = lol::max(1, (int)((size * .25f) / data.m_segment_size)); | int segment_nb = lol::max(1, (int)((size * .25f) / data.m_segment_size)); | ||||
for (int i = -1; i < 2; i += 2) | for (int i = -1; i < 2; i += 2) | ||||
@@ -97,7 +97,6 @@ void CsgBsp::AddTriangleToTree(int const &tri_idx, vec3 const &tri_p0, vec3 cons | |||||
{ | { | ||||
//there are two intersections, no more. | //there are two intersections, no more. | ||||
vec3 isec_v[2] = { vec3(.0f), vec3(.0f) }; | vec3 isec_v[2] = { vec3(.0f), vec3(.0f) }; | ||||
int isec_i[2] = { 0, 0 }; | |||||
int isec_base = 0; | int isec_base = 0; | ||||
int isec_idx = 0; | int isec_idx = 0; | ||||
@@ -108,7 +107,7 @@ void CsgBsp::AddTriangleToTree(int const &tri_idx, vec3 const &tri_p0, vec3 cons | |||||
if (TestRayVsPlane(v[i], v[(i + 1) % 3], | if (TestRayVsPlane(v[i], v[(i + 1) % 3], | ||||
m_tree[leaf_idx].m_origin, m_tree[leaf_idx].m_normal, | m_tree[leaf_idx].m_origin, m_tree[leaf_idx].m_normal, | ||||
isec_v[isec_idx])) | isec_v[isec_idx])) | ||||
isec_i[isec_idx++] = i; | |||||
++isec_idx; | |||||
else | else | ||||
isec_base = i; | isec_base = i; | ||||
} | } | ||||
@@ -274,7 +273,6 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
int isec_i[2] = { 0, 0 }; | int isec_i[2] = { 0, 0 }; | ||||
int new_v_idx[2] = { 0, 0 }; | int new_v_idx[2] = { 0, 0 }; | ||||
int isec_base = 0; | int isec_base = 0; | ||||
int isec_idx = 0; | |||||
int i = 0; | int i = 0; | ||||
for (; i < m_tree[leaf_idx].m_tri_list.count(); i++) | for (; i < m_tree[leaf_idx].m_tri_list.count(); i++) | ||||
@@ -351,11 +349,11 @@ int CsgBsp::TestTriangleToTree(vec3 const &tri_p0, vec3 const &tri_p1, vec3 cons | |||||
int v_idx0 = (isec_base == 1)?(1):(0); | int v_idx0 = (isec_base == 1)?(1):(0); | ||||
int v_idx1 = (isec_base == 1)?(0):(1); | int v_idx1 = (isec_base == 1)?(0):(1); | ||||
int tri_to_remove = tri_to_process.count() - 1; | |||||
#if 0 | |||||
//Leaf_type is the type for the triangle that is alone on its side. | //Leaf_type is the type for the triangle that is alone on its side. | ||||
int leaf_type = res_side[(isec_base + 2) % 3]; | int leaf_type = res_side[(isec_base + 2) % 3]; | ||||
int tri_to_remove = tri_to_process.count() - 1; | |||||
#if 0 | |||||
if (m_tree[leaf_idx].m_leaves[leaf_type] == LEAF_CURRENT && tri_to_process.last().m1.last() == 1) | if (m_tree[leaf_idx].m_leaves[leaf_type] == LEAF_CURRENT && tri_to_process.last().m1.last() == 1) | ||||
tri_list.push(leaf_type, | tri_list.push(leaf_type, | ||||
t[(isec_base + 2) % 3], new_v_idx[v_idx1], new_v_idx[v_idx0]); | t[(isec_base + 2) % 3], new_v_idx[v_idx1], new_v_idx[v_idx0]); | ||||
@@ -187,17 +187,18 @@ const LuaObjectLibrary* EasyMeshLuaObject::GetLib() | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
bool EasyMesh::Compile(char const *command, bool Execute) | |||||
bool EasyMesh::Compile(char const *command, bool execute) | |||||
{ | { | ||||
bool res = false; | bool res = false; | ||||
// FIXME: make this work again | // FIXME: make this work again | ||||
UNUSED(command, execute); | |||||
#if 0 | #if 0 | ||||
EasyMeshCompiler mc(*this); | EasyMeshCompiler mc(*this); | ||||
BD()->Enable(MeshBuildOperation::CommandRecording); | BD()->Enable(MeshBuildOperation::CommandRecording); | ||||
if ((res = mc.ParseString(command))) | if ((res = mc.ParseString(command))) | ||||
{ | { | ||||
BD()->Disable(MeshBuildOperation::CommandRecording); | BD()->Disable(MeshBuildOperation::CommandRecording); | ||||
if (Execute) | |||||
if (execute) | |||||
ExecuteCmdStack(); | ExecuteCmdStack(); | ||||
} | } | ||||
#endif | #endif | ||||
@@ -259,6 +259,8 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) : | |||||
Ticker::Setup(fps); | Ticker::Setup(fps); | ||||
Video::Setup((ivec2)data->screen_size); | Video::Setup((ivec2)data->screen_size); | ||||
audio::init(); | audio::init(); | ||||
#else | |||||
UNUSED(title, res, fps); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -70,7 +70,7 @@ void Emitter::TickDraw(float seconds, Scene &scene) | |||||
for (int i = 0; i < data->nparticles; i++) | for (int i = 0; i < data->nparticles; i++) | ||||
scene.AddTile(data->tileset, data->particles[i], | scene.AddTile(data->tileset, data->particles[i], | ||||
data->positions[i], 0, vec2(1.0f), 0.0f); | |||||
data->positions[i], vec2(1.0f), 0.0f); | |||||
} | } | ||||
void Emitter::AddParticle(int id, vec3 pos, vec3 vel) | void Emitter::AddParticle(int id, vec3 pos, vec3 vel) | ||||
@@ -69,7 +69,7 @@ void Entity::TickGame(float seconds) | |||||
void Entity::TickDraw(float seconds, Scene &scene) | void Entity::TickDraw(float seconds, Scene &scene) | ||||
{ | { | ||||
(void)seconds; | |||||
UNUSED(seconds, scene); | |||||
#if !LOL_BUILD_RELEASE | #if !LOL_BUILD_RELEASE | ||||
if (m_tickstate != STATE_PRETICK_DRAW) | if (m_tickstate != STATE_PRETICK_DRAW) | ||||
msg::error("invalid entity draw tick\n"); | msg::error("invalid entity draw tick\n"); | ||||
@@ -89,7 +89,7 @@ void Font::Print(Scene &scene, vec3 pos, char const *str, vec2 scale, float spac | |||||
break; | break; | ||||
default: | default: | ||||
if (ch != ' ') | if (ch != ' ') | ||||
scene.AddTile(data->tileset, ch & 255, pos, 0, scale, 0.0f); | |||||
scene.AddTile(data->tileset, ch & 255, pos, scale, 0.0f); | |||||
pos.x += data->size.x * scale.x; | pos.x += data->size.x * scale.x; | ||||
break; | break; | ||||
} | } | ||||
@@ -320,6 +320,7 @@ static float cie_1931_xyz[] = | |||||
/* CIE 1964 Colorimetric Observer, aka. 10º Observer | /* CIE 1964 Colorimetric Observer, aka. 10º Observer | ||||
* for wavelengths 360 to 830. */ | * for wavelengths 360 to 830. */ | ||||
#if 0 | |||||
static float cie_1964_xyz[] = | static float cie_1964_xyz[] = | ||||
{ | { | ||||
/* 360 — 399 nm */ | /* 360 — 399 nm */ | ||||
@@ -571,6 +572,7 @@ static float cie_1964_xyz[] = | |||||
1.747e-06f, 7.074e-07f, 0.0000000f, 1.647e-06f, 6.675e-07f, 0.0000000f, | 1.747e-06f, 7.074e-07f, 0.0000000f, 1.647e-06f, 6.675e-07f, 0.0000000f, | ||||
1.553e-06f, 6.297e-07f, 0.0000000f, | 1.553e-06f, 6.297e-07f, 0.0000000f, | ||||
}; | }; | ||||
#endif | |||||
vec3 Color::WavelengthToCIExyY(float nm) | vec3 Color::WavelengthToCIExyY(float nm) | ||||
{ | { | ||||
@@ -152,7 +152,7 @@ image image::Median(ivec2 ksize) const | |||||
return ret; | return ret; | ||||
} | } | ||||
image image::Median(array2d<float> const &kernel) const | |||||
image image::Median(array2d<float> const &ker) const | |||||
{ | { | ||||
ivec2 const isize = size(); | ivec2 const isize = size(); | ||||
image tmp = *this; | image tmp = *this; | ||||
@@ -166,7 +166,7 @@ image image::Median(array2d<float> const &kernel) const | |||||
else | else | ||||
#endif | #endif | ||||
{ | { | ||||
ivec2 const ksize = kernel.size(); | |||||
ivec2 const ksize = ker.size(); | |||||
array2d<vec3> list(ksize); | array2d<vec3> list(ksize); | ||||
vec4 *srcp = tmp.lock<PixelFormat::RGBA_F32>(); | vec4 *srcp = tmp.lock<PixelFormat::RGBA_F32>(); | ||||
@@ -207,7 +207,7 @@ image image::Median(array2d<float> const &kernel) const | |||||
for (int j = 0; j < ksize.y; ++j) | for (int j = 0; j < ksize.y; ++j) | ||||
for (int i = 0; i < ksize.x; ++i) | for (int i = 0; i < ksize.x; ++i) | ||||
{ | { | ||||
float d = kernel[i][j] / | |||||
float d = ker[i][j] / | |||||
(1e-10f + distance(median, list[i][j])); | (1e-10f + distance(median, list[i][j])); | ||||
s1 += list[i][j] * d; | s1 += list[i][j] * d; | ||||
s2 += d; | s2 += d; | ||||
@@ -99,9 +99,11 @@ bool movie::open_file(char const *filename) | |||||
msg::error("could not write header: %s\n", ERROR_TO_STRING(ret)); | msg::error("could not write header: %s\n", ERROR_TO_STRING(ret)); | ||||
return false; | return false; | ||||
} | } | ||||
#endif | |||||
return true; | return true; | ||||
#else | |||||
UNUSED(filename); | |||||
return false; | |||||
#endif | |||||
} | } | ||||
bool movie::push_image(image &im) | bool movie::push_image(image &im) | ||||
@@ -144,6 +146,8 @@ bool movie::push_image(image &im) | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
#else | |||||
UNUSED(im); | |||||
#endif | #endif | ||||
return true; | return true; | ||||
@@ -63,6 +63,10 @@ struct LOL_ATTR_NODISCARD mat_t | |||||
inline vec_t<T,ROWS>& operator[](size_t n) { return m_data[n]; } | inline vec_t<T,ROWS>& operator[](size_t n) { return m_data[n]; } | ||||
inline vec_t<T,ROWS> const& operator[](size_t n) const { return m_data[n]; } | inline vec_t<T,ROWS> const& operator[](size_t n) const { return m_data[n]; } | ||||
template<class U> | |||||
friend std::ostream &operator<<(std::ostream &stream, | |||||
mat_t<U,COLS,ROWS> const &m); | |||||
private: | private: | ||||
vec_t<T,ROWS> m_data[COLS]; | vec_t<T,ROWS> m_data[COLS]; | ||||
}; | }; | ||||
@@ -131,10 +135,6 @@ struct LOL_ATTR_NODISCARD mat_t<T, 2, 2> | |||||
void printf() const; | void printf() const; | ||||
String tostring() const; | String tostring() const; | ||||
template<class U> | |||||
friend std::ostream &operator<<(std::ostream &stream, | |||||
mat_t<U,2,2> const &m); | |||||
static const mat_t<T,2,2> identity; | static const mat_t<T,2,2> identity; | ||||
private: | private: | ||||
@@ -262,10 +262,6 @@ struct LOL_ATTR_NODISCARD mat_t<T, 3, 3> | |||||
void printf() const; | void printf() const; | ||||
String tostring() const; | String tostring() const; | ||||
template<class U> | |||||
friend std::ostream &operator<<(std::ostream &stream, | |||||
mat_t<U,3,3> const &m); | |||||
static const mat_t<T,3,3> identity; | static const mat_t<T,3,3> identity; | ||||
private: | private: | ||||
@@ -442,10 +438,6 @@ struct LOL_ATTR_NODISCARD mat_t<T, 4, 4> | |||||
void printf() const; | void printf() const; | ||||
String tostring() const; | String tostring() const; | ||||
template<class U> | |||||
friend std::ostream &operator<<(std::ostream &stream, | |||||
mat_t<U,4,4> const &m); | |||||
static const mat_t<T,4,4> identity; | static const mat_t<T,4,4> identity; | ||||
private: | private: | ||||
@@ -463,6 +455,24 @@ static_assert(sizeof(f16mat4) == 32, "sizeof(f16mat4) == 32"); | |||||
static_assert(sizeof(mat4) == 64, "sizeof(mat4) == 64"); | static_assert(sizeof(mat4) == 64, "sizeof(mat4) == 64"); | ||||
static_assert(sizeof(dmat4) == 128, "sizeof(dmat4) == 128"); | static_assert(sizeof(dmat4) == 128, "sizeof(dmat4) == 128"); | ||||
/* | |||||
* stdstream method implementations | |||||
*/ | |||||
template<class U, int COLS, int ROWS> | |||||
std::ostream &operator<<(std::ostream &stream, | |||||
mat_t<U,COLS,ROWS> const &m) | |||||
{ | |||||
for (int y = 0; y < ROWS; ++y) | |||||
{ | |||||
stream << (y == 0 ? "(" : ", "); | |||||
for (int x = 0; x < COLS; ++x) | |||||
stream << (x == 0 ? "(" : ", ") << m[x][y]; | |||||
stream << ")"; | |||||
} | |||||
return stream << ")"; | |||||
} | |||||
/* | /* | ||||
* Transpose any matrix | * Transpose any matrix | ||||
*/ | */ | ||||
@@ -321,6 +321,23 @@ struct LOL_ATTR_NODISCARD sqt_t | |||||
T s; | T s; | ||||
}; | }; | ||||
/* | |||||
* stdstream method implementations | |||||
*/ | |||||
template<typename U> | |||||
std::ostream &operator<<(std::ostream &stream, cmplx_t<U> const &c) | |||||
{ | |||||
return stream << "(" << c.x << ", " << c.y << ")"; | |||||
} | |||||
template<typename U> | |||||
std::ostream &operator<<(std::ostream &stream, quat_t<U> const &q) | |||||
{ | |||||
return stream << "(" << q.w << ", " << q.x << ", " | |||||
<< q.y << ", " << q.z << ")"; | |||||
} | |||||
/* | /* | ||||
* Common operations on transforms | * Common operations on transforms | ||||
*/ | */ | ||||
@@ -1017,6 +1017,29 @@ static_assert(sizeof(f16vec4) == 8, "sizeof(f16vec4) == 8"); | |||||
static_assert(sizeof(vec4) == 16, "sizeof(vec4) == 16"); | static_assert(sizeof(vec4) == 16, "sizeof(vec4) == 16"); | ||||
static_assert(sizeof(dvec4) == 32, "sizeof(dvec4) == 32"); | static_assert(sizeof(dvec4) == 32, "sizeof(dvec4) == 32"); | ||||
/* | |||||
* stdstream method implementations | |||||
*/ | |||||
template<typename U> | |||||
std::ostream &operator<<(std::ostream &stream, vec_t<U,2> const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ")"; | |||||
} | |||||
template<typename U> | |||||
std::ostream &operator<<(std::ostream &stream, vec_t<U,3> const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ", " << v.z << ")"; | |||||
} | |||||
template<typename U> | |||||
std::ostream &operator<<(std::ostream &stream, vec_t<U,4> const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ", " | |||||
<< v.z << ", " << v.w << ")"; | |||||
} | |||||
/* | /* | ||||
* vec_t *(scalar, vec_t) | * vec_t *(scalar, vec_t) | ||||
*/ | */ | ||||
@@ -346,6 +346,8 @@ void LolImGui::TickDraw(float seconds, Scene &scene) | |||||
} | } | ||||
void PrimitiveLolImGui::Render(Scene& scene, PrimitiveSource* primitive) | void PrimitiveLolImGui::Render(Scene& scene, PrimitiveSource* primitive) | ||||
{ | { | ||||
UNUSED(scene, primitive); | |||||
ImGuiIO& io = ImGui::GetIO(); | ImGuiIO& io = ImGui::GetIO(); | ||||
if (io.Fonts->TexID) | if (io.Fonts->TexID) | ||||
ImGui::Render(); | ImGui::Render(); | ||||
@@ -416,7 +418,7 @@ void LolImGui::RenderDrawListsMethod(ImDrawData* draw_data) | |||||
for (int n = 0; n < draw_data->CmdListsCount; n++) | for (int n = 0; n < draw_data->CmdListsCount; n++) | ||||
{ | { | ||||
const ImDrawList* cmd_list = draw_data->CmdLists[n]; | const ImDrawList* cmd_list = draw_data->CmdLists[n]; | ||||
const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front(); | |||||
/*const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();*/ | |||||
//Register uniforms | //Register uniforms | ||||
m_shader->SetUniform(m_ortho, ortho); | m_shader->SetUniform(m_ortho, ortho); | ||||
@@ -151,7 +151,7 @@ void Loader::StoreObject(lua_State* l, Object* obj) | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
bool Loader::ExecLuaFile(String const &lua) | bool Loader::ExecLuaFile(String const &lua) | ||||
{ | { | ||||
const char* c = lua_pushstring(m_lua_state, lua.C()); | |||||
lua_pushstring(m_lua_state, lua.C()); | |||||
int status = LuaBaseData::LuaDoFile(m_lua_state); | int status = LuaBaseData::LuaDoFile(m_lua_state); | ||||
return status == 0; | return status == 0; | ||||
} | } | ||||
@@ -123,7 +123,7 @@ namespace lol | |||||
//We first need to find two points intersecting, no matter on which triangle. | //We first need to find two points intersecting, no matter on which triangle. | ||||
for (int i = 0; i < 2 && isecIdx < 2; i++) | for (int i = 0; i < 2 && isecIdx < 2; i++) | ||||
{ | { | ||||
int found_isec = -1; | |||||
/*int found_isec = -1;*/ | |||||
for (int j = 0; j < 3 && isecIdx < 2; j++) | for (int j = 0; j < 3 && isecIdx < 2; j++) | ||||
{ | { | ||||
int pIdx = j + i * 3; | int pIdx = j + i * 3; | ||||
@@ -150,7 +150,7 @@ namespace lol | |||||
//if it's the second intersection, we need it to be different from the first one. | //if it's the second intersection, we need it to be different from the first one. | ||||
(isecIdx == 1 && length(isec[0] - isec[1]) > TestEpsilon::Get())) | (isecIdx == 1 && length(isec[0] - isec[1]) > TestEpsilon::Get())) | ||||
{ | { | ||||
found_isec = i; | |||||
/*found_isec = i;*/ | |||||
isecIdx++; | isecIdx++; | ||||
} | } | ||||
} | } | ||||
@@ -172,11 +172,9 @@ namespace lol | |||||
vec3 &isec_p) | vec3 &isec_p) | ||||
{ | { | ||||
vec3 rayD0 = ray_p01 - ray_p00; | vec3 rayD0 = ray_p01 - ray_p00; | ||||
float rayS0 = length(rayD0); | |||||
vec3 rayD0N = normalize(rayD0); | vec3 rayD0N = normalize(rayD0); | ||||
vec3 rayD1 = ray_p11 - ray_p10; | vec3 rayD1 = ray_p11 - ray_p10; | ||||
float rayS1 = length(rayD1); | |||||
vec3 rayD1N = normalize(rayD1); | vec3 rayD1N = normalize(rayD1); | ||||
vec3 rayP0P1 = ray_p10 - ray_p00; | vec3 rayP0P1 = ray_p10 - ray_p00; | ||||
@@ -92,61 +92,5 @@ template<> String mat4::tostring() const | |||||
p[0][3], p[1][3], p[2][3], p[3][3]); | p[0][3], p[1][3], p[2][3], p[3][3]); | ||||
} | } | ||||
template<> std::ostream &operator<<(std::ostream &stream, ivec2 const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ")"; | |||||
} | |||||
template<> std::ostream &operator<<(std::ostream &stream, ivec3 const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ", " << v.z << ")"; | |||||
} | |||||
template<> std::ostream &operator<<(std::ostream &stream, ivec4 const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ", " | |||||
<< v.z << ", " << v.w << ")"; | |||||
} | |||||
template<> std::ostream &operator<<(std::ostream &stream, vec2 const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ")"; | |||||
} | |||||
template<> std::ostream &operator<<(std::ostream &stream, cmplx const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ")"; | |||||
} | |||||
template<> std::ostream &operator<<(std::ostream &stream, vec3 const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ", " << v.z << ")"; | |||||
} | |||||
template<> std::ostream &operator<<(std::ostream &stream, vec4 const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ", " | |||||
<< v.z << ", " << v.w << ")"; | |||||
} | |||||
template<> std::ostream &operator<<(std::ostream &stream, quat const &v) | |||||
{ | |||||
return stream << "(" << v.x << ", " << v.y << ", " | |||||
<< v.z << ", " << v.w << ")"; | |||||
} | |||||
template<> std::ostream &operator<<(std::ostream &stream, mat4 const &m) | |||||
{ | |||||
stream << "((" << m[0][0] << ", " << m[1][0] | |||||
<< ", " << m[2][0] << ", " << m[3][0] << "), "; | |||||
stream << "(" << m[0][1] << ", " << m[1][1] | |||||
<< ", " << m[2][1] << ", " << m[3][1] << "), "; | |||||
stream << "(" << m[0][2] << ", " << m[1][2] | |||||
<< ", " << m[2][2] << ", " << m[3][2] << "), "; | |||||
stream << "(" << m[0][3] << ", " << m[1][3] | |||||
<< ", " << m[2][3] << ", " << m[3][3] << "))"; | |||||
return stream; | |||||
} | |||||
} /* namespace lol */ | } /* namespace lol */ | ||||
@@ -132,11 +132,13 @@ void SubMesh::Render() | |||||
attribs[j] = m_shader->GetAttribLocation(usage, usages[usage_index]++); | attribs[j] = m_shader->GetAttribLocation(usage, usages[usage_index]++); | ||||
} | } | ||||
vertex_count = m_vbos[i]->GetSize() / m_vdecl->GetStream(i).GetSize(); | |||||
vertex_count += m_vbos[i]->GetSize() / m_vdecl->GetStream(i).GetSize(); | |||||
m_vdecl->SetStream(m_vbos[i], attribs); | m_vdecl->SetStream(m_vbos[i], attribs); | ||||
} | } | ||||
UNUSED(vertex_count); | |||||
for (int i = 0; i < m_textures.count(); ++i) | for (int i = 0; i < m_textures.count(); ++i) | ||||
{ | { | ||||
// TODO: might be good to cache this | // TODO: might be good to cache this | ||||
@@ -39,6 +39,9 @@ void PrimitiveMesh::Render(Scene& scene, PrimitiveSource* primitive) | |||||
ShaderUniform u_model, u_modelview, u_normalmat, uni_tex, uni_texsize; | ShaderUniform u_model, u_modelview, u_normalmat, uni_tex, uni_texsize; | ||||
ShaderAttrib a_pos, a_tex; | ShaderAttrib a_pos, a_tex; | ||||
/* FIXME: ignored for now */ | |||||
UNUSED(primitive); | |||||
{ | { | ||||
/* If this primitive uses a new shader, update attributes */ | /* If this primitive uses a new shader, update attributes */ | ||||
if (m_submesh->GetShader() != shader) | if (m_submesh->GetShader() != shader) | ||||
@@ -58,6 +58,8 @@ static inline void gpu_marker(char const *message) | |||||
#if LOL_USE_GLEW | #if LOL_USE_GLEW | ||||
if (GLEW_GREMEDY_string_marker) | if (GLEW_GREMEDY_string_marker) | ||||
glStringMarkerGREMEDY(0, message); | glStringMarkerGREMEDY(0, message); | ||||
#else | |||||
UNUSED(message); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -498,7 +500,7 @@ void Scene::ReleaseAllPrimitiveRenderers(uintptr_t key) | |||||
} | } | ||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
void Scene::AddTile(TileSet *tileset, int id, vec3 pos, int o, vec2 scale, float radians) | |||||
void Scene::AddTile(TileSet *tileset, int id, vec3 pos, vec2 scale, float radians) | |||||
{ | { | ||||
ASSERT(id < tileset->GetTileCount()); | ASSERT(id < tileset->GetTileCount()); | ||||
@@ -582,7 +584,7 @@ void Scene::DisableDisplay() | |||||
static bool do_pp = true; | static bool do_pp = true; | ||||
void Scene::pre_render(float seconds) | |||||
void Scene::pre_render(float) | |||||
{ | { | ||||
gpu_marker("Pre Render"); | gpu_marker("Pre Render"); | ||||
@@ -615,7 +617,7 @@ void Scene::render(float seconds) | |||||
render_lines(seconds); | render_lines(seconds); | ||||
} | } | ||||
void Scene::post_render(float seconds) | |||||
void Scene::post_render(float) | |||||
{ | { | ||||
gpu_marker("Post Render"); | gpu_marker("Post Render"); | ||||
@@ -230,7 +230,7 @@ public: | |||||
/* FIXME: this should be deprecated -- it doesn't really match | /* FIXME: this should be deprecated -- it doesn't really match | ||||
* the architecture we want to build */ | * the architecture we want to build */ | ||||
void AddTile(TileSet *tileset, int id, vec3 pos, int o, vec2 scale, float radians); | |||||
void AddTile(TileSet *tileset, int id, vec3 pos, vec2 scale, float radians); | |||||
void AddTile(TileSet *tileset, int id, mat4 model); | void AddTile(TileSet *tileset, int id, mat4 model); | ||||
public: | public: | ||||
@@ -46,7 +46,7 @@ void Sprite::TickDraw(float seconds, Scene &scene) | |||||
{ | { | ||||
Entity::TickDraw(seconds, scene); | Entity::TickDraw(seconds, scene); | ||||
scene.AddTile(data->tileset, data->id, m_position, 0, vec2(1.0f), 0.0f); | |||||
scene.AddTile(data->tileset, data->id, m_position, vec2(1.0f), 0.0f); | |||||
} | } | ||||
Sprite::~Sprite() | Sprite::~Sprite() | ||||
@@ -25,6 +25,10 @@ | |||||
# include <dirent.h> | # include <dirent.h> | ||||
#endif | #endif | ||||
#if defined HAVE_UNISTD_H | |||||
# include <unistd.h> | |||||
#endif | |||||
#include <atomic> | #include <atomic> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
@@ -60,6 +64,7 @@ class FileData | |||||
case StreamType::StdOut: m_fd = stdout; break; | case StreamType::StdOut: m_fd = stdout; break; | ||||
case StreamType::StdErr: m_fd = stderr; break; | case StreamType::StdErr: m_fd = stderr; break; | ||||
#endif | #endif | ||||
default: break; | |||||
} | } | ||||
} | } | ||||
@@ -352,6 +357,8 @@ class DirectoryData | |||||
void Open(String const &directory, FileAccess mode) | void Open(String const &directory, FileAccess mode) | ||||
{ | { | ||||
UNUSED(mode); /* FIXME */ | |||||
m_type = StreamType::File; | m_type = StreamType::File; | ||||
#if __ANDROID__ | #if __ANDROID__ | ||||
/* FIXME: not implemented */ | /* FIXME: not implemented */ | ||||
@@ -540,6 +547,7 @@ bool Directory::GetContent(array<String>* files, array<Directory>* directories) | |||||
{ | { | ||||
array<String> sfiles, sdirectories; | array<String> sfiles, sdirectories; | ||||
bool found_some = m_data->GetContentList(&sfiles, &sdirectories); | bool found_some = m_data->GetContentList(&sfiles, &sdirectories); | ||||
UNUSED(found_some); | |||||
if (directories) | if (directories) | ||||
for (int i = 0; i < sdirectories.count(); i++) | for (int i = 0; i < sdirectories.count(); i++) | ||||
@@ -608,8 +616,8 @@ bool Directory::SetCurrent(String directory) | |||||
String result = directory; | String result = directory; | ||||
result.replace('/', '\\', true); | result.replace('/', '\\', true); | ||||
return !!SetCurrentDirectory(result.C()); | return !!SetCurrentDirectory(result.C()); | ||||
#elif HAVE_STDIO_H | |||||
/* FIXME: not implemented */ | |||||
#elif HAVE_UNISTD_H | |||||
chdir(directory.C()); | |||||
#endif | #endif | ||||
return false; | return false; | ||||
} | } | ||||
@@ -46,21 +46,21 @@ protected: | |||||
*/ | */ | ||||
TileSet::TileSet(char const *path) | TileSet::TileSet(char const *path) | ||||
: m_tileset_data(new TileSetData()), | |||||
m_palette(nullptr), | |||||
TextureImage(path) | |||||
: TextureImage(path), | |||||
m_tileset_data(new TileSetData()), | |||||
m_palette(nullptr) | |||||
{ | { | ||||
} | } | ||||
TileSet::TileSet(char const *path, Image* image) | TileSet::TileSet(char const *path, Image* image) | ||||
: TextureImage(path, image), | |||||
: TextureImage(path, image), | |||||
m_tileset_data(new TileSetData()), | m_tileset_data(new TileSetData()), | ||||
m_palette(nullptr) | m_palette(nullptr) | ||||
{ | { | ||||
} | } | ||||
TileSet::TileSet(char const *path, Image* image, array<ivec2, ivec2>& tiles) | TileSet::TileSet(char const *path, Image* image, array<ivec2, ivec2>& tiles) | ||||
: TextureImage(path, image), | |||||
: TextureImage(path, image), | |||||
m_tileset_data(new TileSetData()), | m_tileset_data(new TileSetData()), | ||||
m_palette(nullptr) | m_palette(nullptr) | ||||
{ | { | ||||
@@ -121,6 +121,8 @@ void Video::Capture(uint32_t *buffer) | |||||
buffer[j * width + i] = buffer[(height - j - 1) * width + i]; | buffer[j * width + i] = buffer[(height - j - 1) * width + i]; | ||||
buffer[(height - j - 1) * width + i] = tmp; | buffer[(height - j - 1) * width + i] = tmp; | ||||
} | } | ||||
#else | |||||
UNUSED(buffer); | |||||
#endif | #endif | ||||
} | } | ||||