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

glColor4s

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

シグネチャ

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

void glColor4s(
    SHORT red,
    SHORT green,
    SHORT blue,
    SHORT alpha
);

パラメーター

名前方向
redSHORTin
greenSHORTin
blueSHORTin
alphaSHORTin

戻り値の型: void

各言語での呼び出し定義

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

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

glColor4s = ctypes.windll.opengl32.glColor4s
glColor4s.restype = None
glColor4s.argtypes = [
    ctypes.c_short,  # red : SHORT
    ctypes.c_short,  # green : SHORT
    ctypes.c_short,  # blue : SHORT
    ctypes.c_short,  # alpha : SHORT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
	procglColor4s = opengl32.NewProc("glColor4s")
)

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