Skip to main content
gamedev.net
🔒 Locked

My Multi-Threaded Hell

Started by LowCalorieSoftDrink 3 replies 750+ views
Original Post
LowCalorieSoftDrink
LowCalorieSoftDrink
Ok, im thinking to myself, *wouldnt it be nice if i could implement a second thread within which to stuff all my rendering code* So i crack open msdn and a couple of tutorials and within an hour i have a rudimentry knowledge of threads and a base class from which to derive my rendering thread. However, it would appear that i have overlooked something in my haste as now when i run my program in a window i get a grey background (my clear colour is set to black) and i cant even render a triangle... even better when i start in fullscreen the window flickers really fast, which creates a cool looking transparency effect, but not really what i desired. So, my first thought on what was wrong was a possible collision as windows tried to access the device context for the window in one of the default message handlers, so as a quick test i paused my render thread before calling DefWndProc, and resumed it afterwards, however to my dismay this didnt solve the problem, and now im stumped. I realise i havent googled the problem, or whatever, but i wouldnt know what to google for, so if you can provide any help, or even a pointer in the right direction it would be much appreciated. Thanks
JohnBolton
JohnBolton
Just a guess: did you include "D3DCREATE_MULTITHREADED" in the CreateDevice call?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
JohnBolton
JohnBolton
Then perhaps this applies:
quote:
A thread that makes OpenGL calls must have a current rendering context. If an application makes OpenGL calls from a thread that lacks a current rendering context, nothing happens; the call has no effect. An application commonly creates a rendering context, sets it as a thread''s current rendering context, and then calls OpenGL functions. When it finishes calling OpenGL functions, the application uncouples the rendering context from the thread, and then deletes the rendering context. A window can have multiple rendering contexts drawing to it at one time, but a thread can have only one current, active rendering context.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
LowCalorieSoftDrink
LowCalorieSoftDrink
Perfect, that was my problem, i was creating the rendering context in my initial thread, then trying to render with it in my render thread.

Thanks a lot

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.