Cleanup.
This commit is contained in:
parent
47482f470e
commit
3d7a8e904c
@ -13,10 +13,11 @@
|
||||
* http://web.archive.org/web/20190103162730/http://www.celestiamotherlode.net/catalog/mars.php
|
||||
*/
|
||||
|
||||
#include "vt.h"
|
||||
#include <bx/file.h>
|
||||
#include <bx/sort.h>
|
||||
|
||||
#include "vt.h"
|
||||
|
||||
namespace vt
|
||||
{
|
||||
|
||||
@ -1063,7 +1064,7 @@ bx::AllocatorI* VirtualTexture::getAllocator()
|
||||
TileDataFile::TileDataFile(const bx::FilePath& filename, VirtualTextureInfo* _info, bool _readWrite) : m_info(_info)
|
||||
{
|
||||
const char* access = _readWrite ? "w+b" : "rb";
|
||||
m_file = fopen(filename.get(), access);
|
||||
m_file = fopen(filename.getCPtr(), access);
|
||||
m_size = m_info->GetPageSize() * m_info->GetPageSize() * s_channelCount;
|
||||
}
|
||||
|
||||
@ -1133,39 +1134,41 @@ TileGenerator::~TileGenerator()
|
||||
BX_DELETE(VirtualTexture::getAllocator(), m_tileImage);
|
||||
}
|
||||
|
||||
bool TileGenerator::generate(const bx::FilePath& _filename)
|
||||
bool TileGenerator::generate(const bx::FilePath& _filePath)
|
||||
{
|
||||
const bx::StringView baseName = _filePath.getBaseName();
|
||||
|
||||
// Generate cache filename
|
||||
char tmp[256];
|
||||
bx::snprintf(tmp, sizeof(tmp), "%.*s.vt", _filename.getBaseName().getLength(), _filename.getBaseName().getPtr() );
|
||||
bx::snprintf(tmp, sizeof(tmp), "%.*s.vt", baseName.getLength(), baseName.getPtr() );
|
||||
|
||||
bx::FilePath cacheFilename("temp");
|
||||
cacheFilename.join(tmp);
|
||||
bx::FilePath cacheFilePath("temp");
|
||||
cacheFilePath.join(tmp);
|
||||
|
||||
// Check if tile file already exist
|
||||
{
|
||||
bx::Error err;
|
||||
bx::FileReader fileReader;
|
||||
|
||||
if (bx::open(&fileReader, cacheFilename, &err) )
|
||||
if (bx::open(&fileReader, cacheFilePath, &err) )
|
||||
{
|
||||
bx::close(&fileReader);
|
||||
|
||||
bx::debugPrintf("Tile data file '%s' already exists. Skipping generation.\n", cacheFilename.get() );
|
||||
bx::debugPrintf("Tile data file '%s' already exists. Skipping generation.\n", cacheFilePath.getCPtr() );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Read image
|
||||
{
|
||||
bx::debugPrintf("Reading image '%s'.\n", _filename.get() );
|
||||
bx::debugPrintf("Reading image '%s'.\n", _filePath.getCPtr() );
|
||||
|
||||
bx::Error err;
|
||||
bx::FileReader fileReader;
|
||||
|
||||
if (!bx::open(&fileReader, bx::FilePath(_filename.get() ), &err) )
|
||||
if (!bx::open(&fileReader, _filePath, &err) )
|
||||
{
|
||||
bx::debugPrintf("Image open failed'%s'.\n", _filename.get() );
|
||||
bx::debugPrintf("Image open failed'%s'.\n", _filePath.getCPtr() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1173,7 +1176,7 @@ bool TileGenerator::generate(const bx::FilePath& _filename)
|
||||
|
||||
if (0 == size)
|
||||
{
|
||||
bx::debugPrintf("Image '%s' size is 0.\n", _filename.get() );
|
||||
bx::debugPrintf("Image '%s' size is 0.\n", _filePath.getCPtr() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1184,7 +1187,7 @@ bool TileGenerator::generate(const bx::FilePath& _filename)
|
||||
|
||||
if (!err.isOk() )
|
||||
{
|
||||
bx::debugPrintf("Image read failed'%s'.\n", _filename.get() );
|
||||
bx::debugPrintf("Image read failed'%s'.\n", _filePath.getCPtr() );
|
||||
BX_FREE(VirtualTexture::getAllocator(), rawImage);
|
||||
return false;
|
||||
}
|
||||
@ -1194,7 +1197,7 @@ bool TileGenerator::generate(const bx::FilePath& _filename)
|
||||
|
||||
if (!err.isOk() )
|
||||
{
|
||||
bx::debugPrintf("Image parse failed'%s'.\n", _filename.get() );
|
||||
bx::debugPrintf("Image parse failed'%s'.\n", _filePath.getCPtr() );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1204,7 +1207,7 @@ bool TileGenerator::generate(const bx::FilePath& _filename)
|
||||
m_indexer = BX_NEW(VirtualTexture::getAllocator(), PageIndexer)(m_info);
|
||||
|
||||
// Open tile data file
|
||||
m_tileDataFile = BX_NEW(VirtualTexture::getAllocator(), TileDataFile)(cacheFilename, m_info, true);
|
||||
m_tileDataFile = BX_NEW(VirtualTexture::getAllocator(), TileDataFile)(cacheFilePath, m_info, true);
|
||||
m_page1Image = BX_NEW(VirtualTexture::getAllocator(), SimpleImage)(m_pagesize, m_pagesize, s_channelCount, 0xff);
|
||||
m_page2Image = BX_NEW(VirtualTexture::getAllocator(), SimpleImage)(m_pagesize, m_pagesize, s_channelCount, 0xff);
|
||||
m_tileImage = BX_NEW(VirtualTexture::getAllocator(), SimpleImage)(m_tilesize, m_tilesize, s_channelCount, 0xff);
|
||||
|
@ -14,14 +14,16 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
#include "bimg/decode.h"
|
||||
|
||||
#include <bimg/decode.h>
|
||||
#include <tinystl/allocator.h>
|
||||
#include <tinystl/unordered_set.h>
|
||||
#include <tinystl/vector.h>
|
||||
#include <functional>
|
||||
|
||||
#include "common.h"
|
||||
#include "bgfx_utils.h"
|
||||
|
||||
namespace vt
|
||||
{
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace entry
|
||||
virtual bool open(const bx::FilePath& _filePath, bx::Error* _err) override
|
||||
{
|
||||
String filePath(s_currentDir);
|
||||
filePath.append(_filePath.get() );
|
||||
filePath.append(_filePath);
|
||||
return super::open(filePath.getPtr(), _err);
|
||||
}
|
||||
};
|
||||
@ -59,7 +59,7 @@ namespace entry
|
||||
virtual bool open(const bx::FilePath& _filePath, bool _append, bx::Error* _err) override
|
||||
{
|
||||
String filePath(s_currentDir);
|
||||
filePath.append(_filePath.get() );
|
||||
filePath.append(_filePath);
|
||||
return super::open(filePath.getPtr(), _append, _err);
|
||||
}
|
||||
};
|
||||
@ -752,7 +752,7 @@ restart:
|
||||
case Event::DropFile:
|
||||
{
|
||||
const DropFileEvent* drop = static_cast<const DropFileEvent*>(ev);
|
||||
DBG("%s", drop->m_filePath.get() );
|
||||
DBG("%s", drop->m_filePath.getCPtr() );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -251,7 +251,7 @@ struct FileSelectionDialogType
|
||||
};
|
||||
|
||||
bool openFileSelectionDialog(
|
||||
bx::FilePath& _inOutfilePath
|
||||
bx::FilePath& _inOutFilePath
|
||||
, FileSelectionDialogType::Enum _type
|
||||
, const bx::StringView& _title
|
||||
, const bx::StringView& _filter = "All Files | *"
|
||||
@ -266,7 +266,7 @@ bool openFileSelectionDialog(
|
||||
, "--file-selection%s --title \"%.*s\" --filename \"%s\""
|
||||
, FileSelectionDialogType::Save == _type ? " --save" : ""
|
||||
, _title.getLength(), _title.getPtr()
|
||||
, _inOutfilePath.get()
|
||||
, _inOutFilePath.get()
|
||||
);
|
||||
|
||||
for (bx::LineReader lr(_filter); !lr.isDone();)
|
||||
@ -291,11 +291,13 @@ bool openFileSelectionDialog(
|
||||
|
||||
if (0 == pr.getExitCode() )
|
||||
{
|
||||
_inOutfilePath.set(bx::strRTrim(bx::StringView(buffer, total), "\n\r") );
|
||||
_inOutFilePath.set(bx::strRTrim(bx::StringView(buffer, total), "\n\r") );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
BX_UNUSED(_inOutFilePath, _type, _title, _filter);
|
||||
#endif // BX_PLATFORM_LINUX || BX_PLATFORM_OSX
|
||||
|
||||
return false;
|
||||
@ -759,7 +761,7 @@ struct View
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG("File path `%s` not found.", _filePath.get() );
|
||||
DBG("File path `%s` not found.", _filePath.getCPtr() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1225,7 +1227,7 @@ void associate()
|
||||
if (err.isOk() )
|
||||
{
|
||||
std::string cmd;
|
||||
bx::stringPrintf(cmd, "/s %s", filePath.get() );
|
||||
bx::stringPrintf(cmd, "/s %s", filePath.getCPtr() );
|
||||
|
||||
bx::ProcessReader reader;
|
||||
if (bx::open(&reader, "regedit.exe", cmd.c_str(), &err) )
|
||||
@ -1864,7 +1866,7 @@ int _main_(int _argc, char** _argv)
|
||||
if (view.m_files)
|
||||
{
|
||||
char temp[bx::kMaxFilePath];
|
||||
bx::snprintf(temp, BX_COUNTOF(temp), "%s##File", view.m_path.get() );
|
||||
bx::snprintf(temp, BX_COUNTOF(temp), "%s##File", view.m_path.getCPtr() );
|
||||
|
||||
ImGui::SetNextWindowSize(
|
||||
ImVec2(400.0f, 400.0f)
|
||||
@ -2023,7 +2025,7 @@ int _main_(int _argc, char** _argv)
|
||||
fp.join(view.m_fileList[view.m_fileIndex].c_str() );
|
||||
|
||||
bimg::Orientation::Enum orientation;
|
||||
texture = loadTexture(fp.get()
|
||||
texture = loadTexture(fp.getCPtr()
|
||||
, 0
|
||||
| BGFX_SAMPLER_U_CLAMP
|
||||
| BGFX_SAMPLER_V_CLAMP
|
||||
@ -2072,7 +2074,7 @@ int _main_(int _argc, char** _argv)
|
||||
}
|
||||
|
||||
bx::stringPrintf(title, "%s (%d x %d%s, mips: %d, layers %d, %s)"
|
||||
, fp.get()
|
||||
, fp.getCPtr()
|
||||
, view.m_textureInfo.width
|
||||
, view.m_textureInfo.height
|
||||
, name
|
||||
|
Loading…
Reference in New Issue
Block a user