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

glRectf

関数
単精度座標で塗りつぶし矩形を描画する。
DLLOPENGL32.dll呼出規約winapi

シグネチャ

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

void glRectf(
    FLOAT x1,
    FLOAT y1,
    FLOAT x2,
    FLOAT y2
);

パラメーター

名前方向説明
x1FLOATin矩形の一方の頂点のx座標。単精度で指定する。
y1FLOATin矩形の一方の頂点のy座標。単精度で指定する。
x2FLOATin対角の頂点のx座標。単精度で指定する。
y2FLOATin対角の頂点のy座標。単精度で指定する。

戻り値の型: void

各言語での呼び出し定義

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

void glRectf(
    FLOAT x1,
    FLOAT y1,
    FLOAT x2,
    FLOAT y2
);
[DllImport("OPENGL32.dll", ExactSpelling = true)]
static extern void glRectf(
    float x1,   // FLOAT
    float y1,   // FLOAT
    float x2,   // FLOAT
    float y2   // FLOAT
);
<DllImport("OPENGL32.dll", ExactSpelling:=True)>
Public Shared Sub glRectf(
    x1 As Single,   ' FLOAT
    y1 As Single,   ' FLOAT
    x2 As Single,   ' FLOAT
    y2 As Single   ' FLOAT
)
End Sub
' x1 : FLOAT
' y1 : FLOAT
' x2 : FLOAT
' y2 : FLOAT
Declare PtrSafe Sub glRectf Lib "opengl32" ( _
    ByVal x1 As Single, _
    ByVal y1 As Single, _
    ByVal x2 As Single, _
    ByVal y2 As Single)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

glRectf = ctypes.windll.opengl32.glRectf
glRectf.restype = None
glRectf.argtypes = [
    ctypes.c_float,  # x1 : FLOAT
    ctypes.c_float,  # y1 : FLOAT
    ctypes.c_float,  # x2 : FLOAT
    ctypes.c_float,  # y2 : FLOAT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OPENGL32.dll')
glRectf = Fiddle::Function.new(
  lib['glRectf'],
  [
    Fiddle::TYPE_FLOAT,  # x1 : FLOAT
    Fiddle::TYPE_FLOAT,  # y1 : FLOAT
    Fiddle::TYPE_FLOAT,  # x2 : FLOAT
    Fiddle::TYPE_FLOAT,  # y2 : FLOAT
  ],
  Fiddle::TYPE_VOID)
#[link(name = "opengl32")]
extern "system" {
    fn glRectf(
        x1: f32,  // FLOAT
        y1: f32,  // FLOAT
        x2: f32,  // FLOAT
        y2: f32  // FLOAT
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OPENGL32.dll")]
public static extern void glRectf(float x1, float y1, float x2, float y2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OPENGL32_glRectf' -Namespace Win32 -PassThru
# $api::glRectf(x1, y1, x2, y2)
#uselib "OPENGL32.dll"
#func global glRectf "glRectf" float, float, float, float
; glRectf x1, y1, x2, y2
; x1 : FLOAT -> "float"
; y1 : FLOAT -> "float"
; x2 : FLOAT -> "float"
; y2 : FLOAT -> "float"
#uselib "OPENGL32.dll"
#func global glRectf "glRectf" float, float, float, float
; glRectf x1, y1, x2, y2
; x1 : FLOAT -> "float"
; y1 : FLOAT -> "float"
; x2 : FLOAT -> "float"
; y2 : FLOAT -> "float"
; void glRectf(FLOAT x1, FLOAT y1, FLOAT x2, FLOAT y2)
#uselib "OPENGL32.dll"
#func global glRectf "glRectf" float, float, float, float
; glRectf x1, y1, x2, y2
; x1 : FLOAT -> "float"
; y1 : FLOAT -> "float"
; x2 : FLOAT -> "float"
; y2 : FLOAT -> "float"
import (
	"math"
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
	procglRectf = opengl32.NewProc("glRectf")
)

// x1 (FLOAT), y1 (FLOAT), x2 (FLOAT), y2 (FLOAT)
r1, _, err := procglRectf.Call(
	uintptr(math.Float32bits(x1)),
	uintptr(math.Float32bits(y1)),
	uintptr(math.Float32bits(x2)),
	uintptr(math.Float32bits(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 glRectf(
  x1: Single;   // FLOAT
  y1: Single;   // FLOAT
  x2: Single;   // FLOAT
  y2: Single   // FLOAT
); stdcall;
  external 'OPENGL32.dll' name 'glRectf';
result := DllCall("OPENGL32\glRectf"
    , "Float", x1   ; FLOAT
    , "Float", y1   ; FLOAT
    , "Float", x2   ; FLOAT
    , "Float", y2   ; FLOAT
    , "Int")   ; return: void
●glRectf(x1, y1, x2, y2) = DLL("OPENGL32.dll", "int glRectf(float, float, float, float)")
# 呼び出し: glRectf(x1, y1, x2, y2)
# x1 : FLOAT -> "float"
# y1 : FLOAT -> "float"
# x2 : FLOAT -> "float"
# y2 : FLOAT -> "float"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "opengl32" fn glRectf(
    x1: f32, // FLOAT
    y1: f32, // FLOAT
    x2: f32, // FLOAT
    y2: f32 // FLOAT
) callconv(std.os.windows.WINAPI) void;
proc glRectf(
    x1: float32,  # FLOAT
    y1: float32,  # FLOAT
    x2: float32,  # FLOAT
    y2: float32  # FLOAT
) {.importc: "glRectf", stdcall, dynlib: "OPENGL32.dll".}
pragma(lib, "opengl32");
extern(Windows)
void glRectf(
    float x1,   // FLOAT
    float y1,   // FLOAT
    float x2,   // FLOAT
    float y2   // FLOAT
);
ccall((:glRectf, "OPENGL32.dll"), stdcall, Cvoid,
      (Float32, Float32, Float32, Float32),
      x1, y1, x2, y2)
# x1 : FLOAT -> Float32
# y1 : FLOAT -> Float32
# x2 : FLOAT -> Float32
# y2 : FLOAT -> Float32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void glRectf(
    float x1,
    float y1,
    float x2,
    float y2);
]]
local opengl32 = ffi.load("opengl32")
-- opengl32.glRectf(x1, y1, x2, y2)
-- x1 : FLOAT
-- y1 : FLOAT
-- x2 : FLOAT
-- y2 : FLOAT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('OPENGL32.dll');
const glRectf = lib.func('__stdcall', 'glRectf', 'void', ['float', 'float', 'float', 'float']);
// glRectf(x1, y1, x2, y2)
// x1 : FLOAT -> 'float'
// y1 : FLOAT -> 'float'
// x2 : FLOAT -> 'float'
// y2 : FLOAT -> 'float'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("OPENGL32.dll", {
  glRectf: { parameters: ["f32", "f32", "f32", "f32"], result: "void" },
});
// lib.symbols.glRectf(x1, y1, x2, y2)
// x1 : FLOAT -> "f32"
// y1 : FLOAT -> "f32"
// x2 : FLOAT -> "f32"
// y2 : FLOAT -> "f32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void glRectf(
    float x1,
    float y1,
    float x2,
    float y2);
