From a133d36dfc71c287524bd119d14eb1dc21685762 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 13 Mar 2013 12:48:14 +0000 Subject: [PATCH] =?UTF-8?q?base:=20roll=20our=20own=20constants=20because?= =?UTF-8?q?=20it=E2=80=99s=20always=20a=20pain=20in=20the=20ass=20to=20get?= =?UTF-8?q?=20M=5FPI=20from=20the=20platform=20headers=20and=20cast=20it?= =?UTF-8?q?=20to=20float.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- neercs/neercs.cpp | 15 --------------- neercs/old/wm.cpp | 15 +++------------ neercs/term/term.cpp | 17 ++++------------- neercs/video/render.cpp | 19 +++++-------------- 4 files changed, 12 insertions(+), 54 deletions(-) diff --git a/neercs/neercs.cpp b/neercs/neercs.cpp index 23546f0..d8aae1f 100644 --- a/neercs/neercs.cpp +++ b/neercs/neercs.cpp @@ -8,21 +8,6 @@ # include "config.h" #endif -#if defined _XBOX -# define _USE_MATH_DEFINES /* for M_PI */ -# include -# undef near /* Fuck Microsoft */ -# undef far /* Fuck Microsoft again */ -#elif defined _WIN32 -# define _USE_MATH_DEFINES /* for M_PI */ -# define WIN32_LEAN_AND_MEAN -# include -# undef near /* Fuck Microsoft */ -# undef far /* Fuck Microsoft again */ -#else -# include -#endif - #include #include diff --git a/neercs/old/wm.cpp b/neercs/old/wm.cpp index b336613..03a1f2f 100644 --- a/neercs/old/wm.cpp +++ b/neercs/old/wm.cpp @@ -15,17 +15,6 @@ # include "config.h" #endif -#if defined _XBOX -# define _USE_MATH_DEFINES /* for M_PI */ -# include -# undef near /* Fuck Microsoft */ -# undef far /* Fuck Microsoft again */ -#elif defined _WIN32 -# define _USE_MATH_DEFINES /* for M_PI */ -# define WIN32_LEAN_AND_MEAN -# include -#endif - #include #include #include @@ -33,6 +22,8 @@ #include "core.h" +using namespace lol; + extern "C" { #include "neercs.h" } @@ -458,7 +449,7 @@ void wm_refresh_cube(struct screen_list *screen_list) float angle = 90.0f * ((float)cur_time / (float)screen_list->cube.duration); - angle *= (M_PI / 180.0f); + angle *= (F_PI / 180.0f); if (screen_list->cube.side == 1) angle = -angle; diff --git a/neercs/term/term.cpp b/neercs/term/term.cpp index 70fbe74..c02765c 100644 --- a/neercs/term/term.cpp +++ b/neercs/term/term.cpp @@ -6,15 +6,6 @@ # include "config.h" #endif -#if defined _XBOX -# define _USE_MATH_DEFINES /* for M_PI */ -# include -#elif defined _WIN32 -# define _USE_MATH_DEFINES /* for M_PI */ -# define WIN32_LEAN_AND_MEAN -# include -#endif - #include "core.h" using namespace std; @@ -207,8 +198,8 @@ void Term::DrawFancyShit() caca_set_color_argb(m_caca, 0x0f0, bg_color); for(int i = 0; i < h; i++) { - float a = M_PI / 180 * i * 16 + m_time * 4; - float b = M_PI / 180 * i * 12; + float a = F_PI / 180 * i * 16 + m_time * 4; + float b = F_PI / 180 * i * 12; int x = w / 2 - 14 + w / 4 * lol::cos(a) + w / 4 * lol::sin(b); caca_put_str(m_caca, x, i, "LOL WUT! NEERCS SI TEH RULEZ"); } @@ -216,8 +207,8 @@ void Term::DrawFancyShit() caca_set_color_argb(m_caca, 0x444, bg_color); for(int i = 0; i < w; i++) { - float a = m_time * 1 + M_PI / 180 * i * 8; - float b = m_time * -2 + M_PI / 180 * i * 5; + float a = m_time * 1 + F_PI / 180 * i * 8; + float b = m_time * -2 + F_PI / 180 * i * 5; int y = h / 2 + h / 4 * lol::cos(a) + h / 4 * lol::sin(b); caca_set_color_argb(m_caca, hex_color(0.25f + 0.5f / w * i - 0.25f / h * y, 0.25f, 0.25f + 0.25f / w * i + 0.25f / h * y), bg_color); caca_draw_line(m_caca, i, y - 1, i, y + 1,'%'); diff --git a/neercs/video/render.cpp b/neercs/video/render.cpp index 487dd4f..62ef2d0 100644 --- a/neercs/video/render.cpp +++ b/neercs/video/render.cpp @@ -6,15 +6,6 @@ # include "config.h" #endif -#if defined _XBOX -# define _USE_MATH_DEFINES /* for M_PI */ -# include -#elif defined _WIN32 -# define _USE_MATH_DEFINES /* for M_PI */ -# define WIN32_LEAN_AND_MEAN -# include -#endif - #include #include #include @@ -44,7 +35,7 @@ LOLFX_RESOURCE_DECLARE(postfx); LOLFX_RESOURCE_DECLARE(mirror); LOLFX_RESOURCE_DECLARE(radial); -#define PID M_PI/180.0f // pi ratio +#define PID F_PI/180.0f // pi ratio /* * Global variable -- ugly ( sam: c'est toi qui est ugly! \:D/) @@ -1668,10 +1659,10 @@ void Render::Draw3D() shader_postfx->SetUniform(shader_postfx_gradient_color, postfx_gradient_color); shader_postfx->SetUniform(shader_postfx_vignetting, postfx_vignetting); shader_postfx->SetUniform(shader_postfx_aberration, postfx_aberration); - shader_postfx->SetUniform(shader_postfx_moire_h, vec4(postfx_moire_h.xyz, postfx_moire_h.w * (float)(2 * M_PI))); - shader_postfx->SetUniform(shader_postfx_moire_v, vec4(postfx_moire_v.xyz, postfx_moire_v.w * (float)(2 * M_PI))); - shader_postfx->SetUniform(shader_postfx_scanline_h, vec4(postfx_scanline_h.xyz, postfx_scanline_h.w * (float)(2 * M_PI))); - shader_postfx->SetUniform(shader_postfx_scanline_v, vec4(postfx_scanline_v.xyz, postfx_scanline_v.w * (float)(2 * M_PI))); + shader_postfx->SetUniform(shader_postfx_moire_h, vec4(postfx_moire_h.xyz, postfx_moire_h.w * (2 * F_PI))); + shader_postfx->SetUniform(shader_postfx_moire_v, vec4(postfx_moire_v.xyz, postfx_moire_v.w * (2 * F_PI))); + shader_postfx->SetUniform(shader_postfx_scanline_h, vec4(postfx_scanline_h.xyz, postfx_scanline_h.w * (2 * F_PI))); + shader_postfx->SetUniform(shader_postfx_scanline_v, vec4(postfx_scanline_v.xyz, postfx_scanline_v.w * (2 * F_PI))); shader_postfx->SetUniform(shader_postfx_corner, postfx_corner); shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(sync_value * cosf((main_angle - sync_angle) * 6.0f))); shader_postfx->SetUniform(shader_postfx_beat, (float)fabs(beat_value * cosf((main_angle - beat_angle) * 6.0f)));