Jump to content
  • Advertisement
Sign in to follow this  
MarkS

Win32 - Creating a window in a thread?

This topic is 2592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to use multiple windows in an OpenGL application. I've done quite a bit of searching both on this site and with Google, and the one method that I keep coming up on is creating the windows in their own threads.

I've never messed around with multithreading. I am aware of CreateThread, but I can find no examples of how to open a window in a thread. I just don't have enough of a concept of what I'm trying to do to fully grasp it. Can someone enlighten me or direct me to some source code? I have found lots of examples for CreateThread, but none pertaining to this.

Share this post


Link to post
Share on other sites
Advertisement
You can create multiple windows in the same thread in pretty much every GUI framework/library I've ever used. If you're not sure that you need threads, don't bother.

Share this post


Link to post
Share on other sites
I'm guessing that the only benefit to using multiple threads would be to not create lots of stress on any one core, but with today's technology, you don't need to worry unless there's a ton of windows.

Share this post


Link to post
Share on other sites
Actually, doing multiple windows spanning multiple threads is substantially harder than just doing them all from one thread.

Believe me, if you're new to multithreading, you don't want to go there. I've been writing multithreaded code for a long time, and running windows on multiple threads still scares me.

Share this post


Link to post
Share on other sites
[edit]

Never mind...

It was a stupid error on my part that was keeping this from working.

I declared the function to set up the rendering context as:

bool CreateRenderingContext(HWND gl_wind,HDC gl_DC,HGLRC gl_hrc),

instead of:

bool CreateRenderingContext(HWND gl_wind,HDC gl_DC,HGLRC *gl_hrc).

That little asterisk made all of the difference and I don't need multiple threads.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!