Win32 API 日本語リファレンス
ホームGraphics.Direct3D11 › D3D11CreateDevice

D3D11CreateDevice

関数
Direct3D11デバイスとイミディエイトコンテキストを作成する。
DLLd3d11.dll呼出規約winapi

シグネチャ

// d3d11.dll
#include <windows.h>

HRESULT D3D11CreateDevice(
    IDXGIAdapter* pAdapter,   // optional
    D3D_DRIVER_TYPE DriverType,
    HMODULE Software,   // optional
    D3D11_CREATE_DEVICE_FLAG Flags,
    const D3D_FEATURE_LEVEL* pFeatureLevels,   // optional
    DWORD FeatureLevels,
    DWORD SDKVersion,
    ID3D11Device** ppDevice,   // optional
    D3D_FEATURE_LEVEL* pFeatureLevel,   // optional
    ID3D11DeviceContext** ppImmediateContext   // optional
);

パラメーター

名前方向
pAdapterIDXGIAdapter*inoptional
DriverTypeD3D_DRIVER_TYPEin
SoftwareHMODULEoptional
FlagsD3D11_CREATE_DEVICE_FLAGin
pFeatureLevelsD3D_FEATURE_LEVEL*inoptional
FeatureLevelsDWORDin
SDKVersionDWORDin
ppDeviceID3D11Device**outoptional
pFeatureLevelD3D_FEATURE_LEVEL*outoptional
ppImmediateContextID3D11DeviceContext**outoptional

戻り値の型: HRESULT

各言語での呼び出し定義

// d3d11.dll
#include <windows.h>

