Ray Tracer  2020
ImageDisplay.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef IMAGE_DISPLAY_H_INCLUDED
4 #define IMAGE_DISPLAY_H_INCLUDED
5 
6 #include "Colour.h"
7 #include "NonCopyable.h"
8 
9 #include "stb_image_write.h"
10 #include <string>
11 #include <vector>
12 
29 class ImageDisplay : private NonCopyable {
30 public:
31 
45  ImageDisplay(const std::string& windowName, unsigned int width, unsigned int height);
46 
52  ~ImageDisplay();
53 
68  void set(int x, int y, const Colour& colour);
69 
77  void refresh();
78 
88  void save(const std::string& filename) const;
89 
97  void pause(double seconds);
98 
99 private:
100 
101  std::vector<unsigned char> image_;
102  size_t width_;
103  size_t height_;
105 };
106 
107 #endif
Colour class header file.
NonCopyable class header file.
Class to store colour information.
Definition: Colour.h:25
Class to display and save images.
Definition: ImageDisplay.h:29
ImageDisplay(const std::string &windowName, unsigned int width, unsigned int height)
ImageDisplay constructor.
Definition: ImageDisplay.cpp:6
void save(const std::string &filename) const
Save an image to file.
Definition: ImageDisplay.cpp:26
void set(int x, int y, const Colour &colour)
Set a pixel value.
Definition: ImageDisplay.cpp:15
size_t height_
Height of the image.
Definition: ImageDisplay.h:103
size_t lastRowWritten_
Last row rendered, for the purpose of progress reporting.
Definition: ImageDisplay.h:104
size_t width_
Width of the image.
Definition: ImageDisplay.h:102
void pause(double seconds)
Wait for a specified duration.
Definition: ImageDisplay.cpp:30
std::vector< unsigned char > image_
Internal storage of the image to render to.
Definition: ImageDisplay.h:101
~ImageDisplay()
ImageDisplay destructor.
Definition: ImageDisplay.cpp:12
void refresh()
Update the window displaying the image.
Definition: ImageDisplay.cpp:22
NonCopyable class.
Definition: NonCopyable.h:27