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