X-Git-Url: http://git.treefish.org/~alex/seamulator.git/blobdiff_plain/ddf55f4232002ee06d7ae4af670ce80f1ec37eb3..e19dd20d04a2a92b3d91bd25a69210a2351b08c9:/watersurface.cpp diff --git a/watersurface.cpp b/watersurface.cpp index c27e7db..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,14 +24,16 @@ int WaterSurface::size() const return m_size; } -double WaterSurface::unitLength() const +double WaterSurface::extend() const { - return m_unitLength; + 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) {