   Multithreading and OpenGL problem
  hi everybodyi implemented multithreading in my opengl application. i have a therad for all the rendering job. i have to create the opengl context in this thread (with SDL) otherwise it doesen't work. now i want to load textures in background in a other therad. but this doesen't work, glGenTextures fails. i have to call the texture loading function in the reander thread. but i want to avoid this. how can i call opengl commands (here glGenTextures) in other threads so that they work.thanks   
  The call fails because there's no OGL context in the other thread. I've never done OGL with multithreading so my advice is limited, but I think you'll have to create another context in the loading thread and sync between them.   ;  Easiest is to keep all the loading in a separate thread, except for the final step of actually calling GL to upload the texture data. All the heavy lifting will be independant of GL (loading from disk, decompression, image conversion) then you do the last tiny bit of work in your rendering thread. No need for awkward context sharing. :)   ;  thxi already implemented this solution and it works fine. the data is loaded in the loader thread an then the glGenTexture is called in the ogl thred. for loading one tex this is no problem. but what, when i have to do a lot of glGenTexture and texture generationg calls? i think this will slow down the fps for a few seconds. well, this wouldn't bother anyone, but it would be nice to do a smooth background loading without fps lacks.   ;  You can look into platform specific extensions (like wglShareLists).In general, on PC platforms, multithreading with the 3D API doesn't win much. Where you will win big is dividing your scene graph and other processing using MP.   ;Quote:Original post by LPVOID_CHi think this will slow down the fps for a few seconds. well, this wouldn't bother anyone, but it would be nice to do a smooth background loading without fps lacks.Think or know?If its a problem you can limit the number of actual gl texture creates done per frame and defer any extra to the next, which just means your textures arrive a tad later but keeps the smoothness. However you aren't gonna need it.   ;  i'll keep the texture loading in the rendering thread and only call a limited amout of gl loading functions per frame.thanks for the suggestions   