Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / Student_OMP_Image / src / cpp / core / 01_Rippling / a_image / RipplingImage.cpp
1 #include <iostream>
2 #include <assert.h>
3 #include <omp.h>
4 #include <math.h>
5
6 #include "MathTools.h"
7 #include "RipplingImage.h"
8 #include "StringTools.h"
9 #include "OmpTools.h"
10
11 using std::cout;
12 using std::endl;
13 using std::string;
14
15 /*----------------------------------------------------------------------*\
16 |* Declaration *|
17 \*---------------------------------------------------------------------*/
18
19 /*--------------------------------------*\
20 |* Public *|
21 \*-------------------------------------*/
22
23 /*--------------------------------------*\
24 |* Private *|
25 \*-------------------------------------*/
26
27 /*----------------------------------------------------------------------*\
28 |* Implementation *|
29 \*---------------------------------------------------------------------*/
30
31 /*--------------------------------------*\
32 |* Public *|
33 \*-------------------------------------*/
34
35 RipplingImage::RipplingImage(unsigned int w, unsigned int h, float dt) :
36 ImageMOOs_A(w, h)
37 {
38 assert(w==h); // Image carrer
39
40 this->ptrRipplingMOO=new RipplingMOO(w,h,dt);
41 }
42
43 RipplingImage::~RipplingImage(void)
44 {
45 delete ptrRipplingMOO;
46 }
47
48 /*--------------------------------------*\
49 |* Override *|
50 \*-------------------------------------*/
51
52 /**
53 * Override
54 * call periodicly by the api
55 */
56 void RipplingImage::fillImageGL(uchar4* ptrTabPixels, int w, int h)
57 {
58 ptrRipplingMOO->process(ptrTabPixels,w,h);
59 }
60
61 /**
62 * Override
63 * call periodicly by the api
64 */
65 void RipplingImage::animationStep(bool& isNeedUpdateView)
66 {
67 ptrRipplingMOO->animationStep();
68 }
69
70 /**
71 * Override
72 * call periodicly by the api
73 */
74 void RipplingImage::paintPrimitives(Graphic2Ds& graphic2D)
75 {
76 const Font_A* ptrFont = graphic2D.getFont(TIMES_ROMAN_24);
77
78 float r = 1;
79 float g = 0;
80 float b = 0;
81 graphic2D.setColorRGB(r, g, b);
82
83 // Top
84 {
85 float t=ptrRipplingMOO->getT();
86
87 string message = "It's up to you! t= " + StringTools::toString(t);
88 graphic2D.drawTitleTop(message, ptrFont);
89 }
90
91 // Bottom
92 {
93 graphic2D.drawTitleBottom("Rippling OMP", ptrFont);
94 }
95 }
96
97 /*--------------------------------------*\
98 |* Private *|
99 \*-------------------------------------*/
100
101
102 /*----------------------------------------------------------------------*\
103 |* End *|
104 \*---------------------------------------------------------------------*/