HRESULT D3D11CreateDevice(
    IDXGIAdapter* pAdapter,   // optional
    D3D_DRIVER_TYPE DriverType,
    HMODULE Software,   // optional
    D3D11_CREATE_DEVICE_FLAG Flags,
    const D3D_FEATURE_LEVEL* pFeatureLevels,   // optional
    DWORD FeatureLevels,
    DWORD SDKVersion,
    ID3D11Device** ppDevice,   // optional
    D3D_FEATURE_LEVEL* pFeatureLevel,   // optional
    ID3D11DeviceContext** ppImmediateContext   // optional
);
[DllImport("d3d11.dll", ExactSpelling = true)]
static extern int D3D11CreateDevice(
    IntPtr pAdapter,   // IDXGIAdapter* optional
    int DriverType,   // D3D_DRIVER_TYPE
    IntPtr Software,   // HMODULE optional
    uint Flags,   // D3D11_CREATE_DEVICE_FLAG
    IntPtr pFeatureLevels,   // D3D_FEATURE_LEVEL* optional
    uint FeatureLevels,   // DWORD
    uint SDKVersion,   // DWORD
    IntPtr ppDevice,   // ID3D11Device** optional, out
    IntPtr pFeatureLevel,   // D3D_FEATURE_LEVEL* optional, out
    IntPtr ppImmediateContext   // ID3D11DeviceContext** optional, out
);
<DllImport("d3d11.dll", ExactSpelling:=True)>
Public Shared Function D3D11CreateDevice(
    pAdapter As IntPtr,   ' IDXGIAdapter* optional
    DriverType As Integer,   ' D3D_DRIVER_TYPE
    Software As IntPtr,   ' HMODULE optional
    Flags As UInteger,   ' D3D11_CREATE_DEVICE_FLAG
    pFeatureLevels As IntPtr,   ' D3D_FEATURE_LEVEL* optional
    FeatureLevels As UInteger,   ' DWORD
    SDKVersion As UInteger,   ' DWORD
    ppDevice As IntPtr,   ' ID3D11Device** optional, out
    pFeatureLevel As IntPtr,   ' D3D_FEATURE_LEVEL* optional, out
    ppImmediateContext As IntPtr   ' ID3D11DeviceContext** optional, out
) As Integer
End Function
' pAdapter : IDXGIAdapter* optional
' DriverType : D3D_DRIVER_TYPE
' Software : HMODULE optional
' Flags : D3D11_CREATE_DEVICE_FLAG
' pFeatureLevels : D3D_FEATURE_LEVEL* optional
' FeatureLevels : DWORD
' SDKVersion : DWORD
' ppDevice : ID3D11Device** optional, out
' pFeatureLevel : D3D_FEATURE_LEVEL* optional, out
' ppImmediateContext : ID3D11DeviceContext** optional, out
Declare PtrSafe Function D3D11CreateDevice Lib "d3d11" ( _
    ByVal pAdapter As LongPtr, _
    ByVal DriverType As Long, _
    ByVal Software As LongPtr, _
    ByVal Flags As Long, _
    ByVal pFeatureLevels As LongPtr, _
    ByVal FeatureLevels As Long, _
    ByVal SDKVersion As Long, _
    ByVal ppDevice As LongPtr, _
    ByVal pFeatureLevel As LongPtr, _
    ByVal ppImmediateContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

D3D11CreateDevice = ctypes.windll.d3d11.D3D11CreateDevice
D3D11CreateDevice.restype = ctypes.c_int
D3D11CreateDevice.argtypes = [
    ctypes.c_void_p,  # pAdapter : IDXGIAdapter* optional
    ctypes.c_int,  # DriverType : D3D_DRIVER_TYPE
    wintypes.HANDLE,  # Software : HMODULE optional
    wintypes.DWORD,  # Flags : D3D11_CREATE_DEVICE_FLAG
    ctypes.c_void_p,  # pFeatureLevels : D3D_FEATURE_LEVEL* optional
    wintypes.DWORD,  # FeatureLevels : DWORD
    wintypes.DWORD,  # SDKVersion : DWORD
    ctypes.c_void_p,  # ppDevice : ID3D11Device** optional, out
    ctypes.c_void_p,  # pFeatureLevel : D3D_FEATURE_LEVEL* optional, out
    ctypes.c_void_p,  # ppImmediateContext : ID3D11DeviceContext** optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('d3d11.dll')
D3D11CreateDevice = Fiddle::Function.new(
  lib['D3D11CreateDevice'],
  [
    Fiddle::TYPE_VOIDP,  # pAdapter : IDXGIAdapter* optional
    Fiddle::TYPE_INT,  # DriverType : D3D_DRIVER_TYPE
    Fiddle::TYPE_VOIDP,  # Software : HMODULE optional
    -Fiddle::TYPE_INT,  # Flags : D3D11_CREATE_DEVICE_FLAG
    Fiddle::TYPE_VOIDP,  # pFeatureLevels : D3D_FEATURE_LEVEL* optional
    -Fiddle::TYPE_INT,  # FeatureLevels : DWORD
    -Fiddle::TYPE_INT,  # SDKVersion : DWORD
    Fiddle::TYPE_VOIDP,  # ppDevice : ID3D11Device** optional, out
    Fiddle::TYPE_VOIDP,  # pFeatureLevel : D3D_FEATURE_LEVEL* optional, out
    Fiddle::TYPE_VOIDP,  # ppImmediateContext : ID3D11DeviceContext** optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "d3d11")]
extern "system" {
    fn D3D11CreateDevice(
        pAdapter: *mut core::ffi::c_void,  // IDXGIAdapter* optional
        DriverType: i32,  // D3D_DRIVER_TYPE
        Software: *mut core::ffi::c_void,  // HMODULE optional
        Flags: u32,  // D3D11_CREATE_DEVICE_FLAG
        pFeatureLevels: *const i32,  // D3D_FEATURE_LEVEL* optional
        FeatureLevels: u32,  // DWORD
        SDKVersion: u32,  // DWORD
        ppDevice: *mut *mut core::ffi::c_void,  // ID3D11Device** optional, out
        pFeatureLevel: *mut i32,  // D3D_FEATURE_LEVEL* optional, out
        ppImmediateContext: *mut *mut core::ffi::c_void  // ID3D11DeviceContext** optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("d3d11.dll")]
public static extern int D3D11CreateDevice(IntPtr pAdapter, int DriverType, IntPtr Software, uint Flags, IntPtr pFeatureLevels, uint FeatureLevels, uint SDKVersion, IntPtr ppDevice, IntPtr pFeatureLevel, IntPtr ppImmediateContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'd3d11_D3D11CreateDevice' -Namespace Win32 -PassThru
# $api::D3D11CreateDevice(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext)
#uselib "d3d11.dll"
#func global D3D11CreateDevice "D3D11CreateDevice" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; D3D11CreateDevice pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext   ; 戻り値は stat
; pAdapter : IDXGIAdapter* optional -> "sptr"
; DriverType : D3D_DRIVER_TYPE -> "sptr"
; Software : HMODULE optional -> "sptr"
; Flags : D3D11_CREATE_DEVICE_FLAG -> "sptr"
; pFeatureLevels : D3D_FEATURE_LEVEL* optional -> "sptr"
; FeatureLevels : DWORD -> "sptr"
; SDKVersion : DWORD -> "sptr"
; ppDevice : ID3D11Device** optional, out -> "sptr"
; pFeatureLevel : D3D_FEATURE_LEVEL* optional, out -> "sptr"
; ppImmediateContext : ID3D11DeviceContext** optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "d3d11.dll"
#cfunc global D3D11CreateDevice "D3D11CreateDevice" sptr, int, sptr, int, int, int, int, sptr, int, sptr
; res = D3D11CreateDevice(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext)
; pAdapter : IDXGIAdapter* optional -> "sptr"
; DriverType : D3D_DRIVER_TYPE -> "int"
; Software : HMODULE optional -> "sptr"
; Flags : D3D11_CREATE_DEVICE_FLAG -> "int"
; pFeatureLevels : D3D_FEATURE_LEVEL* optional -> "int"
; FeatureLevels : DWORD -> "int"
; SDKVersion : DWORD -> "int"
; ppDevice : ID3D11Device** optional, out -> "sptr"
; pFeatureLevel : D3D_FEATURE_LEVEL* optional, out -> "int"
; ppImmediateContext : ID3D11DeviceContext** optional, out -> "sptr"
; HRESULT D3D11CreateDevice(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, D3D11_CREATE_DEVICE_FLAG Flags, D3D_FEATURE_LEVEL* pFeatureLevels, DWORD FeatureLevels, DWORD SDKVersion, ID3D11Device** ppDevice, D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext)
#uselib "d3d11.dll"
#cfunc global D3D11CreateDevice "D3D11CreateDevice" intptr, int, intptr, int, int, int, int, intptr, int, intptr
; res = D3D11CreateDevice(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext)
; pAdapter : IDXGIAdapter* optional -> "intptr"
; DriverType : D3D_DRIVER_TYPE -> "int"
; Software : HMODULE optional -> "intptr"
; Flags : D3D11_CREATE_DEVICE_FLAG -> "int"
; pFeatureLevels : D3D_FEATURE_LEVEL* optional -> "int"
; FeatureLevels : DWORD -> "int"
; SDKVersion : DWORD -> "int"
; ppDevice : ID3D11Device** optional, out -> "intptr"
; pFeatureLevel : D3D_FEATURE_LEVEL* optional, out -> "int"
; ppImmediateContext : ID3D11DeviceContext** optional, out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	d3d11 = windows.NewLazySystemDLL("d3d11.dll")
	procD3D11CreateDevice = d3d11.NewProc("D3D11CreateDevice")
)

// pAdapter (IDXGIAdapter* optional), DriverType (D3D_DRIVER_TYPE), Software (HMODULE optional), Flags (D3D11_CREATE_DEVICE_FLAG), pFeatureLevels (D3D_FEATURE_LEVEL* optional), FeatureLevels (DWORD), SDKVersion (DWORD), ppDevice (ID3D11Device** optional, out), pFeatureLevel (D3D_FEATURE_LEVEL* optional, out), ppImmediateContext (ID3D11DeviceContext** optional, out)
r1, _, err := procD3D11CreateDevice.Call(
	uintptr(pAdapter),
	uintptr(DriverType),
	uintptr(Software),
	uintptr(Flags),
	uintptr(pFeatureLevels),
	uintptr(FeatureLevels),
	uintptr(SDKVersion),
	uintptr(ppDevice),
	uintptr(pFeatureLevel),
	uintptr(ppImmediateContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function D3D11CreateDevice(
  pAdapter: Pointer;   // IDXGIAdapter* optional
  DriverType: Integer;   // D3D_DRIVER_TYPE
  Software: THandle;   // HMODULE optional
  Flags: DWORD;   // D3D11_CREATE_DEVICE_FLAG
  pFeatureLevels: Pointer;   // D3D_FEATURE_LEVEL* optional
  FeatureLevels: DWORD;   // DWORD
  SDKVersion: DWORD;   // DWORD
  ppDevice: Pointer;   // ID3D11Device** optional, out
  pFeatureLevel: Pointer;   // D3D_FEATURE_LEVEL* optional, out
  ppImmediateContext: Pointer   // ID3D11DeviceContext** optional, out
): Integer; stdcall;
  external 'd3d11.dll' name 'D3D11CreateDevice';
result := DllCall("d3d11\D3D11CreateDevice"
    , "Ptr", pAdapter   ; IDXGIAdapter* optional
    , "Int", DriverType   ; D3D_DRIVER_TYPE
    , "Ptr", Software   ; HMODULE optional
    , "UInt", Flags   ; D3D11_CREATE_DEVICE_FLAG
    , "Ptr", pFeatureLevels   ; D3D_FEATURE_LEVEL* optional
    , "UInt", FeatureLevels   ; DWORD
    , "UInt", SDKVersion   ; DWORD
    , "Ptr", ppDevice   ; ID3D11Device** optional, out
    , "Ptr", pFeatureLevel   ; D3D_FEATURE_LEVEL* optional, out
    , "Ptr", ppImmediateContext   ; ID3D11DeviceContext** optional, out
    , "Int")   ; return: HRESULT
●D3D11CreateDevice(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext) = DLL("d3d11.dll", "int D3D11CreateDevice(void*, int, void*, dword, void*, dword, dword, void*, void*, void*)")
# 呼び出し: D3D11CreateDevice(pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion, ppDevice, pFeatureLevel, ppImmediateContext)
# pAdapter : IDXGIAdapter* optional -> "void*"
# DriverType : D3D_DRIVER_TYPE -> "int"
# Software : HMODULE optional -> "void*"
# Flags : D3D11_CREATE_DEVICE_FLAG -> "dword"
# pFeatureLevels : D3D_FEATURE_LEVEL* optional -> "void*"
# FeatureLevels : DWORD -> "dword"
# SDKVersion : DWORD -> "dword"
# ppDevice : ID3D11Device** optional, out -> "void*"
# pFeatureLevel : D3D_FEATURE_LEVEL* optional, out -> "void*"
# ppImmediateContext : ID3D11DeviceContext** optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。