Skip to content

Commit

Permalink
logger function instead of printf
Browse files Browse the repository at this point in the history
  • Loading branch information
CedricGuillemet committed Jan 3, 2019
1 parent e2cd2f9 commit 22d7e0f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions PathTracer/src/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace GLSLPathTracer
static const float M_PI = 3.14159265358979323846f;

static const int kMaxLineLength = 2048;
int(*Log)(const char* szFormat, ...) = printf;

void LoadModel(Scene *scene, const std::string &filename, float materialId)
{
Expand Down Expand Up @@ -135,11 +136,11 @@ namespace GLSLPathTracer

if (!file)
{
printf("Couldn't open %s for reading\n", filename.c_str());
Log("Couldn't open %s for reading\n", filename.c_str());
return false;
}

printf("Loading Scene..\n");
Log("Loading Scene..\n");

struct Material
{
Expand Down Expand Up @@ -395,7 +396,7 @@ namespace GLSLPathTracer
}
if (!meshPath.empty())
{
printf("Loading Model: %s\n", meshPath.c_str());
Log("Loading Model: %s\n", meshPath.c_str());
LoadModel(scene, meshPath, materialId);
}
}
Expand All @@ -415,7 +416,7 @@ namespace GLSLPathTracer
//Load albedo Textures
for (size_t i = 0; i < albedoTex.size(); i++)
{
printf("Loading Texture: %s\n", albedoTex[i].c_str());
Log("Loading Texture: %s\n", albedoTex[i].c_str());
unsigned char * texture = SOIL_load_image(albedoTex[i].c_str(), &width, &height, 0, SOIL_LOAD_RGB);
if (i == 0) // Alloc memory based on first texture size
scene->texData.albedoTextures = new unsigned char[width * height * 3 * albedoTex.size()];
Expand All @@ -427,7 +428,7 @@ namespace GLSLPathTracer
//Load MetallicRoughness textures
for (size_t i = 0; i < metallicRoughnessTex.size(); i++)
{
printf("Loading Texture: %s\n", metallicRoughnessTex[i].c_str());
Log("Loading Texture: %s\n", metallicRoughnessTex[i].c_str());
unsigned char * texture = SOIL_load_image(metallicRoughnessTex[i].c_str(), &width, &height, 0, SOIL_LOAD_RGB);
if (i == 0) // Alloc memory based on first texture size
scene->texData.metallicRoughnessTextures = new unsigned char[width * height * 3 * metallicRoughnessTex.size()];
Expand All @@ -439,7 +440,7 @@ namespace GLSLPathTracer
//Load normal textures
for (size_t i = 0; i < normalTex.size(); i++)
{
printf("Loading Texture: %s\n", normalTex[i].c_str());
Log("Loading Texture: %s\n", normalTex[i].c_str());
unsigned char * texture = SOIL_load_image(normalTex[i].c_str(), &width, &height, 0, SOIL_LOAD_RGB);
if (i == 0) // Alloc memory based on first texture size
scene->texData.normalTextures = new unsigned char[width * height * 3 * normalTex.size()];
Expand Down
2 changes: 2 additions & 0 deletions PathTracer/src/Loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ namespace GLSLPathTracer

void LoadModel(Scene *scene, const std::string &filename, float materialId);
bool LoadScene(Scene *scene, const std::string &filename);
// logger function. might be set at init time
extern int(*Log)(const char* szFormat, ...);
}
2 changes: 1 addition & 1 deletion PathTracer/src/TiledRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ namespace GLSLPathTracer
if (tileY < 0)
{
renderCompleted = true;
printf("Completed: %f secs\n", totalTime);
Log("Completed: %f secs\n", totalTime);
}
}
}
Expand Down
Binary file modified lib/x64/SBVH.lib
Binary file not shown.

0 comments on commit 22d7e0f

Please sign in to comment.