Skip to content

Commit

Permalink
Remove redundant codes
Browse files Browse the repository at this point in the history
  • Loading branch information
durswd committed Jul 26, 2023
1 parent cb13af5 commit c298268
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 108 deletions.
56 changes: 30 additions & 26 deletions Dev/Cpp/Test/Backend/GPUParticle.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifdef _WIN32
#include <RenderingEnvironment/RenderingEnvironmentDX11.h>
#include <EffekseerRendererDX11.h>
#include <RenderingEnvironment/RenderingEnvironmentDX11.h>
#endif
#include <RenderingEnvironment/RenderingEnvironmentGL.h>

Expand Down Expand Up @@ -354,7 +354,7 @@ class GpuParticleContext
return;
}

initEmitVertex(); //Update Buffer‚Å‚â‚é‚ׂ«
initEmitVertex(); // Update Buffer‚Å‚â‚é‚ׂ«

Effekseer::Backend::PipelineStateParameter pipParam;

Expand Down Expand Up @@ -411,7 +411,7 @@ class GpuParticleContext

void initUniformLayouts()
{
std::string DirectoryPath = GetDirectoryPath(__FILE__);
std::string DirectoryPath = Effekseer::PathHelper::GetDirectoryName(std::string(__FILE__));
Effekseer::CustomVector<Effekseer::Backend::UniformLayoutElement> updateUniformLayoutElements;
updateUniformLayoutElements.resize(1);
updateUniformLayoutElements[0].Name = "DeltaTime";
Expand Down Expand Up @@ -505,7 +505,7 @@ class GpuParticleContext

void initTraitUniformLayoutAndShaders()
{
std::string DirectoryPath = GetDirectoryPath(__FILE__);
std::string DirectoryPath = Effekseer::PathHelper::GetDirectoryName(std::string(__FILE__));
Effekseer::CustomVector<Effekseer::Backend::UniformLayoutElement> renderUniformLayoutElements;
renderUniformLayoutElements.resize(4);
renderUniformLayoutElements[0].Name = "ID2TPos";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
24 changes: 1 addition & 23 deletions Dev/Cpp/Test/TestHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 0 additions & 2 deletions Dev/Cpp/Test/TestHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <string>
#include <vector>

std::string GetDirectoryPath(const char* path);

std::u16string GetDirectoryPathAsU16(const char* path);

std::vector<uint8_t> LoadFile(const char16_t* path);
Expand Down
57 changes: 0 additions & 57 deletions Examples/Multithread/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,23 +256,8 @@ void MainLoop()
}
}

#if _WIN32
#include <windows.h>
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();

// 描画用インスタンスの生成
Expand Down Expand Up @@ -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

//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------

0 comments on commit c298268

Please sign in to comment.