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

DXGI_MODE_DESC

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

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

フィールド

フィールドサイズx64x86説明
WidthDWORD4+0+0表示モードの解像度の幅(ピクセル数)。
HeightDWORD4+4+4表示モードの解像度の高さ(ピクセル数)。
RefreshRateDXGI_RATIONAL8+8+8リフレッシュレートを分数で表すDXGI_RATIONAL。
FormatDXGI_FORMAT4+16+16表示モードのピクセルフォーマットを示す列挙値。
ScanlineOrderingDXGI_MODE_SCANLINE_ORDER4+20+20走査線の描画順序(プログレッシブ/インターレース)を示す列挙値。
ScalingDXGI_MODE_SCALING4+24+24解像度がネイティブと異なる場合のスケーリング方式を示す列挙値。

各言語での定義

#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;
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;
}
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
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),
    ]
#[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,
}
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_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;
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,
};
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
struct DXGI_RATIONAL
{
    uint Numerator;
    uint Denominator;
}

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

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DXGI_MODE_DESC サイズ: 28 バイト(x64)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; Width : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Height : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; RefreshRate : DXGI_RATIONAL (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; Format : DXGI_FORMAT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ScanlineOrdering : DXGI_MODE_SCANLINE_ORDER (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; Scaling : DXGI_MODE_SCALING (+24, 4byte)  st.6 = 値  /  値 = st.6   (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

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