rayzor

diff src/main.cc @ 17:79609d482762

the renderer renders, also fixed an unnoticed matrix conversion problem between scenegraph and min3d
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 14 Apr 2014 07:34:45 +0300
parents a9a948809c6f
children 859ccadca671
line diff
     1.1 --- a/src/main.cc	Sun Apr 13 09:54:51 2014 +0300
     1.2 +++ b/src/main.cc	Mon Apr 14 07:34:45 2014 +0300
     1.3 @@ -3,6 +3,7 @@
     1.4  #include <string.h>
     1.5  #include <signal.h>
     1.6  #include <errno.h>
     1.7 +#include <float.h>
     1.8  #include <direct.h>
     1.9  #include "inttypes.h"
    1.10  #include "gfx.h"
    1.11 @@ -102,6 +103,9 @@
    1.12  	signal(SIGILL, sig);
    1.13  	signal(SIGFPE, sig);
    1.14  
    1.15 +	// mask all fpe except invalid op
    1.16 +	_control87(~_EM_INVALID, _MCW_EM);
    1.17 +
    1.18  	init_timer(128);
    1.19  
    1.20  	if(!novideo) {
    1.21 @@ -144,11 +148,21 @@
    1.22  	scene = new Scene;
    1.23  
    1.24  	Sphere *sph = new Sphere;
    1.25 +	sph->mtl.diffuse = Vector3(1.0, 0.3, 0.1);
    1.26 +	sph->mtl.roughness = 0.4;
    1.27  	scene->add(sph);
    1.28  
    1.29  	Box *box = new Box;
    1.30 +	box->mtl.diffuse = Vector3(0.1, 0.4, 1.0);
    1.31 +	box->mtl.roughness = 0.9;
    1.32 +	box->set_position(Vector3(0, -1.1, 0));
    1.33 +	box->set_scaling(Vector3(4, 0.1, 4));
    1.34  	scene->add(box);
    1.35 -	box->set_scaling(Vector3(2, 0.25, 2));
    1.36 +
    1.37 +	Light *lt = new Light;
    1.38 +	lt->set_intensity(0.8);
    1.39 +	lt->set_position(Vector3(-10, 10, 10));
    1.40 +	scene->add(lt);
    1.41  
    1.42  	Modeller *modeller = new Modeller;
    1.43  	if(!modeller->init()) {
    1.44 @@ -322,7 +336,7 @@
    1.45  		return;
    1.46  	}
    1.47  
    1.48 -	fprintf(fp, "P6\n" PPM_COMMENT "\n%d %d\n255\n", fb_width, fb_height);
    1.49 +	fprintf(fp, "P6\n# " PPM_COMMENT "\n%d %d\n255\n", fb_width, fb_height);
    1.50  	for(int i=0; i<fb_width * fb_height; i++) {
    1.51  		uint32_t c = fb_pixels[i];
    1.52  		fputc(UNPACK_RED(c), fp);
    1.53 @@ -353,7 +367,6 @@
    1.54  			}
    1.55  			break;
    1.56  
    1.57 -		case KB_SYSRQ:
    1.58  		case KB_F12:
    1.59  			cap_shot = true;
    1.60  			break;
    1.61 @@ -467,5 +480,11 @@
    1.62  {
    1.63  	cleanup();
    1.64  	fprintf(stderr, "signal caught: %d\n", s);
    1.65 +
    1.66 +	if(s == SIGFPE) {
    1.67 +		unsigned int st = _status87();
    1.68 +		fprintf(stderr, "fpu status: %x\n", st);
    1.69 +	}
    1.70 +
    1.71  	exit(1);
    1.72  }