Ajout de l'ensemble du workspace.
[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)
40 {
41 assert(getW() == getH()); // image carrer
42
43 // Input
44 this->dt = dt;
45
46 // Tools
47 this->t = 0;
48 }
49
50 Vague0Image::~Vague0Image(void)
51 {
52 // rien
53 }
54
55 /*--------------------------------------*\
56 |* Override *|
57 \*-------------------------------------*/
58
59 /**
60 * Override
61 * Call automaticly by the api
62 */
63 void Vague0Image::animationStep(bool& isNeedUpdateView)
64 {
65 this->t += dt;
66 isNeedUpdateView = true; // true par default
67 }
68
69 /**
70 * Override
71 * Call automaticly by the api
72 */
73 void Vague0Image::fillImageGL(uchar4* ptrDevImageGL, int w, int h)
74 {
75 launchKernelVague0(ptrDevImageGL, w, h, t);
76 }
77
78 /**
79 * Override
80 * Call automaticly by the api
81 */
82 void Vague0Image::paintPrimitives(Graphic2Ds& graphic2D)
83 {
84 const Font_A* ptrFont = graphic2D.getFont(TIMES_ROMAN_24);
85
86 float r = 1;
87 float g = 0;
88 float b = 0;
89
90 graphic2D.setColorRGB(r, g, b);
91
92 // top
93 {
94 string message = "t = " + StringTools::toString(t);
95 graphic2D.drawTitleTop(message, ptrFont);
96 }
97
98 // bottom
99 {
100 graphic2D.drawTitleBottom("[API Image Cuda] : VagueImage warmup CUDA", ptrFont);
101 }
102 }
103
104 /*--------------------------------------*\
105 |* Private *|
106 \*-------------------------------------*/
107
108 /*----------------------------------------------------------------------*\
109 |* End *|
110 \*---------------------------------------------------------------------*/