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

DXGI_SWAP_CHAIN_DESC

構造体
サイズx64: 72 バイト / x86: 60 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
BufferDescDXGI_MODE_DESC28+0+0バックバッファの表示モードを表すDXGI_MODE_DESC。
SampleDescDXGI_SAMPLE_DESC8+28+28マルチサンプリングのパラメータを表すDXGI_SAMPLE_DESC。
BufferUsageDXGI_USAGE4+36+36バッファの用途(レンダーターゲット出力等)を示すDXGI_USAGEフラグ。
BufferCountDWORD4+40+40スワップチェーン内のバッファ数。
OutputWindowHWND8/4+48+44出力先となるウィンドウのハンドル。
WindowedBOOL4+56+48ウィンドウモードか(falseで全画面)を示すブール値。
SwapEffectDXGI_SWAP_EFFECT4+60+52Present時のバッファ入れ替え方式を示す列挙値。
FlagsDWORD4+64+56スワップチェーンの動作を制御するDXGI_SWAP_CHAIN_FLAGの組み合わせ。

各言語での定義

#include <windows.h>

// DXGI_RATIONAL  (x64 8 / x86 8 バイト)
typedef struct DXGI_RATIONAL {
    DWORD Numerator;
    DWORD Denominator;
} DXGI_RATIONAL;

// DXGI_MODE_DESC  (x64 28 / x86 28 バイト)
typedef struct DXGI_MODE_DESC {
    DWORD Width;
    DWORD Height;
    DXGI_RATIONAL RefreshRate;
    DXGI_FORMAT Format;
    DXGI_MODE_SCANLINE_ORDER ScanlineOrdering;
    DXGI_MODE_SCALING Scaling;
} DXGI_MODE_DESC;

// DXGI_SAMPLE_DESC  (x64 8 / x86 8 バイト)
typedef struct DXGI_SAMPLE_DESC {
    DWORD Count;
    DWORD Quality;
} DXGI_SAMPLE_DESC;

