Heightfield 1.0
GPUHeightField Class Reference

A heightfield stored on the GPU. More...

#include <gpuheightfield.h>

Inheritance diagram for GPUHeightField:
Array2 Box2

Public Member Functions

 GPUHeightField (const HeightField &)
 Constructor from a heightfield.
 
 GPUHeightField (GLuint buffer, const Box2 &, int, int)
 Constructor from an existing opengl buffer.
 
void Destroy ()
 Release the GPU data.
 
void GetData (HeightField &) const
 Get the elevation data back on the CPU into a heightfield.
 
GLBuffer GetInBuffer () const
 Get the input GPU elevation buffer.
 
GLBuffer GetOutBuffer () const
 Get the output GPU elevation buffer.
 

Protected Attributes

GLBuffer inBuffer = 0
 Input data.
 
GLBuffer outBuffer = 0
 Output data.
 
bool owner = true
 Boolean for testing if the instance holds GPU data ownership.
 

Detailed Description

A heightfield stored on the GPU.

This class is a work in progress. There are several open questions: => Use double, or float ? Most of the time on the GPU we only use float, but sometimes we need precision, or we work on large terrains which require lots of precision. Ideally, this class should allow to switch between single and double precision, but then this means that the simulation shaders should be adapted accordingly. And what happens when we work on double precision for the rendering ? The buffers cannot be shared between the widget and the simulation/analysis.

=> Most of the time we work with multiple layer, which means that we might need a GPULayerField class ? With at least bedrock, sediment, and maybe water as layers.

Constructor & Destructor Documentation

◆ GPUHeightField() [1/2]

GPUHeightField::GPUHeightField ( const HeightField & hf)
explicit

Constructor from a heightfield.

Parameters
hfHeightfield.

◆ GPUHeightField() [2/2]

GPUHeightField::GPUHeightField ( GLuint buffer,
const Box2 & box,
int nx,
int ny )

Constructor from an existing opengl buffer.

Ownership is set to false.

Member Function Documentation

◆ GetData()

void GPUHeightField::GetData ( HeightField & hf) const

Get the elevation data back on the CPU into a heightfield.

Parameters
hfThe heightfield, should be initialized to the correct size.