예제 #1
0
int main(int argc, char* argv[]) {
  FreeImage_Initialise();
  
  Camera camera;  
  Sample sample;
  Ray ray;
  Color* color = new Color(0.f, 0.f, 0.f);

  initColor();

  readfile(argv[1], &camera);

  const float pi = 3.14159265 ;
  float fovx = 2 * atan( tan(camera.fovy * pi/180/2.f) * ((float) w) / ((float) h) ) * 180/pi;

  Film film = Film::Film(w, h);
  while (Sample::getSample(&sample, w, h)) {
      if (sample.x % 700 == 0) printf("Sample: %d, %d\n", sample.x, sample.y);
      if (sample.y < 200) continue;
      camera.generateRay(sample, &ray, w, h, fovx, camera.fovy);
      RayTracer::trace(ray, 0, color, maxdepth, numprimitives, geometricPrimitives, numused, lights, attenuation); 
      film.commit(sample, *color);
      if (sample.y > 250) break;
  }
  film.writeImage(outputFilename);

  FreeImage_DeInitialise();
  return 0;
}
예제 #2
0
#include "catch.hpp"

#include "../src/film.hpp"

TEST_CASE( "Can commit color to buffer in the Film Class", "[Film]" ) {
    Film film(200, 200);

    SECTION( "Do not throw exceptions when commit not out of bound" ) {
        REQUIRE_NOTHROW(film.commit(199, 199, ColorRGB(0, 0, 0)));
    }

    SECTION( "Exceptions when try to commit out of bound" ) {
        REQUIRE_THROWS_AS(film.commit(200, 200, ColorRGB(0, 0, 0)), std::out_of_range);
    }
}