I'm attempting to copy data from a normal windows hwnd, into a D3D8 texture, but I'm not certain of the procedure to follow.
I figure the steps are something like:
1) Obtain a lock on texture memory
2) Obtain a lock on window handle DC
3) Copy data from DC to texture memory
4) Unlock both
5) Update
...but I'm not certain what functions are available. Step #3 is what puzzles me. Ideas?
Thanks!
MatrixCubed
http://MatrixCubed.cjb.net
Edited by - MatrixCubed on November 17, 2001 9:39:07 PM
Win32 hwnd -> Direct3DTexture8
Nope. Just a regular window. And yes, rendering it to a texture
One used to be able to DirectDrawSurface7->GetDC() and use BitBlt() to draw (whatever) to the surface from another DC, but that doesn''t seem possible with DirectX 8.
MatrixCubed
http://MatrixCubed.cjb.net
One used to be able to DirectDrawSurface7->GetDC() and use BitBlt() to draw (whatever) to the surface from another DC, but that doesn''t seem possible with DirectX 8.
MatrixCubed
http://MatrixCubed.cjb.net
Small update...
I''ve come up with a sort of scheme, which is not working at this point. Perhaps someone could offer guidance.
1. GetDC of the window to capture (source DC)
2. CreateCompatibleBitmap of DC from #1
3. LockRect on the D3D texture in question
4. Fill out a BITMAPINFO structure and pass to GetDIBits (this should theoretically fill the texture with pixels from the source window).
5. UnlockRect on the D3D texture.
6. Set the texture for use with the renderer, and we''re done
The problem lies with #4, the data is not copied, and no error is returned.
Ideas?
MatrixCubed
http://MatrixCubed.cjb.net
I''ve come up with a sort of scheme, which is not working at this point. Perhaps someone could offer guidance.
1. GetDC of the window to capture (source DC)
2. CreateCompatibleBitmap of DC from #1
3. LockRect on the D3D texture in question
4. Fill out a BITMAPINFO structure and pass to GetDIBits (this should theoretically fill the texture with pixels from the source window).
5. UnlockRect on the D3D texture.
6. Set the texture for use with the renderer, and we''re done
The problem lies with #4, the data is not copied, and no error is returned.
Ideas?
MatrixCubed
http://MatrixCubed.cjb.net
Here''s some code for capturing the desktop to HBITMAP - sorry it''s in C - I have no idea about how to transfer the HBITMAP to a DX surface - you''ll have to figure that part out for yourself.
// ----------------------------------------------------------------------------// Function captures current desktop storing the image in the bitmap parameter//BOOL __stdcall CaptureDesktop(HBITMAP *hBmpScr){ *hBmpScr = NULL; HWND hwndDeskTop = GetDesktopWindow(); UpdateWindow(hwndDeskTop); Sleep(500); // give the desktop time to repaint itself HDC hdc = GetWindowDC(hwndDeskTop); int iWidth = GetDeviceCaps(hdc, HORZRES); int iHeight = GetDeviceCaps(hdc, VERTRES); HDC memdc = CreateCompatibleDC(hdc); *hBmpScr = CreateCompatibleBitmap(hdc, iWidth, iHeight); HBITMAP hBmpPre = (HBITMAP)SelectObject(memdc, *hBmpScr); BitBlt(memdc, 0, 0, iWidth, iHeight, hdc, 0, 0, SRCCOPY); *hBmpScr = (HBITMAP)SelectObject(memdc, hBmpPre); // ?? DeleteDC(memdc); DeleteObject(hBmpPre); ReleaseDC(hwndDeskTop, hdc); return ( *hBmpScr != NULL );}
Thanks... still no luck though.
Maybe it''s a problem with my logic in general? I''m trying to grab the data from video capture, but all I get is a black screen of the appropriate size and color depth.
MatrixCubed
http://MatrixCubed.cjb.net
Maybe it''s a problem with my logic in general? I''m trying to grab the data from video capture, but all I get is a black screen of the appropriate size and color depth.
MatrixCubed
http://MatrixCubed.cjb.net
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement