How to render the "reprint" OLE Control in Direct3D

Source: Internet
Author: User
Tags ole

Original:how OLE controls are rendered in Direct3D

Graphical drawing on Windows is based on GDI, and Direct3D is not, so there are a lot of problems in displaying some controls in Windows in a 3D window

So what's the way to make GDI's content appear in 3D? Anyway, it's all images, there's always a way to achieve it!

In the previous period of time in the research browser embedded in the game, the basic idea is to open a browsing window in the background, and then copy the contents of it to a texture, and then the texture in the D3D to draw out, as for the event processing will be another fuss.

So, other windows of GDI drawing things can be done like this!
Originally I was getdc, then getpixel pixel copy, slow I want to die ....
Later discovered the BitBlt this fast copy method, has the practical value:

1. Get the control's DC:GETDC (HWND)
2. Obtaining the DC:IDIRECT3DSURFACE9::GETDC of texture
3. Copy the past with BitBlt

BOOL BitBlt (
HDC hdcdest,//handle to destination DC
int nxdest,//X-coord of destination Upper-left corner
int nydest,//Y-coord of destination Upper-left corner
int nwidth,//width of destination Rectangle
int nheight,//height of destination Rectangle
HDC hdcsrc,//handle to source DC
int NXSRC,//x-coordinate of source Upper-left Corner
int NYSRC,//y-coordinate of source Upper-left Corner
DWORD dwrop//Raster operation code
);

If it's an OLE control, it's even easier:

Winoleapi Oledraw (
IUnknown * PUnk,//pointer to the View object to be drawn
DWORD Dwaspect,//how the object is to be represented
HDC Hdcdraw,//device context on which to draw
Lpcrect lprcbounds//pointer to the rectangle in which the object
is drawn
);

For example, I have a IWebBrowser2 pointer that I want to copy to the texture, so I can do this:

idirect3dsurface9* psurface = NULL;
This->mtexture->getsurfacelevel (0, &psurface);
if (NULL! = psurface)
{
HDC hdctexture;
HRESULT hr = PSURFACE->GETDC (&hdctexture);
if (FAILED (HR)) return;
:: Setmapmode (Hdctexture, mm_text);
:: Oledraw (Pbrowser, Dvaspect_content, Hdctexture, &rect);
Psurface->releasedc (hdctexture);
Psurface->release ();
}

Show me a bit:

Not only the browser, but any OLE control, you can use your imagination:

How to render the "reprint" OLE Control in Direct3D

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.