Rippling CUDA Warmup et Smart.
[GPU.git] / WCudaMSE / Student_Cuda_Image / src / cpp / core / 00_Rippling_warmup / 01_imageAPI / 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), dt(dt), t(0)
41 {
42 }
43
44 Rippling0Image::~Rippling0Image(void)
45 {
46 // rien
47 }
48
49 /*--------------------------------------*\
50 |* Redefinition *|
51 \*-------------------------------------*/
52
53 /**
54 * Call automaticly by the api
55 */
56 void Rippling0Image::animationStep(bool& isNeedUpdateView) // Override
57 {
58 this->t += dt;
59 isNeedUpdateView = true; // true par default
60 }
61
62 /**
63 * Call automaticly by the api
64 */
65 void Rippling0Image::fillImageGL(uchar4* ptrDevImageGL, int w, int h) // Override
66 {
67 launchKernelRippling0(ptrDevImageGL, w, h, this->t);
68 }
69
70 /**
71 * Call automaticly by the api
72 */
73 void Rippling0Image::paintPrimitives(Graphic2Ds& graphic2D) // Override
74 {
75 const Font_A* ptrFont = graphic2D.getFont(TIMES_ROMAN_24);
76
77 float r = 1;
78 float g = 0;
79 float b = 0;
80
81 graphic2D.setColorRGB(r, g, b);
82
83 // top
84 {
85 string message = "t = " + StringTools::toString(t);
86 graphic2D.drawTitleTop(message, ptrFont);
87 }
88
89 // bottom
90 {
91 graphic2D.drawTitleBottom("Rippling warmup CUDA", ptrFont);
92 }
93 }
94
95 /*--------------------------------------*\
96 |* Private *|
97 \*-------------------------------------*/
98
99 /*----------------------------------------------------------------------*\
100 |* End *|
101 \*---------------------------------------------------------------------*/