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

DD_SURFACE_LOCAL

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

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

フィールド

フィールドサイズx64x86説明
lpGblDD_SURFACE_GLOBAL*8/4+0+0対応するグローバルサーフェスオブジェクトへのポインタ。
dwFlagsDWORD4+8+4サーフェスの状態や属性を示すフラグ。
ddsCapsDDSCAPS4+12+8サーフェスの能力を示すDDSCAPS。
dwReserved1UINT_PTR8/4+16+12将来の使用のために予約されたフィールド。
Anonymous1_Anonymous1_e__Union8+24+16カラーキー(転送元)情報を保持する無名共用体。
Anonymous2_Anonymous2_e__Union8+32+24カラーキー(転送先)情報を保持する無名共用体。
lpSurfMoreDD_SURFACE_MORE*8/4+40+32追加サーフェス情報DD_SURFACE_MOREへのポインタ。
lpAttachListDD_ATTACHLIST*8/4+48+36このサーフェスにアタッチされたサーフェスのリストへのポインタ。NULL可。
lpAttachListFromDD_ATTACHLIST*8/4+56+40このサーフェスをアタッチ元とするリストへのポインタ。NULL可。
rcOverlaySrcRECT16+64+44オーバーレイ表示元の矩形を示すRECT。

共用体: _Anonymous1_e__Union x64 8B / x86 8B

フィールドサイズx64x86
ddckCKSrcOverlayDDCOLORKEY8+0+0
ddckCKSrcBltDDCOLORKEY8+0+0

共用体: _Anonymous2_e__Union x64 8B / x86 8B

フィールドサイズx64x86
ddckCKDestOverlayDDCOLORKEY8+0+0
ddckCKDestBltDDCOLORKEY8+0+0

各言語での定義

#include <windows.h>

// DDSCAPS  (x64 4 / x86 4 バイト)
typedef struct DDSCAPS {
    DWORD dwCaps;
} DDSCAPS;

// RECT  (x64 16 / x86 16 バイト)
typedef struct RECT {
    INT left;
    INT top;
    INT right;
    INT bottom;
} RECT;

