56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
#include "utils.h"
|
|
|
|
void printCurrentDirectory() {
|
|
DWORD nBufferLength = 250;
|
|
LPWSTR lpBuffer = new WCHAR[nBufferLength];
|
|
GetCurrentDirectoryW(nBufferLength, lpBuffer);
|
|
//OutputDebugStringW(lpBuffer);
|
|
MessageBoxW(nullptr, lpBuffer, L"Current working directory", MB_OK);
|
|
}
|
|
|
|
EntryArgs gEntryArgs;
|
|
|
|
void EntryArgs::fill(HINSTANCE hThisInstance, LPSTR lpszArgs, int nWinMode) {
|
|
this->hThisInstance = hThisInstance;
|
|
this->lpszArgs = lpszArgs;
|
|
this->nWinMode = nWinMode;
|
|
}
|
|
|
|
ComPtr<ID3DBlob> loadBlob(const std::string& fileName)
|
|
{
|
|
//printCurrentDirectory();
|
|
|
|
std::ifstream blobFile(fileName, std::ios::binary);
|
|
|
|
if (!blobFile.is_open()) // ha nem sikerült megnyitni a fájlt
|
|
{
|
|
ERRBOX("Could not open blob file '" + fileName + "'!");
|
|
return nullptr;
|
|
}
|
|
|
|
blobFile.seekg(0, std::ios::end);
|
|
size_t fileSize = blobFile.tellg();
|
|
|
|
ComPtr<ID3DBlob> pBlob { nullptr }; // blob létrehozása
|
|
if(D3DCreateBlob(fileSize, pBlob.GetAddressOf()) != S_OK )
|
|
{
|
|
ERRBOX("Could not create D3DBlob for loading '" + fileName + "'!");
|
|
return nullptr;
|
|
}
|
|
|
|
// fájl beolvasása a blob-ba
|
|
blobFile.seekg(0, std::ios::beg);
|
|
if (blobFile.read(reinterpret_cast<char*>(pBlob->GetBufferPointer()), fileSize))
|
|
{
|
|
return pBlob;
|
|
}
|
|
|
|
ERRBOX("Failed to load '" + fileName + "' into buffer!");
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
size_t calc256AlignedSize(size_t origSize) {
|
|
return (origSize + 255) & ~255;
|
|
}
|