cmchtpc / delphidx12 Goto Github PK
View Code? Open in Web Editor NEWDirectX 12 Headers for Delphi and FPC
DirectX 12 Headers for Delphi and FPC
just like:ID2D1DrawingStateBlock;
when i call m_d2dContext.SaveDrawingState(m_stateBlock);
this function crash with :
Debug Output:
D2D DEBUG ERROR - An interface [08ABDA24] not allocated by this DLL was passed to it.
also ID2D1Bitmap:
when i call GetSize().same error and crash?
why ...............?
Some of the pas files are licensed as GPL and others has no overal license information, which is equivalent to "all rights reserved". Are these headers free to use, or are meant only for open sourced applications?
procedure IAGetVertexBuffers(StartSlot: UINT; NumBuffers: UINT; out ppVertexBuffers: PID3D11Buffer;
out pStrides: PUINT; out pOffsets: PUINT); stdcall;
i use this function failed
in Delphi XE8
var
pBuffers: array[0..32] of ID3D11Buffer;
pStrides: array[0..32] of UINT;
pOffsets: array[0..32] of UINT;
begin
ZeroMemory(@pBuffers,SizeOf(pBuffers));
ZeroMemory(@pStrides,SizeOf(pStrides));
ZeroMemory(@pOffsets,SizeOf(pOffsets));
g_pImmediateContext.IAGetVertexBuffers(0,32,@pBuffers[0],@pStrides[0],@pOffsets[0]);---build failed
end;
I modified to
procedure IAGetVertexBuffers(StartSlot: UINT; NumBuffers: UINT; out ppVertexBuffers: ID3D11Buffer;
out pStrides: UINT; out pOffsets: UINT); stdcall;
g_pImmediateContext.IAGetVertexBuffers(0,32,pBuffers[0],pStrides[0],pOffsets[0]);-- is ok
like this:
HRESULT CreateBitmapFromWicBitmap( [in] IWICBitmapSource *wicBitmapSource, [in, optional] const D2D1_BITMAP_PROPERTIES1 *bitmapProperties, [out] ID2D1Bitmap1 **bitmap );
ID2D1RenderTarget = interface(ID2D1Resource) ['{2cd90694-12e2-11dc-9fed-001143a055f9}'] function CreateBitmapFromWicBitmap(wicBitmapSource: IWICBitmapSource;bitmapProperties: PD2D1_BITMAP_PROPERTIES; out bitmap: ID2D1Bitmap): HResult; stdcall;
C++ [in, optional] const<> pascal "const"?
I just dropped at CodeProject an article called "Desktop Duplication API in Delphi" which uses your headers.
MSDN
`
UINT num = 0;
DXGI_FORMAT format = DXGI_FORMAT_R32G32B32A32_FLOAT;
UINT flags = DXGI_ENUM_MODES_INTERLACED;
pOutput->GetDisplayModeList1( format, flags, &num, 0);
...
DXGI_MODE_DESC1 * pDescs = new DXGI_MODE_DESC1[num];
pOutput->GetDisplayModeList1( format, flags, &num, pDescs);
`
that mean last param [pDesc] have not [out] flag because it can be [nil] to get number of Desc array;
The color definitions in the D2D1Helper section are wrong.
For example:
DarkSlateGray = $2F4F4F; // >> #2F4F4F works Ok in C++, but not in Delphi
should be
DarkSlateGray = $004F4F2F; // the correct Delphi TColor equivalent to DarkSlateGray
You can check this by enter the TColorvalue to a TForm.color.
I think the colorfields r and b are mixed up in Delphi.
A correct translation from TColor to D3DCOLORVALUE:
function D2D1TColorF(dcolor: TColor; {opacity} a: Single = 1.0): TD2D1ColorF; begin Result.r := ((dcolor AND $00FF0000) shr 16) / 255; Result.g := ((dcolor AND $0000FF00) shr 8) / 255; Result.b := ((dcolor AND $000000FF)) / 255; Result.a := a; end;
inline is nowdays fully supported in later versions of delphi and in freepascal.
can you add DirectXMath Unit?
In example WICAnimatedGIF
the file CMC.COMBaseAPI.pas is missing.
Found in https://github.com/CMCHTPC/WinUnits
unit AppUnitp.as does not compile
lazarus 2.0.12 complains
AppUnit.pas(418,101) Error: Incompatible type for arg no. 1: Got "TD2D_SIZE_F", expected "PD2D1_SIZE_F"
code changes :
(starting from line 376)
var
...
...
T : TD2D1_SIZE_F; // added 2021-04-22
begin
...
...
T:= DX12.D2D1.SizeF(m_cxGifImage, m_cyGifImage);
Result := m_pHwndRT.CreateCompatibleRenderTarget( @t, nil, nil,
MSDN:
`
HRESULT CreateSolidColorBrush(
[ref] const D2D1_COLOR_F &color,
[out] ID2D1SolidColorBrush **solidColorBrush
);
`
`
ID2D1RenderTarget = interface(ID2D1Resource)
['{2cd90694-12e2-11dc-9fed-001143a055f9}']
function CreateSolidColorBrush(const color: TD2D1_COLOR_F; {brushProperties: PD2D1_BRUSH_PROPERTIES;} out solidColorBrush: ID2D1SolidColorBrush): HResult; stdcall;
`
Windows header files have SAL annotations that make the indent of the code explicit. An example of such annotation is Out_writes_bytes. See the Annotating function parameters and return values topic. The SAL annotations should be ignored.
Example: In d2d1svg.h you have:
STDMETHOD(GetAttributeValue)(
_In_ PCWSTR name,
D2D1_SVG_ATTRIBUTE_POD_TYPE type,
_Out_writes_bytes_(valueSizeInBytes) void *value,
UINT32 valueSizeInBytes
) PURE;
This is translated as:
function GetAttributeValue(Name: PWideChar; AType: TD2D1_SVG_ATTRIBUTE_POD_TYPE; out Value: PByte;
valueSizeInBytes: UINT32): HResult; stdcall; overload;
This should be:
function GetAttributeValue(Name: PWideChar; AType: TD2D1_SVG_ATTRIBUTE_POD_TYPE; Value: Pointer;
valueSizeInBytes: UINT32): HResult; stdcall; overload;
The above has been tested and it works.
Tutorials / FPC / DirectX 12 / BraynzarSoft / Tut04
missing file DirectX.Math.pas
probably is in https://github.com/CMCHTPC/DirectXMath
both ID2D1DeviceContext & ID2D1RenderTarget exports CreateBitmapFromWicBitmap func,
MSDN:
CreateBitmapFromWicBitmap | Overloaded.Creates a Direct2D bitmap by copying a WIC bitmap.
ID2D1DeviceContext = interface(ID2D1RenderTarget) ['{e8f7fe7a-191c-466d-ad95-975678bda998}'] function CreateBitmap(size: TD2D1_SIZE_U; sourceData: Pointer; pitch: UINT32; bitmapProperties: PD2D1_BITMAP_PROPERTIES1; out bitmap: ID2D1Bitmap1): HResult; stdcall; function CreateBitmapFromWicBitmap(wicBitmapSource: IWICBitmapSource; const bitmapProperties: TD2D1_BITMAP_PROPERTIES1; out bitmap: ID2D1Bitmap1): HResult; stdcall;**overload;**
Error Code:
D2D DEBUG ERROR - An interface [006FE67C] not allocated by this DLL was passed to it.
Process PlayerDemo.exe (8572)
IWICImagingFactory2 is inherited from IWICImagingFactory;
and this interface function not declare!?
Perhaps use conditionals to remove operator overloads for Initialize in Delphi. {$ifdef fpc}{$endif}
Under Lazarus 2.0.12 - unit TextAnimation.pas
Compiler complains "TextAnimation.pas(568,71) Error: Incompatible type for arg no. 1: Got "TD2D_SIZE_F", expected "PD2D1_SIZE_F""
Instead, code compiles and runs with
"Result := m_pRT.CreateCompatibleRenderTarget( nil, ....."
Made the Samples in Samples_FPC/DirectComposition compile and run.
Is it possible you can add XAudio2 headers ?
These can be found in when jah install unreal game engine .. under
C:\Program Files\Epic Games\UE_4.19\Engine\Source\ThirdParty\Windows\DirectX\include\XAudio2.h
Would be perfect to have that
need Dcomp.pas and DCompTypes.pas;
thanks;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.