Gui: Use std::numeric_limits and std::numbers instead of defines

This commit is contained in:
Benjamin Nauck
2025-03-27 18:59:58 +01:00
parent 3253f2c2de
commit b625e81a3e
33 changed files with 204 additions and 168 deletions

View File

@@ -25,10 +25,8 @@
#ifndef _PreComp_
#include <array>
#include <boost/math/constants/constants.hpp>
#ifdef FC_OS_WIN32
#define _USE_MATH_DEFINES
#endif
#include <cmath>
#include <numbers>
#ifdef FC_OS_MACOSX
#include <OpenGL/gl.h>
#else
@@ -39,17 +37,23 @@
#include "SoFCBackgroundGradient.h"
static const std::array <GLfloat[2], 32> big_circle = []{
static const float pi2 = boost::math::constants::two_pi<float>();
constexpr float pi = std::numbers::pi_v<float>;
constexpr float sqrt2 = std::numbers::sqrt2_v<float>;
std::array <GLfloat[2], 32> result; int c = 0;
for (GLfloat i = 0; i < pi2; i += pi2 / 32, c++) {
result[c][0] = M_SQRT2*cosf(i); result[c][1] = M_SQRT2*sinf(i);
for (GLfloat i = 0; i < 2 * pi; i += 2 * pi / 32, c++) {
result[c][0] = sqrt2 * cosf(i);
result[c][1] = sqrt2 * sinf(i);
}
return result; }();
static const std::array <GLfloat[2], 32> small_oval = []{
static const float pi2 = boost::math::constants::two_pi<float>();
constexpr float pi = std::numbers::pi_v<float>;
constexpr float sqrt2 = std::numbers::sqrt2_v<float>;
static const float sqrt1_2 = std::sqrt(1 / 2.F);
std::array <GLfloat[2], 32> result; int c = 0;
for (GLfloat i = 0; i < pi2; i += pi2 / 32, c++) {
result[c][0] = 0.3*M_SQRT2*cosf(i); result[c][1] = M_SQRT1_2*sinf(i);
for (GLfloat i = 0; i < 2 * pi; i += 2 * pi / 32, c++) {
result[c][0] = 0.3 * sqrt2 * cosf(i);
result[c][1] = sqrt1_2 * sinf(i);
}
return result; }();