Skip to content

Commit

Permalink
remove any file operation of raytracing
Browse files Browse the repository at this point in the history
  • Loading branch information
plattenschieber committed May 12, 2015
1 parent 49abcf1 commit 8681763
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
27 changes: 4 additions & 23 deletions hscgv_uebung_5/raytracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,7 @@ Raytracer::Raytracer(const char *filename, bool antialiasing):
}

void
Raytracer::start() {
// color clamp index
unsigned int maxColVal = 255;
// clamped RGB color
unsigned int cCol[3];

// prepare byte stream for rgb data
unsigned char * data;
data = (unsigned char*)malloc( sizeof(unsigned char) * g_scene.picture.Xresolution * g_scene.picture.Yresolution * 3 );

Raytracer::start(float *renderedScene) {
// setup viewport, its origin is bottom left
// setup camera coordsys
Vec3d eye_dir = (g_scene.view.lookat - g_scene.view.eyepoint).getNormalized();
Expand Down Expand Up @@ -119,20 +110,10 @@ Raytracer::start() {
}
}

// clamp the computed color value to 0...maxColVal
for (unsigned int cc=0; cc<3; cc++) {
if(col[cc] < 0.0)
cCol[cc] = 0;
else if(col[cc] > 1.0)
cCol[cc] = maxColVal;
else
cCol[cc] = (unsigned int)(maxColVal * col[cc]);
}

int index = 3*((sy-1) * g_scene.picture.Xresolution + sx);
data[index + 0] = (char)cCol[0];
data[index + 1] = (char)cCol[1];
data[index + 2] = (char)cCol[2];
renderedScene[index + 0] = col[0];
renderedScene[index + 1] = col[1];
renderedScene[index + 2] = col[2];
} // foreach x
} // foreach y

Expand Down
2 changes: 1 addition & 1 deletion hscgv_uebung_5/raytracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Raytracer
Raytracer();
Raytracer(bool antialiasing);
Raytracer(const char* filename, bool antialiasing);
void start();
void start(float* renderedScene);
bool m_isFileLoaded;
private:
const char *m_filename;
Expand Down

0 comments on commit 8681763

Please sign in to comment.