Phongo Clap RT  1.0
Simple Raytracing Renderer
Film.h
Go to the documentation of this file.
1 #ifndef _FILM_H_
2 #define _FILM_H_
3 
8 
9 #include <ngl/Vec3.h>
10 #include <ngl/Colour.h>
11 #include <fstream>
12 #include <vector>
13 
14 //----------------------------------------------------------------------------------------------------------------------
16 // ---------------------------------------------------------------------------------------------------------------------
17 typedef struct Pixel
18 {
19  float r;
20  float g;
21  float b;
22 } Pixel;
23 
24 //----------------------------------------------------------------------------------------------------------------------
28 //----------------------------------------------------------------------------------------------------------------------
29 class Film
30 {
31 public:
32  //--------------------------------------------------------------------------------------------------------------------
34  //-------------------------------------------------------------------------------------------------------------------
35  Film();
36  //-------------------------------------------------------------------------------------------------------------------
40  //-------------------------------------------------------------------------------------------------------------------
41  void setDimensions(int _w, int _h);
42  //--------------------------------------------------------------------------------------------------------------------
44  //--------------------------------------------------------------------------------------------------------------------
45  ~Film();
46  //--------------------------------------------------------------------------------------------------------------------
49  //--------------------------------------------------------------------------------------------------------------------
50  void writePixel(ngl::Colour _colour);
51  //--------------------------------------------------------------------------------------------------------------------
54  //--------------------------------------------------------------------------------------------------------------------
55  void writeFile(const char* _image_name);
56 
57  // give renderer permissions to access m_width and m_height with no need of getters
58  friend class Renderer;
59 
60 private:
61  //--------------------------------------------------------------------------------------------------------------------
63  //--------------------------------------------------------------------------------------------------------------------
64  int m_width;
65  //--------------------------------------------------------------------------------------------------------------------
67  //--------------------------------------------------------------------------------------------------------------------
68  int m_height;
69  //--------------------------------------------------------------------------------------------------------------------
71  //-------------------------------------------------------------------------------------------------------------------
72  std::vector<Pixel> m_pixels;
73  //--------------------------------------------------------------------------------------------------------------------
75  //--------------------------------------------------------------------------------------------------------------------
76  std::ofstream m_file;
77 };
78 
79 
80 #endif // Film.h
void writeFile(const char *_image_name)
Iterates over the pixel vector and writes into a file using basic output stream methods.
Definition: Film.cpp:26
float b
Definition: Film.h:21
float g
Definition: Film.h:20
Core of my program, central unit that manages all the other classes almost.
Definition: Renderer.h:23
std::ofstream m_file
File output stream, in charge of writing the pixels into a file.
Definition: Film.h:76
Film()
Film constructor.
Definition: Film.cpp:7
~Film()
Destructor for the Film.
Definition: Film.cpp:9
struct Pixel Pixel
Pixel data structure that will be used to hold the image units.
void setDimensions(int _w, int _h)
Sets the dimensions of the Film.
Definition: Film.cpp:11
std::vector< Pixel > m_pixels
Vector of pixels. The index of the pixel corresponds to this equation: i = height * y + x...
Definition: Film.h:72
float r
Definition: Film.h:19
Holds all the operations regarding to input/output of colour information.
Definition: Film.h:29
int m_width
Width of the Film's image.
Definition: Film.h:64
void writePixel(ngl::Colour _colour)
Will create a pixel and push it to the pixel vector.
Definition: Film.cpp:17
int m_height
Height of the Film's image.
Definition: Film.h:68
Pixel data structure that will be used to hold the image units.
Definition: Film.h:17