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

glColor3ub

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

シグネチャ

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

void glColor3ub(
    BYTE red,
    BYTE green,
    BYTE blue
);

パラメーター

名前方向
redBYTEin
greenBYTEin
blueBYTEin

戻り値の型: void

各言語での呼び出し定義

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

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

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

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

var (
	opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
	procglColor3ub = opengl32.NewProc("glColor3ub")
)

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