From 3d7a8e904c9b07d66b00031835d78d472e54c585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 19 Feb 2019 17:53:03 -0800 Subject: [PATCH] Cleanup. --- examples/40-svt/vt.cpp | 33 ++++++++++++++++++--------------- examples/40-svt/vt.h | 8 +++++--- examples/common/entry/entry.cpp | 6 +++--- tools/texturev/texturev.cpp | 18 ++++++++++-------- 4 files changed, 36 insertions(+), 29 deletions(-) diff --git a/examples/40-svt/vt.cpp b/examples/40-svt/vt.cpp index 95f9f41a0..9c1802180 100644 --- a/examples/40-svt/vt.cpp +++ b/examples/40-svt/vt.cpp @@ -13,10 +13,11 @@ * http://web.archive.org/web/20190103162730/http://www.celestiamotherlode.net/catalog/mars.php */ -#include "vt.h" #include #include +#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); diff --git a/examples/40-svt/vt.h b/examples/40-svt/vt.h index bf7d4ab3e..461f2c2d5 100644 --- a/examples/40-svt/vt.h +++ b/examples/40-svt/vt.h @@ -14,14 +14,16 @@ */ #pragma once -#include "common.h" -#include "bgfx_utils.h" -#include "bimg/decode.h" + +#include #include #include #include #include +#include "common.h" +#include "bgfx_utils.h" + namespace vt { diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index a7fdeacae..6dd9a19a2 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -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(ev); - DBG("%s", drop->m_filePath.get() ); + DBG("%s", drop->m_filePath.getCPtr() ); } break; diff --git a/tools/texturev/texturev.cpp b/tools/texturev/texturev.cpp index 1265c56f6..649218199 100644 --- a/tools/texturev/texturev.cpp +++ b/tools/texturev/texturev.cpp @@ -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