/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #include "MGCLStdAfx.h" #include "mg/tolerance.h" #include "mgGL/color.h" #include "mgGL/OpenGLView.h" #include "mgGL/GLSLProgram.h" #include "mgGL/VBOElement.h" #include "mgGL/VBOLeaf.h" #include "mgGL/ConstructionPlane.h" #if defined(_DEBUG) #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // Implementation of non-categolized global functions. // //Version no. definition. This is used in MGIfstream/MGOfstream.cpp. extern MG_DLL_DECLR const char* _MGCL_VER="MGCL1000"; extern MG_DLL_DECLR const char* _MGCL_FILE="File System fugen,Inc"; MGColors MGColor::m_colors=MGColors(); MGDrawParam mgVBOElement::m_drawPara=MGDrawParam(); MGColor mgVBOElement::m_hilightColor=MGColor::UNDEFINED; GLfloat mgVBOElement::m_pointSize=6.f;//Default outer point size. const GLfloat mgVBOLeaf::m_PolygonModePointSizeBase=1000.; mgGLSLProgram* mgGLSLProgram::m_CurrrentGLSL=0; MGOpenGLView* MGOpenGLView::m_currentGLView=0; // namespace MGCL{ //Get the MGCL_Version number. const char* Version(){ return _MGCL_VER; }; //Get the MGCL File validity. const char* File_validity(){ return _MGCL_FILE; } void start_up(bool need_to_GdiStartUp){ if(need_to_GdiStartUp){ //-> GDI+ startup Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartup( &m_gdiplusToken, &gdiplusStartupInput, NULL ); m_gdiplus_initialized=true; //<- GDI+ startup }else{ m_gdiplus_initialized=false; } } void shut_down(){ if(m_gdiplus_initialized) Gdiplus::GdiplusShutdown( m_gdiplusToken ); } //桁合わせ、デフォルトでは上から4桁を残し、後は切り捨てる double MG_DLL_DECLR decimalAlign(double dValue, int nDigit){ if(dValue == 0.) return 0.; int nValueExp = int(std::log10(std::abs(dValue)) + 1.); double pow = std::pow(10., nDigit - nValueExp); return int(dValue * pow) / pow; } //Round the input angel degree value degree to the multiples of step. //The input degree and step are assumed to be angle in degree. //step must be greater than 1. //degree must be greater or equal to 0. and less than 360. //Returned is a positibe value. double MG_DLL_DECLR round_angle(double degree, double step){ assert(step>1. && degree<=360.); const double BASE=360.; int m=int(degree/step); double rounded1=double(m)*step; double rounded2=double(m+1)*step; if(rounded2-degree >= degree-rounded1) return rounded1; if(MGAEqual(rounded2, BASE)) return 0.; return rounded2; } ///グローバルmin/max関数 double max(double a, double b){return a >= b ? a : b;} double min(double a, double b){return a <= b ? a : b;} int max(int a, int b){return a >= b ? a : b;} int min(int a, int b){return a <= b ? a : b;} }