Implémentation du raytracing pour Global Memory/Shared Memory/Constant Memory
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / mainGL.cpp
index 44ee751..13dd2db 100755 (executable)
@@ -1,6 +1,7 @@
 #include <iostream>\r
 #include <stdlib.h>\r
 #include <string.h>\r
+using namespace std;\r
 \r
 #include "GLUTImageViewers.h"\r
 \r
 \r
 #include "Rippling0Provider.h"\r
 #include "RipplingProvider.h"\r
+#include "FractalProvider.h"\r
+#include "NewtonProvider.h"\r
+#include "HeatTransfertProvider.h"\r
+#include "RayTracingProvider.h"\r
+#include "ConvolutionProvider.h"\r
 \r
-using std::cout;\r
-using std::endl;\r
-using std::string;\r
+#include "Viewer.h"\r
 \r
-/*----------------------------------------------------------------------*\\r
- |*                    Declaration                                     *|\r
- \*---------------------------------------------------------------------*/\r
-\r
-/*--------------------------------------*\\r
- |*            Imported                *|\r
- \*-------------------------------------*/\r
-\r
-/*--------------------------------------*\\r
- |*            Public                  *|\r
- \*-------------------------------------*/\r
-\r
-int mainGL(void);\r
-\r
-/*--------------------------------------*\\r
- |*            Private                 *|\r
- \*-------------------------------------*/\r
-\r
-/*----------------------------------------------------------------------*\\r
- |*                    Implementation                                  *|\r
- \*---------------------------------------------------------------------*/\r
-\r
-/*--------------------------------------*\\r
- |*            Public                  *|\r
- \*-------------------------------------*/\r
-\r
-int mainGL(void)\r
+int mainGL(const vector<string>& args)\r
     {\r
-    Rippling0Image* ptrRippling0 = Rippling0Provider::createGL();\r
-    Image* ptrRippling = RipplingProvider::createGL();\r
-    // TODO : Insert  autres Images ...\r
-\r
-    bool isAnimation = true;\r
-    bool isSelection = true;\r
-\r
-    GLUTImageViewers rippling0Viewer(ptrRippling0, isAnimation, isSelection, 0, 0);\r
-    GLUTImageViewers ripplingViewer(ptrRippling, isAnimation, isSelection, 10, 10);\r
-    // TODO : Insert here autres ImageViewers ...\r
-\r
-    GLUTImageViewers::runALL(); // Bloquant, Tant qu'une fenetre est ouverte\r
-\r
-    // destruction\r
-       {\r
-       delete ptrRippling0;\r
-       delete ptrRippling;\r
-\r
-       ptrRippling0 = NULL;\r
-       ptrRippling = NULL;\r
-       }\r
+    const string defaultCommand = "raytracing";\r
+    const string command = args.size() > 0 ? args[0] : defaultCommand;\r
+\r
+    // AutoViewer<Rippling0Image, Rippling0Provider> rippling0(true, true, 10, 10); // Warmup.\r
+\r
+    if (command == "rippling")\r
+        {\r
+        AutoViewer<Image, RipplingProvider> rippling(true, true, 10, 10);\r
+        }\r
+    else if (command == "mandelbrot")\r
+        {\r
+        const bool multiGPU = args.size() >= 2 && args[1] == "--mp";\r
+        Viewer<ImageFonctionel> fractalMandelbrot(MandelbrotProvider::createGL(multiGPU), true, true, 10, 10);\r
+        }\r
+    else if (command == "julia")\r
+        AutoViewer<ImageFonctionel, JuliaProvider> fractalJulia(true, true, 10, 10);\r
+    else if (command == "newton")\r
+        AutoViewer<ImageFonctionel, NewtonProvider> newtown(true, true, 10, 10);\r
+    else if (command == "heat-transfert")\r
+        AutoViewer<Image, HeatTransfertProvider> heatTransfert(true, false, 10, 10);\r
+    else if (command == "raytracing")\r
+        AutoViewer<Image, RayTracingProvider> rayTracing(true, true, 20, 20);\r
+    else if (command == "convolution")\r
+        {\r
+        const string videoPath = args.size() >= 2 ? args[1] : "/media/Data/Video/nasaFHD_short.avi"; // Vidéo par défaut si pas donnée en paramètre.\r
+        Viewer<Image> convolution(ConvolutionProvider::createGL(videoPath), true, true, 10, 10);\r
+        }\r
+    else if (command == "demo")\r
+        {\r
+        Viewer<Image> convolution(ConvolutionProvider::createGL("/media/Data/Video/nasaFHD_short.avi"), true, true, 10, 10, false);\r
+        AutoViewer<Image, RipplingProvider> rippling(true, true, 60, 30, false);\r
+        Viewer<ImageFonctionel> fractalMandelbrot(MandelbrotProvider::createGL(false), true, true, 120, 60, false);\r
+        AutoViewer<ImageFonctionel, JuliaProvider> fractalJulia(true, true, 180, 80, false);\r
+        AutoViewer<ImageFonctionel, NewtonProvider> newtown(true, true, 260, 120, false);\r
+        AutoViewer<Image, HeatTransfertProvider> heatTransfert(true, false, 1200, 300, false);\r
+        GLUTImageViewers::runALL();\r
+        }\r
+    else\r
+        {\r
+        cout << "Command unknown: " << command << endl;\r
+        }\r
 \r
     return EXIT_SUCCESS;\r
     }\r
-\r
-/*--------------------------------------*\\r
- |*            Private                 *|\r
- \*-------------------------------------*/\r
-\r
-/*----------------------------------------------------------------------*\\r
- |*                    End                                             *|\r
- \*---------------------------------------------------------------------*/\r
-\r