X-Git-Url: http://git.treefish.org/~alex/seamulator.git/blobdiff_plain/3a3ad62faa958b07f2a91b4b21e6cfa92309ba80..f2e44f70d56b60e6eef78656ca4b558917474276:/watersurface.cpp?ds=inline diff --git a/watersurface.cpp b/watersurface.cpp index 930cf7f..a38ad57 100644 --- a/watersurface.cpp +++ b/watersurface.cpp @@ -2,9 +2,9 @@ #include -WaterSurface::WaterSurface(int size, double unitLength) : +WaterSurface::WaterSurface(int size, double extend) : m_size{size}, - m_unitLength{unitLength} + m_extend{extend} { m_points.resize(size*size); } @@ -24,9 +24,16 @@ int WaterSurface::size() const return m_size; } +double WaterSurface::extend() const +{ + return m_extend; +} + void WaterSurface::draw() const { - glScalef(m_unitLength, m_unitLength, 1.0f); + const double scaleFactor{m_extend / m_size}; + + glScalef(scaleFactor, scaleFactor, 1.0f); glTranslatef(-(float)(m_size - 1) / 2, -(float)(m_size - 1) / 2, 0); for (int y = 0; y < m_size - 1; ++y) {