ホーム › Graphics.Direct3D10 › D3D10CreateDevice
D3D10CreateDevice
関数Direct3D10デバイスを作成しグラフィックスアダプターを初期化する。
シグネチャ
// d3d10.dll
#include <windows.h>
HRESULT D3D10CreateDevice(
IDXGIAdapter* pAdapter, // optional
D3D10_DRIVER_TYPE DriverType,
HMODULE Software,
DWORD Flags,
DWORD SDKVersion,
ID3D10Device** ppDevice // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pAdapter | IDXGIAdapter* | inoptional | 使用するディスプレイアダプターのIDXGIAdapter。NULLで既定アダプターを使う。 |
| DriverType | D3D10_DRIVER_TYPE | in | ハードウェアやリファレンス等のドライバー種別を示す列挙値。 |
| Software | HMODULE | in | ソフトウェアラスタライザーDLLのモジュールハンドル。通常NULL。 |
| Flags | DWORD | in | デバイス生成時の動作を制御するD3D10_CREATE_DEVICE_FLAGの組み合わせ。 |
| SDKVersion | DWORD | in | ビルド対象のSDKバージョン。D3D10_SDK_VERSIONを指定する。 |
| ppDevice | ID3D10Device** | outoptional | 生成されたID3D10Deviceを受け取る出力ポインター。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// d3d10.dll
#include <windows.h>
HRESULT D3D10CreateDevice(
IDXGIAdapter* pAdapter, // optional
D3D10_DRIVER_TYPE DriverType,
HMODULE Software,
DWORD Flags,
DWORD SDKVersion,
ID3D10Device** ppDevice // optional
);[DllImport("d3d10.dll", ExactSpelling = true)]
static extern int D3D10CreateDevice(
IntPtr pAdapter, // IDXGIAdapter* optional
int DriverType, // D3D10_DRIVER_TYPE
IntPtr Software, // HMODULE
uint Flags, // DWORD
uint SDKVersion, // DWORD
IntPtr ppDevice // ID3D10Device** optional, out
);<DllImport("d3d10.dll", ExactSpelling:=True)>
Public Shared Function D3D10CreateDevice(
pAdapter As IntPtr, ' IDXGIAdapter* optional
DriverType As Integer, ' D3D10_DRIVER_TYPE
Software As IntPtr, ' HMODULE
Flags As UInteger, ' DWORD
SDKVersion As UInteger, ' DWORD
ppDevice As IntPtr ' ID3D10Device** optional, out
) As Integer
End Function' pAdapter : IDXGIAdapter* optional
' DriverType : D3D10_DRIVER_TYPE
' Software : HMODULE
' Flags : DWORD
' SDKVersion : DWORD
' ppDevice : ID3D10Device** optional, out
Declare PtrSafe Function D3D10CreateDevice Lib "d3d10" ( _
ByVal pAdapter As LongPtr, _
ByVal DriverType As Long, _
ByVal Software As LongPtr, _
ByVal Flags As Long, _
ByVal SDKVersion As Long, _
ByVal ppDevice As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
D3D10CreateDevice = ctypes.windll.d3d10.D3D10CreateDevice
D3D10CreateDevice.restype = ctypes.c_int
D3D10CreateDevice.argtypes = [
ctypes.c_void_p, # pAdapter : IDXGIAdapter* optional
ctypes.c_int, # DriverType : D3D10_DRIVER_TYPE
wintypes.HANDLE, # Software : HMODULE
wintypes.DWORD, # Flags : DWORD
wintypes.DWORD, # SDKVersion : DWORD
ctypes.c_void_p, # ppDevice : ID3D10Device** optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('d3d10.dll')
D3D10CreateDevice = Fiddle::Function.new(
lib['D3D10CreateDevice'],
[
Fiddle::TYPE_VOIDP, # pAdapter : IDXGIAdapter* optional
Fiddle::TYPE_INT, # DriverType : D3D10_DRIVER_TYPE
Fiddle::TYPE_VOIDP, # Software : HMODULE
-Fiddle::TYPE_INT, # Flags : DWORD
-Fiddle::TYPE_INT, # SDKVersion : DWORD
Fiddle::TYPE_VOIDP, # ppDevice : ID3D10Device** optional, out
],
Fiddle::TYPE_INT)#[link(name = "d3d10")]
extern "system" {
fn D3D10CreateDevice(
pAdapter: *mut core::ffi::c_void, // IDXGIAdapter* optional
DriverType: i32, // D3D10_DRIVER_TYPE
Software: *mut core::ffi::c_void, // HMODULE
Flags: u32, // DWORD
SDKVersion: u32, // DWORD
ppDevice: *mut *mut core::ffi::c_void // ID3D10Device** optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("d3d10.dll")]
public static extern int D3D10CreateDevice(IntPtr pAdapter, int DriverType, IntPtr Software, uint Flags, uint SDKVersion, IntPtr ppDevice);
"@
$api = Add-Type -MemberDefinition $sig -Name 'd3d10_D3D10CreateDevice' -Namespace Win32 -PassThru
# $api::D3D10CreateDevice(pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice)#uselib "d3d10.dll"
#func global D3D10CreateDevice "D3D10CreateDevice" sptr, sptr, sptr, sptr, sptr, sptr
; D3D10CreateDevice pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice ; 戻り値は stat
; pAdapter : IDXGIAdapter* optional -> "sptr"
; DriverType : D3D10_DRIVER_TYPE -> "sptr"
; Software : HMODULE -> "sptr"
; Flags : DWORD -> "sptr"
; SDKVersion : DWORD -> "sptr"
; ppDevice : ID3D10Device** optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "d3d10.dll"
#cfunc global D3D10CreateDevice "D3D10CreateDevice" sptr, int, sptr, int, int, sptr
; res = D3D10CreateDevice(pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice)
; pAdapter : IDXGIAdapter* optional -> "sptr"
; DriverType : D3D10_DRIVER_TYPE -> "int"
; Software : HMODULE -> "sptr"
; Flags : DWORD -> "int"
; SDKVersion : DWORD -> "int"
; ppDevice : ID3D10Device** optional, out -> "sptr"; HRESULT D3D10CreateDevice(IDXGIAdapter* pAdapter, D3D10_DRIVER_TYPE DriverType, HMODULE Software, DWORD Flags, DWORD SDKVersion, ID3D10Device** ppDevice)
#uselib "d3d10.dll"
#cfunc global D3D10CreateDevice "D3D10CreateDevice" intptr, int, intptr, int, int, intptr
; res = D3D10CreateDevice(pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice)
; pAdapter : IDXGIAdapter* optional -> "intptr"
; DriverType : D3D10_DRIVER_TYPE -> "int"
; Software : HMODULE -> "intptr"
; Flags : DWORD -> "int"
; SDKVersion : DWORD -> "int"
; ppDevice : ID3D10Device** optional, out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
d3d10 = windows.NewLazySystemDLL("d3d10.dll")
procD3D10CreateDevice = d3d10.NewProc("D3D10CreateDevice")
)
// pAdapter (IDXGIAdapter* optional), DriverType (D3D10_DRIVER_TYPE), Software (HMODULE), Flags (DWORD), SDKVersion (DWORD), ppDevice (ID3D10Device** optional, out)
r1, _, err := procD3D10CreateDevice.Call(
uintptr(pAdapter),
uintptr(DriverType),
uintptr(Software),
uintptr(Flags),
uintptr(SDKVersion),
uintptr(ppDevice),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction D3D10CreateDevice(
pAdapter: Pointer; // IDXGIAdapter* optional
DriverType: Integer; // D3D10_DRIVER_TYPE
Software: THandle; // HMODULE
Flags: DWORD; // DWORD
SDKVersion: DWORD; // DWORD
ppDevice: Pointer // ID3D10Device** optional, out
): Integer; stdcall;
external 'd3d10.dll' name 'D3D10CreateDevice';result := DllCall("d3d10\D3D10CreateDevice"
, "Ptr", pAdapter ; IDXGIAdapter* optional
, "Int", DriverType ; D3D10_DRIVER_TYPE
, "Ptr", Software ; HMODULE
, "UInt", Flags ; DWORD
, "UInt", SDKVersion ; DWORD
, "Ptr", ppDevice ; ID3D10Device** optional, out
, "Int") ; return: HRESULT●D3D10CreateDevice(pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice) = DLL("d3d10.dll", "int D3D10CreateDevice(void*, int, void*, dword, dword, void*)")
# 呼び出し: D3D10CreateDevice(pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice)
# pAdapter : IDXGIAdapter* optional -> "void*"
# DriverType : D3D10_DRIVER_TYPE -> "int"
# Software : HMODULE -> "void*"
# Flags : DWORD -> "dword"
# SDKVersion : DWORD -> "dword"
# ppDevice : ID3D10Device** optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "d3d10" fn D3D10CreateDevice(
pAdapter: ?*anyopaque, // IDXGIAdapter* optional
DriverType: i32, // D3D10_DRIVER_TYPE
Software: ?*anyopaque, // HMODULE
Flags: u32, // DWORD
SDKVersion: u32, // DWORD
ppDevice: ?*anyopaque // ID3D10Device** optional, out
) callconv(std.os.windows.WINAPI) i32;proc D3D10CreateDevice(
pAdapter: pointer, # IDXGIAdapter* optional
DriverType: int32, # D3D10_DRIVER_TYPE
Software: pointer, # HMODULE
Flags: uint32, # DWORD
SDKVersion: uint32, # DWORD
ppDevice: pointer # ID3D10Device** optional, out
): int32 {.importc: "D3D10CreateDevice", stdcall, dynlib: "d3d10.dll".}pragma(lib, "d3d10");
extern(Windows)
int D3D10CreateDevice(
void* pAdapter, // IDXGIAdapter* optional
int DriverType, // D3D10_DRIVER_TYPE
void* Software, // HMODULE
uint Flags, // DWORD
uint SDKVersion, // DWORD
void* ppDevice // ID3D10Device** optional, out
);ccall((:D3D10CreateDevice, "d3d10.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32, Ptr{Cvoid}, UInt32, UInt32, Ptr{Cvoid}),
pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice)
# pAdapter : IDXGIAdapter* optional -> Ptr{Cvoid}
# DriverType : D3D10_DRIVER_TYPE -> Int32
# Software : HMODULE -> Ptr{Cvoid}
# Flags : DWORD -> UInt32
# SDKVersion : DWORD -> UInt32
# ppDevice : ID3D10Device** optional, out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t D3D10CreateDevice(
void* pAdapter,
int32_t DriverType,
void* Software,
uint32_t Flags,
uint32_t SDKVersion,
void* ppDevice);
]]
local d3d10 = ffi.load("d3d10")
-- d3d10.D3D10CreateDevice(pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice)
-- pAdapter : IDXGIAdapter* optional
-- DriverType : D3D10_DRIVER_TYPE
-- Software : HMODULE
-- Flags : DWORD
-- SDKVersion : DWORD
-- ppDevice : ID3D10Device** optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('d3d10.dll');
const D3D10CreateDevice = lib.func('__stdcall', 'D3D10CreateDevice', 'int32_t', ['void *', 'int32_t', 'void *', 'uint32_t', 'uint32_t', 'void *']);
// D3D10CreateDevice(pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice)
// pAdapter : IDXGIAdapter* optional -> 'void *'
// DriverType : D3D10_DRIVER_TYPE -> 'int32_t'
// Software : HMODULE -> 'void *'
// Flags : DWORD -> 'uint32_t'
// SDKVersion : DWORD -> 'uint32_t'
// ppDevice : ID3D10Device** optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("d3d10.dll", {
D3D10CreateDevice: { parameters: ["pointer", "i32", "pointer", "u32", "u32", "pointer"], result: "i32" },
});
// lib.symbols.D3D10CreateDevice(pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice)
// pAdapter : IDXGIAdapter* optional -> "pointer"
// DriverType : D3D10_DRIVER_TYPE -> "i32"
// Software : HMODULE -> "pointer"
// Flags : DWORD -> "u32"
// SDKVersion : DWORD -> "u32"
// ppDevice : ID3D10Device** optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t D3D10CreateDevice(
void* pAdapter,
int32_t DriverType,
void* Software,
uint32_t Flags,
uint32_t SDKVersion,
void* ppDevice);
C, "d3d10.dll");
// $ffi->D3D10CreateDevice(pAdapter, DriverType, Software, Flags, SDKVersion, ppDevice);
// pAdapter : IDXGIAdapter* optional
// DriverType : D3D10_DRIVER_TYPE
// Software : HMODULE
// Flags : DWORD
// SDKVersion : DWORD
// ppDevice : ID3D10Device** optional, out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface D3d10 extends StdCallLibrary {
D3d10 INSTANCE = Native.load("d3d10", D3d10.class);
int D3D10CreateDevice(
Pointer pAdapter, // IDXGIAdapter* optional
int DriverType, // D3D10_DRIVER_TYPE
Pointer Software, // HMODULE
int Flags, // DWORD
int SDKVersion, // DWORD
Pointer ppDevice // ID3D10Device** optional, out
);
}@[Link("d3d10")]
lib Libd3d10
fun D3D10CreateDevice = D3D10CreateDevice(
pAdapter : Void*, # IDXGIAdapter* optional
DriverType : Int32, # D3D10_DRIVER_TYPE
Software : Void*, # HMODULE
Flags : UInt32, # DWORD
SDKVersion : UInt32, # DWORD
ppDevice : Void* # ID3D10Device** optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef D3D10CreateDeviceNative = Int32 Function(Pointer<Void>, Int32, Pointer<Void>, Uint32, Uint32, Pointer<Void>);
typedef D3D10CreateDeviceDart = int Function(Pointer<Void>, int, Pointer<Void>, int, int, Pointer<Void>);
final D3D10CreateDevice = DynamicLibrary.open('d3d10.dll')
.lookupFunction<D3D10CreateDeviceNative, D3D10CreateDeviceDart>('D3D10CreateDevice');
// pAdapter : IDXGIAdapter* optional -> Pointer<Void>
// DriverType : D3D10_DRIVER_TYPE -> Int32
// Software : HMODULE -> Pointer<Void>
// Flags : DWORD -> Uint32
// SDKVersion : DWORD -> Uint32
// ppDevice : ID3D10Device** optional, out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function D3D10CreateDevice(
pAdapter: Pointer; // IDXGIAdapter* optional
DriverType: Integer; // D3D10_DRIVER_TYPE
Software: THandle; // HMODULE
Flags: DWORD; // DWORD
SDKVersion: DWORD; // DWORD
ppDevice: Pointer // ID3D10Device** optional, out
): Integer; stdcall;
external 'd3d10.dll' name 'D3D10CreateDevice';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "D3D10CreateDevice"
c_D3D10CreateDevice :: Ptr () -> Int32 -> Ptr () -> Word32 -> Word32 -> Ptr () -> IO Int32
-- pAdapter : IDXGIAdapter* optional -> Ptr ()
-- DriverType : D3D10_DRIVER_TYPE -> Int32
-- Software : HMODULE -> Ptr ()
-- Flags : DWORD -> Word32
-- SDKVersion : DWORD -> Word32
-- ppDevice : ID3D10Device** optional, out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let d3d10createdevice =
foreign "D3D10CreateDevice"
((ptr void) @-> int32_t @-> (ptr void) @-> uint32_t @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* pAdapter : IDXGIAdapter* optional -> (ptr void) *)
(* DriverType : D3D10_DRIVER_TYPE -> int32_t *)
(* Software : HMODULE -> (ptr void) *)
(* Flags : DWORD -> uint32_t *)
(* SDKVersion : DWORD -> uint32_t *)
(* ppDevice : ID3D10Device** optional, out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library d3d10 (t "d3d10.dll"))
(cffi:use-foreign-library d3d10)
(cffi:defcfun ("D3D10CreateDevice" d3-d10-create-device :convention :stdcall) :int32
(p-adapter :pointer) ; IDXGIAdapter* optional
(driver-type :int32) ; D3D10_DRIVER_TYPE
(software :pointer) ; HMODULE
(flags :uint32) ; DWORD
(sdkversion :uint32) ; DWORD
(pp-device :pointer)) ; ID3D10Device** optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $D3D10CreateDevice = Win32::API::More->new('d3d10',
'int D3D10CreateDevice(LPVOID pAdapter, int DriverType, HANDLE Software, DWORD Flags, DWORD SDKVersion, LPVOID ppDevice)');
# my $ret = $D3D10CreateDevice->Call($pAdapter, $DriverType, $Software, $Flags, $SDKVersion, $ppDevice);
# pAdapter : IDXGIAdapter* optional -> LPVOID
# DriverType : D3D10_DRIVER_TYPE -> int
# Software : HMODULE -> HANDLE
# Flags : DWORD -> DWORD
# SDKVersion : DWORD -> DWORD
# ppDevice : ID3D10Device** optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f D3D10CreateDevice1 — 機能レベルを指定してDirect3D10.1デバイスを作成する。