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