Scene now writing blank BMP file, accepting settings parameters

git-svn-id: svn://anubis/fart/trunk@24 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-01-22 02:51:43 +00:00
parent 959219ffb8
commit b6008116cf
4 changed files with 37 additions and 1 deletions

View File

@ -5,6 +5,10 @@
#include <stdio.h> #include <stdio.h>
#define BMP_RED 2
#define BMP_GREEN 1
#define BMP_BLUE 0
class BMP class BMP
{ {
public: public:

View File

@ -2,6 +2,7 @@
#include "Scene.h" #include "Scene.h"
#include <string> #include <string>
#include <map> #include <map>
#include "BMP.h"
using namespace std; using namespace std;
Scene::Scene(map<string, const char *> options, Scene::Scene(map<string, const char *> options,
@ -12,14 +13,39 @@ Scene::Scene(map<string, const char *> options,
m_multisample_level = 1; m_multisample_level = 1;
m_output_file_name = "fart.bmp"; m_output_file_name = "fart.bmp";
m_verbose = false; m_verbose = false;
m_data = NULL;
load(filename); load(filename);
} }
Scene::~Scene()
{
if (m_data != NULL)
delete m_data;
}
void Scene::load(const char * filename) void Scene::load(const char * filename)
{ {
} }
void Scene::render() void Scene::render()
{ {
m_data = new unsigned char[m_width * m_height * 3];
for (int i = 0; i < m_height; i++)
{
for (int j = 0; j < m_width; j++)
{
renderPixel(i, j, &m_data[3 * (m_width * i + j)]);
}
}
BMP outputImage(m_output_file_name.c_str(), m_width, m_height, m_data);
}
void Scene::renderPixel(int x, int y, unsigned char * pixel)
{
// TODO: um... real work
pixel[BMP_RED] = 0;
pixel[BMP_GREEN] = 0;
pixel[BMP_BLUE] = 0;
} }

View File

@ -10,16 +10,19 @@ class Scene
public: public:
Scene(std::map<std::string, const char *> options, Scene(std::map<std::string, const char *> options,
const char * filename); const char * filename);
~Scene();
void render(); void render();
private: private:
void load(const char * filename); void load(const char * filename);
void renderPixel(int x, int y, unsigned char * pixel);
int m_width; int m_width;
int m_height; int m_height;
int m_multisample_level; int m_multisample_level;
std::string m_output_file_name; std::string m_output_file_name;
bool m_verbose; bool m_verbose;
unsigned char * m_data;
}; };
#endif #endif

View File

@ -6,6 +6,7 @@
#include <getopt.h> #include <getopt.h>
#include <string> #include <string>
#include <map> #include <map>
#include "Scene.h"
using namespace std; using namespace std;
void usage(const char * progname) void usage(const char * progname)
@ -65,5 +66,7 @@ int main(int argc, char * argv[])
usage(argv[0]); usage(argv[0]);
} }
cout << "hi" << endl; Scene scene(scene_options, argv[optind]);
scene.render();
} }