Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reguarding the ID2D1HwndRenderTarget::GetSize issue you mentioned. #1

Open
jacoblusk opened this issue Sep 19, 2021 · 1 comment
Open

Comments

@jacoblusk
Copy link

Hello,

I had found your repository and saw you mentioning some issues with ID2D1HwndRenderTarget::GetSize in C.
I noticed a probably similar problem with GetPixelSize and I wrote this to fix it, basically instead of returning the size, you should be passing a out pointer as the 2nd argument.

I ran into this problem when I was working with GCC, I haven't tried it on MSVC yet though so if you are let me know if it works!

typedef VOID (* fnID2D1HwndRenderTarget_GetPixelSize) (ID2D1RenderTarget *, D2D1_SIZE_U *);
VOID ID2D1HwndRenderTarget_GetPixelSizeFix(ID2D1HwndRenderTarget *this, D2D1_SIZE_U *puSize) {
    fnID2D1HwndRenderTarget_GetPixelSize fnGetPixelSize = (fnID2D1HwndRenderTarget_GetPixelSize) ((ID2D1RenderTarget *)this)->lpVtbl->GetPixelSize;
    (*fnGetPixelSize)((ID2D1RenderTarget *)this, puSize);
}
@ybop
Copy link

ybop commented Jan 14, 2024

I know this is ancient but just to add my 2 cents... I independently discovered that changing the definition of ID2D1HwndRenderTarget_GetSize to add a pointer to the size as the 2nd argument, worked! So there is no longer any need for any cpp files at all! Most likely any other function with a similar problem will have a similar solution. But it's sad that microsoft decided to deprecate and then remove these C accessible functions to it will only work with an old SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants