Archived

This topic is now archived and is closed to further replies.

SpazBoy the Mitey

Maybe it's just me and I'm really really crap

Recommended Posts

I''m working on a crappy crap thing and I''d really liek to have the game run in a new thread so it can be made without ten million state machines pissing me off. But wehnever I try to do anything with OpenGL in the created thread, nothing displays Here''s roughly how my thing works... WINMAIN 1. MAEK TEH WINDOW 2. START OPENGL 3. RUN TEH THREAD 4. GO INTO TEH MESSAGE LOOP END WINMAIN THREAD FUNCTION 1. DRAW STUFF 2. SWAP TEH BUFFERS END THREAD FUNCTION When I put the stuff from the thread into the winmain function it all works fine! WHY OH WHY OH WHY???

Share this post


Link to post
Share on other sites
LizardAl    122
you should be creating the window in the same thread as you draw it in. what i mean is, in your thread callback function, first create and show the window, and then run your message loop. don''t create the window in WinMain and then run the message loop in a different thread, because your app won''t be able to see the messages.

scott

Share this post


Link to post
Share on other sites
The Message loop IS in the thread the window is created, it is
receiving messages fine. Is there any way I can draw to the window from outside the thread it is created in?

AHA! I was playing with the code while i wrote this and
I fixed my problem:

this is how it goes now


WINMAIN
1.CREATE THE WINDOW
2.CREATE THE GAME THREAD
3.DO THE MESSAGE LOOP (IN *THIS* THREAD)
END

GAME THREAD
1.START OPENGL
2.DRAW STUFF
3.SWAP THE BUFFERS
END

My guess is that I needed to get the rendering context in the
thread that OpenGL runs in. it''s just a guess though.

All I know is that it werks and I can write my programs in
glorious linear fashion now

Share this post


Link to post
Share on other sites
Gorg    248
You have to make the context current in the drawing thread and NOT make it current in the main thread.

Share this post


Link to post
Share on other sites