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