Fix for Windows platform.
This commit is contained in:
@@ -21,7 +21,8 @@ solution "objview"
|
|||||||
includedirs { "./" }
|
includedirs { "./" }
|
||||||
includedirs { "../../" }
|
includedirs { "../../" }
|
||||||
|
|
||||||
buildoptions { "-std=c++11" }
|
flags { "c++11" }
|
||||||
|
--buildoptions { "-std=c++11" }
|
||||||
|
|
||||||
if _OPTIONS['with-zlib'] then
|
if _OPTIONS['with-zlib'] then
|
||||||
defines { 'ENABLE_ZLIB' }
|
defines { 'ENABLE_ZLIB' }
|
||||||
@@ -48,14 +49,15 @@ solution "objview"
|
|||||||
|
|
||||||
configuration { "windows" }
|
configuration { "windows" }
|
||||||
-- Path to GLFW3
|
-- Path to GLFW3
|
||||||
includedirs { '../../../../local/glfw-3.1.2.bin.WIN64/include' }
|
includedirs { '../../../local/glfw-3.2.bin.WIN64/include' }
|
||||||
libdirs { '../../../../local/glfw-3.1.2.bin.WIN64/lib-vc2013' }
|
libdirs { '../../../local/glfw-3.2.bin.WIN64/lib-vc2015' }
|
||||||
-- Path to GLEW
|
-- Path to GLEW
|
||||||
includedirs { '../../../../local/glew-1.13.0/include' }
|
includedirs { '../../../local/glew-1.13.0/include' }
|
||||||
libdirs { '../../../../local/glew-1.13.0/lib/Release/x64' }
|
libdirs { '../../../local/glew-1.13.0/lib/Release/x64' }
|
||||||
|
|
||||||
links { "glfw3", "glew32", "gdi32", "winmm", "user32", "glu32","opengl32", "kernel32" }
|
links { "glfw3", "glew32", "gdi32", "winmm", "user32", "glu32","opengl32", "kernel32" }
|
||||||
defines { "_CRT_SECURE_NO_WARNINGS" }
|
defines { "_CRT_SECURE_NO_WARNINGS" }
|
||||||
|
defines { "NOMINMAX" }
|
||||||
|
|
||||||
configuration { "macosx" }
|
configuration { "macosx" }
|
||||||
includedirs { "/usr/local/include" }
|
includedirs { "/usr/local/include" }
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||||||
#ifndef TINOBJ_LOADER_OPT_H_
|
#ifndef TINOBJ_LOADER_OPT_H_
|
||||||
#define TINOBJ_LOADER_OPT_H_
|
#define TINOBJ_LOADER_OPT_H_
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN32
|
||||||
#define atoll(S) _atoi64(S)
|
#define atoll(S) _atoi64(S)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
@@ -1263,7 +1263,7 @@ bool parseObj(attrib_t *attrib, std::vector<shape_t> *shapes,
|
|||||||
? std::thread::hardware_concurrency()
|
? std::thread::hardware_concurrency()
|
||||||
: option.req_num_threads;
|
: option.req_num_threads;
|
||||||
num_threads =
|
num_threads =
|
||||||
std::max(1, std::min(static_cast<int>(num_threads), kMaxThreads));
|
(std::max)(1, (std::min)(static_cast<int>(num_threads), kMaxThreads));
|
||||||
|
|
||||||
if (option.verbose) {
|
if (option.verbose) {
|
||||||
std::cout << "# of threads = " << num_threads << std::endl;
|
std::cout << "# of threads = " << num_threads << std::endl;
|
||||||
@@ -1295,7 +1295,7 @@ bool parseObj(attrib_t *attrib, std::vector<shape_t> *shapes,
|
|||||||
for (size_t t = 0; t < static_cast<size_t>(num_threads); t++) {
|
for (size_t t = 0; t < static_cast<size_t>(num_threads); t++) {
|
||||||
workers->push_back(std::thread([&, t]() {
|
workers->push_back(std::thread([&, t]() {
|
||||||
auto start_idx = (t + 0) * chunk_size;
|
auto start_idx = (t + 0) * chunk_size;
|
||||||
auto end_idx = std::min((t + 1) * chunk_size, len - 1);
|
auto end_idx = (std::min)((t + 1) * chunk_size, len - 1);
|
||||||
if (t == static_cast<size_t>((num_threads - 1))) {
|
if (t == static_cast<size_t>((num_threads - 1))) {
|
||||||
end_idx = len - 1;
|
end_idx = len - 1;
|
||||||
}
|
}
|
||||||
@@ -1325,7 +1325,7 @@ bool parseObj(attrib_t *attrib, std::vector<shape_t> *shapes,
|
|||||||
|
|
||||||
// Find extra line which spand across chunk boundary.
|
// Find extra line which spand across chunk boundary.
|
||||||
if ((t < num_threads) && (buf[end_idx - 1] != '\n')) {
|
if ((t < num_threads) && (buf[end_idx - 1] != '\n')) {
|
||||||
auto extra_span_idx = std::min(end_idx - 1 + chunk_size, len - 1);
|
auto extra_span_idx = (std::min)(end_idx - 1 + chunk_size, len - 1);
|
||||||
for (size_t i = end_idx; i < extra_span_idx; i++) {
|
for (size_t i = end_idx; i < extra_span_idx; i++) {
|
||||||
if (is_line_ending(buf, i, extra_span_idx)) {
|
if (is_line_ending(buf, i, extra_span_idx)) {
|
||||||
LineInfo info;
|
LineInfo info;
|
||||||
|
|||||||
@@ -90,16 +90,24 @@ void CalcNormal(float N[3], float v0[3], float v1[3], float v2[3]) {
|
|||||||
const char *mmap_file(size_t *len, const char* filename)
|
const char *mmap_file(size_t *len, const char* filename)
|
||||||
{
|
{
|
||||||
(*len) = 0;
|
(*len) = 0;
|
||||||
#ifdef _WIN64
|
#ifdef _WIN32
|
||||||
HANDLE file = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
HANDLE file = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
assert(file != INVALID_HANDLE_VALUE);
|
assert(file != INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
HANDLE fileMapping = CreateFileMapping(file, NULL, PAGE_READONLY, 0, 0, NULL);
|
HANDLE fileMapping = CreateFileMapping(file, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||||
assert(fileMapping != INVALID_HANDLE_VALUE);
|
assert(fileMapping != INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
|
LPVOID fileMapView = MapViewOfFile(fileMapping, FILE_MAP_READ, 0, 0, 0);
|
||||||
|
auto fileMapViewChar = (const char*)fileMapView;
|
||||||
|
assert(fileMapView != NULL);
|
||||||
|
|
||||||
|
LARGE_INTEGER fileSize;
|
||||||
|
fileSize.QuadPart = 0;
|
||||||
|
GetFileSizeEx(file, &fileSize);
|
||||||
|
|
||||||
|
(*len) = static_cast<size_t>(fileSize.QuadPart);
|
||||||
|
return fileMapViewChar;
|
||||||
|
|
||||||
LPVOID fileMapView = MapViewOfFile(fileMapping, FILE_MAP_READ, 0, 0, 0);
|
|
||||||
auto fileMapViewChar = (const char*)fileMapView;
|
|
||||||
assert(fileMapView != NULL);
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
FILE* f = fopen(filename, "r" );
|
FILE* f = fopen(filename, "r" );
|
||||||
@@ -324,6 +332,10 @@ bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int n
|
|||||||
option.verbose = verbose;
|
option.verbose = verbose;
|
||||||
bool ret = parseObj(&attrib, &shapes, &materials, data, data_len, option);
|
bool ret = parseObj(&attrib, &shapes, &materials, data, data_len, option);
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
std::cerr << "Failed to parse .obj" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
bmin[0] = bmin[1] = bmin[2] = std::numeric_limits<float>::max();
|
bmin[0] = bmin[1] = bmin[2] = std::numeric_limits<float>::max();
|
||||||
bmax[0] = bmax[1] = bmax[2] = -std::numeric_limits<float>::max();
|
bmax[0] = bmax[1] = bmax[2] = -std::numeric_limits<float>::max();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user