use glsl::syntax::ShaderStage; use glsl_quasiquote::glsl; use super::CodePiece; use glsl::syntax::TranslationUnit; use glsl::transpiler::glsl::show_translation_unit; use crate::impl_code_piece; pub struct Constants { pub raw: ShaderStage, } impl Constants { pub fn new() -> Constants { let raw = glsl! { #ifndef _GLUMPY__CONSTANTS__ #define _GLUMPY__CONSTANTS__ // The base of natural logarithms (e) const float M_E = 2.71828182845904523536028747135266250; // The logarithm to base 2 of M_E (log2(e)) const float M_LOG2E = 1.44269504088896340735992468100189214; // The logarithm to base 10 of M_E (log10(e)) const float M_LOG10E = 0.434294481903251827651128918916605082; // The natural logarithm of 2 (loge(2)) const float M_LN2 = 0.693147180559945309417232121458176568; // The natural logarithm of 10 (loge(10)) const float M_LN10 = 2.30258509299404568401799145468436421; // Pi, the ratio of a circle's circumference to its diameter. const float M_PI = 3.14159265358979323846264338327950288; // Pi divided by two (pi/2) const float M_PI_2 = 1.57079632679489661923132169163975144; // Pi divided by four (pi/4) const float M_PI_4 = 0.785398163397448309615660845819875721; // The reciprocal of pi (1/pi) const float M_1_PI = 0.318309886183790671537767526745028724; // Two times the reciprocal of pi (2/pi) const float M_2_PI = 0.636619772367581343075535053490057448; // Two times the reciprocal of the square root of pi (2/sqrt(pi)) const float M_2_SQRTPI = 1.12837916709551257389615890312154517; // The square root of two (sqrt(2)) const float M_SQRT2 = 1.41421356237309504880168872420969808; // The reciprocal of the square root of two (1/sqrt(2)) const float M_SQRT1_2 = 0.707106781186547524400844362104849039; // 1 degree in radians const float degree = 180.0/M_PI; // 1 radian in degrees const float radian = M_PI/180.0; #endif }; Constants { raw } } } impl_code_piece!(Constants, raw);