klepto2 Posted October 26, 2023 Share Posted October 26, 2023 It would be nice to have the out of the box ability to include files into the main engine and load them from there. Also it would be nice to have a LoadPlugins method with the ability to load from a stream. I know this is not possible with the default windows options, but maybe this lib will help for this: https://github.com/fancycode/MemoryModule Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted October 26, 2023 Share Posted October 26, 2023 The thought has occurred to me, but what is the purpose of loading plugins from memory? Here is something I wrote a while back that might be useful: #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto stream = ReadFile("Source/IncBinFiles.cpp"); std::vector<String> sarr; bool pause = false; while (!stream->EOF()) { auto s = stream->ReadLine(); if (s.Trim() == "//begin incbin") pause = true; if (!pause) sarr.push_back(s); if (s.Trim() == "//end incbin") { sarr.push_back("//begin incbin"); auto j3 = LoadJSON("Source/IncBin.json"); if (j3["IncBinFiles"].is_array()) { for (int n = 0; n < j3["IncBinFiles"].size(); ++n) { auto bin = ReadFile(std::string(j3["IncBinFiles"][n])); if (bin == NULL) { continue; } sarr.push_back(" if (rpath == RealPath(\""+std::string(j3["IncBinFiles"][n])+"\"))"); sarr.push_back(" {"); uint64_t sz = Ceil(float(bin->GetSize()) / 8.0f) * 8; String s = " static const std::array<uint64_t, " + String(sz/8) + "> data = {"; s.reserve(bin->GetSize() * 4 + s.size()); auto buf = CreateBuffer(sz); bin->Read(buf->Data(), bin->GetSize()); uint64_t v; for (uint64_t n = 0; n < buf->GetSize() / 8; ++n) { memcpy(&v, buf->Data() + (n*8), 8); if (n > 0) s += ","; //s += "UINT64_C(" + String(v) + ")"; s += Hex(v) + "ULL"; } //while (!bin->EOF()) //{ // s += "," + String(int(bin->ReadByte())); //} s += " };"; sarr.push_back(s); sarr.push_back(" auto buffer = CreateBuffer(" +String(bin->GetSize())+ "); "); sarr.push_back(" buffer->Poke(0,(const char*)data.data(),"+String(bin->GetSize())+");"); sarr.push_back(" return CreateBufferStream(buffer);"); sarr.push_back(" }"); } } sarr.push_back("//end incbin"); pause = false; } } stream->Close(); stream = WriteFile("Source/IncBinFiles.cpp"); for (auto s : sarr) { stream->WriteLine(s); } stream->Close(); return 0; } Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted October 26, 2023 Share Posted October 26, 2023 Have you tried this approach? It's probably more advanced than what I am doing above: https://github.com/graphitemaster/incbin Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted October 27, 2023 Author Share Posted October 27, 2023 yeah, this https://github.com/graphitemaster/incbin is the same i want use now. 19 hours ago, Josh said: The thought has occurred to me, but what is the purpose of loading plugins from memory? The idea is to supply a basic set of plugins (or directly needed) directly in the executable itself. The idea is to have the ability to include everything in the executable and provide single file tools. This would make distribution easier. Lets say you have a tools folder with a lot of tools. every folder needs the plugins, but have different search pathes for the plugins (eg:plugins or plg) each tool might be dependend on a specific version of a plugin and is not updated to use the plugins which are there. the executable will be bigger, but it may be worth it. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted October 27, 2023 Share Posted October 27, 2023 Ah, okay, so this is to pack files into a single EXE? That makes some sense... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.