@@ -94,7 +94,7 @@ public: | |||
m_texture->SetData(m_heightmap); | |||
m_shader->Bind(); | |||
m_shader->SetUniform(m_texture_uni, m_texture->GetTexture(), 0); | |||
m_shader->SetUniform(m_texture_uni, m_texture->GetTextureUniform(), 0); | |||
m_vdecl->SetStream(m_vbo, m_coord); | |||
m_vdecl->Bind(); | |||
m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | |||
@@ -100,7 +100,7 @@ public: | |||
* we cannot expect the render target contents to be preserved. | |||
* This code snippet should be moved inside the Framebuffer class. */ | |||
m_shader->SetUniform(m_uni_flag, 1.f); | |||
m_shader->SetUniform(m_uni_texture, m_fbo->GetTexture(), 0); | |||
m_shader->SetUniform(m_uni_texture, m_fbo->GetTextureUniform(), 0); | |||
m_vdecl->SetStream(m_vbo, m_coord); | |||
m_vdecl->Bind(); | |||
m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | |||
@@ -119,7 +119,7 @@ public: | |||
m_shader->Bind(); | |||
m_shader->SetUniform(m_uni_flag, 1.f); | |||
m_shader->SetUniform(m_uni_texture, m_fbo->GetTexture(), 0); | |||
m_shader->SetUniform(m_uni_texture, m_fbo->GetTextureUniform(), 0); | |||
m_vdecl->SetStream(m_vbo, m_coord); | |||
m_vdecl->Bind(); | |||
m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | |||
@@ -277,7 +277,7 @@ public: | |||
m_fbos[f].m2->Bind(); | |||
int i = 0; | |||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], src_buf->GetTexture(), 0); //"in_texture" | |||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], src_buf->GetTextureUniform(), 0); //"in_texture" | |||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], voronoi_points[j].m1); //"in_source_point" | |||
m_fbos[f].m2->SetUniform(m_fbos[f].m3[i++], vec2(512.f, 512.f)); //"in_screen_res" | |||
@@ -344,7 +344,7 @@ public: | |||
* we cannot expect the render target contents to be preserved. | |||
* This code snippet should be moved inside the Framebuffer class. */ | |||
//m_fbos[m_cur_fbo].m2->SetUniform(m_uni_flag, 1.f); | |||
//m_fbos[m_cur_fbo].m2->SetUniform(m_uni_texture, m_fbo->GetTexture(), 0); | |||
//m_fbos[m_cur_fbo].m2->SetUniform(m_uni_texture, m_fbo->GetTextureUniform(), 0); | |||
//m_vdecl->SetStream(m_vbo, m_fbos[m_cur_fbo].m4.Last()); | |||
//m_vdecl->Bind(); | |||
//m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | |||
@@ -353,10 +353,10 @@ public: | |||
int i = 0; | |||
if (curres == ivec2::zero) | |||
m_screen_shader->SetUniform(m_screen_texture, src_buf->GetTexture(), 0); | |||
m_screen_shader->SetUniform(m_screen_texture, src_buf->GetTextureUniform(), 0); | |||
else if (m_cur_fbo == VoronoiFbo) | |||
{ | |||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], src_buf->GetTexture(), 0); //"in_texture" | |||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], src_buf->GetTextureUniform(), 0); //"in_texture" | |||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], ((float)curres.x) / 512.f); //"in_step" | |||
shader->SetUniform(m_fbos[m_cur_fbo].m3[i++], vec2(512.f, 512.f)); //"in_screen_res" | |||
} | |||
@@ -384,7 +384,7 @@ public: | |||
//SCREEN DRAW | |||
m_screen_shader->Bind(); | |||
m_screen_shader->SetUniform(m_screen_texture, m_fbos[m_cur_fbo].m1->GetTexture(), 0); | |||
m_screen_shader->SetUniform(m_screen_texture, m_fbos[m_cur_fbo].m1->GetTextureUniform(), 0); | |||
m_vdecl->SetStream(m_vbo, m_screen_coord); | |||
m_vdecl->Bind(); | |||
m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6); | |||
@@ -434,9 +434,9 @@ Framebuffer::~Framebuffer() | |||
delete m_data; | |||
} | |||
ShaderTexture Framebuffer::GetTexture() const | |||
TextureUniform Framebuffer::GetTextureUniform() const | |||
{ | |||
ShaderTexture ret; | |||
TextureUniform ret; | |||
#if defined USE_D3D9 || defined _XBOX | |||
ret.m_flags = (uint64_t)(uintptr_t)m_data->m_texture; | |||
#else | |||
@@ -664,7 +664,7 @@ void Shader::SetUniform(ShaderUniform const &uni, mat4 const &m) | |||
#endif | |||
} | |||
void Shader::SetUniform(ShaderUniform const &uni, ShaderTexture tex, int index) | |||
void Shader::SetUniform(ShaderUniform const &uni, TextureUniform tex, int index) | |||
{ | |||
#if defined USE_D3D9 || defined _XBOX | |||
data->m_dev->SetTexture(index, (LPDIRECT3DTEXTURE9)tex.m_flags); | |||
@@ -175,9 +175,9 @@ Texture::Texture(ivec2 size, PixelFormat format) | |||
#endif | |||
} | |||
ShaderTexture Texture::GetTexture() const | |||
TextureUniform Texture::GetTextureUniform() const | |||
{ | |||
ShaderTexture ret; | |||
TextureUniform ret; | |||
#if defined USE_D3D9 || defined _XBOX | |||
ret.m_flags = (uint64_t)(uintptr_t)m_data->m_texture; | |||
ret.m_attrib = m_data->m_mag_filter; | |||
@@ -101,7 +101,7 @@ public: | |||
Framebuffer(ivec2 size, FramebufferFormat fbo_format = FramebufferFormat()); | |||
~Framebuffer(); | |||
ShaderTexture GetTexture() const; | |||
TextureUniform GetTextureUniform() const; | |||
ivec2 GetSize() const; | |||
void Bind(); | |||
@@ -133,14 +133,14 @@ private: | |||
uint64_t m_flags; | |||
}; | |||
struct ShaderTexture | |||
struct TextureUniform | |||
{ | |||
friend class Shader; | |||
friend class Framebuffer; | |||
friend class Texture; | |||
public: | |||
inline ShaderTexture() : m_flags(0) {} | |||
inline TextureUniform() : m_flags(0) {} | |||
private: | |||
uint64_t m_flags; | |||
@@ -172,7 +172,7 @@ public: | |||
void SetUniform(ShaderUniform const &uni, mat2 const &m); | |||
void SetUniform(ShaderUniform const &uni, mat3 const &m); | |||
void SetUniform(ShaderUniform const &uni, mat4 const &m); | |||
void SetUniform(ShaderUniform const &uni, ShaderTexture tex, int index); | |||
void SetUniform(ShaderUniform const &uni, TextureUniform tex, int index); | |||
void SetUniform(ShaderUniform const &uni, Array<float> const &v); | |||
void SetUniform(ShaderUniform const &uni, Array<vec2> const &v); | |||
@@ -102,7 +102,7 @@ public: | |||
void SetMinFiltering(TextureMinFilter filter); | |||
void GenerateMipmaps(); | |||
ShaderTexture GetTexture() const; | |||
TextureUniform GetTextureUniform() const; | |||
private: | |||
class TextureData *m_data; | |||
@@ -104,7 +104,7 @@ void SubMesh::Render(Shader* shader) | |||
{ | |||
// TODO: might be good to cache this | |||
ShaderUniform u_tex = shader->GetUniformLocation(m_textures[i].m1.C()); | |||
shader->SetUniform(u_tex, m_textures[i].m2->GetTexture(), i); | |||
shader->SetUniform(u_tex, m_textures[i].m2->GetTextureUniform(), i); | |||
} | |||
m_vdecl->Bind(); | |||
@@ -299,18 +299,20 @@ class DirectoryData | |||
DirectoryData() : m_type(StreamType::File) | |||
{ | |||
#if WIN32 | |||
#if __CELLOS_LV2__ || __ANDROID__ | |||
/* FIXME: not implemented */ | |||
#elif WIN32 | |||
m_handle = INVALID_HANDLE_VALUE; | |||
#elif HAVE_STDIO_H | |||
m_dd = nullptr; | |||
#endif WIN32 | |||
#endif | |||
} | |||
void Open(String const &directory, FileAccess mode) | |||
{ | |||
m_type = StreamType::File; | |||
#if __CELLOS_LV2__ || __ANDROID__ | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#elif WIN32 | |||
m_directory = directory; | |||
String filter = m_directory + String("*"); | |||
@@ -330,15 +332,16 @@ class DirectoryData | |||
if (IsValid()) | |||
{ | |||
#if __CELLOS_LV2__ || __ANDROID__ | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#elif WIN32 | |||
FindClose(m_handle); | |||
#elif HAVE_STDIO_H | |||
closedir(m_dd); | |||
#endif | |||
} | |||
#if __CELLOS_LV2__ || __ANDROID__ | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#elif WIN32 | |||
m_handle = INVALID_HANDLE_VALUE; | |||
#elif HAVE_STDIO_H | |||
@@ -352,7 +355,7 @@ class DirectoryData | |||
return false; | |||
#if __CELLOS_LV2__ || __ANDROID__ | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#elif WIN32 | |||
String filter = m_directory + String("*"); | |||
filter.Replace('/', '\\', true); | |||
@@ -364,7 +367,7 @@ class DirectoryData | |||
{ | |||
if (find_data.cFileName[0] != '.') | |||
{ | |||
//We have a directory | |||
// We have a directory | |||
if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) | |||
{ | |||
if (directories) | |||
@@ -380,7 +383,7 @@ class DirectoryData | |||
file_valid = FindNextFile(m_handle, &find_data); | |||
} | |||
#elif HAVE_STDIO_H | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#endif | |||
return ((files && files->Count()) || (directories && directories->Count())); | |||
} | |||
@@ -388,7 +391,7 @@ class DirectoryData | |||
inline bool IsValid() const | |||
{ | |||
#if __CELLOS_LV2__ || __ANDROID__ | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#elif WIN32 | |||
return (m_handle != INVALID_HANDLE_VALUE); | |||
#elif HAVE_STDIO_H | |||
@@ -399,7 +402,7 @@ class DirectoryData | |||
} | |||
#if __CELLOS_LV2__ || __ANDROID__ | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#elif WIN32 | |||
HANDLE m_handle; | |||
String m_directory; | |||
@@ -522,14 +525,14 @@ String Directory::GetCurrent() | |||
{ | |||
String result; | |||
#if __CELLOS_LV2__ || __ANDROID__ | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#elif WIN32 | |||
TCHAR buff[MAX_PATH * 2]; | |||
GetCurrentDirectory(MAX_PATH, buff); | |||
result = buff; | |||
result.Replace('\\', '/', true); | |||
#elif HAVE_STDIO_H | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#endif | |||
return result; | |||
} | |||
@@ -538,13 +541,13 @@ String Directory::GetCurrent() | |||
bool Directory::SetCurrent(String directory) | |||
{ | |||
#if __CELLOS_LV2__ || __ANDROID__ | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#elif WIN32 | |||
String result = directory; | |||
result.Replace('/', '\\', true); | |||
return SetCurrentDirectory(result.C()); | |||
#elif HAVE_STDIO_H | |||
//NO IMPLEMENTATION | |||
/* FIXME: not implemented */ | |||
#endif | |||
return false; | |||
} | |||
@@ -180,9 +180,9 @@ ivec2 TileSet::GetTextureSize() const | |||
return m_data->m_texture_size; | |||
} | |||
ShaderTexture TileSet::GetShaderTexture() const | |||
Texture * TileSet::GetTexture() | |||
{ | |||
return m_data->m_texture->GetTexture(); | |||
return m_data->m_texture; | |||
} | |||
Texture const * TileSet::GetTexture() const | |||
@@ -48,9 +48,9 @@ public: | |||
int GetTileCount() const; | |||
ivec2 GetTileSize(int tileid) const; | |||
ivec2 GetTextureSize() const; | |||
ShaderTexture GetShaderTexture() const; | |||
Texture * GetTexture(); | |||
Texture const * GetTexture() const; | |||
ivec2 GetTextureSize() const; | |||
void Bind(); | |||
void Unbind(); | |||
void BlitTile(uint32_t id, vec3 pos, int o, vec2 scale, float angle, | |||
@@ -585,7 +585,7 @@ void BtPhysTest::TickDraw(float seconds) | |||
(1 << VertexUsage::TexCoord) | | |||
(1 << VertexUsage::TexCoordExt)), | |||
m_cat_shader); | |||
m_cat_sdata->m_shader_texture = m_cat_texture->GetShaderTexture(); | |||
m_cat_sdata->m_tex_uniform = m_cat_texture->GetTexture()->GetTextureUniform(); | |||
m_cat_sdata->m_sprite_flip = ((rand(2) == 1)?(1.f):(0.f)) / (float)(NB_SPRITE * PARTICLE_SIZE); | |||
PhysObj->SetCustomShaderData(m_cat_sdata); | |||
m_cat_sdata = NULL; | |||
@@ -708,7 +708,7 @@ void CatShaderData::SetupShaderDatas(mat4 const &model) | |||
m_shader->SetUniform(*GetUniform("in_model_view"), modelview); | |||
m_shader->SetUniform(*GetUniform("in_normal_mat"), normalmat); | |||
m_shader->SetUniform(*GetUniform("in_proj"), proj); | |||
m_shader->SetUniform(*GetUniform("in_texture"), m_shader_texture, 0); | |||
m_shader->SetUniform(*GetUniform("in_texture"), m_tex_uniform, 0); | |||
m_shader->SetUniform(*GetUniform("in_sprite_orientation"), m_sprite_orientation); | |||
m_shader->SetUniform(*GetUniform("in_sprite_flip"), m_sprite_flip); | |||
} | |||
@@ -24,7 +24,7 @@ public: | |||
virtual lol::String GetInColorName() { return lol::String("in_color"); } | |||
virtual lol::String GetInTexCoordName() { return lol::String("in_texcoord"); } | |||
ShaderTexture m_shader_texture; | |||
TextureUniform m_tex_uniform; | |||
float m_sprite_orientation; | |||
float m_sprite_flip; | |||
}; | |||
@@ -34,11 +34,12 @@ class PhysicsObject : public WorldEntity | |||
{ | |||
public: | |||
PhysicsObject(Simulation* new_sim, const vec3 &base_location, const quat &base_rotation) | |||
: m_ready(false), m_should_render(true), m_is_character(false), m_custom_shader(0) | |||
: m_custom_shader(0), | |||
m_ready(false), | |||
m_should_render(true), | |||
m_is_character(false), | |||
m_is_phys(false) | |||
{ | |||
#if CAT_MODE | |||
m_is_phys = false; | |||
#endif //CAT_MODE | |||
m_physics = new EasyPhysic(this); | |||
m_mesh.Compile("[sc#ddd afcb 60 1 60 -.1]"); | |||
@@ -52,11 +53,12 @@ public: | |||
} | |||
PhysicsObject(Simulation* new_sim, const vec3 &base_location, const quat &base_rotation, int dummy) | |||
: m_ready(false), m_should_render(true), m_is_character(false), m_custom_shader(0) | |||
: m_custom_shader(0), | |||
m_ready(false), | |||
m_should_render(true), | |||
m_is_character(false), | |||
m_is_phys(false) | |||
{ | |||
#if CAT_MODE | |||
m_is_phys = false; | |||
#endif //CAT_MODE | |||
if (dummy == 1) //for platform purpose | |||
{ | |||
m_physics = new EasyPhysic(this); | |||
@@ -122,16 +124,16 @@ public: | |||
} | |||
PhysicsObject(Simulation* new_sim, float base_mass, const vec3 &base_location, int RandValue = -1) | |||
: m_ready(false), m_should_render(true), m_is_character(false), m_custom_shader(0) | |||
: m_custom_shader(0), | |||
m_ready(false), | |||
m_should_render(true), | |||
m_is_character(false), | |||
m_is_phys(false) | |||
{ | |||
Array<char const *> MeshRand; | |||
Array<int> MeshLimit; | |||
Array<int> MeshType; | |||
#if CAT_MODE | |||
m_is_phys = true; | |||
#endif //CAT_MODE | |||
MeshLimit << 0; | |||
#if USE_BOX | |||
@@ -342,18 +344,16 @@ protected: | |||
} | |||
private: | |||
//Base datas | |||
EasyMesh m_mesh; | |||
EasyPhysic* m_physics; | |||
EasyCharacterController* m_character; | |||
GpuShaderData* m_custom_shader; | |||
bool m_ready; | |||
bool m_should_render; | |||
bool m_is_character; | |||
#if CAT_MODE | |||
bool m_is_phys; | |||
#endif //CAT_MODE | |||
// Base data | |||
EasyMesh m_mesh; | |||
EasyPhysic* m_physics; | |||
EasyCharacterController* m_character; | |||
GpuShaderData* m_custom_shader; | |||
bool m_ready; | |||
bool m_should_render; | |||
bool m_is_character; | |||
bool m_is_phys; /* Only used in CAT_MODE */ | |||
}; | |||
#endif /* __PHYSICOBJECT_H__ */ | |||