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

gluUnProject

関数
ウィンドウ座標をオブジェクト座標へ逆投影変換する。
DLLGLU32.dll呼出規約winapi

シグネチャ

// GLU32.dll
#include <windows.h>

INT gluUnProject(
    DOUBLE winx,
    DOUBLE winy,
    DOUBLE winz,
    const DOUBLE* modelMatrix,
    const DOUBLE* projMatrix,
    const INT* viewport,
    DOUBLE* objx,
    DOUBLE* objy,
    DOUBLE* objz
);

パラメーター

名前方向
winxDOUBLEin
winyDOUBLEin
winzDOUBLEin
modelMatrixDOUBLE*in
projMatrixDOUBLE*in
viewportINT*in
objxDOUBLE*inout
objyDOUBLE*inout
objzDOUBLE*inout

戻り値の型: INT

各言語での呼び出し定義

// GLU32.dll
#include <windows.h>

INT gluUnProject(
    DOUBLE winx,
    DOUBLE winy,
    DOUBLE winz,
    const DOUBLE* modelMatrix,
    const DOUBLE* projMatrix,
    const INT* viewport,
    DOUBLE* objx,
    DOUBLE* objy,
    DOUBLE* objz
);
[DllImport("GLU32.dll", ExactSpelling = true)]
static extern int gluUnProject(
    double winx,   // DOUBLE
    double winy,   // DOUBLE
    double winz,   // DOUBLE
    ref double modelMatrix,   // DOUBLE*
    ref double projMatrix,   // DOUBLE*
    ref int viewport,   // INT*
    ref double objx,   // DOUBLE* in/out
    ref double objy,   // DOUBLE* in/out
    ref double objz   // DOUBLE* in/out
);
<DllImport("GLU32.dll", ExactSpelling:=True)>
Public Shared Function gluUnProject(
    winx As Double,   ' DOUBLE
    winy As Double,   ' DOUBLE
    winz As Double,   ' DOUBLE
    ByRef modelMatrix As Double,   ' DOUBLE*
    ByRef projMatrix As Double,   ' DOUBLE*
    ByRef viewport As Integer,   ' INT*
    ByRef objx As Double,   ' DOUBLE* in/out
    ByRef objy As Double,   ' DOUBLE* in/out
    ByRef objz As Double   ' DOUBLE* in/out
) As Integer
End Function
' winx : DOUBLE
' winy : DOUBLE
' winz : DOUBLE
' modelMatrix : DOUBLE*
' projMatrix : DOUBLE*
' viewport : INT*
' objx : DOUBLE* in/out
' objy : DOUBLE* in/out
' objz : DOUBLE* in/out
Declare PtrSafe Function gluUnProject Lib "glu32" ( _
    ByVal winx As Double, _
    ByVal winy As Double, _
    ByVal winz As Double, _
    ByRef modelMatrix As Double, _
    ByRef projMatrix As Double, _
    ByRef viewport As Long, _
    ByRef objx As Double, _
    ByRef objy As Double, _
    ByRef objz As Double) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

