From 51b92390b676a546d1f6b741604fb4634b410222 Mon Sep 17 00:00:00 2001
From: Thomas Goyne <plorkyeran@aegisub.org>
Date: Wed, 16 Jul 2014 18:02:33 -0700
Subject: [PATCH] Fix a bunch of float <-> double conversion warnings

---
 src/audio_colorscheme.cpp       |  2 +-
 src/audio_renderer_spectrum.cpp |  4 ++--
 src/colorspace.cpp              |  6 +++---
 src/gl_wrap.cpp                 | 12 ++++++------
 src/video_display.cpp           |  4 ++--
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/audio_colorscheme.cpp b/src/audio_colorscheme.cpp
index 80f35a15d..a7a1142c9 100644
--- a/src/audio_colorscheme.cpp
+++ b/src/audio_colorscheme.cpp
@@ -58,7 +58,7 @@ AudioColorScheme::AudioColorScheme(int prec, std::string const& scheme_name, int
 
 	for (size_t i = 0; i <= factor; ++i)
 	{
-		float t = (float)i / factor;
+		auto t = (double)i / factor;
 		hsl_to_rgb(
 			mid<int>(0, h_base + t * h_scale, 255),
 			mid<int>(0, s_base + t * s_scale, 255),
diff --git a/src/audio_renderer_spectrum.cpp b/src/audio_renderer_spectrum.cpp
index 9b14e81e2..9d79feaa8 100644
--- a/src/audio_renderer_spectrum.cpp
+++ b/src/audio_renderer_spectrum.cpp
@@ -178,7 +178,7 @@ void AudioSpectrumRenderer::FillBlock(size_t block_index, float *block)
 
 	fftw_execute(dft_plan);
 
-	float scale_factor = 9 / sqrt(2 * (float)(2<<derivation_size));
+	double scale_factor = 9 / sqrt(2 << (derivation_size + 1));
 
 	fftw_complex *o = dft_output;
 	for (size_t si = 1<<derivation_size; si > 0; --si)
@@ -253,7 +253,7 @@ void AudioSpectrumRenderer::Render(wxBitmap &bmp, int start, AudioRenderingStyle
 			{
 				assert(px >= imgdata);
 				assert(px < imgdata + imgheight*stride);
-				float ideal = (float)(y+1.)/imgheight * (maxband-minband) + minband;
+				auto ideal = (double)(y+1.)/imgheight * (maxband-minband) + minband;
 				float sample1 = power[(int)floor(ideal)+minband];
 				float sample2 = power[(int)ceil(ideal)+minband];
 				float frac = ideal - floor(ideal);
diff --git a/src/colorspace.cpp b/src/colorspace.cpp
index 2d9df415c..bd3dafd68 100644
--- a/src/colorspace.cpp
+++ b/src/colorspace.cpp
@@ -92,8 +92,8 @@ void hsl_to_rgb(int H, int S, int L, unsigned char *R, unsigned char *G, unsigne
 	l = L / 255.f;
 
 	float temp2;
-	if (l < .5) {
-		temp2 = l * (1. + s);
+	if (l < .5f) {
+		temp2 = l * (1.f + s);
 	} else {
 		temp2 = l + s - l*s;
 	}
@@ -257,7 +257,7 @@ void rgb_to_hsl(int R, int G, int B, unsigned char *H, unsigned char *S, unsigne
 		h = 0;
 		s = 0;
 	} else {
-		if (l < 0.5) {
+		if (l < .5f) {
 			s = (maxrgb - minrgb) / (maxrgb + minrgb);
 		} else {
 			s = (maxrgb - minrgb) / (2.f - maxrgb - minrgb);
diff --git a/src/gl_wrap.cpp b/src/gl_wrap.cpp
index a7eb769f6..66e582958 100644
--- a/src/gl_wrap.cpp
+++ b/src/gl_wrap.cpp
@@ -131,12 +131,12 @@ void OpenGLWrapper::DrawRectangle(Vector2D p1, Vector2D p2) const {
 	buf.Set(3, Vector2D(p1, p2));
 
 	// Fill
-	if (fill_a != 0.0) {
+	if (fill_a != 0.f) {
 		SetModeFill();
 		buf.Draw(GL_QUADS, false);
 	}
 	// Outline
-	if (line_a != 0.0) {
+	if (line_a != 0.f) {
 		SetModeLine();
 		buf.Draw(GL_LINE_LOOP);
 	}
@@ -149,12 +149,12 @@ void OpenGLWrapper::DrawTriangle(Vector2D p1, Vector2D p2, Vector2D p3) const {
 	buf.Set(2, p3);
 
 	// Fill
-	if (fill_a != 0.0) {
+	if (fill_a != 0.f) {
 		SetModeFill();
 		buf.Draw(GL_TRIANGLES, false);
 	}
 	// Outline
-	if (line_a != 0.0) {
+	if (line_a != 0.f) {
 		SetModeLine();
 		buf.Draw(GL_LINE_LOOP);
 	}
@@ -183,7 +183,7 @@ void OpenGLWrapper::DrawRing(Vector2D center, float r1, float r2, float ar, floa
 	Vector2D scale_inner = Vector2D(ar, 1) * r1;
 	Vector2D scale_outer = Vector2D(ar, 1) * r2;
 
-	if (fill_a != 0.0) {
+	if (fill_a != 0.f) {
 		SetModeFill();
 
 		// Annulus
@@ -210,7 +210,7 @@ void OpenGLWrapper::DrawRing(Vector2D center, float r1, float r2, float ar, floa
 		cur_angle = arc_start;
 	}
 
-	if (line_a == 0.0) return;
+	if (line_a == 0.f) return;
 
 	// Outer
 	steps++;
diff --git a/src/video_display.cpp b/src/video_display.cpp
index 620869b50..7a3931890 100644
--- a/src/video_display.cpp
+++ b/src/video_display.cpp
@@ -282,13 +282,13 @@ void VideoDisplay::PositionVideo() {
 		double videoAr = arType == AspectRatio::Default ? double(vidW) / vidH : con->videoController->GetAspectRatioValue();
 
 		// Window is wider than video, blackbox left/right
-		if (displayAr - videoAr > 0.01f) {
+		if (displayAr - videoAr > 0.01) {
 			int delta = viewport_width - videoAr * viewport_height;
 			viewport_left = delta / 2;
 			viewport_width -= delta;
 		}
 		// Video is wider than window, blackbox top/bottom
-		else if (videoAr - displayAr > 0.01f) {
+		else if (videoAr - displayAr > 0.01) {
 			int delta = viewport_height - viewport_width / videoAr;
 			viewport_top = viewport_bottom = delta / 2;
 			viewport_height -= delta;
-- 
GitLab