ホーム › Graphics.OpenGL › gluPickMatrix
gluPickMatrix
関数ピッキング用に指定領域に限定する投影行列を設定する。
シグネチャ
// GLU32.dll
#include <windows.h>
void gluPickMatrix(
DOUBLE x,
DOUBLE y,
DOUBLE width,
DOUBLE height,
INT* viewport
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| x | DOUBLE | in | ピッキング領域中心のx座標(ウィンドウ座標)。 |
| y | DOUBLE | in | ピッキング領域中心のy座標(ウィンドウ座標)。 |
| width | DOUBLE | in | ピッキング領域の幅(ピクセル)。 |
| height | DOUBLE | in | ピッキング領域の高さ(ピクセル)。 |
| viewport | INT* | inout | 現在のビューポート(x,y,w,h)を格納したINT配列。 |
戻り値の型: void
各言語での呼び出し定義
// GLU32.dll
#include <windows.h>
void gluPickMatrix(
DOUBLE x,
DOUBLE y,
DOUBLE width,
DOUBLE height,
INT* viewport
);[DllImport("GLU32.dll", ExactSpelling = true)]
static extern void gluPickMatrix(
double x, // DOUBLE
double y, // DOUBLE
double width, // DOUBLE
double height, // DOUBLE
ref int viewport // INT* in/out
);<DllImport("GLU32.dll", ExactSpelling:=True)>
Public Shared Sub gluPickMatrix(
x As Double, ' DOUBLE
y As Double, ' DOUBLE
width As Double, ' DOUBLE
height As Double, ' DOUBLE
ByRef viewport As Integer ' INT* in/out
)
End Sub' x : DOUBLE
' y : DOUBLE
' width : DOUBLE
' height : DOUBLE
' viewport : INT* in/out
Declare PtrSafe Sub gluPickMatrix Lib "glu32" ( _
ByVal x As Double, _
ByVal y As Double, _
ByVal width As Double, _
ByVal height As Double, _
ByRef viewport As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
gluPickMatrix = ctypes.windll.glu32.gluPickMatrix
gluPickMatrix.restype = None
gluPickMatrix.argtypes = [
ctypes.c_double, # x : DOUBLE
ctypes.c_double, # y : DOUBLE
ctypes.c_double, # width : DOUBLE
ctypes.c_double, # height : DOUBLE
ctypes.POINTER(ctypes.c_int), # viewport : INT* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GLU32.dll')
gluPickMatrix = Fiddle::Function.new(
lib['gluPickMatrix'],
[
Fiddle::TYPE_DOUBLE, # x : DOUBLE
Fiddle::TYPE_DOUBLE, # y : DOUBLE
Fiddle::TYPE_DOUBLE, # width : DOUBLE
Fiddle::TYPE_DOUBLE, # height : DOUBLE
Fiddle::TYPE_VOIDP, # viewport : INT* in/out
],
Fiddle::TYPE_VOID)#[link(name = "glu32")]
extern "system" {
fn gluPickMatrix(
x: f64, // DOUBLE
y: f64, // DOUBLE
width: f64, // DOUBLE
height: f64, // DOUBLE
viewport: *mut i32 // INT* in/out
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GLU32.dll")]
public static extern void gluPickMatrix(double x, double y, double width, double height, ref int viewport);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GLU32_gluPickMatrix' -Namespace Win32 -PassThru
# $api::gluPickMatrix(x, y, width, height, viewport)#uselib "GLU32.dll"
#func global gluPickMatrix "gluPickMatrix" double, double, double, double, sptr
; gluPickMatrix x, y, width, height, varptr(viewport)
; x : DOUBLE -> "double"
; y : DOUBLE -> "double"
; width : DOUBLE -> "double"
; height : DOUBLE -> "double"
; viewport : INT* in/out -> "sptr"出力引数:
#uselib "GLU32.dll" #func global gluPickMatrix "gluPickMatrix" double, double, double, double, var ; gluPickMatrix x, y, width, height, viewport ; x : DOUBLE -> "double" ; y : DOUBLE -> "double" ; width : DOUBLE -> "double" ; height : DOUBLE -> "double" ; viewport : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GLU32.dll" #func global gluPickMatrix "gluPickMatrix" double, double, double, double, sptr ; gluPickMatrix x, y, width, height, varptr(viewport) ; x : DOUBLE -> "double" ; y : DOUBLE -> "double" ; width : DOUBLE -> "double" ; height : DOUBLE -> "double" ; viewport : INT* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void gluPickMatrix(DOUBLE x, DOUBLE y, DOUBLE width, DOUBLE height, INT* viewport) #uselib "GLU32.dll" #func global gluPickMatrix "gluPickMatrix" double, double, double, double, var ; gluPickMatrix x, y, width, height, viewport ; x : DOUBLE -> "double" ; y : DOUBLE -> "double" ; width : DOUBLE -> "double" ; height : DOUBLE -> "double" ; viewport : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void gluPickMatrix(DOUBLE x, DOUBLE y, DOUBLE width, DOUBLE height, INT* viewport) #uselib "GLU32.dll" #func global gluPickMatrix "gluPickMatrix" double, double, double, double, intptr ; gluPickMatrix x, y, width, height, varptr(viewport) ; x : DOUBLE -> "double" ; y : DOUBLE -> "double" ; width : DOUBLE -> "double" ; height : DOUBLE -> "double" ; viewport : INT* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
glu32 = windows.NewLazySystemDLL("GLU32.dll")
procgluPickMatrix = glu32.NewProc("gluPickMatrix")
)
// x (DOUBLE), y (DOUBLE), width (DOUBLE), height (DOUBLE), viewport (INT* in/out)
r1, _, err := procgluPickMatrix.Call(
uintptr(math.Float64bits(x)),
uintptr(math.Float64bits(y)),
uintptr(math.Float64bits(width)),
uintptr(math.Float64bits(height)),
uintptr(viewport),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。procedure gluPickMatrix(
x: Double; // DOUBLE
y: Double; // DOUBLE
width: Double; // DOUBLE
height: Double; // DOUBLE
viewport: Pointer // INT* in/out
); stdcall;
external 'GLU32.dll' name 'gluPickMatrix';result := DllCall("GLU32\gluPickMatrix"
, "Double", x ; DOUBLE
, "Double", y ; DOUBLE
, "Double", width ; DOUBLE
, "Double", height ; DOUBLE
, "Ptr", viewport ; INT* in/out
, "Int") ; return: void●gluPickMatrix(x, y, width, height, viewport) = DLL("GLU32.dll", "int gluPickMatrix(double, double, double, double, void*)")
# 呼び出し: gluPickMatrix(x, y, width, height, viewport)
# x : DOUBLE -> "double"
# y : DOUBLE -> "double"
# width : DOUBLE -> "double"
# height : DOUBLE -> "double"
# viewport : INT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "glu32" fn gluPickMatrix(
x: f64, // DOUBLE
y: f64, // DOUBLE
width: f64, // DOUBLE
height: f64, // DOUBLE
viewport: [*c]i32 // INT* in/out
) callconv(std.os.windows.WINAPI) void;proc gluPickMatrix(
x: float64, # DOUBLE
y: float64, # DOUBLE
width: float64, # DOUBLE
height: float64, # DOUBLE
viewport: ptr int32 # INT* in/out
) {.importc: "gluPickMatrix", stdcall, dynlib: "GLU32.dll".}pragma(lib, "glu32");
extern(Windows)
void gluPickMatrix(
double x, // DOUBLE
double y, // DOUBLE
double width, // DOUBLE
double height, // DOUBLE
int* viewport // INT* in/out
);ccall((:gluPickMatrix, "GLU32.dll"), stdcall, Cvoid,
(Float64, Float64, Float64, Float64, Ptr{Int32}),
x, y, width, height, viewport)
# x : DOUBLE -> Float64
# y : DOUBLE -> Float64
# width : DOUBLE -> Float64
# height : DOUBLE -> Float64
# viewport : INT* in/out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void gluPickMatrix(
double x,
double y,
double width,
double height,
int32_t* viewport);
]]
local glu32 = ffi.load("glu32")
-- glu32.gluPickMatrix(x, y, width, height, viewport)
-- x : DOUBLE
-- y : DOUBLE
-- width : DOUBLE
-- height : DOUBLE
-- viewport : INT* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GLU32.dll');
const gluPickMatrix = lib.func('__stdcall', 'gluPickMatrix', 'void', ['double', 'double', 'double', 'double', 'int32_t *']);
// gluPickMatrix(x, y, width, height, viewport)
// x : DOUBLE -> 'double'
// y : DOUBLE -> 'double'
// width : DOUBLE -> 'double'
// height : DOUBLE -> 'double'
// viewport : INT* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GLU32.dll", {
gluPickMatrix: { parameters: ["f64", "f64", "f64", "f64", "pointer"], result: "void" },
});
// lib.symbols.gluPickMatrix(x, y, width, height, viewport)
// x : DOUBLE -> "f64"
// y : DOUBLE -> "f64"
// width : DOUBLE -> "f64"
// height : DOUBLE -> "f64"
// viewport : INT* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void gluPickMatrix(
double x,
double y,
double width,
double height,
int32_t* viewport);
C, "GLU32.dll");
// $ffi->gluPickMatrix(x, y, width, height, viewport);
// x : DOUBLE
// y : DOUBLE
// width : DOUBLE
// height : DOUBLE
// viewport : INT* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Glu32 extends StdCallLibrary {
Glu32 INSTANCE = Native.load("glu32", Glu32.class);
void gluPickMatrix(
double x, // DOUBLE
double y, // DOUBLE
double width, // DOUBLE
double height, // DOUBLE
IntByReference viewport // INT* in/out
);
}@[Link("glu32")]
lib LibGLU32
fun gluPickMatrix = gluPickMatrix(
x : Float64, # DOUBLE
y : Float64, # DOUBLE
width : Float64, # DOUBLE
height : Float64, # DOUBLE
viewport : Int32* # INT* in/out
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef gluPickMatrixNative = Void Function(Double, Double, Double, Double, Pointer<Int32>);
typedef gluPickMatrixDart = void Function(double, double, double, double, Pointer<Int32>);
final gluPickMatrix = DynamicLibrary.open('GLU32.dll')
.lookupFunction<gluPickMatrixNative, gluPickMatrixDart>('gluPickMatrix');
// x : DOUBLE -> Double
// y : DOUBLE -> Double
// width : DOUBLE -> Double
// height : DOUBLE -> Double
// viewport : INT* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure gluPickMatrix(
x: Double; // DOUBLE
y: Double; // DOUBLE
width: Double; // DOUBLE
height: Double; // DOUBLE
viewport: Pointer // INT* in/out
); stdcall;
external 'GLU32.dll' name 'gluPickMatrix';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "gluPickMatrix"
c_gluPickMatrix :: CDouble -> CDouble -> CDouble -> CDouble -> Ptr Int32 -> IO ()
-- x : DOUBLE -> CDouble
-- y : DOUBLE -> CDouble
-- width : DOUBLE -> CDouble
-- height : DOUBLE -> CDouble
-- viewport : INT* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let glupickmatrix =
foreign "gluPickMatrix"
(double @-> double @-> double @-> double @-> (ptr int32_t) @-> returning void)
(* x : DOUBLE -> double *)
(* y : DOUBLE -> double *)
(* width : DOUBLE -> double *)
(* height : DOUBLE -> double *)
(* viewport : INT* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library glu32 (t "GLU32.dll"))
(cffi:use-foreign-library glu32)
(cffi:defcfun ("gluPickMatrix" glu-pick-matrix :convention :stdcall) :void
(x :double) ; DOUBLE
(y :double) ; DOUBLE
(width :double) ; DOUBLE
(height :double) ; DOUBLE
(viewport :pointer)) ; INT* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $gluPickMatrix = Win32::API::More->new('GLU32',
'void gluPickMatrix(double x, double y, double width, double height, LPVOID viewport)');
# my $ret = $gluPickMatrix->Call($x, $y, $width, $height, $viewport);
# x : DOUBLE -> double
# y : DOUBLE -> double
# width : DOUBLE -> double
# height : DOUBLE -> double
# viewport : INT* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。