gluUnProject = ctypes.windll.glu32.gluUnProject
gluUnProject.restype = ctypes.c_int
gluUnProject.argtypes = [
    ctypes.c_double,  # winx : DOUBLE
    ctypes.c_double,  # winy : DOUBLE
    ctypes.c_double,  # winz : DOUBLE
    ctypes.POINTER(ctypes.c_double),  # modelMatrix : DOUBLE*
    ctypes.POINTER(ctypes.c_double),  # projMatrix : DOUBLE*
    ctypes.POINTER(ctypes.c_int),  # viewport : INT*
    ctypes.POINTER(ctypes.c_double),  # objx : DOUBLE* in/out
    ctypes.POINTER(ctypes.c_double),  # objy : DOUBLE* in/out
    ctypes.POINTER(ctypes.c_double),  # objz : DOUBLE* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GLU32.dll')
gluUnProject = Fiddle::Function.new(
  lib['gluUnProject'],
  [
    Fiddle::TYPE_DOUBLE,  # winx : DOUBLE
    Fiddle::TYPE_DOUBLE,  # winy : DOUBLE
    Fiddle::TYPE_DOUBLE,  # winz : DOUBLE
    Fiddle::TYPE_VOIDP,  # modelMatrix : DOUBLE*
    Fiddle::TYPE_VOIDP,  # projMatrix : DOUBLE*
    Fiddle::TYPE_VOIDP,  # viewport : INT*
    Fiddle::TYPE_VOIDP,  # objx : DOUBLE* in/out
    Fiddle::TYPE_VOIDP,  # objy : DOUBLE* in/out
    Fiddle::TYPE_VOIDP,  # objz : DOUBLE* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "glu32")]
extern "system" {
    fn gluUnProject(
        winx: f64,  // DOUBLE
        winy: f64,  // DOUBLE
        winz: f64,  // DOUBLE
        modelMatrix: *const f64,  // DOUBLE*
        projMatrix: *const f64,  // DOUBLE*
        viewport: *const i32,  // INT*
        objx: *mut f64,  // DOUBLE* in/out
        objy: *mut f64,  // DOUBLE* in/out
        objz: *mut f64  // DOUBLE* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GLU32.dll")]
public static extern int gluUnProject(double winx, double winy, double winz, ref double modelMatrix, ref double projMatrix, ref int viewport, ref double objx, ref double objy, ref double objz);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GLU32_gluUnProject' -Namespace Win32 -PassThru
# $api::gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz)
#uselib "GLU32.dll"
#func global gluUnProject "gluUnProject" double, double, double, sptr, sptr, sptr, sptr, sptr, sptr
; gluUnProject winx, winy, winz, varptr(modelMatrix), varptr(projMatrix), varptr(viewport), varptr(objx), varptr(objy), varptr(objz)   ; 戻り値は stat
; winx : DOUBLE -> "double"
; winy : DOUBLE -> "double"
; winz : DOUBLE -> "double"
; modelMatrix : DOUBLE* -> "sptr"
; projMatrix : DOUBLE* -> "sptr"
; viewport : INT* -> "sptr"
; objx : DOUBLE* in/out -> "sptr"
; objy : DOUBLE* in/out -> "sptr"
; objz : DOUBLE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GLU32.dll"
#cfunc global gluUnProject "gluUnProject" double, double, double, var, var, var, var, var, var
; res = gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz)
; winx : DOUBLE -> "double"
; winy : DOUBLE -> "double"
; winz : DOUBLE -> "double"
; modelMatrix : DOUBLE* -> "var"
; projMatrix : DOUBLE* -> "var"
; viewport : INT* -> "var"
; objx : DOUBLE* in/out -> "var"
; objy : DOUBLE* in/out -> "var"
; objz : DOUBLE* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT gluUnProject(DOUBLE winx, DOUBLE winy, DOUBLE winz, DOUBLE* modelMatrix, DOUBLE* projMatrix, INT* viewport, DOUBLE* objx, DOUBLE* objy, DOUBLE* objz)
#uselib "GLU32.dll"
#cfunc global gluUnProject "gluUnProject" double, double, double, var, var, var, var, var, var
; res = gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz)
; winx : DOUBLE -> "double"
; winy : DOUBLE -> "double"
; winz : DOUBLE -> "double"
; modelMatrix : DOUBLE* -> "var"
; projMatrix : DOUBLE* -> "var"
; viewport : INT* -> "var"
; objx : DOUBLE* in/out -> "var"
; objy : DOUBLE* in/out -> "var"
; objz : DOUBLE* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"math"
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	glu32 = windows.NewLazySystemDLL("GLU32.dll")
	procgluUnProject = glu32.NewProc("gluUnProject")
)

// winx (DOUBLE), winy (DOUBLE), winz (DOUBLE), modelMatrix (DOUBLE*), projMatrix (DOUBLE*), viewport (INT*), objx (DOUBLE* in/out), objy (DOUBLE* in/out), objz (DOUBLE* in/out)
r1, _, err := procgluUnProject.Call(
	uintptr(math.Float64bits(winx)),
	uintptr(math.Float64bits(winy)),
	uintptr(math.Float64bits(winz)),
	uintptr(modelMatrix),
	uintptr(projMatrix),
	uintptr(viewport),
	uintptr(objx),
	uintptr(objy),
	uintptr(objz),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。
function gluUnProject(
  winx: Double;   // DOUBLE
  winy: Double;   // DOUBLE
  winz: Double;   // DOUBLE
  modelMatrix: Pointer;   // DOUBLE*
  projMatrix: Pointer;   // DOUBLE*
  viewport: Pointer;   // INT*
  objx: Pointer;   // DOUBLE* in/out
  objy: Pointer;   // DOUBLE* in/out
  objz: Pointer   // DOUBLE* in/out
): Integer; stdcall;
  external 'GLU32.dll' name 'gluUnProject';
result := DllCall("GLU32\gluUnProject"
    , "Double", winx   ; DOUBLE
    , "Double", winy   ; DOUBLE
    , "Double", winz   ; DOUBLE
    , "Ptr", modelMatrix   ; DOUBLE*
    , "Ptr", projMatrix   ; DOUBLE*
    , "Ptr", viewport   ; INT*
    , "Ptr", objx   ; DOUBLE* in/out
    , "Ptr", objy   ; DOUBLE* in/out
    , "Ptr", objz   ; DOUBLE* in/out
    , "Int")   ; return: INT
●gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz) = DLL("GLU32.dll", "int gluUnProject(double, double, double, void*, void*, void*, void*, void*, void*)")
# 呼び出し: gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz)
# winx : DOUBLE -> "double"
# winy : DOUBLE -> "double"
# winz : DOUBLE -> "double"
# modelMatrix : DOUBLE* -> "void*"
# projMatrix : DOUBLE* -> "void*"
# viewport : INT* -> "void*"
# objx : DOUBLE* in/out -> "void*"
# objy : DOUBLE* in/out -> "void*"
# objz : DOUBLE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。