aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-graphics/glm/glm/0001-Fix-Wimplicit-int-float-conversion-warnings-with-cla.patch
blob: 2eb50a5a3a5d9ec149acdd44be1571d16cb7838e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
From 461861cd2e34294830b121db834c05ff39424f6f Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 27 Dec 2019 18:42:51 -0800
Subject: [PATCH] Fix Wimplicit-int-float-conversion warnings with clang 10+

This is a new warning in clang which will be available in clang 10
onwards

Fixes
error: implicit conversion from 'const int' to 'float' may lose precision [-Werror,-Wimplicit-int-float-conversion]

Upstream-Status: Submitted [https://github.com/g-truc/glm/pull/986]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 glm/gtx/scalar_multiplication.hpp  |  2 +-
 test/gtx/gtx_fast_trigonometry.cpp | 32 +++++++++++++++---------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/glm/gtx/scalar_multiplication.hpp b/glm/gtx/scalar_multiplication.hpp
index f391f8de..496ba193 100644
--- a/glm/gtx/scalar_multiplication.hpp
+++ b/glm/gtx/scalar_multiplication.hpp
@@ -54,7 +54,7 @@ namespace glm
 	template<typename T> \
 	return_type_scalar_multiplication<T, Vec> \
 	operator/(Vec lh, T const& s){ \
-		return lh *= 1.0f / s; \
+		return lh *= 1.0f / static_cast<float>(s); \
 	}
 
 GLM_IMPLEMENT_SCAL_MULT(vec2)
diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp
index f3bf17bf..f3c4e957 100644
--- a/test/gtx/gtx_fast_trigonometry.cpp
+++ b/test/gtx/gtx_fast_trigonometry.cpp
@@ -239,12 +239,12 @@ namespace taylorCos
 		std::vector<glm::vec4> Results;
 		Results.resize(Samples);
 
-		float Steps = (End - Begin) / Samples;
+		float Steps = (End - Begin) / float(Samples);
 
 		std::clock_t const TimeStampBegin = std::clock();
 
 		for(std::size_t i = 0; i < Samples; ++i)
-			Results[i] = fastCosNew(AngleShift + glm::vec4(Begin + Steps * i));
+			Results[i] = fastCosNew(AngleShift + glm::vec4(Begin + Steps * float(i)));
 
 		std::clock_t const TimeStampEnd = std::clock();
 
@@ -280,12 +280,12 @@ namespace taylorCos
 		std::vector<glm::vec4> Results;
 		Results.resize(Samples);
 
-		float Steps = (End - Begin) / Samples;
+		float Steps = (End - Begin) / float(Samples);
 
 		std::clock_t const TimeStampBegin = std::clock();
 
 		for(std::size_t i = 0; i < Samples; ++i)
-			Results[i] = taylorCos::fastCosDeterminisctic(AngleShift + glm::vec4(Begin + Steps * i));
+			Results[i] = taylorCos::fastCosDeterminisctic(AngleShift + glm::vec4(Begin + Steps * float(i)));
 
 		std::clock_t const TimeStampEnd = std::clock();
 
@@ -327,12 +327,12 @@ namespace taylorCos
 		std::vector<glm::vec4> Results;
 		Results.resize(Samples);
 
-		float Steps = (End - Begin) / Samples;
+		float Steps = (End - Begin) / float(Samples);
 
 		std::clock_t const TimeStampBegin = std::clock();
 
 		for(std::size_t i = 0; i < Samples; ++i)
-			Results[i] = taylorCos::fastRefCos(AngleShift + glm::vec4(Begin + Steps * i));
+			Results[i] = taylorCos::fastRefCos(AngleShift + glm::vec4(Begin + Steps * float(i)));
 
 		std::clock_t const TimeStampEnd = std::clock();
 
@@ -349,12 +349,12 @@ namespace taylorCos
 		std::vector<glm::vec4> Results;
 		Results.resize(Samples);
 
-		float Steps = (End - Begin) / Samples;
+		float Steps = (End - Begin) / float(Samples);
 
 		std::clock_t const TimeStampBegin = std::clock();
 
 		for(std::size_t i = 0; i < Samples; ++i)
-			Results[i] = glm::fastCos(AngleShift + glm::vec4(Begin + Steps * i));
+			Results[i] = glm::fastCos(AngleShift + glm::vec4(Begin + Steps * float(i)));
 
 		std::clock_t const TimeStampEnd = std::clock();
 
@@ -371,12 +371,12 @@ namespace taylorCos
 		std::vector<glm::vec4> Results;
 		Results.resize(Samples);
 
-		float Steps = (End - Begin) / Samples;
+		float Steps = (End - Begin) / float(Samples);
 
 		std::clock_t const TimeStampBegin = std::clock();
 
 		for(std::size_t i = 0; i < Samples; ++i)
-			Results[i] = glm::cos(AngleShift + glm::vec4(Begin + Steps * i));
+			Results[i] = glm::cos(AngleShift + glm::vec4(Begin + Steps * float(i)));
 
 		std::clock_t const TimeStampEnd = std::clock();
 
@@ -466,12 +466,12 @@ namespace taylor2
 		std::vector<float> Results;
 		Results.resize(Samples);
 
-		float Steps = (End - Begin) / Samples;
+		float Steps = (End - Begin) / float(Samples);
 
 		std::clock_t const TimeStampBegin = std::clock();
 
 		for(std::size_t i = 0; i < Samples; ++i)
-			Results[i] = taylorCosA(AngleShift.x + Begin + Steps * i);
+			Results[i] = taylorCosA(AngleShift.x + Begin + Steps * float(i));
 
 		std::clock_t const TimeStampEnd = std::clock();
 
@@ -488,12 +488,12 @@ namespace taylor2
 		std::vector<float> Results;
 		Results.resize(Samples);
 
-		float Steps = (End - Begin) / Samples;
+		float Steps = (End - Begin) / float(Samples);
 
 		std::clock_t const TimeStampBegin = std::clock();
 
 		for(std::size_t i = 0; i < Samples; ++i)
-			Results[i] = taylorCosB(AngleShift.x + Begin + Steps * i);
+			Results[i] = taylorCosB(AngleShift.x + Begin + Steps * float(i));
 
 		std::clock_t const TimeStampEnd = std::clock();
 
@@ -510,12 +510,12 @@ namespace taylor2
 		std::vector<float> Results;
 		Results.resize(Samples);
 
-		float Steps = (End - Begin) / Samples;
+		float Steps = (End - Begin) / float(Samples);
 
 		std::clock_t const TimeStampBegin = std::clock();
 
 		for(std::size_t i = 0; i < Samples; ++i)
-			Results[i] = taylorCosC(AngleShift.x + Begin + Steps * i);
+			Results[i] = taylorCosC(AngleShift.x + Begin + Steps * float(i));
 
 		std::clock_t const TimeStampEnd = std::clock();
 
-- 
2.24.1