Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

is it possible to render direct3d scene to printer?

8 views
Skip to first unread message

Mark Lintner

unread,
Mar 10, 1999, 3:00:00 AM3/10/99
to
I have been searching for a solution to printing a 3d scene and aim
stumped.
Is there a simple approach to rendering a directX surface to a printer?

This is a problem that I have not seen addressed anywhere.
Any help would be appreciated.
Thanks,
Mark


Sami Vaaraniemi

unread,
Mar 10, 1999, 3:00:00 AM3/10/99
to

I think you may be able to do it like this. First, get the surface onto
which
you are rendering with the GetRenderTarget method of the D3D device
(call it
pSurf). You can then blit the image from that surface onto a Windows
bitmap
using good old GDI. Pseudo-code follows:

HDC hdcFrom = NULL;
pSurf->GetDC(&hdcFrom);

// Create a Windows bitmap and select it into a
// memory device context
HDC hdcMem = ::CreateCompatibleDC(hdcFrom);
HBITMAP hbm = ::CreateCompatibleBitmap(hdcMem, sizex, sizey);
HBITMAP hbmOld = ::SelectObject(hdcMem, hbm);

// Blit the image from the rendering surface onto
// the Windows bitmap
::BitBlt(hdcMem, 0, 0, sizex, sizey, hdcFrom, 0, 0, SRCCOPY);

// Now we've got the rendered image in 'hbm' - clean up
pSurf->ReleaseDC(hdcFrom);
::SelectObject(hdcMem, hbmOld);
::DeleteDC(hdcMem);

Finally, MSDN contains sample code that shows how to output the Windows
bitmap
'hbm' onto a printer. Note that I haven't actually tried this so I don't
guarantee it works :)


Regards,
Sami

Oliver Headey

unread,
Mar 10, 1999, 3:00:00 AM3/10/99
to
>I think you may be able to do it like this. First, get the surface onto
>which you are rendering with the GetRenderTarget method of the
>D3D device (call it pSurf). You can then blit the image from that
>surface onto a Windows bitmap using good old GDI. >

this is indeed how you do it. i simply get the dc and save the bitmap then
in my OnPrint function (i'm using MFC which makes things easier) just blit
the bitmap to the printer dc.


cheers, olly.

0 new messages