GLvoid oglClass::CreateVideoTexture(HWND hWndV){ HDC hDC, // Handle to the display device context hDCMem; // Handle to the memory device context HBITMAP hBitmap, // Handle to the new bitmap hOldBitmap; // Handle to the old bitmap BITMAP bm; int iWidth, iHeight; // Width and height of the bitmap char str[256]; // this should be done on init // do you have control over window? if yes, use CS_OWNDC class style and keep this code // if no, we need something else hDC = GetDC (hWndV); hDCMem = CreateCompatibleDC (hDC); hBitmap = CreateCompatibleBitmap (hDCMem, 512, 512); iWidth=320; iHeight=240; int bytes=GetObject(hBitmap, sizeof(BITMAP), &bm); HGDIOBJ OldBitmap = SelectObject (hDCMem, hBitmap); // this should be done every frame BitBlt (hDCMem, 0, 0, iWidth, iHeight, hDC, 0, 0, SRCCOPY); GdiFlush(); glBindTexture(GL_TEXTURE_2D,videoTexture); // Bind To The Video Texture glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, bm.bmBits); // this should be done on cleanup SelectObject(hDCMem, OldBitmap); DeleteObject (hBitmap); DeleteDC (hDCMem); // don't delete hDC if you have CS_OWNDC}
[edited by - niyaw on December 8, 2002 5:46:07 PM]