ホーム › Graphics.Direct2D › D2D1CreateDevice
D2D1CreateDevice
関数DXGIデバイスからDirect2Dデバイスを生成する。
シグネチャ
// d2d1.dll
#include <windows.h>
HRESULT D2D1CreateDevice(
IDXGIDevice* dxgiDevice,
const D2D1_CREATION_PROPERTIES* creationProperties, // optional
ID2D1Device** d2dDevice
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dxgiDevice | IDXGIDevice* | in |
| creationProperties | D2D1_CREATION_PROPERTIES* | inoptional |
| d2dDevice | ID2D1Device** | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// d2d1.dll
#include <windows.h>
HRESULT D2D1CreateDevice(
IDXGIDevice* dxgiDevice,
const D2D1_CREATION_PROPERTIES* creationProperties, // optional
ID2D1Device** d2dDevice
);[DllImport("d2d1.dll", ExactSpelling = true)]
static extern int D2D1CreateDevice(
IntPtr dxgiDevice, // IDXGIDevice*
IntPtr creationProperties, // D2D1_CREATION_PROPERTIES* optional
IntPtr d2dDevice // ID2D1Device** out
);<DllImport("d2d1.dll", ExactSpelling:=True)>
Public Shared Function D2D1CreateDevice(
dxgiDevice As IntPtr, ' IDXGIDevice*
creationProperties As IntPtr, ' D2D1_CREATION_PROPERTIES* optional
d2dDevice As IntPtr ' ID2D1Device** out
) As Integer
End Function' dxgiDevice : IDXGIDevice*
' creationProperties : D2D1_CREATION_PROPERTIES* optional
' d2dDevice : ID2D1Device** out
Declare PtrSafe Function D2D1CreateDevice Lib "d2d1" ( _
ByVal dxgiDevice As LongPtr, _
ByVal creationProperties As LongPtr, _
ByVal d2dDevice As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
D2D1CreateDevice = ctypes.windll.d2d1.D2D1CreateDevice
D2D1CreateDevice.restype = ctypes.c_int
D2D1CreateDevice.argtypes = [
ctypes.c_void_p, # dxgiDevice : IDXGIDevice*
ctypes.c_void_p, # creationProperties : D2D1_CREATION_PROPERTIES* optional
ctypes.c_void_p, # d2dDevice : ID2D1Device** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('d2d1.dll')
D2D1CreateDevice = Fiddle::Function.new(
lib['D2D1CreateDevice'],
[
Fiddle::TYPE_VOIDP, # dxgiDevice : IDXGIDevice*
Fiddle::TYPE_VOIDP, # creationProperties : D2D1_CREATION_PROPERTIES* optional
Fiddle::TYPE_VOIDP, # d2dDevice : ID2D1Device** out
],
Fiddle::TYPE_INT)#[link(name = "d2d1")]
extern "system" {
fn D2D1CreateDevice(
dxgiDevice: *mut core::ffi::c_void, // IDXGIDevice*
creationProperties: *const D2D1_CREATION_PROPERTIES, // D2D1_CREATION_PROPERTIES* optional
d2dDevice: *mut *mut core::ffi::c_void // ID2D1Device** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("d2d1.dll")]
public static extern int D2D1CreateDevice(IntPtr dxgiDevice, IntPtr creationProperties, IntPtr d2dDevice);
"@
$api = Add-Type -MemberDefinition $sig -Name 'd2d1_D2D1CreateDevice' -Namespace Win32 -PassThru
# $api::D2D1CreateDevice(dxgiDevice, creationProperties, d2dDevice)#uselib "d2d1.dll"
#func global D2D1CreateDevice "D2D1CreateDevice" sptr, sptr, sptr
; D2D1CreateDevice dxgiDevice, varptr(creationProperties), d2dDevice ; 戻り値は stat
; dxgiDevice : IDXGIDevice* -> "sptr"
; creationProperties : D2D1_CREATION_PROPERTIES* optional -> "sptr"
; d2dDevice : ID2D1Device** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "d2d1.dll" #cfunc global D2D1CreateDevice "D2D1CreateDevice" sptr, var, sptr ; res = D2D1CreateDevice(dxgiDevice, creationProperties, d2dDevice) ; dxgiDevice : IDXGIDevice* -> "sptr" ; creationProperties : D2D1_CREATION_PROPERTIES* optional -> "var" ; d2dDevice : ID2D1Device** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "d2d1.dll" #cfunc global D2D1CreateDevice "D2D1CreateDevice" sptr, sptr, sptr ; res = D2D1CreateDevice(dxgiDevice, varptr(creationProperties), d2dDevice) ; dxgiDevice : IDXGIDevice* -> "sptr" ; creationProperties : D2D1_CREATION_PROPERTIES* optional -> "sptr" ; d2dDevice : ID2D1Device** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT D2D1CreateDevice(IDXGIDevice* dxgiDevice, D2D1_CREATION_PROPERTIES* creationProperties, ID2D1Device** d2dDevice) #uselib "d2d1.dll" #cfunc global D2D1CreateDevice "D2D1CreateDevice" intptr, var, intptr ; res = D2D1CreateDevice(dxgiDevice, creationProperties, d2dDevice) ; dxgiDevice : IDXGIDevice* -> "intptr" ; creationProperties : D2D1_CREATION_PROPERTIES* optional -> "var" ; d2dDevice : ID2D1Device** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT D2D1CreateDevice(IDXGIDevice* dxgiDevice, D2D1_CREATION_PROPERTIES* creationProperties, ID2D1Device** d2dDevice) #uselib "d2d1.dll" #cfunc global D2D1CreateDevice "D2D1CreateDevice" intptr, intptr, intptr ; res = D2D1CreateDevice(dxgiDevice, varptr(creationProperties), d2dDevice) ; dxgiDevice : IDXGIDevice* -> "intptr" ; creationProperties : D2D1_CREATION_PROPERTIES* optional -> "intptr" ; d2dDevice : ID2D1Device** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
d2d1 = windows.NewLazySystemDLL("d2d1.dll")
procD2D1CreateDevice = d2d1.NewProc("D2D1CreateDevice")
)
// dxgiDevice (IDXGIDevice*), creationProperties (D2D1_CREATION_PROPERTIES* optional), d2dDevice (ID2D1Device** out)
r1, _, err := procD2D1CreateDevice.Call(
uintptr(dxgiDevice),
uintptr(creationProperties),
uintptr(d2dDevice),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction D2D1CreateDevice(
dxgiDevice: Pointer; // IDXGIDevice*
creationProperties: Pointer; // D2D1_CREATION_PROPERTIES* optional
d2dDevice: Pointer // ID2D1Device** out
): Integer; stdcall;
external 'd2d1.dll' name 'D2D1CreateDevice';result := DllCall("d2d1\D2D1CreateDevice"
, "Ptr", dxgiDevice ; IDXGIDevice*
, "Ptr", creationProperties ; D2D1_CREATION_PROPERTIES* optional
, "Ptr", d2dDevice ; ID2D1Device** out
, "Int") ; return: HRESULT●D2D1CreateDevice(dxgiDevice, creationProperties, d2dDevice) = DLL("d2d1.dll", "int D2D1CreateDevice(void*, void*, void*)")
# 呼び出し: D2D1CreateDevice(dxgiDevice, creationProperties, d2dDevice)
# dxgiDevice : IDXGIDevice* -> "void*"
# creationProperties : D2D1_CREATION_PROPERTIES* optional -> "void*"
# d2dDevice : ID2D1Device** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。