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

D3D12_VIEWPORT

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

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

フィールド

フィールドサイズx64x86説明
TopLeftXFLOAT4+0+0ビューポート左上のX座標(ピクセル)。
TopLeftYFLOAT4+4+4ビューポート左上のY座標(ピクセル)。
WidthFLOAT4+8+8ビューポートの幅(ピクセル)。
HeightFLOAT4+12+12ビューポートの高さ(ピクセル)。
MinDepthFLOAT4+16+16深度範囲の最小値。通常0.0。
MaxDepthFLOAT4+20+20深度範囲の最大値。通常1.0。

各言語での定義

#include <windows.h>

// D3D12_VIEWPORT  (x64 24 / x86 24 バイト)
typedef struct D3D12_VIEWPORT {
    FLOAT TopLeftX;
    FLOAT TopLeftY;
    FLOAT Width;
    FLOAT Height;
    FLOAT MinDepth;
    FLOAT MaxDepth;
} D3D12_VIEWPORT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3D12_VIEWPORT
{
    public float TopLeftX;
    public float TopLeftY;
    public float Width;
    public float Height;
    public float MinDepth;
    public float MaxDepth;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3D12_VIEWPORT
    Public TopLeftX As Single
    Public TopLeftY As Single
    Public Width As Single
    Public Height As Single
    Public MinDepth As Single
    Public MaxDepth As Single
End Structure
import ctypes
from ctypes import wintypes

class D3D12_VIEWPORT(ctypes.Structure):
    _fields_ = [
        ("TopLeftX", ctypes.c_float),
        ("TopLeftY", ctypes.c_float),
        ("Width", ctypes.c_float),
        ("Height", ctypes.c_float),
        ("MinDepth", ctypes.c_float),
        ("MaxDepth", ctypes.c_float),
    ]
#[repr(C)]
pub struct D3D12_VIEWPORT {
    pub TopLeftX: f32,
    pub TopLeftY: f32,
    pub Width: f32,
    pub Height: f32,
    pub MinDepth: f32,
    pub MaxDepth: f32,
}
import "golang.org/x/sys/windows"

type D3D12_VIEWPORT struct {
	TopLeftX float32
	TopLeftY float32
	Width float32
	Height float32
	MinDepth float32
	MaxDepth float32
}
type
  D3D12_VIEWPORT = record
    TopLeftX: Single;
    TopLeftY: Single;
    Width: Single;
    Height: Single;
    MinDepth: Single;
    MaxDepth: Single;
  end;
const D3D12_VIEWPORT = extern struct {
    TopLeftX: f32,
    TopLeftY: f32,
    Width: f32,
    Height: f32,
    MinDepth: f32,
    MaxDepth: f32,
};
type
  D3D12_VIEWPORT {.bycopy.} = object
    TopLeftX: float32
    TopLeftY: float32
    Width: float32
    Height: float32
    MinDepth: float32
    MaxDepth: float32
struct D3D12_VIEWPORT
{
    float TopLeftX;
    float TopLeftY;
    float Width;
    float Height;
    float MinDepth;
    float MaxDepth;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; D3D12_VIEWPORT サイズ: 24 バイト(x64)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; TopLeftX : FLOAT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; TopLeftY : FLOAT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Width : FLOAT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Height : FLOAT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; MinDepth : FLOAT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; MaxDepth : FLOAT (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global D3D12_VIEWPORT
    #field float TopLeftX
    #field float TopLeftY
    #field float Width
    #field float Height
    #field float MinDepth
    #field float MaxDepth
#endstruct

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