Original Post
So I have a C#/Tao app. I'm using WGL_ARB_pixel_format to create the rendering context, and when I do that, apparently another thread on this process gets started and it seems to be running an empty loop. When I exit the app, the process stays running at 100% processor usage. I can't for the life of me figure it out. When I use a GDI pixel format, everything works fine. I can only assume its an error with my code. Check it out:
private int GetBestPixelFormat( )
{
//Create dummmy context...
Panel dummywindow = new Panel( );
IntPtr dummyhDC = User.GetDC( dummywindow.Handle );
int pf = Gdi.ChoosePixelFormat( dummyhDC, ref default_pfd );
Gdi.SetPixelFormat( dummyhDC, pf, ref default_pfd );
IntPtr dummyhRC = Wgl.wglCreateContext( dummyhDC );
Wgl.wglMakeCurrent( dummyhDC, dummyhRC );
//Find the best pixel format...
Wgl.ReloadFunctions( );
if( Wgl.IsExtensionSupported( "WGL_ARB_pixel_format" ) )
{
//Stuff we want to support.
int[] attributes = new int[]
{
Wgl.WGL_SUPPORT_OPENGL_ARB, 1,
Wgl.WGL_ACCELERATION_ARB, Wgl.WGL_FULL_ACCELERATION_ARB,
Wgl.WGL_DRAW_TO_WINDOW_ARB, 1,
Wgl.WGL_DOUBLE_BUFFER_ARB, 1,
Wgl.WGL_PIXEL_TYPE_ARB, Wgl.WGL_TYPE_RGBA_ARB,
Wgl.WGL_DEPTH_BITS_ARB, depth_bits,
Wgl.WGL_STENCIL_BITS_ARB, stencil_bits,
Wgl.WGL_SAMPLE_BUFFERS_ARB, 1,
Wgl.WGL_SAMPLES_ARB, (int)FSAA
};
//Number of formats that match.
int[] numformats = new int[] { 0 };
int[] format = new int[] { 0 };
float[] attrib = new float[] { 0.0f, 0.0f };
//Get the number of formats that match our requirements.
bool result = Wgl.wglChoosePixelFormatARB( dummyhDC, attributes, attrib, 1, format, numformats );
if( result && numformats[0] >= 1 )
{
//Found one!
return format[0];
}
}
//Destroy the dummy context
Wgl.wglMakeCurrent( dummyhDC, IntPtr.Zero );
Wgl.wglDeleteContext( dummyhRC );
User.ReleaseDC( dummywindow.Handle, dummyhDC );
dummywindow.Dispose( );
//Return the default pixel format.
return pf;
}