M
Hi,
ich habe folgendes Problem: Mein Programm läuft fehlerfrei, bis ich ein zweites beliebiges OpenGL starte. Dann fängt meins an wie wild zu flimmern und hat Darstellungsfehler. Der Grund ist, dass es auch einen Backbufferswitch ausführt, wenn es das andere Programm macht. Irgendwie müssen sich die DCs überschneiden, ich habe aber keinen Fehler in meinem Code gefunden (der mir nicht wie eine wilde Katze entspringen würde )
Ich habe ein bißchen mit den Style Parametern der Klasse herumgespielt, aber es hat nichts geholfen. Hier ist der entsprechende Codeauszug:
//Main window
HWND hwndMain;
MSG msg;
WNDCLASSEX wc;
//Pointers to Opengl Contexts
HGLRC hRC;
HDC hDC;
//
// Register our main window class
//
wc.cbSize = sizeof(wc);
//wc.style = 0;
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor (NULL, IDC_SIZENS);
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = szAppName;
wc.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
RegisterClassEx(&wc);
//
// Create the main window.
//
hwndMain = CreateWindowEx(
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,// Window Ext. Style
szAppName, // window class name
szAppName, // window caption
WS_OVERLAPPEDWINDOW|
WS_CLIPSIBLINGS | //
WS_CLIPCHILDREN, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
xsize, // initial x size
ysize, // initial y size
NULL, // parent window handle
NULL, // use window class menu
hInstance, // program instance handle
NULL); // creation parameters
ShowWindow(hwndMain, nCmdShow);
hDC = GetDC( hwndMain );
PIXELFORMATDESCRIPTOR pfd = {
sizeof(pfd), // Size of this structure
1, // Version of this structure
PFD_DRAW_TO_WINDOW | // Draw to Window (not to bitmap)
PFD_SUPPORT_OPENGL | // Support OpenGL calls in window
PFD_DOUBLEBUFFER, // Double buffered mode
PFD_TYPE_RGBA, // RGBA Color mode
16, // choose supported bit depth
0,0,0,0,0,0, // Not used to select mode
0,0, // Not used to select mode
0,0,0,0,0, // Not used to select mode
24, // Size of depth buffer
0, // Not used to select mode
0, // Not used to select mode
PFD_MAIN_PLANE, // Not used to select mode
0, // Not used to select mode
0,0,0 }; // Not used to select mode*/
int iFormat = ChoosePixelFormat( hDC, &pfd );
SetPixelFormat( hDC, iFormat, &pfd );
// create and enable the render context (RC)
hRC = wglCreateContext( hDC );
wglMakeCurrent( hDC, hRC );
bool quit = false;
// program main loop
while ( !quit )
{
// check for messages
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
// handle or dispatch messages
if ( msg.message == WM_QUIT )
{
quit = TRUE;
}
else
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else doSomething();
}
// shutdown OpenGL
wglMakeCurrent( NULL, NULL );
wglDeleteContext( hRC );
ReleaseDC( hwndMain, hDC );
UnregisterClass(szAppName, hInstance);
Mach ich etwas grundlegendes falsch?