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

glOrtho

関数
正射影変換行列を現在の行列に乗算する。
DLLOPENGL32.dll呼出規約winapi

シグネチャ

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

void glOrtho(
    DOUBLE left,
    DOUBLE right,
    DOUBLE bottom,
    DOUBLE top,
    DOUBLE zNear,
    DOUBLE zFar
);

パラメーター

名前方向
leftDOUBLEin
rightDOUBLEin
bottomDOUBLEin
topDOUBLEin
zNearDOUBLEin
zFarDOUBLEin

戻り値の型: 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)。