ホーム › Graphics.OpenGL › gluProject
gluProject
関数オブジェクト座標をウィンドウ座標へ投影変換する。
シグネチャ
// GLU32.dll
#include <windows.h>
INT gluProject(
DOUBLE objx,
DOUBLE objy,
DOUBLE objz,
const DOUBLE* modelMatrix,
const DOUBLE* projMatrix,
const INT* viewport,
DOUBLE* winx,
DOUBLE* winy,
DOUBLE* winz
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| objx | DOUBLE | in |
| objy | DOUBLE | in |
| objz | DOUBLE | in |
| modelMatrix | DOUBLE* | in |
| projMatrix | DOUBLE* | in |
| viewport | INT* | in |
| winx | DOUBLE* | inout |
| winy | DOUBLE* | inout |
| winz | DOUBLE* | inout |
戻り値の型: INT
各言語での呼び出し定義
// GLU32.dll
#include <windows.h>
INT gluProject(
DOUBLE objx,
DOUBLE objy,
DOUBLE objz,
const DOUBLE* modelMatrix,
const DOUBLE* projMatrix,
const INT* viewport,
DOUBLE* winx,
DOUBLE* winy,
DOUBLE* winz
);[DllImport("GLU32.dll", ExactSpelling = true)]
static extern int gluProject(
double objx, // DOUBLE
double objy, // DOUBLE
double objz, // DOUBLE
ref double modelMatrix, // DOUBLE*
ref double projMatrix, // DOUBLE*
ref int viewport, // INT*
ref double winx, // DOUBLE* in/out
ref double winy, // DOUBLE* in/out
ref double winz // DOUBLE* in/out
);<DllImport("GLU32.dll", ExactSpelling:=True)>
Public Shared Function gluProject(
objx As Double, ' DOUBLE
objy As Double, ' DOUBLE
objz As Double, ' DOUBLE
ByRef modelMatrix As Double, ' DOUBLE*
ByRef projMatrix As Double, ' DOUBLE*
ByRef viewport As Integer, ' INT*
ByRef winx As Double, ' DOUBLE* in/out
ByRef winy As Double, ' DOUBLE* in/out
ByRef winz As Double ' DOUBLE* in/out
) As Integer
End Function' objx : DOUBLE
' objy : DOUBLE
' objz : DOUBLE
' modelMatrix : DOUBLE*
' projMatrix : DOUBLE*
' viewport : INT*
' winx : DOUBLE* in/out
' winy : DOUBLE* in/out
' winz : DOUBLE* in/out
Declare PtrSafe Function gluProject Lib "glu32" ( _
ByVal objx As Double, _
ByVal objy As Double, _
ByVal objz As Double, _
ByRef modelMatrix As Double, _
ByRef projMatrix As Double, _
ByRef viewport As Long, _
ByRef winx As Double, _
ByRef winy As Double, _
ByRef winz As Double) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
gluProject = ctypes.windll.glu32.gluProject
gluProject.restype = ctypes.c_int
gluProject.argtypes = [
ctypes.c_double, # objx : DOUBLE
ctypes.c_double, # objy : DOUBLE
ctypes.c_double, # objz : 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), # winx : DOUBLE* in/out
ctypes.POINTER(ctypes.c_double), # winy : DOUBLE* in/out
ctypes.POINTER(ctypes.c_double), # winz : DOUBLE* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GLU32.dll')
gluProject = Fiddle::Function.new(
lib['gluProject'],
[
Fiddle::TYPE_DOUBLE, # objx : DOUBLE
Fiddle::TYPE_DOUBLE, # objy : DOUBLE
Fiddle::TYPE_DOUBLE, # objz : DOUBLE
Fiddle::TYPE_VOIDP, # modelMatrix : DOUBLE*
Fiddle::TYPE_VOIDP, # projMatrix : DOUBLE*
Fiddle::TYPE_VOIDP, # viewport : INT*
Fiddle::TYPE_VOIDP, # winx : DOUBLE* in/out
Fiddle::TYPE_VOIDP, # winy : DOUBLE* in/out
Fiddle::TYPE_VOIDP, # winz : DOUBLE* in/out
],
Fiddle::TYPE_INT)#[link(name = "glu32")]
extern "system" {
fn gluProject(
objx: f64, // DOUBLE
objy: f64, // DOUBLE
objz: f64, // DOUBLE
modelMatrix: *const f64, // DOUBLE*
projMatrix: *const f64, // DOUBLE*
viewport: *const i32, // INT*
winx: *mut f64, // DOUBLE* in/out
winy: *mut f64, // DOUBLE* in/out
winz: *mut f64 // DOUBLE* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GLU32.dll")]
public static extern int gluProject(double objx, double objy, double objz, ref double modelMatrix, ref double projMatrix, ref int viewport, ref double winx, ref double winy, ref double winz);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GLU32_gluProject' -Namespace Win32 -PassThru
# $api::gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, winx, winy, winz)#uselib "GLU32.dll"
#func global gluProject "gluProject" double, double, double, sptr, sptr, sptr, sptr, sptr, sptr
; gluProject objx, objy, objz, varptr(modelMatrix), varptr(projMatrix), varptr(viewport), varptr(winx), varptr(winy), varptr(winz) ; 戻り値は stat
; objx : DOUBLE -> "double"
; objy : DOUBLE -> "double"
; objz : DOUBLE -> "double"
; modelMatrix : DOUBLE* -> "sptr"
; projMatrix : DOUBLE* -> "sptr"
; viewport : INT* -> "sptr"
; winx : DOUBLE* in/out -> "sptr"
; winy : DOUBLE* in/out -> "sptr"
; winz : DOUBLE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GLU32.dll" #cfunc global gluProject "gluProject" double, double, double, var, var, var, var, var, var ; res = gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, winx, winy, winz) ; objx : DOUBLE -> "double" ; objy : DOUBLE -> "double" ; objz : DOUBLE -> "double" ; modelMatrix : DOUBLE* -> "var" ; projMatrix : DOUBLE* -> "var" ; viewport : INT* -> "var" ; winx : DOUBLE* in/out -> "var" ; winy : DOUBLE* in/out -> "var" ; winz : DOUBLE* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GLU32.dll" #cfunc global gluProject "gluProject" double, double, double, sptr, sptr, sptr, sptr, sptr, sptr ; res = gluProject(objx, objy, objz, varptr(modelMatrix), varptr(projMatrix), varptr(viewport), varptr(winx), varptr(winy), varptr(winz)) ; objx : DOUBLE -> "double" ; objy : DOUBLE -> "double" ; objz : DOUBLE -> "double" ; modelMatrix : DOUBLE* -> "sptr" ; projMatrix : DOUBLE* -> "sptr" ; viewport : INT* -> "sptr" ; winx : DOUBLE* in/out -> "sptr" ; winy : DOUBLE* in/out -> "sptr" ; winz : DOUBLE* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT gluProject(DOUBLE objx, DOUBLE objy, DOUBLE objz, DOUBLE* modelMatrix, DOUBLE* projMatrix, INT* viewport, DOUBLE* winx, DOUBLE* winy, DOUBLE* winz) #uselib "GLU32.dll" #cfunc global gluProject "gluProject" double, double, double, var, var, var, var, var, var ; res = gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, winx, winy, winz) ; objx : DOUBLE -> "double" ; objy : DOUBLE -> "double" ; objz : DOUBLE -> "double" ; modelMatrix : DOUBLE* -> "var" ; projMatrix : DOUBLE* -> "var" ; viewport : INT* -> "var" ; winx : DOUBLE* in/out -> "var" ; winy : DOUBLE* in/out -> "var" ; winz : DOUBLE* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT gluProject(DOUBLE objx, DOUBLE objy, DOUBLE objz, DOUBLE* modelMatrix, DOUBLE* projMatrix, INT* viewport, DOUBLE* winx, DOUBLE* winy, DOUBLE* winz) #uselib "GLU32.dll" #cfunc global gluProject "gluProject" double, double, double, intptr, intptr, intptr, intptr, intptr, intptr ; res = gluProject(objx, objy, objz, varptr(modelMatrix), varptr(projMatrix), varptr(viewport), varptr(winx), varptr(winy), varptr(winz)) ; objx : DOUBLE -> "double" ; objy : DOUBLE -> "double" ; objz : DOUBLE -> "double" ; modelMatrix : DOUBLE* -> "intptr" ; projMatrix : DOUBLE* -> "intptr" ; viewport : INT* -> "intptr" ; winx : DOUBLE* in/out -> "intptr" ; winy : DOUBLE* in/out -> "intptr" ; winz : DOUBLE* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
glu32 = windows.NewLazySystemDLL("GLU32.dll")
procgluProject = glu32.NewProc("gluProject")
)
// objx (DOUBLE), objy (DOUBLE), objz (DOUBLE), modelMatrix (DOUBLE*), projMatrix (DOUBLE*), viewport (INT*), winx (DOUBLE* in/out), winy (DOUBLE* in/out), winz (DOUBLE* in/out)
r1, _, err := procgluProject.Call(
uintptr(math.Float64bits(objx)),
uintptr(math.Float64bits(objy)),
uintptr(math.Float64bits(objz)),
uintptr(modelMatrix),
uintptr(projMatrix),
uintptr(viewport),
uintptr(winx),
uintptr(winy),
uintptr(winz),
)
_ = 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 gluProject(
objx: Double; // DOUBLE
objy: Double; // DOUBLE
objz: Double; // DOUBLE
modelMatrix: Pointer; // DOUBLE*
projMatrix: Pointer; // DOUBLE*
viewport: Pointer; // INT*
winx: Pointer; // DOUBLE* in/out
winy: Pointer; // DOUBLE* in/out
winz: Pointer // DOUBLE* in/out
): Integer; stdcall;
external 'GLU32.dll' name 'gluProject';result := DllCall("GLU32\gluProject"
, "Double", objx ; DOUBLE
, "Double", objy ; DOUBLE
, "Double", objz ; DOUBLE
, "Ptr", modelMatrix ; DOUBLE*
, "Ptr", projMatrix ; DOUBLE*
, "Ptr", viewport ; INT*
, "Ptr", winx ; DOUBLE* in/out
, "Ptr", winy ; DOUBLE* in/out
, "Ptr", winz ; DOUBLE* in/out
, "Int") ; return: INT●gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, winx, winy, winz) = DLL("GLU32.dll", "int gluProject(double, double, double, void*, void*, void*, void*, void*, void*)")
# 呼び出し: gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, winx, winy, winz)
# objx : DOUBLE -> "double"
# objy : DOUBLE -> "double"
# objz : DOUBLE -> "double"
# modelMatrix : DOUBLE* -> "void*"
# projMatrix : DOUBLE* -> "void*"
# viewport : INT* -> "void*"
# winx : DOUBLE* in/out -> "void*"
# winy : DOUBLE* in/out -> "void*"
# winz : DOUBLE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。