dc9e211dc980a9ceef9c93793b086cd1417beb76
[GPU.git] / Rippling0Image.cpp
1 #include <iostream>
2 #include <assert.h>
3 #include <math.h>
4
5 #include "MathTools.h"
6 #include "StringTools.h"
7
8 #include "Rippling0Image.h"
9
10 using std::cout;
11 using std::endl;
12
13 /*----------------------------------------------------------------------*\
14 |* Declaration *|
15 \*---------------------------------------------------------------------*/
16
17 /*--------------------------------------*\
18 |* Imported *|
19 \*-------------------------------------*/
20
21 extern void launchKernelRippling0(uchar4* ptrDevPixels, int w, int h, float t);
22
23 /*--------------------------------------*\
24 |* Public *|
25 \*-------------------------------------*/
26
27 /*--------------------------------------*\
28 |* Private *|
29 \*-------------------------------------*/
30
31 /*----------------------------------------------------------------------*\
32 |* Implementation *|
33 \*---------------------------------------------------------------------*/
34
35 /*--------------------------------------*\
36 |* Public *|
37 \*-------------------------------------*/
38
39 Rippling0Image::Rippling0Image(unsigned int w, unsigned int h, float dt) :
40 ImageMOOs_A(w, h)
41 {
42 assert(getW() == getH()); // image carrer
43
44 // Input
45 this->dt = dt;
46
47 // Tools
48 this->t = 0;
49 }
50
51 Rippling0Image::~Rippling0Image(void)
52 {
53 // rien
54 }
55
56 /*--------------------------------------*\
57 |* Redefinition *|
58 \*-------------------------------------*/
59
60 /**
61 * Call automaticly by the api
62 */
63 void Rippling0Image::animationStep(bool& isNeedUpdateView) // Override
64 {
65 this->t += dt;
66 isNeedUpdateView = true; // true par default
67 }
68
69 /**
70 * Call automaticly by the api
71 */
72 void Rippling0Image::fillImageGL(uchar4* ptrDevImageGL, int w, int h) // Override
73 {
74 launchKernelRippling0(ptrDevImageGL, w, h, t);
75 }
76
77 /**
78 * Call automaticly by the api
79 */
80 void Rippling0Image::paintPrimitives(Graphic2Ds& graphic2D) // Override
81 {
82 const Font_A* ptrFont = graphic2D.getFont(TIMES_ROMAN_24);
83
84 float r = 1;
85 float g = 0;
86 float b = 0;
87
88 graphic2D.setColorRGB(r, g, b);
89
90 // top
91 {
92 string message = "t = " + StringTools::toString(t);
93 graphic2D.drawTitleTop(message, ptrFont);
94 }
95
96 // bottom
97 {
98 graphic2D.drawTitleBottom("Rippling warmup CUDA", ptrFont);
99 }
100 }
101
102 /*--------------------------------------*\
103 |* Private *|
104 \*-------------------------------------*/
105
106 /*----------------------------------------------------------------------*\
107 |* End *|
108 \*---------------------------------------------------------------------*/