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

D3DVIEWPORT9

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

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

フィールド

フィールドサイズx64x86説明
XDWORD4+0+0ビューポート左上のX座標(ピクセル単位)。
YDWORD4+4+4ビューポート左上のY座標(ピクセル単位)。
WidthDWORD4+8+8ビューポートの幅(ピクセル単位)。
HeightDWORD4+12+12ビューポートの高さ(ピクセル単位)。
MinZFLOAT4+16+16深度バッファの最小Z値(通常0.0)。
MaxZFLOAT4+20+20深度バッファの最大Z値(通常1.0)。

各言語での定義

#include <windows.h>

// D3DVIEWPORT9  (x64 24 / x86 24 バイト)
typedef struct D3DVIEWPORT9 {
    DWORD X;
    DWORD Y;
    DWORD Width;
    DWORD Height;
    FLOAT MinZ;
    FLOAT MaxZ;
} D3DVIEWPORT9;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3DVIEWPORT9
{
    public uint X;
    public uint Y;
    public uint Width;
    public uint Height;
    public float MinZ;
    public float MaxZ;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3DVIEWPORT9
    Public X As UInteger
    Public Y As UInteger
    Public Width As UInteger
    Public Height As UInteger
    Public MinZ As Single
    Public MaxZ As Single
End Structure
import ctypes
from ctypes import wintypes

class D3DVIEWPORT9(ctypes.Structure):
    _fields_ = [
        ("X", wintypes.DWORD),
        ("Y", wintypes.DWORD),
        ("Width", wintypes.DWORD),
        ("Height", wintypes.DWORD),
        ("MinZ", ctypes.c_float),
        ("MaxZ", ctypes.c_float),
    ]
#[repr(C)]
pub struct D3DVIEWPORT9 {
    pub X: u32,
    pub Y: u32,
    pub Width: u32,
    pub Height: u32,
    pub MinZ: f32,
    pub MaxZ: f32,
}
import "golang.org/x/sys/windows"

type D3DVIEWPORT9 struct {
	X uint32
	Y uint32
	Width uint32
	Height uint32
	MinZ float32
	MaxZ float32
}
type
  D3DVIEWPORT9 = record
    X: DWORD;
    Y: DWORD;
    Width: DWORD;
    Height: DWORD;
    MinZ: Single;
    MaxZ: Single;
  end;
const D3DVIEWPORT9 = extern struct {
    X: u32,
    Y: u32,
    Width: u32,
    Height: u32,
    MinZ: f32,
    MaxZ: f32,
};
type
  D3DVIEWPORT9 {.bycopy.} = object
    X: uint32
    Y: uint32
    Width: uint32
    Height: uint32
    MinZ: float32
    MaxZ: float32
struct D3DVIEWPORT9
{
    uint X;
    uint Y;
    uint Width;
    uint Height;
    float MinZ;
    float MaxZ;
}

HSP用 定義

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

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

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