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