ParaToxic Posted September 13, 2012 Share Posted September 13, 2012 Hei ya I would like to make a loader for gamestarts with a video and a loader for meshes / textures. I would like to make a video at the start like in all games and load at the same time the stuff for the game. The problem is that I can't do that with Threads ( loading a mesh in a second thread close the whole app ) And playing the video in a other thread needs the created GL Context..... An other idea was to load the data in a ifstream to some buffers ( in a thread) and "copy that to the memory" ( I saw that LE loads the data from the memory when you load the same asset the second time ) Have somebody a idea ? Quote Link to comment Share on other sites More sharing options...
Daimour Posted September 13, 2012 Share Posted September 13, 2012 - To not use GL Context for video playing... - To make separate applications for game and for video player... Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted September 13, 2012 Author Share Posted September 13, 2012 But I need a Context for video playing, because the Data is loaded into a GLTexture. And how should I separate the App ?? Quote Link to comment Share on other sites More sharing options...
Daimour Posted September 13, 2012 Share Posted September 13, 2012 But I need a Context for video playing, because the Data is loaded into a GLTexture. Not sure if it's a best way for playing video. And how should I separate the App ?? I'm not sure. That was just an idea. You can create a standalone app for player and run it from game app in separate thread with waiting for finishing. And after closing player app your thread will get control and continue execution. So you will know that video is finished. Quote Link to comment Share on other sites More sharing options...
Guest Red Ocktober Posted September 13, 2012 Share Posted September 13, 2012 would something along the lines of an anim-gif be a satisfactory solution... although, that itself may take a while to load... --Mike Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted September 14, 2012 Author Share Posted September 14, 2012 Okey I have it now.I created a manager for videos with sound in a second thread with DirectShow , supporting lots of formats, will upload the new player Now I can load assets and play a video at the same time Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted September 14, 2012 Share Posted September 14, 2012 Nice work ParaToxic, that's about as much as you can do really given that LE2's commands are not thread safe. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Daimour Posted September 14, 2012 Share Posted September 14, 2012 Cool! Quote Link to comment Share on other sites More sharing options...
Canardia Posted September 15, 2012 Share Posted September 15, 2012 Actually only LoadModel is not thread-safe, because it gets the texture size from the GPU, which returns 0 for other threads. 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...
Pixel Perfect Posted September 15, 2012 Share Posted September 15, 2012 Actually only LoadModel is not thread-safe, because it gets the texture size from the GPU, which returns 0 for other threads. From all that I've seen in the past from people that have tried it, most of the commands are not thread safe and can cause crashes if run asynchronously, what makes you believe the others are all 'thread safe'? Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Canardia Posted September 15, 2012 Share Posted September 15, 2012 I made once a multi-threaded demo which did everything else except loading models on a 2nd thread, and it worked fine. 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...
Pixel Perfect Posted September 15, 2012 Share Posted September 15, 2012 Well I have seen examples where mutli-threaded calls to basic Entity functions caused crashes. The general concensus as I understand it has always been that Leadwerks is NOT thread safe! What mechanisms are in place to ensure, for example, that only one thread reads or writes shared data at any time? Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Canardia Posted September 15, 2012 Share Posted September 15, 2012 You can use mutexes to avoid that 2 threads use LE2 commands at the same time. But I prefer to do all heavy calculations on other threads only (like AI, raycasts, etc...), and let the main thread handle all the LE2 commands. Then I just unlock the mutex and inform the main thread that it can read now, so the main thread can read the calculated data and do its LE2 commands on the data. 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...
Pixel Perfect Posted September 15, 2012 Share Posted September 15, 2012 Fair comment, but that's not the same as saying that LE2 commands are thread safe ... they are not! Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Canardia Posted September 15, 2012 Share Posted September 15, 2012 Even if they would be internally threadsafe, they would use mutexes anyway, so there is really not a big difference. 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...
Pixel Perfect Posted September 15, 2012 Share Posted September 15, 2012 Except that when you tell people it is thread safe they assume you don't have to use mutexes. Avoid misinformation please, it's not helpful to people. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
klepto2 Posted September 15, 2012 Share Posted September 15, 2012 As long as you are not using seperate contextes for each thread and use shared memory there is no way making it threadsafe. @metatron: As far as i remember your mt sample was based on loading the meshes seperatly before loading the scene in another thread. And due the instanced nature of le this might have worked. But as soon as you load a new mesh outside the mainthread le/opengl will crash and this has nothing to do with mutexes. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI 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.