From c2982685e9d9e36e83ad97920b632181ef6669ca Mon Sep 17 00:00:00 2001 From: durswd Date: Wed, 26 Jul 2023 19:30:25 +0900 Subject: [PATCH] Remove redundant codes --- Dev/Cpp/Test/Backend/GPUParticle.cpp | 56 ++++++++++++++------------- Dev/Cpp/Test/TestHelper.cpp | 24 +----------- Dev/Cpp/Test/TestHelper.h | 2 - Examples/Multithread/main.cpp | 57 ---------------------------- 4 files changed, 31 insertions(+), 108 deletions(-) diff --git a/Dev/Cpp/Test/Backend/GPUParticle.cpp b/Dev/Cpp/Test/Backend/GPUParticle.cpp index 7bd27bc97c..d443a82530 100644 --- a/Dev/Cpp/Test/Backend/GPUParticle.cpp +++ b/Dev/Cpp/Test/Backend/GPUParticle.cpp @@ -1,6 +1,6 @@ #ifdef _WIN32 -#include #include +#include #endif #include @@ -354,7 +354,7 @@ class GpuParticleContext return; } - initEmitVertex(); //Update Bufferでやるべき + initEmitVertex(); // Update Bufferでやるべき Effekseer::Backend::PipelineStateParameter pipParam; @@ -411,7 +411,7 @@ class GpuParticleContext void initUniformLayouts() { - std::string DirectoryPath = GetDirectoryPath(__FILE__); + std::string DirectoryPath = Effekseer::PathHelper::GetDirectoryName(std::string(__FILE__)); Effekseer::CustomVector updateUniformLayoutElements; updateUniformLayoutElements.resize(1); updateUniformLayoutElements[0].Name = "DeltaTime"; @@ -505,7 +505,7 @@ class GpuParticleContext void initTraitUniformLayoutAndShaders() { - std::string DirectoryPath = GetDirectoryPath(__FILE__); + std::string DirectoryPath = Effekseer::PathHelper::GetDirectoryName(std::string(__FILE__)); Effekseer::CustomVector renderUniformLayoutElements; renderUniformLayoutElements.resize(4); renderUniformLayoutElements[0].Name = "ID2TPos"; @@ -625,28 +625,28 @@ class GpuParticleContext trailOffset = TrailBufferSize - 1; } - //gl.viewport(0, 0, this.texWidth, this.texHeight); - //gl.useProgram(this.trailUpdateShader); - //gl.bindFramebuffer(gl.FRAMEBUFFER, this.trailFrameBuffer); - //this.buffers[sourceIndex].setUpdateSource(); - //gl.uniform1i(gl.getUniformLocation(this.trailUpdateShader, "i_ParticleData0"), 0); - //gl.uniform1i(gl.getUniformLocation(this.trailUpdateShader, "i_ParticleData1"), 1); - //gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, this.trailBufferTexture, 0, this.trailOffset); - //gl.bindBuffer(gl.ARRAY_BUFFER, this.quadBuffer); - //gl.enableVertexAttribArray(0); - //gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0); - //gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); - //gl.disableVertexAttribArray(0); - //gl.bindFramebuffer(gl.FRAMEBUFFER, null); + // gl.viewport(0, 0, this.texWidth, this.texHeight); + // gl.useProgram(this.trailUpdateShader); + // gl.bindFramebuffer(gl.FRAMEBUFFER, this.trailFrameBuffer); + // this.buffers[sourceIndex].setUpdateSource(); + // gl.uniform1i(gl.getUniformLocation(this.trailUpdateShader, "i_ParticleData0"), 0); + // gl.uniform1i(gl.getUniformLocation(this.trailUpdateShader, "i_ParticleData1"), 1); + // gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, this.trailBufferTexture, 0, this.trailOffset); + // gl.bindBuffer(gl.ARRAY_BUFFER, this.quadBuffer); + // gl.enableVertexAttribArray(0); + // gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0); + // gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + // gl.disableVertexAttribArray(0); + // gl.bindFramebuffer(gl.FRAMEBUFFER, null); // Position texture to graphicsDevice->CopyTexture(trailHistoriesTexture, buffers[sourceIndex].textures.at(0), {0, 0, 0}, {0, 0, 0}, {texWidth, texHeight, 1}, trailOffset, 0); - //gl.bindFramebuffer(gl.FRAMEBUFFER, ); - //gl.bindTexture(gl.TEXTURE_2D_ARRAY, this.trailBufferTexture, ); - //gl.copyTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, this.trailOffset, 0, 0, this.texWidth, this.texHeight); - //gl.bindTexture(gl.TEXTURE_2D_ARRAY, null); - //gl.bindFramebuffer(gl.FRAMEBUFFER, null); + // gl.bindFramebuffer(gl.FRAMEBUFFER, ); + // gl.bindTexture(gl.TEXTURE_2D_ARRAY, this.trailBufferTexture, ); + // gl.copyTexSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, this.trailOffset, 0, 0, this.texWidth, this.texHeight); + // gl.bindTexture(gl.TEXTURE_2D_ARRAY, null); + // gl.bindFramebuffer(gl.FRAMEBUFFER, null); } Effekseer::Backend::PipelineStateParameter pipParam; @@ -815,13 +815,17 @@ void GpuParticle(GraphicsDeviceType deviceType, bool trailMode) #if !defined(__FROM_CI__) -TestRegister Test_GpuParticle_GL("Backend.GpuParticle_GL", []() -> void { GpuParticle(GraphicsDeviceType::OpenGL, false); }); -TestRegister Test_GpuParticleTrail_GL("Backend.GpuParticle_Trail_GL", []() -> void { GpuParticle(GraphicsDeviceType::OpenGL, true); }); +TestRegister Test_GpuParticle_GL("Backend.GpuParticle_GL", []() -> void + { GpuParticle(GraphicsDeviceType::OpenGL, false); }); +TestRegister Test_GpuParticleTrail_GL("Backend.GpuParticle_Trail_GL", []() -> void + { GpuParticle(GraphicsDeviceType::OpenGL, true); }); #ifdef _WIN32 -TestRegister Test_GpuParticle_DX11("Backend.GpuParticle_DX11", []() -> void { GpuParticle(GraphicsDeviceType::DirectX11, false); }); -TestRegister Test_GpuParticleTrail_DX11("Backend.GpuParticle_Trail_DX11", []() -> void { GpuParticle(GraphicsDeviceType::DirectX11, true); }); +TestRegister Test_GpuParticle_DX11("Backend.GpuParticle_DX11", []() -> void + { GpuParticle(GraphicsDeviceType::DirectX11, false); }); +TestRegister Test_GpuParticleTrail_DX11("Backend.GpuParticle_Trail_DX11", []() -> void + { GpuParticle(GraphicsDeviceType::DirectX11, true); }); #endif #endif diff --git a/Dev/Cpp/Test/TestHelper.cpp b/Dev/Cpp/Test/TestHelper.cpp index 12a66ee8a7..492745fc66 100644 --- a/Dev/Cpp/Test/TestHelper.cpp +++ b/Dev/Cpp/Test/TestHelper.cpp @@ -27,31 +27,9 @@ static std::wstring ToWide(const char* text) } #endif -std::string GetDirectoryPath(const char* path) -{ - auto p = std::string(path); - size_t last = -1; - for (size_t i = 0; i < p.size(); i++) - { - if (p[i] == '/' || p[i] == '\\') - { - last = i; - } - } - - if (last >= 0) - { - p.resize(last); - p += "/"; - return p; - } - - return ""; -} - std::u16string GetDirectoryPathAsU16(const char* path) { - auto p = GetDirectoryPath(path); + auto p = Effekseer::PathHelper::GetDirectoryName(std::string(path)); #ifdef _WIN32 auto w = ToWide(p.c_str()); diff --git a/Dev/Cpp/Test/TestHelper.h b/Dev/Cpp/Test/TestHelper.h index fe3d932546..c2235e23f9 100644 --- a/Dev/Cpp/Test/TestHelper.h +++ b/Dev/Cpp/Test/TestHelper.h @@ -12,8 +12,6 @@ #include #include -std::string GetDirectoryPath(const char* path); - std::u16string GetDirectoryPathAsU16(const char* path); std::vector LoadFile(const char16_t* path); diff --git a/Examples/Multithread/main.cpp b/Examples/Multithread/main.cpp index b259299124..3d32cdce06 100644 --- a/Examples/Multithread/main.cpp +++ b/Examples/Multithread/main.cpp @@ -256,23 +256,8 @@ void MainLoop() } } -#if _WIN32 -#include -std::wstring ToWide(const char* pText); -void GetDirectoryName(char* dst, char* src); -#endif - -//---------------------------------------------------------------------------------- -// -//---------------------------------------------------------------------------------- int main(int argc, char** argv) { -#if _WIN32 - char current_path[MAX_PATH + 1]; - GetDirectoryName(current_path, argv[0]); - SetCurrentDirectoryA(current_path); -#endif - InitWindow(); // 謠冗判逕ィ繧、繝ウ繧ケ繧ソ繝ウ繧ケ縺ョ逕滓 @@ -352,45 +337,3 @@ int main(int argc, char** argv) return 0; } -//---------------------------------------------------------------------------------- -// -//---------------------------------------------------------------------------------- - -#if _WIN32 -static std::wstring ToWide(const char* pText) -{ - int Len = ::MultiByteToWideChar(CP_ACP, 0, pText, -1, NULL, 0); - - wchar_t* pOut = new wchar_t[Len + 1]; - ::MultiByteToWideChar(CP_ACP, 0, pText, -1, pOut, Len); - std::wstring Out(pOut); - delete[] pOut; - - return Out; -} - -void GetDirectoryName(char* dst, char* src) -{ - auto Src = std::string(src); - int pos = 0; - int last = 0; - while (Src.c_str()[pos] != 0) - { - dst[pos] = Src.c_str()[pos]; - - if (Src.c_str()[pos] == L'\\' || Src.c_str()[pos] == L'/') - { - last = pos; - } - - pos++; - } - - dst[pos] = 0; - dst[last] = 0; -} -#endif - -//---------------------------------------------------------------------------------- -// -//---------------------------------------------------------------------------------- \ No newline at end of file