5 #ifndef MERCATOR_BUFFER_H 6 #define MERCATOR_BUFFER_H 13 template<
typename DataType>
31 explicit Buffer(
const Segment & segment,
unsigned int channels = 4);
39 DataType &
operator()(
unsigned int x,
unsigned int y,
unsigned int channel) {
40 return m_data[(y * m_size + x) * m_channels + channel];
50 unsigned int channel)
const {
51 return m_data[(y * m_size + x) * m_channels + channel];
79 m_data =
new DataType[m_size * m_size *
m_channels];
101 #endif // MERCATOR_BUFFER_H const Segment & getSegment() const
Accessor for the terrain height segment this buffer is associated with.
Definition: Buffer.h:55
DataType * m_data
Pointer to buffer containing data values.
Definition: Buffer.h:24
DataType * getData()
Accessor for a pointer to buffer containing data values.
Definition: Buffer.h:70
bool isValid() const
Determine if this buffer has valid allocated storage.
Definition: Buffer.h:85
unsigned int getSize() const
Accessor for the size of segment, m_res + 1.
Definition: Buffer.h:60
void invalidate()
De-allocate the storage for this buffer.
Definition: Buffer.h:92
Template for managing buffers of data for a segment.
Definition: Buffer.h:14
const unsigned int m_size
The size of segment, m_res + 1.
Definition: Buffer.h:22
const Segment & m_segment
The terrain height segment this buffer is associated with.
Definition: Buffer.h:17
const unsigned int m_channels
The number of data values per height point.
Definition: Buffer.h:20
Buffer(const Segment &segment, unsigned int channels=4)
Constructor.
Definition: Buffer_impl.h:12
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: Segment.h:36
unsigned int getChannels() const
Accessor for the number of data values per height point.
Definition: Buffer.h:65
void allocate()
Allocate the storage required by the buffer.
Definition: Buffer.h:78
DataType & operator()(unsigned int x, unsigned int y, unsigned int channel)
Retrieve the data value at a given point.
Definition: Buffer.h:39
const DataType & operator()(unsigned int x, unsigned int y, unsigned int channel) const
Retrieve the data value at a given point.
Definition: Buffer.h:48