   Implementing separate render thread
  HiThis is something I've been pondering for a little while and I was just wondering how people actually go about implementing a separate rendering thread - its seemingly recommended often but little clue is given as to how to go about it.From various forum threads I've figured that the API's (DX/GL) aren't really threadsafe (yes I know DX can be flagged but at a performance cost). Yet in another thread on GL multithreading Yann L says..."This is a common misconception. OpenGL is perfectly threadsafe, as long as one adheres to a couple of simple rules."... but doesn't elaborate as to what those rules are.So how is it done? One bit thats conceptually giving me grief is how to load resources - do you have the resources loaded into memory in other threads (texture/vertex data, shaders etc) then signal the render thread to actually create the device objects or are there better ways?Cheersdaz   
  The couple of simple rules would seem to be only ever access anything relating to your OpenGL context in the same thread. I.e. you create it in one thread and that will forever more be the thread that you access it from.Say for example, you create your OpenGL context in the main thread (i.e. the one that has your main function in it, assuming its a console app) but you have another thread that loads resources asyncronously like textures and models. This "loader" thread can go away and load up all of the textures and model in it's own time as tga or 3DS files whatever and either once it loaded them all, or periodically during the loading, the main thread retrieves the currently loaded assets (texture, model, etc) and then the "main" thread does the actual job of turning models into VBOs and tga files into texture handles.Thus you've only ever touched your OpenGL context from a single thread (the "main" one) but you've still done work relevent too it in another.It doesn't really matter as far as I know if you're using the multi-threaded CLib with, for example, Visual Studio or not if you're not actually going ahead and making other threads as far as OpenGL is concerned. Even if you are it's only a potential problem if you're accessing OpenGL from those worker threads.Hope that helps.Andy   ;  "Thread safe" is really an abused term that doesn't tell you what you can and can't do. even if it may be "safe" to call into the API from two different thread (meaning it doesn't crash), because they are state machines if you don't synchronize (or completely serialize your calls) your result may look a bit weird. Also some API (Direct3D) have other restrictions (for example, createWindow and CreateDevice/Reset/TestForCooperativeLevels have to be from the same THREAD ID). Anyway, if you're interested in decoupling your render thread from your main thread in Direct3D, I had compiled a step by step process on my website :How do I run a multithreaded device in Direct3D ?It doesn't cover all things related to multithreading but should get you started.LeGreg   ;  Ah right... food for thought there.Thanks for the advice!daz   ;  you can find some very good info about multithreading in this thread.   