X-Git-Url: http://git.treefish.org/~alex/seamulator.git/blobdiff_plain/b23099025e3db2682b0260c0cef3a807fad136a8..22a843aa7b0ca3d8f307ba5c0a27ea9d6da50c00:/src/seamulator.cpp?ds=inline
diff --git a/src/seamulator.cpp b/src/seamulator.cpp
index 98e92df..aec8da1 100644
--- a/src/seamulator.cpp
+++ b/src/seamulator.cpp
@@ -1,3 +1,22 @@
+/**
+ * Copyright (C) 2016 Alexander Schmidt
+ *
+ * This file is part of Seamulator.
+ *
+ * Seamulator is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Seamulator is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Seamulator. If not, see .
+ */
+
#include
#include
#include
@@ -8,6 +27,7 @@
#include "sea.h"
#include "seaview.h"
+#include "synthesizer.h"
#include "watersurface.h"
const int INIT_WINDOW_POS_X{50};
@@ -21,6 +41,7 @@ const char WINDOW_TITLE[]{"seamulator"};
SeaPtr sea;
WaterSurfacePtr surface;
std::unique_ptr seaView;
+std::unique_ptr synthesizer;
struct Settings {
double windSpeed;
@@ -29,38 +50,28 @@ struct Settings {
double amplitudeFactor;
};
-namespace po = boost::program_options;
-
void glDisplayFunc();
void glReshapeFunc(int width, int height);
void glMouseFunc(int button, int state, int x, int y);
void glMotionFunc(int x, int y);
-Settings parseArguments(int argc, char** argv, po::options_description desc);
+Settings parseArguments(int argc, char** argv);
+
+namespace po = boost::program_options;
int main(int argc, char** argv)
{
- po::options_description desc("Available options");
- desc.add_options()
- ("help,h", "produce help message")
- ("windspeed,w", po::value()->default_value(10),
- "wind speed given in m/s")
- ("size,s", po::value()->default_value("small"),
- "lattice size (small/large)")
- ("amplitude,a", po::value()->default_value(1),
- "amplitude multiplicator")
- ;
-
- Settings settings = parseArguments(argc, argv, desc);
+ Settings settings = parseArguments(argc, argv);
std::srand(std::time(0));
surface = std::make_shared(settings.latticeSize,
- settings.latticeExtend);
+ settings.latticeExtend);
sea = std::make_shared(surface,
- settings.windSpeed,
- settings.amplitudeFactor);
+ settings.windSpeed,
+ settings.amplitudeFactor);
seaView = std::make_unique(settings.latticeExtend * 1.5,
- INIT_VIEW_AZIMUTH,
- INIT_VIEW_ALTITUDE);
+ INIT_VIEW_AZIMUTH,
+ INIT_VIEW_ALTITUDE);
+ synthesizer = std::make_unique(surface);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE);
@@ -79,8 +90,19 @@ int main(int argc, char** argv)
return 0;
}
-Settings parseArguments(int argc, char** argv, po::options_description desc)
+Settings parseArguments(int argc, char** argv)
{
+ po::options_description desc("Available options");
+ desc.add_options()
+ ("help,h", "show this help")
+ ("windspeed,w", po::value()->default_value(10),
+ "wind speed (m/s)")
+ ("size,s", po::value()->default_value('s'),
+ "lattice size (s|l)")
+ ("amplitude,a", po::value()->default_value(1),
+ "amplitude multiplicator")
+ ;
+
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
@@ -94,7 +116,7 @@ Settings parseArguments(int argc, char** argv, po::options_description desc)
settings.windSpeed = vm["windspeed"].as();
- if (vm["size"].as() == "large") {
+ if (vm["size"].as() == 'l') {
settings.latticeSize = 256;
settings.latticeExtend = 20;
settings.amplitudeFactor = vm["amplitude"].as() * 0.00000004;
@@ -115,6 +137,7 @@ void glDisplayFunc()
seaView->setupView();
sea->update();
surface->draw();
+ synthesizer->tick();
glutSwapBuffers();
glutPostRedisplay();