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

glRects

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

シグネチャ

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

void glRects(
    SHORT x1,
    SHORT y1,
    SHORT x2,
    SHORT y2
);

パラメーター

名前方向説明
x1SHORTin矩形の一方の頂点のx座標。短整数で指定する。
y1SHORTin矩形の一方の頂点のy座標。短整数で指定する。
x2SHORTin対角の頂点のx座標。短整数で指定する。
y2SHORTin対角の頂点のy座標。短整数で指定する。

戻り値の型: void

各言語での呼び出し定義

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

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

glRects = ctypes.windll.opengl32.glRects
glRects.restype = None
glRects.argtypes = [
    ctypes.c_short,  # x1 : SHORT
    ctypes.c_short,  # y1 : SHORT
    ctypes.c_short,  # x2 : SHORT
    ctypes.c_short,  # y2 : SHORT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
	procglRects = opengl32.NewProc("glRects")
)

// x1 (SHORT), y1 (SHORT), x2 (SHORT), y2 (SHORT)
r1, _, err := procglRects.Call(
	uintptr(x1),
	uintptr(y1),
	uintptr(x2),
	uintptr(y2),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure glRects(
  x1: Smallint;   // SHORT
  y1: Smallint;   // SHORT
  x2: Smallint;   // SHORT
  y2: Smallint   // SHORT
); stdcall;
  external 'OPENGL32.dll' name 'glRects';
result := DllCall("OPENGL32\glRects"
    , "Short", x1   ; SHORT
    , "Short", y1   ; SHORT
    , "Short", x2   ; SHORT
    , "Short", y2   ; SHORT
    , "Int")   ; return: void
●glRects(x1, y1, x2, y2) = DLL("OPENGL32.dll", "int glRects(int, int, int, int)")
# 呼び出し: glRects(x1, y1, x2, y2)
# x1 : SHORT -> "int"
# y1 : SHORT -> "int"
# x2 : SHORT -> "int"
# y2 : SHORT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

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

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

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

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