Quellcode durchsuchen

Merge pull request #185 from adrianbroher/master

Fix various errors and warnings that prevented build assimp_view as linux to win32 cross compile.
Kim Kulling vor 11 Jahren
Ursprung
Commit
896d1b3f7e

+ 1 - 1
CMakeLists.txt

@@ -18,7 +18,7 @@ set(LIBASSIMP-DEV_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_M
 set(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev)
 set(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names")
 
-if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW )
   add_definitions(-fPIC) # this is a very important switch and some libraries seem now to have it....
   # hide all not-exported symbols
   add_definitions( -fvisibility=hidden -Wall )

+ 1 - 0
include/assimp/types.h

@@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <memory.h>
 #include <math.h>
 #include <stddef.h>
+#include <string.h>
 #include <limits.h>
 
 // Our compile configuration

+ 0 - 2
samples/SimpleTexturedOpenGL/CMakeLists.txt

@@ -22,8 +22,6 @@ INCLUDE_DIRECTORIES(
 LINK_DIRECTORIES( 
 	${Assimp_BINARY_DIR} 
 	${Assimp_BINARY_DIR}/lib/
-	${Assimp_SOURCE_DIR}/samples/glut/
-	${Assimp_SOURCE_DIR}/samples/DevIL/lib/
 )
 
 ADD_EXECUTABLE( assimp_simpletexturedogl WIN32

+ 5 - 6
samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp

@@ -17,9 +17,9 @@
 
 #include <windows.h>
 #include <stdio.h>
-#include <gl\GL.h>
-#include <gl\GLU.h>
-#include <IL\il.h>
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <IL/il.h>
 
 #include <fstream>
 
@@ -30,8 +30,8 @@
 
 // assimp include files. These three are usually needed.
 #include "assimp/Importer.hpp"	//OO version Header!
-#include "assimp/PostProcess.h"
-#include "assimp/Scene.h"
+#include "assimp/postprocess.h"
+#include "assimp/scene.h"
 #include "assimp/DefaultLogger.hpp"
 #include "assimp/LogStream.hpp"
 
@@ -177,7 +177,6 @@ int LoadGLTextures(const aiScene* scene)
 	/* Before calling ilInit() version should be checked. */
 	if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION)
 	{
-		ILint test = ilGetInteger(IL_VERSION_NUM);
 		/// wrong DevIL version ///
 		std::string err_msg = "Wrong DevIL version. Old devil.dll in system32/SysWow64?";
 		char* cErr_msg = (char *) err_msg.c_str();

+ 6 - 5
tools/assimp_view/AssetHelper.h

@@ -139,19 +139,20 @@ class AssetHelper
 					: 
 					piVB				(NULL),
 					piIB				(NULL),
-					piEffect			(NULL),
 					piVBNormals			(NULL),
+					piEffect			(NULL),
+					bSharedFX           (false),
 					piDiffuseTexture	(NULL),
 					piSpecularTexture	(NULL),
 					piAmbientTexture	(NULL),
-					piNormalTexture		(NULL),
 					piEmissiveTexture	(NULL),
+					piNormalTexture		(NULL),
 					piOpacityTexture	(NULL),
 					piShininessTexture	(NULL),
 					piLightmapTexture	(NULL),
-					pvOriginalNormals	(NULL),
-					bSharedFX(false),
-					twosided (false){}
+					twosided            (false),
+					pvOriginalNormals	(NULL)
+                {}
 
 				~MeshHelper ()
 					{

+ 3 - 3
tools/assimp_view/Background.h

@@ -47,10 +47,10 @@ class CBackgroundPainter
 	{
 	CBackgroundPainter()
 		: 
-		pcTexture(NULL),
 		clrColor(D3DCOLOR_ARGB(0xFF,100,100,100)),
-		eMode(SIMPLE_COLOR),
-		piSkyBoxEffect(NULL)
+		pcTexture(NULL),
+		piSkyBoxEffect(NULL),
+		eMode(SIMPLE_COLOR)
 		{}
 
 public:

+ 6 - 3
tools/assimp_view/CMakeLists.txt

@@ -43,8 +43,11 @@ ADD_EXECUTABLE(  assimp_viewer WIN32
 
 SET_PROPERTY(TARGET assimp_viewer PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX})
 
-ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
-ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
+
+IF ( MSVC )
+	ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
+	ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
+ENDIF ( MSVC )
 
 
 #
@@ -54,7 +57,7 @@ ADD_CUSTOM_COMMAND(TARGET assimp_viewer
 	MAIN_DEPENDENCY assimp)
 
 # Link the executable to the assimp + dx libs.
-TARGET_LINK_LIBRARIES ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32.lib Winmm.lib  ) 
+TARGET_LINK_LIBRARIES ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32.lib winmm.lib )
 
 INSTALL( TARGETS assimp_viewer
 	DESTINATION "${ASSIMP_BIN_INSTALL_DIR}" COMPONENT assimp-dev

+ 1 - 1
tools/assimp_view/Camera.h

@@ -55,8 +55,8 @@ class Camera
 			:
 
 			vPos(0.0f,0.0f,-10.0f),
-			vLookAt(0.0f,0.0f,1.0f),
 			vUp(0.0f,1.0f,0.0f),
+			vLookAt(0.0f,0.0f,1.0f),
 			vRight(0.0f,1.0f,0.0f)
 			{
 

+ 2 - 6
tools/assimp_view/Display.cpp

@@ -287,10 +287,6 @@ int CDisplay::ReplaceCurrentTexture(const char* szPath)
 	TreeView_SetItem(GetDlgItem(g_hDlg,IDC_TREE1),
 		m_pcCurrentTexture->hTreeItem);
 
-	// change this in the old aiMaterial structure, too
-	aiMaterial* pcMat = (aiMaterial*)
-		g_pcAsset->pcScene->mMaterials[m_pcCurrentTexture->iMatIndex];
- 	
 	// update all meshes referencing this material
 	for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
 	{
@@ -1187,7 +1183,7 @@ int CDisplay::HandleTreeViewPopup(WPARAM wParam,LPARAM lParam)
 {
 	// get the current selected material
 	std::vector<Info> apclrOut;
-	const char* szMatKey;
+	const char* szMatKey = "";
 
 	switch (LOWORD(wParam))
 	{
@@ -1255,7 +1251,7 @@ int CDisplay::HandleTreeViewPopup(WPARAM wParam,LPARAM lParam)
 		clr.lpCustColors = g_aclCustomColors;
 		clr.lpfnHook = NULL;
 		clr.lpTemplateName = NULL;
-		clr.lCustData = NULL;
+		clr.lCustData = 0;
 
 		ChooseColor(&clr);
 

+ 2 - 3
tools/assimp_view/HelpDialog.cpp

@@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "stdafx.h"
 #include "assimp_view.h"
 
-#include "RICHEDIT.H"
+#include "richedit.h"
 
 namespace AssimpView {
 
@@ -53,7 +53,7 @@ namespace AssimpView {
 INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
 	WPARAM wParam,LPARAM lParam)
 	{
-	lParam;
+	(void)lParam;
 	switch (uMsg)
 		{
 		case WM_INITDIALOG:
@@ -70,7 +70,6 @@ INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
 			SendDlgItemMessage(hwndDlg,IDC_RICHEDIT21,
 				EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM) pData);
 
-			UnlockResource(hg);
 			FreeResource(hg);
 			return TRUE;
 			}

+ 2 - 2
tools/assimp_view/LogWindow.cpp

@@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "stdafx.h"
 #include "assimp_view.h"
-#include "RichEdit.h"
+#include "richedit.h"
 
 namespace AssimpView {
 
@@ -70,7 +70,7 @@ static const char* AI_VIEW_RTF_LOG_HEADER =
 INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
 	WPARAM wParam,LPARAM lParam)
 	{
-	lParam;
+	(void)lParam;
 	switch (uMsg)
 		{
 		case WM_INITDIALOG:

+ 1 - 1
tools/assimp_view/Material.cpp

@@ -299,7 +299,7 @@ int CMaterialManager::FindValidPath(aiString* p_szString)
 					if( !q ) q=strrchr( tmp2,'\\' ); 
 					if( q ){ 
 						strcpy( q+1,p+1 ); 
-						if(pFile=fopen( tmp2,"r" ) ){ 
+						if((pFile=fopen( tmp2,"r" ))){ 
 							fclose( pFile ); 
 							strcpy(p_szString->data,tmp2);
 							p_szString->length = strlen(tmp2);

+ 1 - 1
tools/assimp_view/MeshRenderer.cpp

@@ -61,7 +61,7 @@ int CMeshRenderer::DrawUnsorted(unsigned int iIndex)
 
 	g_piDevice->SetIndices(g_pcAsset->apcMeshes[iIndex]->piIB);
 
-	D3DPRIMITIVETYPE type;
+	D3DPRIMITIVETYPE type = D3DPT_POINTLIST;
 	switch (g_pcAsset->pcScene->mMeshes[iIndex]->mPrimitiveTypes) {
 		case aiPrimitiveType_POINT:
 			type = D3DPT_POINTLIST;break;

+ 9 - 9
tools/assimp_view/MessageProc.cpp

@@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "stdafx.h"
 #include "assimp_view.h"
-#include <Windowsx.h>
+#include <windowsx.h>
 
 namespace AssimpView {
 
@@ -95,16 +95,16 @@ void MakeFileAssociations()
 		ai_assert(sz[0] == '*');
 		sprintf(buf,"Software\\Classes\\%s",sz+1);
 
-		RegCreateKeyEx(HKEY_CURRENT_USER,buf,NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
+		RegCreateKeyEx(HKEY_CURRENT_USER,buf,0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
 		RegSetValueEx(g_hRegistry,"",0,REG_SZ,(const BYTE*)"ASSIMPVIEW_CLASS",(DWORD)strlen("ASSIMPVIEW_CLASS")+1);
 		RegCloseKey(g_hRegistry);
 	}
-	while (sz = strtok(NULL,";"));
+	while ((sz = strtok(NULL,";")));
 
-	RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
+	RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS",0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
 	RegCloseKey(g_hRegistry);
 
-	RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS\\shell\\open\\command",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
+	RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Classes\\ASSIMPVIEW_CLASS\\shell\\open\\command",0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
 	RegSetValueEx(g_hRegistry,"",0,REG_SZ,(const BYTE*)szTemp,(DWORD)strlen(szTemp)+1);
 	RegCloseKey(g_hRegistry);
 
@@ -522,7 +522,7 @@ void DisplayColorDialog(D3DCOLOR* pclrResult)
 	clr.lpCustColors = g_aclCustomColors;
 	clr.lpfnHook = NULL;
 	clr.lpTemplateName = NULL;
-	clr.lCustData = NULL;
+	clr.lCustData = 0;
 
 	ChooseColor(&clr);
 
@@ -549,7 +549,7 @@ void DisplayColorDialog(D3DXVECTOR4* pclrResult)
 	clr.lpCustColors = g_aclCustomColors;
 	clr.lpfnHook = NULL;
 	clr.lpTemplateName = NULL;
-	clr.lCustData = NULL;
+	clr.lCustData = 0;
 
 	ChooseColor(&clr);
 
@@ -1120,7 +1120,7 @@ void InitUI()
 
 	// store the key in a global variable for later use
 	RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\ASSIMP\\Viewer",
-		NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
+		0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
 
 	if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LastUIState",NULL,NULL,
 		(BYTE*)&dwValue,&dwTemp))
@@ -2411,7 +2411,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
 		};
 	DWORD dwTemp = MAX_PATH;
 	RegCreateKeyEx(HKEY_CURRENT_USER,
-		"Software\\ASSIMP\\Viewer",NULL,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
+		"Software\\ASSIMP\\Viewer",0,NULL,0,KEY_ALL_ACCESS, NULL, &g_hRegistry,NULL);
 	if(ERROR_SUCCESS == RegQueryValueEx(g_hRegistry,"LastSkyBoxSrc",NULL,NULL,
 		(BYTE*)szFileName,&dwTemp) && '\0' != szFileName[0])
 		{

+ 3 - 3
tools/assimp_view/RenderOptions.h

@@ -60,16 +60,16 @@ class RenderOptions
 			bSuperSample	(false),
 			bRenderMats		(true),
 			bRenderNormals	(false),
-			eDrawMode		(NORMAL),
 			b3Lights		(false),
 			bLightRotate	(false),
 			bRotate			(true),
 			bLowQuality		(false),
 			bNoSpecular		(false),
 			bStereoView		(false),
+			bNoAlphaBlending(false),
+			eDrawMode		(NORMAL),
 			bCulling		(false),
-			bSkeleton		(false),
-			bNoAlphaBlending(false)
+			bSkeleton		(false)
 			
 			{}
 

+ 1 - 5
tools/assimp_view/assimp_view.cpp

@@ -106,7 +106,7 @@ aiVector3D g_vRotateSpeed			= aiVector3D(0.5f,0.5f,0.5f);
 aiVector3D g_avLightDirs[1] = 
 {	aiVector3D(-0.5f,0.6f,0.2f)  };
 
-extern D3DCOLOR g_avLightColors[3] = 
+D3DCOLOR g_avLightColors[3] = 
 {
 	D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0xFF),
 	D3DCOLOR_ARGB(0xFF,0xFF,0x00,0x00),
@@ -872,12 +872,10 @@ int CreateHUDTexture()
 		g_pcTexture  = NULL;
 		g_szImageMask = NULL;
 
-		UnlockResource(hg);
 		FreeResource(hg);
 		return 0;
 	}
 
-	UnlockResource(hg);
 	FreeResource(hg);
 
 	D3DSURFACE_DESC sDesc;
@@ -909,12 +907,10 @@ int CreateHUDTexture()
 			D3DCOLOR_ARGB(0xFF,0xFF,0,0));
 		g_szImageMask = NULL;
 
-		UnlockResource(hg);
 		FreeResource(hg);
 		return 0;
 	}
 
-	UnlockResource(hg);
 	FreeResource(hg);
 
 	// lock the texture and copy it to get a pointer

+ 12 - 10
tools/assimp_view/stdafx.h

@@ -44,14 +44,14 @@
 
 #include <d3d9.h>
 #include <d3dx9.h>
-#include <D3DX9Mesh.h>
+#include <d3dx9mesh.h>
 
 // ShellExecute()
 #include <shellapi.h>
 #include <commctrl.h>
 
 // GetOpenFileName()
-#include <Commdlg.h>
+#include <commdlg.h>
 #include <algorithm>
 #include <mmsystem.h>
 
@@ -60,13 +60,15 @@
 #include <list>
 #include <vector>
 
+#if defined _MSC_VER
 // Windows CommonControls 6.0 Manifest Extensions
-#if defined _M_IX86
-#	pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
-#elif defined _M_IA64
-#	pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
-#elif defined _M_X64
-#	pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
-#else
-#	pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#   if defined _M_IX86
+#	    pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#   elif defined _M_IA64
+#	    pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#   elif defined _M_X64
+#	    pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#   else
+#	    pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#   endif
 #endif