gamecreator Posted May 1, 2018 Share Posted May 1, 2018 I have the following code: #include "Leadwerks.h" using namespace Leadwerks; int main(int argc, const char *argv[]) { Leadwerks::Window* window = Leadwerks::Window::Create(); Context* context = Context::Create(window); Font* font = context->GetFont(); while(true) { if(window->Closed() || window->KeyHit(Key::Escape)) break; context->SetColor(0.0, 0.0, 1.0); context->Clear(); // Print argument to console if(argc>1) printf("%s\n",argv[1]); context->SetBlendMode(Blend::Alpha); context->SetColor(1.0, 1.0, 1.0); context->DrawText("Hello", 10, 10); context->SetBlendMode(Blend::Solid); context->Sync(); } return 0; } If you run the EXE by itself (or from Visual Studio) or if you drag a file from the same folder as the EXE, it runs as expected. However, if you drag a file from any other folder, the program fails to load drawtext.shader because it tries to find it in the wrong place. For example, dragging a file from C:\ says Error: Failed to load shader "C://Shaders/Drawing/drawtext.shader" Dragging a file from D:\Test folder says Error: Failed to load shader "D:/Test/Shaders/Drawing/drawtext.shader" etc. even though the project is in the C:\Users...Documents\Projects\ProjectName folder Seems like dragging a file onto the EXE shouldn't mess up anything loading. I could be doing something wrong but this seems like a bug. I'm on release version. Link to comment Share on other sites More sharing options...
gamecreator Posted May 1, 2018 Author Share Posted May 1, 2018 argv[0] doesn't seem to change and shows the correct working folder+filename. I also just dragged a file onto another project EXE I had and it couldn't load a font (the first thing I tried to load in the project) where it works fine otherwise. Link to comment Share on other sites More sharing options...
Josh Posted May 2, 2018 Share Posted May 2, 2018 Quote if you drag a file from the same folder as the EXE ??? This is a strange thing to do for a game. I think this is the correct behavior for Windows: https://stackoverflow.com/questions/882850/dragging-files-to-an-exe-sets-different-working-directory 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...
gamecreator Posted May 2, 2018 Author Share Posted May 2, 2018 Admittedly I'm doing an odder side project more involving Steam than Leadwerks. I'll see if resetting the working folder will help. Edit: here's the code to help Leadwerks find the correct paths again: char buffer[MAX_PATH]; // Get full path and filename GetModuleFileName(NULL, buffer, MAX_PATH); std::string ourpath = buffer; // Remove filename from the end of the path ourpath = ourpath.substr(0, ourpath.find_last_of( "\\/" )); SetCurrentDirectory(ourpath.c_str()); Link to comment Share on other sites More sharing options...
Josh Posted February 26, 2019 Share Posted February 26, 2019 I'm going to say this is not a bug. Please let me know if I am wrong. 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