// DXGI_SWAP_CHAIN_DESC  (x64 72 / x86 60 バイト)
typedef struct DXGI_SWAP_CHAIN_DESC {
    DXGI_MODE_DESC BufferDesc;
    DXGI_SAMPLE_DESC SampleDesc;
    DXGI_USAGE BufferUsage;
    DWORD BufferCount;
    HWND OutputWindow;
    BOOL Windowed;
    DXGI_SWAP_EFFECT SwapEffect;
    DWORD Flags;
} DXGI_SWAP_CHAIN_DESC;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DXGI_RATIONAL
{
    public uint Numerator;
    public uint Denominator;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DXGI_MODE_DESC
{
    public uint Width;
    public uint Height;
    public DXGI_RATIONAL RefreshRate;
    public int Format;
    public int ScanlineOrdering;
    public int Scaling;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DXGI_SAMPLE_DESC
{
    public uint Count;
    public uint Quality;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DXGI_SWAP_CHAIN_DESC
{
    public DXGI_MODE_DESC BufferDesc;
    public DXGI_SAMPLE_DESC SampleDesc;
    public uint BufferUsage;
    public uint BufferCount;
    public IntPtr OutputWindow;
    [MarshalAs(UnmanagedType.Bool)] public bool Windowed;
    public int SwapEffect;
    public uint Flags;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DXGI_RATIONAL
    Public Numerator As UInteger
    Public Denominator As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DXGI_MODE_DESC
    Public Width As UInteger
    Public Height As UInteger
    Public RefreshRate As DXGI_RATIONAL
    Public Format As Integer
    Public ScanlineOrdering As Integer
    Public Scaling As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DXGI_SAMPLE_DESC
    Public Count As UInteger
    Public Quality As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DXGI_SWAP_CHAIN_DESC
    Public BufferDesc As DXGI_MODE_DESC
    Public SampleDesc As DXGI_SAMPLE_DESC
    Public BufferUsage As UInteger
    Public BufferCount As UInteger
    Public OutputWindow As IntPtr
    <MarshalAs(UnmanagedType.Bool)> Public Windowed As Boolean
    Public SwapEffect As Integer
    Public Flags As UInteger
End Structure
import ctypes
from ctypes import wintypes

class DXGI_RATIONAL(ctypes.Structure):
    _fields_ = [
        ("Numerator", wintypes.DWORD),
        ("Denominator", wintypes.DWORD),
    ]

class DXGI_MODE_DESC(ctypes.Structure):
    _fields_ = [
        ("Width", wintypes.DWORD),
        ("Height", wintypes.DWORD),
        ("RefreshRate", DXGI_RATIONAL),
        ("Format", ctypes.c_int),
        ("ScanlineOrdering", ctypes.c_int),
        ("Scaling", ctypes.c_int),
    ]

class DXGI_SAMPLE_DESC(ctypes.Structure):
    _fields_ = [
        ("Count", wintypes.DWORD),
        ("Quality", wintypes.DWORD),
    ]

class DXGI_SWAP_CHAIN_DESC(ctypes.Structure):
    _fields_ = [
        ("BufferDesc", DXGI_MODE_DESC),
        ("SampleDesc", DXGI_SAMPLE_DESC),
        ("BufferUsage", wintypes.DWORD),
        ("BufferCount", wintypes.DWORD),
        ("OutputWindow", ctypes.c_void_p),
        ("Windowed", wintypes.BOOL),
        ("SwapEffect", ctypes.c_int),
        ("Flags", wintypes.DWORD),
    ]
#[repr(C)]
pub struct DXGI_RATIONAL {
    pub Numerator: u32,
    pub Denominator: u32,
}

#[repr(C)]
pub struct DXGI_MODE_DESC {
    pub Width: u32,
    pub Height: u32,
    pub RefreshRate: DXGI_RATIONAL,
    pub Format: i32,
    pub ScanlineOrdering: i32,
    pub Scaling: i32,
}

#[repr(C)]
pub struct DXGI_SAMPLE_DESC {
    pub Count: u32,
    pub Quality: u32,
}

#[repr(C)]
pub struct DXGI_SWAP_CHAIN_DESC {
    pub BufferDesc: DXGI_MODE_DESC,
    pub SampleDesc: DXGI_SAMPLE_DESC,
    pub BufferUsage: u32,
    pub BufferCount: u32,
    pub OutputWindow: *mut core::ffi::c_void,
    pub Windowed: i32,
    pub SwapEffect: i32,
    pub Flags: u32,
}
import "golang.org/x/sys/windows"

type DXGI_RATIONAL struct {
	Numerator uint32
	Denominator uint32
}

type DXGI_MODE_DESC struct {
	Width uint32
	Height uint32
	RefreshRate DXGI_RATIONAL
	Format int32
	ScanlineOrdering int32
	Scaling int32
}

type DXGI_SAMPLE_DESC struct {
	Count uint32
	Quality uint32
}

type DXGI_SWAP_CHAIN_DESC struct {
	BufferDesc DXGI_MODE_DESC
	SampleDesc DXGI_SAMPLE_DESC
	BufferUsage uint32
	BufferCount uint32
	OutputWindow uintptr
	Windowed int32
	SwapEffect int32
	Flags uint32
}
type
  DXGI_RATIONAL = record
    Numerator: DWORD;
    Denominator: DWORD;
  end;

  DXGI_MODE_DESC = record
    Width: DWORD;
    Height: DWORD;
    RefreshRate: DXGI_RATIONAL;
    Format: Integer;
    ScanlineOrdering: Integer;
    Scaling: Integer;
  end;

  DXGI_SAMPLE_DESC = record
    Count: DWORD;
    Quality: DWORD;
  end;

  DXGI_SWAP_CHAIN_DESC = record
    BufferDesc: DXGI_MODE_DESC;
    SampleDesc: DXGI_SAMPLE_DESC;
    BufferUsage: DWORD;
    BufferCount: DWORD;
    OutputWindow: Pointer;
    Windowed: BOOL;
    SwapEffect: Integer;
    Flags: DWORD;
  end;
const DXGI_RATIONAL = extern struct {
    Numerator: u32,
    Denominator: u32,
};

const DXGI_MODE_DESC = extern struct {
    Width: u32,
    Height: u32,
    RefreshRate: DXGI_RATIONAL,
    Format: i32,
    ScanlineOrdering: i32,
    Scaling: i32,
};

const DXGI_SAMPLE_DESC = extern struct {
    Count: u32,
    Quality: u32,
};

const DXGI_SWAP_CHAIN_DESC = extern struct {
    BufferDesc: DXGI_MODE_DESC,
    SampleDesc: DXGI_SAMPLE_DESC,
    BufferUsage: u32,
    BufferCount: u32,
    OutputWindow: ?*anyopaque,
    Windowed: i32,
    SwapEffect: i32,
    Flags: u32,
};
type
  DXGI_RATIONAL {.bycopy.} = object
    Numerator: uint32
    Denominator: uint32

  DXGI_MODE_DESC {.bycopy.} = object
    Width: uint32
    Height: uint32
    RefreshRate: DXGI_RATIONAL
    Format: int32
    ScanlineOrdering: int32
    Scaling: int32

  DXGI_SAMPLE_DESC {.bycopy.} = object
    Count: uint32
    Quality: uint32

  DXGI_SWAP_CHAIN_DESC {.bycopy.} = object
    BufferDesc: DXGI_MODE_DESC
    SampleDesc: DXGI_SAMPLE_DESC
    BufferUsage: uint32
    BufferCount: uint32
    OutputWindow: pointer
    Windowed: int32
    SwapEffect: int32
    Flags: uint32
struct DXGI_RATIONAL
{
    uint Numerator;
    uint Denominator;
}

struct DXGI_MODE_DESC
{
    uint Width;
    uint Height;
    DXGI_RATIONAL RefreshRate;
    int Format;
    int ScanlineOrdering;
    int Scaling;
}

struct DXGI_SAMPLE_DESC
{
    uint Count;
    uint Quality;
}

struct DXGI_SWAP_CHAIN_DESC
{
    DXGI_MODE_DESC BufferDesc;
    DXGI_SAMPLE_DESC SampleDesc;
    uint BufferUsage;
    uint BufferCount;
    void* OutputWindow;
    int Windowed;
    int SwapEffect;
    uint Flags;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DXGI_SWAP_CHAIN_DESC サイズ: 60 バイト(x86)
dim st, 15    ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; BufferDesc : DXGI_MODE_DESC (+0, 28byte)  varptr(st)+0 を基点に操作(28byte:入れ子/配列)
; SampleDesc : DXGI_SAMPLE_DESC (+28, 8byte)  varptr(st)+28 を基点に操作(8byte:入れ子/配列)
; BufferUsage : DXGI_USAGE (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; BufferCount : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; OutputWindow : HWND (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; Windowed : BOOL (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; SwapEffect : DXGI_SWAP_EFFECT (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; Flags : DWORD (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DXGI_SWAP_CHAIN_DESC サイズ: 72 バイト(x64)
dim st, 18    ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; BufferDesc : DXGI_MODE_DESC (+0, 28byte)  varptr(st)+0 を基点に操作(28byte:入れ子/配列)
; SampleDesc : DXGI_SAMPLE_DESC (+28, 8byte)  varptr(st)+28 を基点に操作(8byte:入れ子/配列)
; BufferUsage : DXGI_USAGE (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; BufferCount : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; OutputWindow : HWND (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; Windowed : BOOL (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; SwapEffect : DXGI_SWAP_EFFECT (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; Flags : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DXGI_RATIONAL
    #field int Numerator
    #field int Denominator
#endstruct

#defstruct global DXGI_MODE_DESC
    #field int Width
    #field int Height
    #field DXGI_RATIONAL RefreshRate
    #field int Format
    #field int ScanlineOrdering
    #field int Scaling
#endstruct

#defstruct global DXGI_SAMPLE_DESC
    #field int Count
    #field int Quality
#endstruct

#defstruct global DXGI_SWAP_CHAIN_DESC
    #field DXGI_MODE_DESC BufferDesc
    #field DXGI_SAMPLE_DESC SampleDesc
    #field int BufferUsage
    #field int BufferCount
    #field intptr OutputWindow
    #field bool Windowed
    #field int SwapEffect
    #field int Flags
#endstruct

stdim st, DXGI_SWAP_CHAIN_DESC        ; NSTRUCT 変数を確保
st->BufferUsage = 100
mes "BufferUsage=" + st->BufferUsage