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

DXGI_SWAP_CHAIN_DESC1

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

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

フィールド

フィールドサイズx64x86説明
WidthDWORD4+0+0バックバッファの幅(ピクセル数)。0で自動算出。
HeightDWORD4+4+4バックバッファの高さ(ピクセル数)。0で自動算出。
FormatDXGI_FORMAT4+8+8バックバッファのピクセルフォーマットを示す列挙値。
StereoBOOL4+12+12ステレオ(立体視)スワップチェーンかを示すブール値。
SampleDescDXGI_SAMPLE_DESC8+16+16マルチサンプリングのパラメータを表すDXGI_SAMPLE_DESC。
BufferUsageDXGI_USAGE4+24+24バッファの用途を示すDXGI_USAGEフラグ。
BufferCountDWORD4+28+28スワップチェーン内のバッファ数。
ScalingDXGI_SCALING4+32+32バックバッファのスケーリング方式を示す列挙値。
SwapEffectDXGI_SWAP_EFFECT4+36+36Present時のバッファ入れ替え方式を示す列挙値。
AlphaModeDXGI_ALPHA_MODE4+40+40バックバッファのアルファ扱いを示す列挙値。
FlagsDWORD4+44+44スワップチェーンの動作を制御するDXGI_SWAP_CHAIN_FLAGの組み合わせ。

各言語での定義

#include <windows.h>

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

// DXGI_SWAP_CHAIN_DESC1  (x64 48 / x86 48 バイト)
typedef struct DXGI_SWAP_CHAIN_DESC1 {
    DWORD Width;
    DWORD Height;
    DXGI_FORMAT Format;
    BOOL Stereo;
    DXGI_SAMPLE_DESC SampleDesc;
    DXGI_USAGE BufferUsage;
    DWORD BufferCount;
    DXGI_SCALING Scaling;
    DXGI_SWAP_EFFECT SwapEffect;
    DXGI_ALPHA_MODE AlphaMode;
    DWORD Flags;
} DXGI_SWAP_CHAIN_DESC1;
using System;
using System.Runtime.InteropServices;

[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_DESC1
{
    public uint Width;
    public uint Height;
    public int Format;
    [MarshalAs(UnmanagedType.Bool)] public bool Stereo;
    public DXGI_SAMPLE_DESC SampleDesc;
    public uint BufferUsage;
    public uint BufferCount;
    public int Scaling;
    public int SwapEffect;
    public int AlphaMode;
    public uint Flags;
}
Imports System.Runtime.InteropServices

<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_DESC1
    Public Width As UInteger
    Public Height As UInteger
    Public Format As Integer
    <MarshalAs(UnmanagedType.Bool)> Public Stereo As Boolean
    Public SampleDesc As DXGI_SAMPLE_DESC
    Public BufferUsage As UInteger
    Public BufferCount As UInteger
    Public Scaling As Integer
    Public SwapEffect As Integer
    Public AlphaMode As Integer
    Public Flags As UInteger
End Structure
import ctypes
from ctypes import wintypes

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

class DXGI_SWAP_CHAIN_DESC1(ctypes.Structure):
    _fields_ = [
        ("Width", wintypes.DWORD),
        ("Height", wintypes.DWORD),
        ("Format", ctypes.c_int),
        ("Stereo", wintypes.BOOL),
        ("SampleDesc", DXGI_SAMPLE_DESC),
        ("BufferUsage", wintypes.DWORD),
        ("BufferCount", wintypes.DWORD),
        ("Scaling", ctypes.c_int),
        ("SwapEffect", ctypes.c_int),
        ("AlphaMode", ctypes.c_int),
        ("Flags", wintypes.DWORD),
    ]
#[repr(C)]
pub struct DXGI_SAMPLE_DESC {
    pub Count: u32,
    pub Quality: u32,
}

#[repr(C)]
pub struct DXGI_SWAP_CHAIN_DESC1 {
    pub Width: u32,
    pub Height: u32,
    pub Format: i32,
    pub Stereo: i32,
    pub SampleDesc: DXGI_SAMPLE_DESC,
    pub BufferUsage: u32,
    pub BufferCount: u32,
    pub Scaling: i32,
    pub SwapEffect: i32,
    pub AlphaMode: i32,
    pub Flags: u32,
}
import "golang.org/x/sys/windows"

type DXGI_SAMPLE_DESC struct {
	Count uint32
	Quality uint32
}

type DXGI_SWAP_CHAIN_DESC1 struct {
	Width uint32
	Height uint32
	Format int32
	Stereo int32
	SampleDesc DXGI_SAMPLE_DESC
	BufferUsage uint32
	BufferCount uint32
	Scaling int32
	SwapEffect int32
	AlphaMode int32
	Flags uint32
}
type
  DXGI_SAMPLE_DESC = record
    Count: DWORD;
    Quality: DWORD;
  end;

  DXGI_SWAP_CHAIN_DESC1 = record
    Width: DWORD;
    Height: DWORD;
    Format: Integer;
    Stereo: BOOL;
    SampleDesc: DXGI_SAMPLE_DESC;
    BufferUsage: DWORD;
    BufferCount: DWORD;
    Scaling: Integer;
    SwapEffect: Integer;
    AlphaMode: Integer;
    Flags: DWORD;
  end;
const DXGI_SAMPLE_DESC = extern struct {
    Count: u32,
    Quality: u32,
};

const DXGI_SWAP_CHAIN_DESC1 = extern struct {
    Width: u32,
    Height: u32,
    Format: i32,
    Stereo: i32,
    SampleDesc: DXGI_SAMPLE_DESC,
    BufferUsage: u32,
    BufferCount: u32,
    Scaling: i32,
    SwapEffect: i32,
    AlphaMode: i32,
    Flags: u32,
};
type
  DXGI_SAMPLE_DESC {.bycopy.} = object
    Count: uint32
    Quality: uint32

  DXGI_SWAP_CHAIN_DESC1 {.bycopy.} = object
    Width: uint32
    Height: uint32
    Format: int32
    Stereo: int32
    SampleDesc: DXGI_SAMPLE_DESC
    BufferUsage: uint32
    BufferCount: uint32
    Scaling: int32
    SwapEffect: int32
    AlphaMode: int32
    Flags: uint32
struct DXGI_SAMPLE_DESC
{
    uint Count;
    uint Quality;
}

struct DXGI_SWAP_CHAIN_DESC1
{
    uint Width;
    uint Height;
    int Format;
    int Stereo;
    DXGI_SAMPLE_DESC SampleDesc;
    uint BufferUsage;
    uint BufferCount;
    int Scaling;
    int SwapEffect;
    int AlphaMode;
    uint Flags;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DXGI_SWAP_CHAIN_DESC1 サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; Width : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Height : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Format : DXGI_FORMAT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Stereo : BOOL (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; SampleDesc : DXGI_SAMPLE_DESC (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; BufferUsage : DXGI_USAGE (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; BufferCount : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; Scaling : DXGI_SCALING (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; SwapEffect : DXGI_SWAP_EFFECT (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; AlphaMode : DXGI_ALPHA_MODE (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; Flags : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DXGI_SAMPLE_DESC
    #field int Count
    #field int Quality
#endstruct

#defstruct global DXGI_SWAP_CHAIN_DESC1
    #field int Width
    #field int Height
    #field int Format
    #field bool Stereo
    #field DXGI_SAMPLE_DESC SampleDesc
    #field int BufferUsage
    #field int BufferCount
    #field int Scaling
    #field int SwapEffect
    #field int AlphaMode
    #field int Flags
#endstruct

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