ホーム › Graphics.OpenGL › gluOrtho2D
gluOrtho2D
関数2次元の正射影変換行列を設定する。
シグネチャ
// GLU32.dll
#include <windows.h>
void gluOrtho2D(
DOUBLE left,
DOUBLE right,
DOUBLE bottom,
DOUBLE top
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| left | DOUBLE | in | 正射影クリッピング領域の左端の座標。 |
| right | DOUBLE | in | 正射影クリッピング領域の右端の座標。 |
| bottom | DOUBLE | in | 正射影クリッピング領域の下端の座標。 |
| top | DOUBLE | in | 正射影クリッピング領域の上端の座標。 |
戻り値の型: void
各言語での呼び出し定義
// GLU32.dll
#include <windows.h>
void gluOrtho2D(
DOUBLE left,
DOUBLE right,
DOUBLE bottom,
DOUBLE top
);[DllImport("GLU32.dll", ExactSpelling = true)]
static extern void gluOrtho2D(
double left, // DOUBLE
double right, // DOUBLE
double bottom, // DOUBLE
double top // DOUBLE
);<DllImport("GLU32.dll", ExactSpelling:=True)>
Public Shared Sub gluOrtho2D(
left As Double, ' DOUBLE
right As Double, ' DOUBLE
bottom As Double, ' DOUBLE
top As Double ' DOUBLE
)
End Sub' left : DOUBLE
' right : DOUBLE
' bottom : DOUBLE
' top : DOUBLE
Declare PtrSafe Sub gluOrtho2D Lib "glu32" ( _
ByVal left As Double, _
ByVal right As Double, _
ByVal bottom As Double, _
ByVal top As Double)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
gluOrtho2D = ctypes.windll.glu32.gluOrtho2D
gluOrtho2D.restype = None
gluOrtho2D.argtypes = [
ctypes.c_double, # left : DOUBLE
ctypes.c_double, # right : DOUBLE
ctypes.c_double, # bottom : DOUBLE
ctypes.c_double, # top : DOUBLE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GLU32.dll')
gluOrtho2D = Fiddle::Function.new(
lib['gluOrtho2D'],
[
Fiddle::TYPE_DOUBLE, # left : DOUBLE
Fiddle::TYPE_DOUBLE, # right : DOUBLE
Fiddle::TYPE_DOUBLE, # bottom : DOUBLE
Fiddle::TYPE_DOUBLE, # top : DOUBLE
],
Fiddle::TYPE_VOID)#[link(name = "glu32")]
extern "system" {
fn gluOrtho2D(
left: f64, // DOUBLE
right: f64, // DOUBLE
bottom: f64, // DOUBLE
top: f64 // DOUBLE
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GLU32.dll")]
public static extern void gluOrtho2D(double left, double right, double bottom, double top);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GLU32_gluOrtho2D' -Namespace Win32 -PassThru
# $api::gluOrtho2D(left, right, bottom, top)#uselib "GLU32.dll"
#func global gluOrtho2D "gluOrtho2D" double, double, double, double
; gluOrtho2D left, right, bottom, top
; left : DOUBLE -> "double"
; right : DOUBLE -> "double"
; bottom : DOUBLE -> "double"
; top : DOUBLE -> "double"#uselib "GLU32.dll"
#func global gluOrtho2D "gluOrtho2D" double, double, double, double
; gluOrtho2D left, right, bottom, top
; left : DOUBLE -> "double"
; right : DOUBLE -> "double"
; bottom : DOUBLE -> "double"
; top : DOUBLE -> "double"; void gluOrtho2D(DOUBLE left, DOUBLE right, DOUBLE bottom, DOUBLE top)
#uselib "GLU32.dll"
#func global gluOrtho2D "gluOrtho2D" double, double, double, double
; gluOrtho2D left, right, bottom, top
; left : DOUBLE -> "double"
; right : DOUBLE -> "double"
; bottom : DOUBLE -> "double"
; top : DOUBLE -> "double"import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
glu32 = windows.NewLazySystemDLL("GLU32.dll")
procgluOrtho2D = glu32.NewProc("gluOrtho2D")
)
// left (DOUBLE), right (DOUBLE), bottom (DOUBLE), top (DOUBLE)
r1, _, err := procgluOrtho2D.Call(
uintptr(math.Float64bits(left)),
uintptr(math.Float64bits(right)),
uintptr(math.Float64bits(bottom)),
uintptr(math.Float64bits(top)),
)
_ = 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 gluOrtho2D(
left: Double; // DOUBLE
right: Double; // DOUBLE
bottom: Double; // DOUBLE
top: Double // DOUBLE
); stdcall;
external 'GLU32.dll' name 'gluOrtho2D';result := DllCall("GLU32\gluOrtho2D"
, "Double", left ; DOUBLE
, "Double", right ; DOUBLE
, "Double", bottom ; DOUBLE
, "Double", top ; DOUBLE
, "Int") ; return: void●gluOrtho2D(left, right, bottom, top) = DLL("GLU32.dll", "int gluOrtho2D(double, double, double, double)")
# 呼び出し: gluOrtho2D(left, right, bottom, top)
# left : DOUBLE -> "double"
# right : DOUBLE -> "double"
# bottom : DOUBLE -> "double"
# top : DOUBLE -> "double"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "glu32" fn gluOrtho2D(
left: f64, // DOUBLE
right: f64, // DOUBLE
bottom: f64, // DOUBLE
top: f64 // DOUBLE
) callconv(std.os.windows.WINAPI) void;proc gluOrtho2D(
left: float64, # DOUBLE
right: float64, # DOUBLE
bottom: float64, # DOUBLE
top: float64 # DOUBLE
) {.importc: "gluOrtho2D", stdcall, dynlib: "GLU32.dll".}pragma(lib, "glu32");
extern(Windows)
void gluOrtho2D(
double left, // DOUBLE
double right, // DOUBLE
double bottom, // DOUBLE
double top // DOUBLE
);ccall((:gluOrtho2D, "GLU32.dll"), stdcall, Cvoid,
(Float64, Float64, Float64, Float64),
left, right, bottom, top)
# left : DOUBLE -> Float64
# right : DOUBLE -> Float64
# bottom : DOUBLE -> Float64
# top : DOUBLE -> Float64
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void gluOrtho2D(
double left,
double right,
double bottom,
double top);
]]
local glu32 = ffi.load("glu32")
-- glu32.gluOrtho2D(left, right, bottom, top)
-- left : DOUBLE
-- right : DOUBLE
-- bottom : DOUBLE
-- top : DOUBLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GLU32.dll');
const gluOrtho2D = lib.func('__stdcall', 'gluOrtho2D', 'void', ['double', 'double', 'double', 'double']);
// gluOrtho2D(left, right, bottom, top)
// left : DOUBLE -> 'double'
// right : DOUBLE -> 'double'
// bottom : DOUBLE -> 'double'
// top : DOUBLE -> 'double'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GLU32.dll", {
gluOrtho2D: { parameters: ["f64", "f64", "f64", "f64"], result: "void" },
});
// lib.symbols.gluOrtho2D(left, right, bottom, top)
// left : DOUBLE -> "f64"
// right : DOUBLE -> "f64"
// bottom : DOUBLE -> "f64"
// top : DOUBLE -> "f64"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void gluOrtho2D(
double left,
double right,
double bottom,
double top);
C, "GLU32.dll");
// $ffi->gluOrtho2D(left, right, bottom, top);
// left : DOUBLE
// right : DOUBLE
// bottom : DOUBLE
// top : DOUBLE
// 構造体/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 gluOrtho2D(
double left, // DOUBLE
double right, // DOUBLE
double bottom, // DOUBLE
double top // DOUBLE
);
}@[Link("glu32")]
lib LibGLU32
fun gluOrtho2D = gluOrtho2D(
left : Float64, # DOUBLE
right : Float64, # DOUBLE
bottom : Float64, # DOUBLE
top : Float64 # DOUBLE
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef gluOrtho2DNative = Void Function(Double, Double, Double, Double);
typedef gluOrtho2DDart = void Function(double, double, double, double);
final gluOrtho2D = DynamicLibrary.open('GLU32.dll')
.lookupFunction<gluOrtho2DNative, gluOrtho2DDart>('gluOrtho2D');
// left : DOUBLE -> Double
// right : DOUBLE -> Double
// bottom : DOUBLE -> Double
// top : DOUBLE -> Double
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure gluOrtho2D(
left: Double; // DOUBLE
right: Double; // DOUBLE
bottom: Double; // DOUBLE
top: Double // DOUBLE
); stdcall;
external 'GLU32.dll' name 'gluOrtho2D';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "gluOrtho2D"
c_gluOrtho2D :: CDouble -> CDouble -> CDouble -> CDouble -> IO ()
-- left : DOUBLE -> CDouble
-- right : DOUBLE -> CDouble
-- bottom : DOUBLE -> CDouble
-- top : DOUBLE -> CDouble
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gluortho2d =
foreign "gluOrtho2D"
(double @-> double @-> double @-> double @-> returning void)
(* left : DOUBLE -> double *)
(* right : DOUBLE -> double *)
(* bottom : DOUBLE -> double *)
(* top : DOUBLE -> double *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library glu32 (t "GLU32.dll"))
(cffi:use-foreign-library glu32)
(cffi:defcfun ("gluOrtho2D" glu-ortho2-d :convention :stdcall) :void
(left :double) ; DOUBLE
(right :double) ; DOUBLE
(bottom :double) ; DOUBLE
(top :double)) ; DOUBLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $gluOrtho2D = Win32::API::More->new('GLU32',
'void gluOrtho2D(double left, double right, double bottom, double top)');
# my $ret = $gluOrtho2D->Call($left, $right, $bottom, $top);
# left : DOUBLE -> double
# right : DOUBLE -> double
# bottom : DOUBLE -> double
# top : DOUBLE -> double
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。