Skip to content

Commit c7aad09

Browse files
committed
Shaders assets fix
1 parent 0c02572 commit c7aad09

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Rasterizer/Rasterizer/src/Viewer/Shader.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77
#include <sstream>
88
#include <iostream>
99

10+
#include "../path.h"
11+
1012
namespace Viewer
1113
{
1214
class Shader
1315
{
1416
public:
1517
Shader(const std::string& vertexPath, const std::string& fragmentPath)
1618
{
19+
root = Path::Root({ "Rasterizer", "Assets", "Shaders" });
20+
1721
std::string vertexCode;
1822
std::string fragmentCode;
1923

@@ -25,8 +29,8 @@ namespace Viewer
2529

2630
try
2731
{
28-
vShaderFile.open("../Assets/Shaders/" + vertexPath);
29-
fShaderFile.open("../Assets/Shaders/" + fragmentPath);
32+
vShaderFile.open(root / vertexPath);
33+
fShaderFile.open(root / fragmentPath);
3034

3135
std::stringstream vShaderStream, fShaderStream;
3236

@@ -77,6 +81,7 @@ namespace Viewer
7781

7882
private:
7983
unsigned int ID;
84+
std::filesystem::path root;
8085

8186
static void CheckCompileErrors(GLuint shader, std::string type)
8287
{

Rasterizer/Rasterizer/src/path.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ class Path
88
static std::filesystem::path Root(std::vector<std::string> segments)
99
{
1010
auto root = std::filesystem::current_path();
11-
auto current = root.parent_path().filename();
11+
auto current = root.filename();
1212
while (current.string().find("CPURasterizer") == std::string::npos)
1313
{
1414
root = root.parent_path();
15-
current = root.parent_path().filename();
15+
current = root.filename();
1616
}
1717

18-
root = root.parent_path();
19-
2018
for (const auto segment : segments)
2119
root /= segment;
2220

0 commit comments

Comments
 (0)