X-Git-Url: http://git.treefish.org/~alex/seamulator.git/blobdiff_plain/94e405360849659ff951816a13cf510f11a7eee7..31e7aa23c4e95b5e37f33938e9bb47ea82a3f4d9:/seamulator.cpp diff --git a/seamulator.cpp b/seamulator.cpp index 6bb51c9..b6739b5 100644 --- a/seamulator.cpp +++ b/seamulator.cpp @@ -8,20 +8,20 @@ const int LATTICE_SIZE = 10; const int LATTICE_UNIT = 1; -WaterSurface surface(LATTICE_SIZE); -Sea sea(surface); +SeaPtr sea; +WaterSurfacePtr surface; void drawSingleTile(int x, int y) { glBegin(GL_TRIANGLES); - glVertex3f(x, y, surface.at(x, y).getHeight()); - glVertex3f(x+1, y, surface.at(x+1, y).getHeight()); - glVertex3f(x+1, y+1, surface.at(x+1, y+1).getHeight()); + glVertex3f(x, y, surface->at(x, y).getHeight()); + glVertex3f(x+1, y, surface->at(x+1, y).getHeight()); + glVertex3f(x+1, y+1, surface->at(x+1, y+1).getHeight()); - glVertex3f(x, y, surface.at(x, y).getHeight()); - glVertex3f(x, y+1, surface.at(x, y+1).getHeight()); - glVertex3f(x+1, y+1, surface.at(x+1, y+1).getHeight()); + glVertex3f(x, y, surface->at(x, y).getHeight()); + glVertex3f(x, y+1, surface->at(x, y+1).getHeight()); + glVertex3f(x+1, y+1, surface->at(x+1, y+1).getHeight()); glEnd(); } @@ -37,7 +37,7 @@ void displayMe(void) glClear(GL_COLOR_BUFFER_BIT); - sea.update(); + sea->update(); glScalef(LATTICE_UNIT, LATTICE_UNIT, 1.0f); glTranslatef(-(float)(LATTICE_SIZE-1)/2, -(float)(LATTICE_SIZE-1)/2, 0); @@ -56,6 +56,9 @@ int main(int argc, char** argv) { std::srand(std::time(0)); + surface = std::make_shared(LATTICE_SIZE); + sea = std::make_shared(surface); + glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH); glEnable(GL_DEPTH_TEST);