Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


share pasting HBITMAP and IDirect3DDevice9::Present method


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 anders211   Members   -  Reputation: 215

Like
0Likes
Like

Posted 16 March 2014 - 12:23 PM

Hi

I have a problem that Present method overwrite HBITMAP paste method. Here is my code:

 

if(mRefreshWindow)
{
       //mRefreshWindow = false;
            static bool once = false; 
            if(!once) //(-)
{
                pDev->Clear(0, 0, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0xff000000, 1, 0); //(=)
   once = true;
   hDCWin=GetDC(NULL);


                i32 width = GetDeviceCaps(hDCWin, HORZRES);
                i32 height = GetDeviceCaps(hDCWin, VERTRES);


                HDC helpDc;
                helpDc=CreateCompatibleDC(NULL); //gui->hDCWin
                SelectObject(helpDc,hBMP);
                BOOL status = BitBlt(hDCWin,0,0,width,height,helpDc,0,0,SRCCOPY);
                ReleaseDC(hWnd,hDCWin); //do not release hdc, keep it for future purposes
                DeleteDC(helpDc);
}
}


pDev->BeginScene();


if(!mRefreshWindow)
   dialMgr->onRender(timeDelta);


pDev->EndScene();
if(!mRefreshWindow) //(*)
   pDev->Present(0, 0, 0, 0); //present back buffer

With the above code I have pasted my image on the screen.

If I uncomment (*) then my window is the whole black.

If I in addition to (*) delete (-) and (=) my window is black and image is pasted and this is very quickly changed like there is some fighting between "black screen and my image".

Does anybody know how to paste the image on the screen and then use Present method so that there is on the screen my image and also objects drawn between Begin and EndScene.


Edited by anders211, 16 March 2014 - 12:25 PM.


Sponsor:

#2 Buckeye   GDNet+   -  Reputation: 9000

Like
0Likes
Like

Posted 16 March 2014 - 02:33 PM


Does anybody know how to paste the image on the screen and then use Present method so that there is on the screen my image and also objects drawn between Begin and EndScene.

What do you mean by "the image?" Does it have something to do with "hBmp?"

 

It would help, also, if you describe, in a general sense, if there's a problem you're trying to solve.

 

Also, the following line isn't correct. hDCWin is the DC for the desktop returned from GetDC(NULL), not a DC for hWnd. DC's should be released only by the window from which it was retrieved.
 

ReleaseDC(hWnd,hDCWin);


Also note that pDev->Clear is called only once, the first time that mRefreshWindow is true. After that initial call, you don't clear the backbuffer before drawing and, among other effects, the depth buffer is never reset.


Edited by Buckeye, 16 March 2014 - 02:34 PM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.


#3 anders211   Members   -  Reputation: 215

Like
0Likes
Like

Posted 16 March 2014 - 04:19 PM

By image I mean HBITMAP. Probably it isn't possible to use BitBlt and Present method because they have nothing in common, one overwrrite another one. Probably I must convert HBITMAP to texture and then render this texture with directx method and I cannot use BitBlt. However I don't know it is is true but based on my today experience I suppose it might be the true.



#4 Aardvajk   Crossbones+   -  Reputation: 8346

Like
0Likes
Like

Posted 17 March 2014 - 04:11 PM

By image I mean HBITMAP. Probably it isn't possible to use BitBlt and Present method because they have nothing in common, one overwrrite another one. Probably I must convert HBITMAP to texture and then render this texture with directx method and I cannot use BitBlt. However I don't know it is is true but based on my today experience I suppose it might be the true.

 

D3DXCreateTextureFromFile will open most image formats as a texture. It may be possible to use GDI to somehow draw an image to the backbuffer but it will be far more efficient to have it loaded as a texture and render it with a full-screen quad.

 

Just bear in mind a lot of hardware only supports textures with power-of-2 dimensions so unless your image happens to be that, D3DXCreateTextureFromFile will create an image of the wrong size for you. You may need to calculate the texture-co-ordinates yourself based on the difference between the image size and the size of the texture the method returns.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS