-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sampler.h
executable file
·52 lines (37 loc) · 1.23 KB
/
Sampler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef SAMPLERH
#define SAMPLERH
#include "randomc.h"
/* A simple way to describe a pixel sample in
terms of the screen coordinates. */
typedef struct sample_struct {
double horiz;
double vert;
unsigned int p; // Which sample on the given pixel produced this?
unsigned int q;
} Sample;
/* Sampler objects enumerate through all the samples necessary to draw
every pixel on the screen. Currently, the Sampler class only does one
sample per pixel. This is not difficult to change. */
class Sampler {
private:
/* Instance vars */
unsigned int pixelWidth; // Width of the screen
unsigned int pixelHeight; // Height of the screen
unsigned int i, j; // The next pixel to sample
unsigned int p, q; // The next part of the pixel to sample
unsigned int n; // n = sqrt(# of samples per pixel)
CRandomMersenne* randGen; // Random number generator
public:
/* Constructors */
Sampler(unsigned int width, unsigned int height, unsigned int perPixel);
/* Destructor */
~Sampler();
/* Instance methods */
inline bool hasMoreSamples() {
return i < pixelWidth &&
j < pixelHeight;
}
Sample nextSample();
Sample normalizeSample(const Sample& samp);
};
#endif