// DD_SURFACE_LOCAL  (x64 80 / x86 60 バイト)
typedef struct DD_SURFACE_LOCAL {
    DD_SURFACE_GLOBAL* lpGbl;
    DWORD dwFlags;
    DDSCAPS ddsCaps;
    UINT_PTR dwReserved1;
    _Anonymous1_e__Union Anonymous1;
    _Anonymous2_e__Union Anonymous2;
    DD_SURFACE_MORE* lpSurfMore;
    DD_ATTACHLIST* lpAttachList;
    DD_ATTACHLIST* lpAttachListFrom;
    RECT rcOverlaySrc;
} DD_SURFACE_LOCAL;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DDSCAPS
{
    public uint dwCaps;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RECT
{
    public int left;
    public int top;
    public int right;
    public int bottom;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DD_SURFACE_LOCAL
{
    public IntPtr lpGbl;
    public uint dwFlags;
    public DDSCAPS ddsCaps;
    public UIntPtr dwReserved1;
    public _Anonymous1_e__Union Anonymous1;
    public _Anonymous2_e__Union Anonymous2;
    public IntPtr lpSurfMore;
    public IntPtr lpAttachList;
    public IntPtr lpAttachListFrom;
    public RECT rcOverlaySrc;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DDSCAPS
    Public dwCaps As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RECT
    Public left As Integer
    Public top As Integer
    Public right As Integer
    Public bottom As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DD_SURFACE_LOCAL
    Public lpGbl As IntPtr
    Public dwFlags As UInteger
    Public ddsCaps As DDSCAPS
    Public dwReserved1 As UIntPtr
    Public Anonymous1 As _Anonymous1_e__Union
    Public Anonymous2 As _Anonymous2_e__Union
    Public lpSurfMore As IntPtr
    Public lpAttachList As IntPtr
    Public lpAttachListFrom As IntPtr
    Public rcOverlaySrc As RECT
End Structure
import ctypes
from ctypes import wintypes

class DDSCAPS(ctypes.Structure):
    _fields_ = [
        ("dwCaps", wintypes.DWORD),
    ]

class RECT(ctypes.Structure):
    _fields_ = [
        ("left", ctypes.c_int),
        ("top", ctypes.c_int),
        ("right", ctypes.c_int),
        ("bottom", ctypes.c_int),
    ]

class DD_SURFACE_LOCAL(ctypes.Structure):
    _fields_ = [
        ("lpGbl", ctypes.c_void_p),
        ("dwFlags", wintypes.DWORD),
        ("ddsCaps", DDSCAPS),
        ("dwReserved1", ctypes.c_size_t),
        ("Anonymous1", _Anonymous1_e__Union),
        ("Anonymous2", _Anonymous2_e__Union),
        ("lpSurfMore", ctypes.c_void_p),
        ("lpAttachList", ctypes.c_void_p),
        ("lpAttachListFrom", ctypes.c_void_p),
        ("rcOverlaySrc", RECT),
    ]
#[repr(C)]
pub struct DDSCAPS {
    pub dwCaps: u32,
}

#[repr(C)]
pub struct RECT {
    pub left: i32,
    pub top: i32,
    pub right: i32,
    pub bottom: i32,
}

#[repr(C)]
pub struct DD_SURFACE_LOCAL {
    pub lpGbl: *mut core::ffi::c_void,
    pub dwFlags: u32,
    pub ddsCaps: DDSCAPS,
    pub dwReserved1: usize,
    pub Anonymous1: _Anonymous1_e__Union,
    pub Anonymous2: _Anonymous2_e__Union,
    pub lpSurfMore: *mut core::ffi::c_void,
    pub lpAttachList: *mut core::ffi::c_void,
    pub lpAttachListFrom: *mut core::ffi::c_void,
    pub rcOverlaySrc: RECT,
}
import "golang.org/x/sys/windows"

type DDSCAPS struct {
	dwCaps uint32
}

type RECT struct {
	left int32
	top int32
	right int32
	bottom int32
}

type DD_SURFACE_LOCAL struct {
	lpGbl uintptr
	dwFlags uint32
	ddsCaps DDSCAPS
	dwReserved1 uintptr
	Anonymous1 _Anonymous1_e__Union
	Anonymous2 _Anonymous2_e__Union
	lpSurfMore uintptr
	lpAttachList uintptr
	lpAttachListFrom uintptr
	rcOverlaySrc RECT
}
type
  DDSCAPS = record
    dwCaps: DWORD;
  end;

  RECT = record
    left: Integer;
    top: Integer;
    right: Integer;
    bottom: Integer;
  end;

  DD_SURFACE_LOCAL = record
    lpGbl: Pointer;
    dwFlags: DWORD;
    ddsCaps: DDSCAPS;
    dwReserved1: NativeUInt;
    Anonymous1: _Anonymous1_e__Union;
    Anonymous2: _Anonymous2_e__Union;
    lpSurfMore: Pointer;
    lpAttachList: Pointer;
    lpAttachListFrom: Pointer;
    rcOverlaySrc: RECT;
  end;
const DDSCAPS = extern struct {
    dwCaps: u32,
};

const RECT = extern struct {
    left: i32,
    top: i32,
    right: i32,
    bottom: i32,
};

const DD_SURFACE_LOCAL = extern struct {
    lpGbl: ?*anyopaque,
    dwFlags: u32,
    ddsCaps: DDSCAPS,
    dwReserved1: usize,
    Anonymous1: _Anonymous1_e__Union,
    Anonymous2: _Anonymous2_e__Union,
    lpSurfMore: ?*anyopaque,
    lpAttachList: ?*anyopaque,
    lpAttachListFrom: ?*anyopaque,
    rcOverlaySrc: RECT,
};
type
  DDSCAPS {.bycopy.} = object
    dwCaps: uint32

  RECT {.bycopy.} = object
    left: int32
    top: int32
    right: int32
    bottom: int32

  DD_SURFACE_LOCAL {.bycopy.} = object
    lpGbl: pointer
    dwFlags: uint32
    ddsCaps: DDSCAPS
    dwReserved1: uint
    Anonymous1: _Anonymous1_e__Union
    Anonymous2: _Anonymous2_e__Union
    lpSurfMore: pointer
    lpAttachList: pointer
    lpAttachListFrom: pointer
    rcOverlaySrc: RECT
struct DDSCAPS
{
    uint dwCaps;
}

struct RECT
{
    int left;
    int top;
    int right;
    int bottom;
}

struct DD_SURFACE_LOCAL
{
    void* lpGbl;
    uint dwFlags;
    DDSCAPS ddsCaps;
    size_t dwReserved1;
    _Anonymous1_e__Union Anonymous1;
    _Anonymous2_e__Union Anonymous2;
    void* lpSurfMore;
    void* lpAttachList;
    void* lpAttachListFrom;
    RECT rcOverlaySrc;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DD_SURFACE_LOCAL サイズ: 60 バイト(x86)
dim st, 15    ; 4byte整数×15(構造体サイズ 60 / 4 切り上げ)
; lpGbl : DD_SURFACE_GLOBAL* (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; dwFlags : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ddsCaps : DDSCAPS (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; dwReserved1 : UINT_PTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; Anonymous1 : _Anonymous1_e__Union (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; Anonymous2 : _Anonymous2_e__Union (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; lpSurfMore : DD_SURFACE_MORE* (+32, 4byte)  varptr(st)+32 を基点に操作(4byte:入れ子/配列)
; lpAttachList : DD_ATTACHLIST* (+36, 4byte)  varptr(st)+36 を基点に操作(4byte:入れ子/配列)
; lpAttachListFrom : DD_ATTACHLIST* (+40, 4byte)  varptr(st)+40 を基点に操作(4byte:入れ子/配列)
; rcOverlaySrc : RECT (+44, 16byte)  varptr(st)+44 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DD_SURFACE_LOCAL サイズ: 80 バイト(x64)
dim st, 20    ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; lpGbl : DD_SURFACE_GLOBAL* (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; dwFlags : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; ddsCaps : DDSCAPS (+12, 4byte)  varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; dwReserved1 : UINT_PTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; Anonymous1 : _Anonymous1_e__Union (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; Anonymous2 : _Anonymous2_e__Union (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; lpSurfMore : DD_SURFACE_MORE* (+40, 8byte)  varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; lpAttachList : DD_ATTACHLIST* (+48, 8byte)  varptr(st)+48 を基点に操作(8byte:入れ子/配列)
; lpAttachListFrom : DD_ATTACHLIST* (+56, 8byte)  varptr(st)+56 を基点に操作(8byte:入れ子/配列)
; rcOverlaySrc : RECT (+64, 16byte)  varptr(st)+64 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DDSCAPS
    #field int dwCaps
#endstruct

#defstruct global RECT
    #field int left
    #field int top
    #field int right
    #field int bottom
#endstruct

#defstruct global DD_SURFACE_LOCAL
    #field intptr lpGbl
    #field int dwFlags
    #field DDSCAPS ddsCaps
    #field intptr dwReserved1
    #field byte Anonymous1 8
    #field byte Anonymous2 8
    #field intptr lpSurfMore
    #field intptr lpAttachList
    #field intptr lpAttachListFrom
    #field RECT rcOverlaySrc
#endstruct

stdim st, DD_SURFACE_LOCAL        ; NSTRUCT 変数を確保
st->dwFlags = 100
mes "dwFlags=" + st->dwFlags
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。