Original Post
Hi all. I'm trying to render in two windows,which were created using pure API(Windows XP). The windows were created like this: //////////////////////CODE/////////////////////////////////////// WNDCLASSEX wndclass; wndclass.cbSize=sizeof(wndclass); wndclass.style=CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wndclass.lpfnWndProc=wndproc1; wndclass.cbClsExtra=NULL; wndclass.cbWndExtra=NULL; wndclass.hInstance=NULL; wndclass.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(668));; wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground=(HBRUSH)13; wndclass.lpszMenuName=NULL; wndclass.lpszClassName=classname; wndclass.hIconSm=NULL; RegisterClassEx(&wndclass); HWND winhandle=CreateWindowEx(NULL,classname,L"FIRST",WS_OVERLAPPEDWINDOW|WS_MAXIMIZE, 0,0,790,550,NULL,NULL, NULL,NULL); HDC mDC = GetDC(winhandle); PIXELFORMATDESCRIPTOR pfd; pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 32; pfd.cRedBits = 8; pfd.cRedShift = 16; pfd.cGreenBits = 8; pfd.cGreenShift = 8; pfd.cBlueBits = 8; pfd.cBlueShift = 0; pfd.cAlphaBits = 0; pfd.cAlphaShift = 0; pfd.cAccumBits = 64; pfd.cAccumRedBits = 16; pfd.cAccumGreenBits = 16; pfd.cAccumBlueBits = 16; pfd.cAccumAlphaBits = 0; pfd.cDepthBits = 32; pfd.cStencilBits = 8; pfd.cAuxBuffers = 0; pfd.iLayerType = PFD_MAIN_PLANE; pfd.bReserved = 0; pfd.dwLayerMask = 0; pfd.dwVisibleMask = 0; pfd.dwDamageMask = 0; int PixelFormat = ChoosePixelFormat(mDC,&pfd); if(PixelFormat==0) DescribePixelFormat(mDC,1,sizeof(PIXELFORMATDESCRIPTOR),&pfd); else { if(!SetPixelFormat(mDC,PixelFormat,&pfd)) MessageBox(0,L"Error setting pixel format",L"Error",MB_OK); } HGLRC mRC = wglCreateContext(mDC); if(mRC == 0) MessageBox(0,L"wglCreateContext failed",L"ERROR",MB_OK); if(!wglMakeCurrent(mDC,mRC)) MessageBox(0,L"wglMakeCurrent failed",L"ERROR",MB_OK); ShowWindow(winhandle,SW_SHOW); UpdateWindow(winhandle); //creating second window WNDCLASSEX wndclass1; wndclass.cbSize=sizeof(wndclass1); wndclass.style=CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wndclass.lpfnWndProc=wndproc2; wndclass.cbClsExtra=NULL; wndclass.cbWndExtra=NULL; wndclass.hInstance=NULL; wndclass.hIcon=0; wndclass.hCursor=0; wndclass.hbrBackground=(HBRUSH)13; wndclass.lpszMenuName=NULL; wndclass.lpszClassName=classname1; wndclass.hIconSm=NULL; RegisterClassEx(&wndclass1); HWND winhandle2=CreateWindowEx(NULL,classname1,L"SECOND",WS_OVERLAPPEDWINDOW|WS_MAXIMIZE, 0,0,790,550,NULL,NULL, NULL,NULL); mDC = GetDC(winhandle2); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 32; pfd.cRedBits = 8; pfd.cRedShift = 16; pfd.cGreenBits = 8; pfd.cGreenShift = 8; pfd.cBlueBits = 8; pfd.cBlueShift = 0; pfd.cAlphaBits = 0; pfd.cAlphaShift = 0; pfd.cAccumBits = 64; pfd.cAccumRedBits = 16; pfd.cAccumGreenBits = 16; pfd.cAccumBlueBits = 16; pfd.cAccumAlphaBits = 0; pfd.cDepthBits = 32; pfd.cStencilBits = 8; pfd.cAuxBuffers = 0; pfd.iLayerType = PFD_MAIN_PLANE; pfd.bReserved = 0; pfd.dwLayerMask = 0; pfd.dwVisibleMask = 0; pfd.dwDamageMask = 0; PixelFormat = ChoosePixelFormat(mDC,&pfd); if(PixelFormat==0) DescribePixelFormat(mDC,1,sizeof(PIXELFORMATDESCRIPTOR),&pfd); else { if(!SetPixelFormat(mDC,PixelFormat,&pfd)) MessageBox(0,L"Error setting pixel format",L"Error",MB_OK); } mRC = wglCreateContext(mDC); if(mRC == 0) MessageBox(0,L"wglCreateContext failed",L"ERROR",MB_OK); if(!wglMakeCurrent(mDC,mRC)) MessageBox(0,L"wglMakeCurrent failed",L"ERROR",MB_OK); ShowWindow(winhandle2,SW_SHOW); UpdateWindow(winhandle2); After each window was created it's dc was initilized for OpenGL use like shown above.Each window has in it's WM_PAINT and WM_SIZE the following code: RECT rect; HDC clientdc = GetDC(hWnd); GetClientRect(hWnd,▭); int width = rect.right - rect.left; int height = rect.bottom - rect.top; glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-width/2,width/2,-height/2,height/2); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT); //drawing zero line glBegin(GL_LINES); glColor3f(1,1,1); glVertex2d(width/2,0); glVertex2d(-width/2,100); glEnd(); glFlush(); SwapBuffers(clientdc); Everything is rendering, the problem is that the first window is repainted incorrectly.When i'm trying to change is's size the strange lines are shown.When i remove the OpenGL initilization for the second window the first is repaited well on resize.Where can be the problem?