Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
On Thu, Nov 5, 2020 at 5:30 PM Biswapriyo Nath wrote: > > Vincent Torri, if you are not familiar with the header files here, I > may send the required patches this week. that would be very nice if you can send those patches thank you Vincent Torri ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
On Thu, Nov 5, 2020 at 5:30 PM Biswapriyo Nath wrote: > > Vincent Torri, if you are not familiar with the header files here, I > may send the required patches this week. i'm not familiar at all with the mingw-w64 headers, indeed. I'm just guessing stuff by comparing what is in d2d1.h, d2d1_1.h and the d2d1_1.h generated with widl. Vincent Torri ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
Vincent Torri, if you are not familiar with the header files here, I may send the required patches this week. ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
On Thu, Nov 5, 2020 at 3:18 PM Liu Hao wrote: > > 在 2020/11/5 21:37, Vincent Torri 写道: > > > > i can add what is missing part by part in d2d1.h. What is the standard > > procedure ? if there is a github mirror and if PR are a possible way > > to provide patches, i can do that > > > > regards > > > > > > You may clone the mingw-w64 repo, commit your changes locally, then use `git > format-patch [-o > ]` to create patches, then send them to this mailing > list. Patches can be > opened with an email client directly, or sent as attachments. Your > contribution will be appreciated. > > > For example, to export the last 3 commits in the current branch to the > current directory, use > > git format-patch HEAD~3 > > To export all commits since `origin/master`, use > > git format-patch origin/master > > To export a specific commit, use > > git format-patch -1 > > To export only the last commit in the current branch, use > > git format-patch HEAD~ # alternative 1 > git format-patch -1 HEAD# alternative 2 Question: I have added ID2D1Properties C API (see attached diff). In d2d1.h, STDMETHOD_ was used for the functions in the Vtbl struct. Should I do the same ? thank you Vincent Torri ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
在 2020/11/5 21:37, Vincent Torri 写道: > > i can add what is missing part by part in d2d1.h. What is the standard > procedure ? if there is a github mirror and if PR are a possible way > to provide patches, i can do that > > regards > > You may clone the mingw-w64 repo, commit your changes locally, then use `git format-patch [-o ]` to create patches, then send them to this mailing list. Patches can be opened with an email client directly, or sent as attachments. Your contribution will be appreciated. For example, to export the last 3 commits in the current branch to the current directory, use git format-patch HEAD~3 To export all commits since `origin/master`, use git format-patch origin/master To export a specific commit, use git format-patch -1 To export only the last commit in the current branch, use git format-patch HEAD~ # alternative 1 git format-patch -1 HEAD# alternative 2 -- Best regards, LH_Mouse signature.asc Description: OpenPGP digital signature ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
On Wed, Nov 4, 2020 at 8:08 PM Jacek Caban wrote: > > On 04/11/2020 10:31, Biswapriyo Nath wrote: > > > I would like to avoid the manual editing of d2d1 header files. I tried > > to import d2d1.idl and d2d1_1.idl from wine. widl produces the > > corresponding headers file without any errors. But while compiling > > crt, it conflicts with `namespace D2D1` in d2d1helper.h as it is in > > C++ realm. One thing can be done but I am not sure about it: > > 0. Sync mingw-w64's d2d1_1.h with wine's d2d1_1.idl. > > 1. Import d2d1.idl and d2d1_1.idl from wine. > > 2. Generate header for d2d1_1.idl but NOT for d2d1.h. > > 3. Fix necessary changes in mingw-w64's d2d1.h manually. > > > There are multiple problems with C++ constructs used in d2d1.h that are > not possible in IDL files and we'd need solutions to those first. I'm > not convinced if it's the right thing to do for that particular header. > > > For the time being, I'd suggest to extend the existing header. i can add what is missing part by part in d2d1.h. What is the standard procedure ? if there is a github mirror and if PR are a possible way to provide patches, i can do that regards Vincent Torri ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
On 04/11/2020 10:31, Biswapriyo Nath wrote: I would like to avoid the manual editing of d2d1 header files. I tried to import d2d1.idl and d2d1_1.idl from wine. widl produces the corresponding headers file without any errors. But while compiling crt, it conflicts with `namespace D2D1` in d2d1helper.h as it is in C++ realm. One thing can be done but I am not sure about it: 0. Sync mingw-w64's d2d1_1.h with wine's d2d1_1.idl. 1. Import d2d1.idl and d2d1_1.idl from wine. 2. Generate header for d2d1_1.idl but NOT for d2d1.h. 3. Fix necessary changes in mingw-w64's d2d1.h manually. There are multiple problems with C++ constructs used in d2d1.h that are not possible in IDL files and we'd need solutions to those first. I'm not convinced if it's the right thing to do for that particular header. For the time being, I'd suggest to extend the existing header. Jacek ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
On Wed, Nov 4, 2020 at 10:34 AM Biswapriyo Nath wrote: > > I would like to avoid the manual editing of d2d1 header files. I tried > to import d2d1.idl and d2d1_1.idl from wine. widl produces the > corresponding headers file without any errors. But while compiling > crt, it conflicts with `namespace D2D1` in d2d1helper.h as it is in > C++ realm. One thing can be done but I am not sure about it: > 0. Sync mingw-w64's d2d1_1.h with wine's d2d1_1.idl. > 1. Import d2d1.idl and d2d1_1.idl from wine. > 2. Generate header for d2d1_1.idl but NOT for d2d1.h. > 3. Fix necessary changes in mingw-w64's d2d1.h manually. i also have an error that i do not understand when i use ID2D1Factory1_CreateDevice(***); the compiler says that d2d.c:12:60: error: 'ID2D1FactoryVtbl' has no member named 'CreateDevice' 12 | #define ID2D1Factory1_CreateDevice(this,A,B) (this)->lpVtbl->CreateDevice(this,A,B) |^~ d2d.c:301:16: note: in expansion of macro 'ID2D1Factory1_CreateDevice' 301 | if (FAILED(ID2D1Factory1_CreateDevice(factory, dxgi_device, &d2d_device))) |^~ i don't understand why. I've properly defined #define D2D_USE_C_DEFINITIONS #define _WIN32_WINNT 0x0A00 before inclusion of d2d header any idea why ? Vincent ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
I would like to avoid the manual editing of d2d1 header files. I tried to import d2d1.idl and d2d1_1.idl from wine. widl produces the corresponding headers file without any errors. But while compiling crt, it conflicts with `namespace D2D1` in d2d1helper.h as it is in C++ realm. One thing can be done but I am not sure about it: 0. Sync mingw-w64's d2d1_1.h with wine's d2d1_1.idl. 1. Import d2d1.idl and d2d1_1.idl from wine. 2. Generate header for d2d1_1.idl but NOT for d2d1.h. 3. Fix necessary changes in mingw-w64's d2d1.h manually. /cc nsivov. ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
On Wed, Nov 4, 2020 at 9:12 AM Vincent Torri wrote: > > On Wed, Nov 4, 2020 at 8:18 AM Ruslan Garipov > wrote: > > > > Oh, I'm sorry, I accidentally replied directly to you, not to the list. > > > > On 11/4/2020 10:01 AM, Vincent Torri wrote: > > > for now : > > > > > > CreateDeviceContext method of a ID2D1Device1 > > It's already in the master: > > > > $ fgrep -n CreateDeviceContext mingw-w64-headers/include/d2d1_1.h > > 1014:STDMETHOD(CreateDeviceContext)(D2D1_DEVICE_CONTEXT_OPTIONS > > options, ID2D1DeviceContext **deviceContext) PURE; > > 1034:STDMETHOD(CreateDeviceContext)(ID2D1Device *This, > > > > $ git blame -L1034,1036 HEAD mingw-w64-headers/include/d2d1_1.h > > 3cc762bfb (Ruslan Garipov 2020-05-19 14:29:13 +0500 1034) > > STDMETHOD(CreateDeviceContext)(ID2D1Device *This, > > 3cc762bfb (Ruslan Garipov 2020-05-19 14:29:13 +0500 1035) > > D2D1_DEVICE_CONTEXT_OPTIONS options, > > 3cc762bfb (Ruslan Garipov 2020-05-19 14:29:13 +0500 1036) > > ID2D1DeviceContext **deviceContext) PURE; > > i know how to use fgrep... > > what is missing is the classic C API, like (in d2d1_1.h) : > > ID2D1Factory1_QueryInterface > > that is, a define that call the method from the "virtual table" : > > #define ID2D1Factory1_QueryInterface(this,A,B) > (this)->lpVtbl->Base.Base.QueryInterface((IUnknown *)(this),A,B) > > it calls QueryInterface from the IUnknownVtbl structure, through > Base.Base in the define above > > These are those defines that are missing. > > Same for BeginDraw and EndDraw for example, adding in d2d1_1.h around line 1054 : #define ID2D1Device_CreateDeviceContext(this,A,B) (this)->lpVtbl->CreateDeviceContext(this,A,B) ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
On Wed, Nov 4, 2020 at 8:18 AM Ruslan Garipov wrote: > > Oh, I'm sorry, I accidentally replied directly to you, not to the list. > > On 11/4/2020 10:01 AM, Vincent Torri wrote: > > for now : > > > > CreateDeviceContext method of a ID2D1Device1 > It's already in the master: > > $ fgrep -n CreateDeviceContext mingw-w64-headers/include/d2d1_1.h > 1014:STDMETHOD(CreateDeviceContext)(D2D1_DEVICE_CONTEXT_OPTIONS > options, ID2D1DeviceContext **deviceContext) PURE; > 1034:STDMETHOD(CreateDeviceContext)(ID2D1Device *This, > > $ git blame -L1034,1036 HEAD mingw-w64-headers/include/d2d1_1.h > 3cc762bfb (Ruslan Garipov 2020-05-19 14:29:13 +0500 1034) > STDMETHOD(CreateDeviceContext)(ID2D1Device *This, > 3cc762bfb (Ruslan Garipov 2020-05-19 14:29:13 +0500 1035) > D2D1_DEVICE_CONTEXT_OPTIONS options, > 3cc762bfb (Ruslan Garipov 2020-05-19 14:29:13 +0500 1036) > ID2D1DeviceContext **deviceContext) PURE; i know how to use fgrep... what is missing is the classic C API, like (in d2d1_1.h) : ID2D1Factory1_QueryInterface that is, a define that call the method from the "virtual table" : #define ID2D1Factory1_QueryInterface(this,A,B) (this)->lpVtbl->Base.Base.QueryInterface((IUnknown *)(this),A,B) it calls QueryInterface from the IUnknownVtbl structure, through Base.Base in the define above These are those defines that are missing. Same for BeginDraw and EndDraw Vincent Torri > $ git show --pretty=fuller 3cc762bfb > commit 3cc762bfbbbefcefa97d937fed89764ed4f58034 > Author: Ruslan Garipov > AuthorDate: Tue May 19 14:29:13 2020 +0500 > Commit: Liu Hao > CommitDate: Tue May 19 22:31:26 2020 +0800 > > d2d1_1.h: Add C declaration for ID2D1Device > > Signed-off-by: ‡Ruslan Garipov > Signed-off-by: Liu Hao > > diff --git a/mingw-w64-headers/include/d2d1_1.h > b/mingw-w64-headers/include/d2d1_1.h > index f090be7a..f48ac349 100644 > --- a/mingw-w64-headers/include/d2d1_1.h > +++ b/mingw-w64-headers/include/d2d1_1.h > @@ -1014,7 +1014,29 @@ interface ID2D1Device : public ID2D1Resource > #else > > typedef interface ID2D1Device ID2D1Device; > -/* FIXME: Add full C declaration */ > + > +typedef struct ID2D1DeviceVtbl { > +struct ID2D1ResourceVtbl Base; > + > +STDMETHOD(CreateDeviceContext)(ID2D1Device *This, > +D2D1_DEVICE_CONTEXT_OPTIONS options, > +ID2D1DeviceContext **deviceContext) PURE; > +STDMETHOD(CreatePrintControl)(ID2D1Device *This, > +IWICImagingFactory *wicFactory, > +IPrintDocumentPackageTarget *documentTarget, > +CONST D2D1_PRINT_CONTROL_PROPERTIES *printControlProperties, > +ID2D1PrintControl **printControl) PURE; > +STDMETHOD_(void, SetMaximumTextureMemory)(ID2D1Device *This, > +UINT64 maximumInBytes) PURE; > +STDMETHOD_(UINT64, GetMaximumTextureMemory)(ID2D1Device *This) PURE; > +STDMETHOD_(void, ClearResources)(ID2D1Device *This, > +UINT32 millisecondsSinceUse) PURE; > +} > +ID2D1DeviceVtbl; > + > +interface ID2D1Device { > +const ID2D1DeviceVtbl *lpVtbl; > +}; > > #endif > > > BeginDraw and EndDraw methods of a ID2D1DeviceContext (which inherits > > from a ID2D1RenderTarget) > The ID2D1DeviceContext is also in the tree (after 0c0da49fd): > > $ fgrep -n "struct ID2D1DeviceContextVtbl" > mingw-w64-headers/include/d2d1_1.h > 881:typedef struct ID2D1DeviceContextVtbl { > > $ tail -n +879 mingw-w64-headers/include/d2d1_1.h | head -130 > ... > > And the functions you are looking for (BeginDraw() and EndDraw()), were > also added for C target long before 0c0da49fd: > > $ tail -n +934 mingw-w64-headers/include/d2d1.h | head -n 120 | egrep > "BeginDraw|EndDraw" > STDMETHOD_(void, BeginDraw)(ID2D1RenderTarget *This) PURE; > STDMETHOD(EndDraw)(ID2D1RenderTarget *This, D2D1_TAG *tag1, D2D1_TAG > *tag2) PURE; > #define ID2D1RenderTarget_BeginDraw(this) (this)->lpVtbl->BeginDraw(this) > #define ID2D1RenderTarget_EndDraw(this,A,B) > (this)->lpVtbl->EndDraw(this,A,B) > > If you need some other interfaces -- let's try to add them. Because I > have developed a C program rendering with Direct2D, and also I'm to > continue with that project in future. > > > > > Vincent Torri > > > > On Tue, Nov 3, 2020 at 9:31 PM Ruslan Garipov > > wrote: > >> > >> On 11/3/2020 9:36 PM, Vincent Torri wrote: > >>> Hello > >> Hello! > >> > >>> > >>> does someone plan to add all the missing C API in d2d1_1.h ? > >> Which interfaces (or some other API parts?) exactly do you need? > >> > >>> Currently, it's not possible to use d2d 1.1 API in C > >>> > >>> thank you > >>> > >>> Vincent Torri > >>> > >>> > >>> ___ > >>> Mingw-w64-public mailing list > >>> Mingw-w64-public@lists.sourceforge.net > >>> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public > >>> ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
here it is (based on https://docs.microsoft.com/en-us/archive/msdn-magazine/2014/june/windows-with-c-high-performance-window-layering-using-the-windows-composition-engine) On Wed, Nov 4, 2020 at 5:11 AM Biswapriyo Nath wrote: > > If you have a project to test new header changes it will be helpful. > > > ___ > Mingw-w64-public mailing list > Mingw-w64-public@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public /* gcc -g -Wall -o d2d d2d.c -ld2d1 -luuid */ #define COBJMACROS #define D2D_USE_C_DEFINITIONS #define _WIN32_WINNT 0x0A00 #include #include #include #include #include static HINSTANCE instance = NULL; static HWND win = NULL; static ID3D11Device *d3d_device = NULL; static IDXGIDevice *dxgi_device = NULL; static IDXGIFactory2 *dxgi_factory = NULL; static ID2D1Factory *factory = NULL; static IDXGISwapChain1 *swapchain= NULL; static ID2D1Device *d2d_device = NULL; static ID2D1DeviceContext *d2d_device_ctx = NULL; static ID2D1HwndRenderTarget* render_target = NULL; LRESULT CALLBACK _window_procedure(HWND window, UINT message, WPARAM window_param, LPARAM data_param); int render_target_properties_new(void) { D2D1_SIZE_U size; D2D1_RENDER_TARGET_PROPERTIES rtp; D2D1_HWND_RENDER_TARGET_PROPERTIES wrtp; RECT r; FLOAT dpix; FLOAT dpiy; HRESULT res; ID2D1Factory_GetDesktopDpi(factory, &dpix, &dpiy); rtp.type = D2D1_RENDER_TARGET_TYPE_HARDWARE; rtp.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; rtp.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; rtp.dpiX = dpix; rtp.dpiY = dpiy; rtp.usage = D2D1_RENDER_TARGET_USAGE_NONE; rtp.minLevel = D2D1_FEATURE_LEVEL_10; GetClientRect(win, &r); size.width = r.right - r.left; size.height = r.bottom - r.top; wrtp.hwnd = win; wrtp.pixelSize = size; wrtp.presentOptions = D2D1_PRESENT_OPTIONS_IMMEDIATELY; res = ID2D1Factory_CreateHwndRenderTarget(factory, &rtp, &wrtp, &render_target); if (FAILED(res)) return 0; return 1; } void render_tartget_properties_free() { ID2D1HwndRenderTarget_Release(render_target); } void render_bitmap(HWND win) { D2D1_BITMAP_PROPERTIES props; D2D1_SIZE_U size; ID2D1RenderTarget* rt; RECT r; D2D1_RECT_F rect; ID2D1Bitmap *bitmap; unsigned int i, j; unsigned int *data, *iter; HRESULT res; GetClientRect(win, &r); size.width = r.right - r.left; size.height = r.bottom - r.top; data = malloc(size.width * size.height * sizeof(unsigned int)); iter = data; for (i = 0; i < size.width; i++) { for (j = 0; j < size.height; j++, iter ++) { if (i >= 50 && j>= 50) *iter = 0xffff; else *iter = 0x; } } props.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; props.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED; props.dpiX = 96.0f; props.dpiY = 96.0f; rt = (ID2D1RenderTarget *)render_target; res = ID2D1RenderTarget_CreateBitmap(rt, size, data, 4 * size.width, &props, &bitmap); if (FAILED(res)) return; ID2D1RenderTarget_BeginDraw(rt); rect.left = (float)r.left; rect.top = (float)r.top; rect.right = (float)r.right; rect.bottom = (float)r.bottom; ID2D1RenderTarget_DrawBitmap(rt, bitmap, &rect, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, NULL); ID2D1RenderTarget_EndDraw(rt, NULL, NULL); } LRESULT CALLBACK _window_procedure(HWND window, UINT message, WPARAM window_param, LPARAM data_param) { switch (message) { case WM_CLOSE: PostQuitMessage(0); return 0; case WM_KEYUP: if (window_param == 'Q') { PostQuitMessage(0); } return 0; /* GDI notifications */ case WM_CREATE: case WM_PAINT: { RECT rect; printf("paint\n"); fflush(stdout); if (GetUpdateRect(window, &rect, FALSE)) { PAINTSTRUCT ps; BeginPaint(window, &ps); //render(); EndPaint(window, &ps); } return 0; } default: return DefWindowProc(window, message, window_param, data_param); } } int main() { /* class */ WNDCLASS wc; instance = GetModuleHandle(NULL); if (!instance) return 1; memset (&wc, 0, sizeof (WNDCLASS)); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = _window_procedure; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = instance; wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
Re: [Mingw-w64-public] d2d1_1.h : plenty of C API missing
If you have a project to test new header changes it will be helpful. ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] d2d1_1.h : plenty of C API missing
Hello does someone plan to add all the missing C API in d2d1_1.h ? Currently, it's not possible to use d2d 1.1 API in C thank you Vincent Torri ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public