2
0
Эх сурвалжийг харах

Merge pull request #1949 from JLouis-B/fix-assimp-viewer-build

Fix Assimp viewer build with MinGW
Kim Kulling 7 жил өмнө
parent
commit
8da12c616f

+ 1 - 1
tools/assimp_view/Display.cpp

@@ -2251,7 +2251,7 @@ int CDisplay::RenderTextureView()
         const float ny = (float)sRect.bottom;
         const float ny = (float)sRect.bottom;
         const float  x = (float)sDesc.Width;
         const float  x = (float)sDesc.Width;
         const float  y = (float)sDesc.Height;
         const float  y = (float)sDesc.Height;
-        float f = min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f);
+        float f = std::min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f);
 
 
         float fHalfX = (nx - (f * x)) / 2.0f;
         float fHalfX = (nx - (f * x)) / 2.0f;
         float fHalfY = (ny - (f * y)) / 2.0f;
         float fHalfY = (ny - (f * y)) / 2.0f;

+ 1 - 1
tools/assimp_view/Material.cpp

@@ -275,7 +275,7 @@ bool CMaterialManager::TryLongerPath(char* szTemp,aiString* p_szString)
                         for (unsigned int i = 0; i < iSizeFound;++i)
                         for (unsigned int i = 0; i < iSizeFound;++i)
                             info.cFileName[i] = (CHAR)tolower(info.cFileName[i]);
                             info.cFileName[i] = (CHAR)tolower(info.cFileName[i]);
 
 
-                        if (0 == memcmp(info.cFileName,szFile2, min(iSizeFound,iSize)))
+                        if (0 == memcmp(info.cFileName,szFile2, std::min(iSizeFound,iSize)))
                         {
                         {
                             // we have it. Build the full path ...
                             // we have it. Build the full path ...
                             char* sz = strrchr(szTempB,'*');
                             char* sz = strrchr(szTempB,'*');

+ 7 - 2
tools/assimp_view/MessageProc.cpp

@@ -45,7 +45,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 #include <windowsx.h>
 #include <windowsx.h>
 #include <commdlg.h>
 #include <commdlg.h>
+
+#ifdef __MINGW32__
+#include <mmsystem.h>
+#else
 #include <timeapi.h>
 #include <timeapi.h>
+#endif
 
 
 namespace AssimpView {
 namespace AssimpView {
 
 
@@ -1050,9 +1055,9 @@ void DoExport(size_t formatId)
         ai_assert(strlen(szFileName) <= MAX_PATH);
         ai_assert(strlen(szFileName) <= MAX_PATH);
 
 
         // invent a nice default file name
         // invent a nice default file name
-        char* sz = max(strrchr(szFileName,'\\'),strrchr(szFileName,'/'));
+        char* sz = std::max(strrchr(szFileName,'\\'),strrchr(szFileName,'/'));
         if (sz) {
         if (sz) {
-            strncpy(sz,max(strrchr(g_szFileName,'\\'),strrchr(g_szFileName,'/')),MAX_PATH);
+            strncpy(sz,std::max(strrchr(g_szFileName,'\\'),strrchr(g_szFileName,'/')),MAX_PATH);
         }
         }
     }
     }
     else {
     else {

+ 6 - 1
tools/assimp_view/assimp_view.cpp

@@ -43,10 +43,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 
 
 #include "assimp_view.h"
 #include "assimp_view.h"
-#include <timeapi.h>
 #include <assimp/StringUtils.h>
 #include <assimp/StringUtils.h>
 #include <map>
 #include <map>
 
 
+#ifdef __MINGW32__
+#include <mmsystem.h>
+#else
+#include <timeapi.h>
+#endif
+
 using namespace std;
 using namespace std;
 
 
 namespace AssimpView {
 namespace AssimpView {

+ 4 - 1
tools/assimp_view/assimp_view.h

@@ -46,6 +46,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 #define AI_SHADER_COMPILE_FLAGS D3DXSHADER_USE_LEGACY_D3DX9_31_DLL
 #define AI_SHADER_COMPILE_FLAGS D3DXSHADER_USE_LEGACY_D3DX9_31_DLL
 
 
+// Because Dx headers include windef.h with min/max redefinition
+#define NOMINMAX
+
 // include resource definitions
 // include resource definitions
 #include "resource.h"
 #include "resource.h"
 
 
@@ -177,7 +180,7 @@ type clamp(intype in)
 {
 {
     // for unsigned types only ...
     // for unsigned types only ...
     intype mask = (0x1u << (sizeof(type)*8))-1;
     intype mask = (0x1u << (sizeof(type)*8))-1;
-    return (type)max((intype)0,min(in,mask));
+    return (type)std::max((intype)0,std::min(in,mask));
 }
 }