flat assembler
Message board for the users of flat assembler.

Index > Windows > Blitting ddraw surface to window

Author
Thread Post new topic Reply to topic
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 06 Nov 2011, 10:56
I have some trouble blitting my IDIRECTDRAWSURFACE7 onto my window. I opted for the gdi method, which seemed to work nicely in the beginning:

Code:
.WM_PAINT:
          mov     esi,ps
              invoke  BeginPaint,[hwindow],esi

                xor     ebx,ebx
             cominvk secondary,GetDC,dc
          invoke  BitBlt,dword [esi],ebx,ebx,WINDOWX,WINDOWY,dword [dc],ebx,ebx,SRCCOPY
               cominvk secondary,ReleaseDC,dword [dc]

          invoke  EndPaint,[hwindow],edi
              jmp     .out    


Problem is that something is leaking memory, and after some 45 seconds of drawing, the blit starts complaining with ERROR_NOACCESS. It is as if the DC:s don't get released even though I ReleaseDC. Any idea why? Should I use another method for drawing?

_________________
This is a block of text that can be added to posts you make.
Post 06 Nov 2011, 10:56
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20450
Location: In your JS exploiting you and your system
revolution 06 Nov 2011, 11:01
Code:
                invoke  BeginPaint,[hwindow],esi
;...
                invoke  EndPaint,[hwindow],edi    
Where do you define EDI?
Post 06 Nov 2011, 11:01
View user's profile Send private message Visit poster's website Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 06 Nov 2011, 11:04
revolution wrote:
Where do you define EDI?


Nice catch! Never thought that it was the ps dc that I was wasting. Always nice with a fresh set of eyes! Smile It seems to be working perfectly now, thanks.

_________________
This is a block of text that can be added to posts you make.
Post 06 Nov 2011, 11:04
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 06 Nov 2011, 17:28
Have you rad the documentation clearly ?

It's
Code:
HDC hDc = BeginPaint(hWin, &ps);
BitBlt(hDc,
    


NOT

Code:
 HDC hDc = BeginPaint(hWin, &ps);
BitBlt(ps.hdc,
    


The second one will give you trouble
Post 06 Nov 2011, 17:28
View user's profile Send private message Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler 06 Nov 2011, 21:15
typedef wrote:
The second one will give you trouble

I don't see why as they are the same thing.

_________________
This is a block of text that can be added to posts you make.
Post 06 Nov 2011, 21:15
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.