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

glColor4d

関数
倍精度値で描画色をRGBAアルファ付きで設定する。
DLLOPENGL32.dll呼出規約winapi

シグネチャ

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

void glColor4d(
    DOUBLE red,
    DOUBLE green,
    DOUBLE blue,
    DOUBLE alpha
);

パラメーター

名前方向説明
redDOUBLEin現在色の赤成分を倍精度浮動小数で指定する。通常0.0〜1.0の範囲で扱う。
greenDOUBLEin現在色の緑成分を倍精度浮動小数で指定する。通常0.0〜1.0の範囲で扱う。
blueDOUBLEin現在色の青成分を倍精度浮動小数で指定する。通常0.0〜1.0の範囲で扱う。
alphaDOUBLEin現在色のアルファ成分を倍精度浮動小数で指定する。1.0が不透明を表す。

戻り値の型: void

各言語での呼び出し定義

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

void glColor4d(
    DOUBLE red,
    DOUBLE green,
    DOUBLE blue,
    DOUBLE alpha
);
[DllImport("OPENGL32.dll", ExactSpelling = true)]
static extern void glColor4d(
    double red,   // DOUBLE
    double green,   // DOUBLE
    double blue,   // DOUBLE
    double alpha   // DOUBLE
);
<DllImport("OPENGL32.dll", ExactSpelling:=True)>
Public Shared Sub glColor4d(
    red As Double,   ' DOUBLE
    green As Double,   ' DOUBLE
    blue As Double,   ' DOUBLE
    alpha As Double   ' DOUBLE
)
End Sub
' red : DOUBLE
' green : DOUBLE
' blue : DOUBLE
' alpha : DOUBLE
Declare PtrSafe Sub glColor4d Lib "opengl32" ( _
    ByVal red As Double, _
    ByVal green As Double, _
    ByVal blue As Double, _
    ByVal alpha As Double)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

glColor4d = ctypes.windll.opengl32.glColor4d
glColor4d.restype = None
glColor4d.argtypes = [
    ctypes.c_double,  # red : DOUBLE
    ctypes.c_double,  # green : DOUBLE
    ctypes.c_double,  # blue : DOUBLE
    ctypes.c_double,  # alpha : DOUBLE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OPENGL32.dll')
glColor4d = Fiddle::Function.new(
  lib['glColor4d'],
  [
    Fiddle::TYPE_DOUBLE,  # red : DOUBLE
    Fiddle::TYPE_DOUBLE,  # green : DOUBLE
    Fiddle::TYPE_DOUBLE,  # blue : DOUBLE
    Fiddle::TYPE_DOUBLE,  # alpha : DOUBLE
  ],
  Fiddle::TYPE_VOID)
#[link(name = "opengl32")]
extern "system" {
    fn glColor4d(
        red: f64,  // DOUBLE
        green: f64,  // DOUBLE
        blue: f64,  // DOUBLE
        alpha: f64  // DOUBLE
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OPENGL32.dll")]
public static extern void glColor4d(double red, double green, double blue, double alpha);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OPENGL32_glColor4d' -Namespace Win32 -PassThru
# $api::glColor4d(red, green, blue, alpha)
#uselib "OPENGL32.dll"
#func global glColor4d "glColor4d" double, double, double, double
; glColor4d red, green, blue, alpha
; red : DOUBLE -> "double"
; green : DOUBLE -> "double"
; blue : DOUBLE -> "double"
; alpha : DOUBLE -> "double"
#uselib "OPENGL32.dll"
#func global glColor4d "glColor4d" double, double, double, double
; glColor4d red, green, blue, alpha
; red : DOUBLE -> "double"
; green : DOUBLE -> "double"
; blue : DOUBLE -> "double"
; alpha : DOUBLE -> "double"
; void glColor4d(DOUBLE red, DOUBLE green, DOUBLE blue, DOUBLE alpha)
#uselib "OPENGL32.dll"
#func global glColor4d "glColor4d" double, double, double, double
; glColor4d red, green, blue, alpha
; red : DOUBLE -> "double"
; green : DOUBLE -> "double"
; blue : DOUBLE -> "double"
; alpha : DOUBLE -> "double"
import (
	"math"
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
	procglColor4d = opengl32.NewProc("glColor4d")
)

// red (DOUBLE), green (DOUBLE), blue (DOUBLE), alpha (DOUBLE)
r1, _, err := procglColor4d.Call(
	uintptr(math.Float64bits(red)),
	uintptr(math.Float64bits(green)),
	uintptr(math.Float64bits(blue)),
	uintptr(math.Float64bits(alpha)),
)
_ = 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 glColor4d(
  red: Double;   // DOUBLE
  green: Double;   // DOUBLE
  blue: Double;   // DOUBLE
  alpha: Double   // DOUBLE
); stdcall;
  external 'OPENGL32.dll' name 'glColor4d';
result := DllCall("OPENGL32\glColor4d"
    , "Double", red   ; DOUBLE
    , "Double", green   ; DOUBLE
    , "Double", blue   ; DOUBLE
    , "Double", alpha   ; DOUBLE
    , "Int")   ; return: void
●glColor4d(red, green, blue, alpha) = DLL("OPENGL32.dll", "int glColor4d(double, double, double, double)")
# 呼び出し: glColor4d(red, green, blue, alpha)
# red : DOUBLE -> "double"
# green : DOUBLE -> "double"
# blue : DOUBLE -> "double"
# alpha : DOUBLE -> "double"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "opengl32" fn glColor4d(
    red: f64, // DOUBLE
    green: f64, // DOUBLE
    blue: f64, // DOUBLE
    alpha: f64 // DOUBLE
) callconv(std.os.windows.WINAPI) void;
proc glColor4d(
    red: float64,  # DOUBLE
    green: float64,  # DOUBLE
    blue: float64,  # DOUBLE
    alpha: float64  # DOUBLE
) {.importc: "glColor4d", stdcall, dynlib: "OPENGL32.dll".}
pragma(lib, "opengl32");
extern(Windows)
void glColor4d(
    double red,   // DOUBLE
    double green,   // DOUBLE
    double blue,   // DOUBLE
    double alpha   // DOUBLE
);
ccall((:glColor4d, "OPENGL32.dll"), stdcall, Cvoid,
      (Float64, Float64, Float64, Float64),
      red, green, blue, alpha)
# red : DOUBLE -> Float64
# green : DOUBLE -> Float64
# blue : DOUBLE -> Float64
# alpha : DOUBLE -> Float64
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void glColor4d(
    double red,
    double green,
    double blue,
    double alpha);
]]
local opengl32 = ffi.load("opengl32")
-- opengl32.glColor4d(red, green, blue, alpha)
-- red : DOUBLE
-- green : DOUBLE
-- blue : DOUBLE
-- alpha : DOUBLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('OPENGL32.dll');
const glColor4d = lib.func('__stdcall', 'glColor4d', 'void', ['double', 'double', 'double', 'double']);
// glColor4d(red, green, blue, alpha)
// red : DOUBLE -> 'double'
// green : DOUBLE -> 'double'
// blue : DOUBLE -> 'double'
// alpha : DOUBLE -> 'double'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("OPENGL32.dll", {
  glColor4d: { parameters: ["f64", "f64", "f64", "f64"], result: "void" },
});
// lib.symbols.glColor4d(red, green, blue, alpha)
// red : DOUBLE -> "f64"
// green : DOUBLE -> "f64"
// blue : DOUBLE -> "f64"
// alpha : DOUBLE -> "f64"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void glColor4d(
    double red,
    double green,
    double blue,
    double alpha);
