Added command-line utility to cmake project
This commit is contained in:
Родитель
98684ac2fa
Коммит
3d9065ff83
|
@ -26,4 +26,4 @@ Release
|
|||
x64
|
||||
/Tests
|
||||
/wiki
|
||||
/DirectXMesh/out
|
||||
/out
|
|
@ -0,0 +1,69 @@
|
|||
# DirectXMesh geometry Library
|
||||
#
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
#
|
||||
# http://go.microsoft.com/fwlink/?LinkID=324981
|
||||
|
||||
cmake_minimum_required (VERSION 3.8)
|
||||
project (DirectXMesh_CMake LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||
|
||||
set(WarningsLib "-Wall" "-Wpedantic" "-Wextra")
|
||||
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-double-promotion" "-Wno-exit-time-destructors" "-Wno-missing-prototypes")
|
||||
|
||||
add_library (directxmesh STATIC
|
||||
DirectXMesh/DirectXMesh.h
|
||||
DirectXMesh/DirectXMeshP.h
|
||||
DirectXMesh/scoped.h
|
||||
DirectXMesh/DirectXMeshAdjacency.cpp
|
||||
DirectXMesh/DirectXMeshClean.cpp
|
||||
DirectXMesh/DirectXMeshGSAdjacency.cpp
|
||||
DirectXMesh/DirectXMeshNormals.cpp
|
||||
DirectXMesh/DirectXMeshOptimize.cpp
|
||||
DirectXMesh/DirectXMeshOptimizeLRU.cpp
|
||||
DirectXMesh/DirectXMeshOptimizeTVC.cpp
|
||||
DirectXMesh/DirectXMeshRemap.cpp
|
||||
DirectXMesh/DirectXMeshTangentFrame.cpp
|
||||
DirectXMesh/DirectXMeshUtil.cpp
|
||||
DirectXMesh/DirectXMeshValidate.cpp
|
||||
DirectXMesh/DirectXMeshVBReader.cpp
|
||||
DirectXMesh/DirectXMeshVBWriter.cpp
|
||||
DirectXMesh/DirectXMeshWeldVertices.cpp
|
||||
)
|
||||
|
||||
target_include_directories( directxmesh PUBLIC DirectXMesh )
|
||||
|
||||
target_compile_options( directxmesh PRIVATE /fp:fast )
|
||||
|
||||
add_executable(meshconvert
|
||||
meshconvert/meshconvert.cpp
|
||||
meshconvert/MeshOBJ.cpp
|
||||
meshconvert/Mesh.h
|
||||
meshconvert/Mesh.cpp
|
||||
meshconvert/SDKMesh.h)
|
||||
target_include_directories(meshconvert PUBLIC MeshConvert Utilities)
|
||||
target_link_libraries(meshconvert directxmesh)
|
||||
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||
target_compile_options( directxmesh PRIVATE ${WarningsLib} )
|
||||
target_compile_options( meshconvert PRIVATE ${WarningsEXE} )
|
||||
if (${CMAKE_SIZEOF_VOID_P} EQUAL "4")
|
||||
target_compile_options( directxmesh PRIVATE /arch:SSE2 )
|
||||
target_compile_options( meshconvert PRIVATE /arch:SSE2 )
|
||||
endif()
|
||||
endif()
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
|
||||
target_compile_options( directxmesh PRIVATE /Wall /permissive- /Zc:__cplusplus )
|
||||
target_compile_options( meshconvert PRIVATE /Wall /permissive- /Zc:__cplusplus )
|
||||
endif()
|
||||
|
||||
# Windows 10 is used here to build the DirectX 12 code paths as well as 11
|
||||
add_compile_definitions(_UNICODE UNICODE _WIN32_WINNT=0x0A00)
|
|
@ -1,52 +0,0 @@
|
|||
# DirectXMesh geometry Library
|
||||
#
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
#
|
||||
# http://go.microsoft.com/fwlink/?LinkID=324981
|
||||
|
||||
cmake_minimum_required (VERSION 3.8)
|
||||
project (DirectXMesh_CMake LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||
|
||||
add_library (directxmesh STATIC
|
||||
DirectXMesh.h
|
||||
DirectXMeshP.h
|
||||
scoped.h
|
||||
DirectXMeshAdjacency.cpp
|
||||
DirectXMeshClean.cpp
|
||||
DirectXMeshGSAdjacency.cpp
|
||||
DirectXMeshNormals.cpp
|
||||
DirectXMeshOptimize.cpp
|
||||
DirectXMeshOptimizeLRU.cpp
|
||||
DirectXMeshOptimizeTVC.cpp
|
||||
DirectXMeshRemap.cpp
|
||||
DirectXMeshTangentFrame.cpp
|
||||
DirectXMeshUtil.cpp
|
||||
DirectXMeshValidate.cpp
|
||||
DirectXMeshVBReader.cpp
|
||||
DirectXMeshVBWriter.cpp
|
||||
DirectXMeshWeldVertices.cpp
|
||||
)
|
||||
|
||||
target_compile_options( directxmesh PRIVATE /fp:fast )
|
||||
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||
target_compile_options( directxmesh PRIVATE -Wall -Wpedantic -Wextra )
|
||||
if (${CMAKE_SIZEOF_VOID_P} EQUAL "4")
|
||||
target_compile_options( directxmesh PRIVATE /arch:SSE2 )
|
||||
endif()
|
||||
endif()
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
|
||||
target_compile_options( directxmesh PRIVATE /Wall /permissive- /Zc:__cplusplus )
|
||||
endif()
|
||||
|
||||
# Windows 10 is used here to build the DirectX 12 code paths as well as 11
|
||||
add_compile_definitions(_UNICODE UNICODE _WIN32_WINNT=0x0A00)
|
|
@ -96,7 +96,7 @@
|
|||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "directxmesh.h"
|
||||
#include "DirectXMesh.h"
|
||||
|
||||
#include "scoped.h"
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#define NOMINMAX
|
||||
#define NODRAWTEXT
|
||||
#define NOGDI
|
||||
#define NOBITMAP
|
||||
#define NOMCX
|
||||
#define NOSERVICE
|
||||
#define NOHELP
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// http://go.microsoft.com/fwlink/?LinkID=324981
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
#include <windows.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -23,9 +23,9 @@
|
|||
#include <d3d11_1.h>
|
||||
#endif
|
||||
|
||||
#include <directxmath.h>
|
||||
#include <DirectXMath.h>
|
||||
|
||||
#include "directxmesh.h"
|
||||
#include "DirectXMesh.h"
|
||||
|
||||
class Mesh
|
||||
{
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#define NOMINMAX
|
||||
#define NODRAWTEXT
|
||||
#define NOGDI
|
||||
#define NOBITMAP
|
||||
#define NOMCX
|
||||
#define NOSERVICE
|
||||
#define NOHELP
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#define NOMINMAX
|
||||
#define NODRAWTEXT
|
||||
#define NOGDI
|
||||
#define NOBITMAP
|
||||
#define NOMCX
|
||||
#define NOSERVICE
|
||||
#define NOHELP
|
||||
|
@ -124,7 +123,9 @@ namespace
|
|||
|
||||
typedef std::unique_ptr<void, find_closer> ScopedFindHandle;
|
||||
|
||||
#ifdef __PREFAST__
|
||||
#pragma prefast(disable : 26018, "Only used with static internal arrays")
|
||||
#endif
|
||||
|
||||
DWORD LookupByName(const wchar_t *pName, const SValue *pArray)
|
||||
{
|
||||
|
@ -140,20 +141,6 @@ namespace
|
|||
}
|
||||
|
||||
|
||||
const wchar_t* LookupByValue(DWORD pValue, const SValue *pArray)
|
||||
{
|
||||
while (pArray->pName)
|
||||
{
|
||||
if (pValue == pArray->dwValue)
|
||||
return pArray->pName;
|
||||
|
||||
pArray++;
|
||||
}
|
||||
|
||||
return L"";
|
||||
}
|
||||
|
||||
|
||||
void SearchForFiles(const wchar_t* path, std::list<SConversion>& files, bool recursive)
|
||||
{
|
||||
// Process files
|
||||
|
@ -280,7 +267,9 @@ extern HRESULT LoadFromOBJ(const wchar_t* szFilename, std::unique_ptr<Mesh>& inM
|
|||
//--------------------------------------------------------------------------------------
|
||||
// Entry-point
|
||||
//--------------------------------------------------------------------------------------
|
||||
#ifdef __PREFAST__
|
||||
#pragma prefast(disable : 28198, "Command-line tool, frees all memory on exit")
|
||||
#endif
|
||||
|
||||
int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
||||
{
|
||||
|
@ -547,8 +536,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
assert(inMesh->GetPositionBuffer() != 0);
|
||||
assert(inMesh->GetIndexBuffer() != 0);
|
||||
assert(inMesh->GetPositionBuffer() != nullptr);
|
||||
assert(inMesh->GetIndexBuffer() != nullptr);
|
||||
|
||||
wprintf(L"\n%zu vertices, %zu faces", nVerts, nFaces);
|
||||
|
||||
|
@ -680,7 +669,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||
// Perform attribute and vertex-cache optimization
|
||||
if (dwOptions & (1 << OPT_OPTIMIZE))
|
||||
{
|
||||
assert(inMesh->GetAdjacencyBuffer() != 0);
|
||||
assert(inMesh->GetAdjacencyBuffer() != nullptr);
|
||||
|
||||
float acmr, atvr;
|
||||
ComputeVertexCacheMissRate(inMesh->GetIndexBuffer(), nFaces, nVerts, OPTFACES_V_DEFAULT, acmr, atvr);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#define NOHELP
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <windows.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
@ -34,8 +34,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <directxmath.h>
|
||||
#include <directxcollision.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <DirectXCollision.h>
|
||||
|
||||
template<class index_t>
|
||||
class WaveFrontReader
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
else if (iPosition < 0)
|
||||
{
|
||||
// Negative values are relative indices
|
||||
vertexIndex = uint32_t(positions.size() + iPosition);
|
||||
vertexIndex = uint32_t(ptrdiff_t(positions.size()) + iPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
else if (iTexCoord < 0)
|
||||
{
|
||||
// Negative values are relative indices
|
||||
coordIndex = uint32_t(texCoords.size() + iTexCoord);
|
||||
coordIndex = uint32_t(ptrdiff_t(texCoords.size()) + iTexCoord);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -221,7 +221,7 @@ public:
|
|||
else if (iNormal < 0)
|
||||
{
|
||||
// Negative values are relative indices
|
||||
normIndex = uint32_t(normals.size() + iNormal);
|
||||
normIndex = uint32_t(ptrdiff_t(normals.size()) + iNormal);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче