Sign in to follow this  
catlinz

OpenGL Choosepixelformat hanging thread

Recommended Posts

I've attached the (small) Visual Studio 2010 project with all the source inside it.
[attachment=4299:CaT.zip]

I'm trying to create a simple window (in Windows) with openGL capabilities. I've done it before, but for some reason this time, no matter what I try I can't get it to work. And by work I mean actually quit the program when the window is closed.


From what I have been able to figure out, the Windows function ChoosePixelFormat (is in the file window.cpp in the zip) creates a new thread when it is called, and this thread refuses to exit once the main thread finishes. I have no idea how to fix it, spent hours on it and have gotten nowhere. Hoping that someone here can help!!

Share this post


Link to post
Share on other sites
I've never heard of that behaviour of ChoosePixelFormat, and have never encountered anything like this when using it. I [i]have[/i] encountered the same symptom as you, but it's always been attributable to my own screw-up, so that's where I'd look first.

There are a number of things wrong with your code. Using both main and WinMain and not returning 0 from WM_DESTROY are two I've found from a brief look through it (I'd also advise changing your "running = false" line to a simple "break"). I'd advise you to fix these first and get it working the way a well-behaved Win32 app should work before even looking at the OpenGL side of things.

Share this post


Link to post
Share on other sites
Hmmm, seems to work when I just put the entry point as WinMain and skip over all the main stuff, which is odd cause I've managed to do that before. I had had it that way to try and make it so it would be more portable in the end. Thanks muchly for your help!!

Share this post


Link to post
Share on other sites
How about:[code]#ifdef _WIN32
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
#else
int main (int argc, char *argv[])
#endif[/code]
In all honesty, your window creation and video startup code is going to be completely differrent for different platforms anyway, so you may as well have different entry points too.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this