C, "OPENGL32.dll");
// $ffi->glRectf(x1, y1, x2, y2);
// x1 : FLOAT
// y1 : FLOAT
// x2 : FLOAT
// y2 : FLOAT
// 構造体/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 glRectf(
        float x1,   // FLOAT
        float y1,   // FLOAT
        float x2,   // FLOAT
        float y2   // FLOAT
    );
}
@[Link("opengl32")]
lib LibOPENGL32
  fun glRectf = glRectf(
    x1 : Float32,   # FLOAT
    y1 : Float32,   # FLOAT
    x2 : Float32,   # FLOAT
    y2 : Float32   # FLOAT
  ) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef glRectfNative = Void Function(Float, Float, Float, Float);
typedef glRectfDart = void Function(double, double, double, double);
final glRectf = DynamicLibrary.open('OPENGL32.dll')
    .lookupFunction<glRectfNative, glRectfDart>('glRectf');
// x1 : FLOAT -> Float
// y1 : FLOAT -> Float
// x2 : FLOAT -> Float
// y2 : FLOAT -> Float
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure glRectf(
  x1: Single;   // FLOAT
  y1: Single;   // FLOAT
  x2: Single;   // FLOAT
  y2: Single   // FLOAT
); stdcall;
  external 'OPENGL32.dll' name 'glRectf';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "glRectf"
  c_glRectf :: CFloat -> CFloat -> CFloat -> CFloat -> IO ()
-- x1 : FLOAT -> CFloat
-- y1 : FLOAT -> CFloat
-- x2 : FLOAT -> CFloat
-- y2 : FLOAT -> CFloat
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let glrectf =
  foreign "glRectf"
    (float @-> float @-> float @-> float @-> returning void)
(* x1 : FLOAT -> float *)
(* y1 : FLOAT -> float *)
(* x2 : FLOAT -> float *)
(* y2 : FLOAT -> float *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library opengl32 (t "OPENGL32.dll"))
(cffi:use-foreign-library opengl32)

(cffi:defcfun ("glRectf" gl-rectf :convention :stdcall) :void
  (x1 :float)   ; FLOAT
  (y1 :float)   ; FLOAT
  (x2 :float)   ; FLOAT
  (y2 :float))   ; FLOAT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $glRectf = Win32::API::More->new('OPENGL32',
    'void glRectf(float x1, float y1, float x2, float y2)');
# my $ret = $glRectf->Call($x1, $y1, $x2, $y2);
# x1 : FLOAT -> float
# y1 : FLOAT -> float
# x2 : FLOAT -> float
# y2 : FLOAT -> float
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。