C, "OPENGL32.dll");
// $ffi->glColor4d(red, green, blue, alpha);
// red : DOUBLE
// green : DOUBLE
// blue : DOUBLE
// alpha : 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 glColor4d(
        double red,   // DOUBLE
        double green,   // DOUBLE
        double blue,   // DOUBLE
        double alpha   // DOUBLE
    );
}
@[Link("opengl32")]
lib LibOPENGL32
  fun glColor4d = glColor4d(
    red : Float64,   # DOUBLE
    green : Float64,   # DOUBLE
    blue : Float64,   # DOUBLE
    alpha : 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 glColor4dNative = Void Function(Double, Double, Double, Double);
typedef glColor4dDart = void Function(double, double, double, double);
final glColor4d = DynamicLibrary.open('OPENGL32.dll')
    .lookupFunction<glColor4dNative, glColor4dDart>('glColor4d');
// red : DOUBLE -> Double
// green : DOUBLE -> Double
// blue : DOUBLE -> Double
// alpha : DOUBLE -> Double
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure glColor4d(
  red: Double;   // DOUBLE
  green: Double;   // DOUBLE
  blue: Double;   // DOUBLE
  alpha: Double   // DOUBLE
); stdcall;
  external 'OPENGL32.dll' name 'glColor4d';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "glColor4d"
  c_glColor4d :: CDouble -> CDouble -> CDouble -> CDouble -> IO ()
-- red : DOUBLE -> CDouble
-- green : DOUBLE -> CDouble
-- blue : DOUBLE -> CDouble
-- alpha : DOUBLE -> CDouble
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let glcolor4d =
  foreign "glColor4d"
    (double @-> double @-> double @-> double @-> returning void)
(* red : DOUBLE -> double *)
(* green : DOUBLE -> double *)
(* blue : DOUBLE -> double *)
(* alpha : DOUBLE -> double *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library opengl32 (t "OPENGL32.dll"))
(cffi:use-foreign-library opengl32)

(cffi:defcfun ("glColor4d" gl-color4d :convention :stdcall) :void
  (red :double)   ; DOUBLE
  (green :double)   ; DOUBLE
  (blue :double)   ; DOUBLE
  (alpha :double))   ; DOUBLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $glColor4d = Win32::API::More->new('OPENGL32',
    'void glColor4d(double red, double green, double blue, double alpha)');
# my $ret = $glColor4d->Call($red, $green, $blue, $alpha);
# red : DOUBLE -> double
# green : DOUBLE -> double
# blue : DOUBLE -> double
# alpha : DOUBLE -> double
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。