Rick Posted January 13, 2010 Share Posted January 13, 2010 Has anyone ever tried calling Graphics() from a dll? It seems to crash my program when I have a dll that has a function that calls Graphics() and I load that dll from a simple lua script: assert(package.loadlib("C:\\Program Files\\Leadwerks Engine SDK\\Models\\Entities\\Pi\\Pi-Cube\\Rick.dll", "luaopen_test"))() Rick.Init() That's the entire lua script. I'm running it stand alone just like that. Init() ends up running: void CreateGraphics() { MessageBoxA(0, "Before Graphics()", "dll", 0); int ret = Graphics(800, 600); if(ret == 0) MessageBoxA(0, "Failed to load graphics", "dll", 0); MessageBoxA(0, "After Graphics()", "dll", 0); } static int Init(lua_State* L) { Initialize(); CreateGraphics(); return 0; } Yet SciTE bombs and I never get a message box after "Before Graphics()". SciTE's debug window says "engine.dll failed to load." I'm not sure why that would be though. There is no other details. The engine.dll is in the same directory as my custom dll. So not sure why it would fail to load it. I mean dll's can use other dlls right? Quote Link to comment Share on other sites More sharing options...
Rick Posted January 13, 2010 Author Share Posted January 13, 2010 hmm, interesting. I needed to have the engine.dll where my lua script was saved to, NOT where Rick.dll was saved to. Quote Link to comment Share on other sites More sharing options...
TylerH Posted January 13, 2010 Share Posted January 13, 2010 All of your DLLs, content, etc. usually needs to be in the same directory or be relatively loaded from the invoker (in this case the Lua script). Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Rick Posted January 13, 2010 Author Share Posted January 13, 2010 Well I just figured that since my custom dll is the one that is loading the engine.dll that the engine.dll would need to be in the directory as my custom dll and not the main program that called my custom dll. That's not that far fetched of thinking. Since my custom dll is the one that is using engine.dll and not the lua interpreter. Quote Link to comment Share on other sites More sharing options...
Canardia Posted January 13, 2010 Share Posted January 13, 2010 You can also have dlls in the system path. I have for example "c:\program files\leadwerks engine sdk" in the path, and never need to copy newton.dll, jointlib.dll and engine.dll to those 3 billion folders of my test programs Saves a lot of harddisk space and manual updating each time the engine is updated. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted January 13, 2010 Author Share Posted January 13, 2010 That's a good idea. I'll give that a try and see what happens. Quote 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.