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

glColor4ub

関数
符号なしバイト値で描画色をRGBAで設定する。
DLLOPENGL32.dll呼出規約winapi

シグネチャ

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

void glColor4ub(
    BYTE red,
    BYTE green,
    BYTE blue,
    BYTE alpha
);

パラメーター

名前方向説明
redBYTEin現在色の赤成分を符号なし8ビット整数で指定する。0〜255が0.0〜1.0へ正規化される。
greenBYTEin現在色の緑成分を符号なし8ビット整数で指定する。0〜255が0.0〜1.0へ正規化される。
blueBYTEin現在色の青成分を符号なし8ビット整数で指定する。0〜255が0.0〜1.0へ正規化される。
alphaBYTEin現在色のアルファ成分を符号なし8ビット整数で指定する。255が不透明を表す。

戻り値の型: void

各言語での呼び出し定義

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

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

glColor4ub = ctypes.windll.opengl32.glColor4ub
glColor4ub.restype = None
glColor4ub.argtypes = [
    ctypes.c_ubyte,  # red : BYTE
    ctypes.c_ubyte,  # green : BYTE
    ctypes.c_ubyte,  # blue : BYTE
    ctypes.c_ubyte,  # alpha : BYTE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
	procglColor4ub = opengl32.NewProc("glColor4ub")
)

// red (BYTE), green (BYTE), blue (BYTE), alpha (BYTE)
r1, _, err := procglColor4ub.Call(
	uintptr(red),
	uintptr(green),
	uintptr(blue),
	uintptr(alpha),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure glColor4ub(
  red: Byte;   // BYTE
  green: Byte;   // BYTE
  blue: Byte;   // BYTE
  alpha: Byte   // BYTE
); stdcall;
  external 'OPENGL32.dll' name 'glColor4ub';
result := DllCall("OPENGL32\glColor4ub"
    , "UChar", red   ; BYTE
    , "UChar", green   ; BYTE
    , "UChar", blue   ; BYTE
    , "UChar", alpha   ; BYTE
    , "Int")   ; return: void
●glColor4ub(red, green, blue, alpha) = DLL("OPENGL32.dll", "int glColor4ub(byte, byte, byte, byte)")
# 呼び出し: glColor4ub(red, green, blue, alpha)
# red : BYTE -> "byte"
# green : BYTE -> "byte"
# blue : BYTE -> "byte"
# alpha : BYTE -> "byte"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。