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

glIndexi

関数
現在のカラーインデックスを整数で設定する。
DLLOPENGL32.dll呼出規約winapi

シグネチャ

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

void glIndexi(
    INT c
);

パラメーター

名前方向説明
cINTin現在のカラーインデックスを符号付き整数で指定する。

戻り値の型: void

公式ドキュメント

glIndexi 関数は、現在のカラーインデックスを設定します。

戻り値

この関数は値を返しません。

解説(Remarks)

glIndexi 関数は、現在の (単一値の) カラーインデックスを更新します。引数は 1 つで、現在のカラーインデックスに設定する新しい値です。

現在のインデックスは浮動小数点値として格納されます。整数値は特別なマッピングを行わずに、そのまま浮動小数点値へ変換されます。

カラーインデックスバッファーで表現可能な範囲を超えるインデックス値は、クランプされません。ただし、インデックスがディザリングされ (有効な場合)、フレームバッファーに書き込まれる前に、固定小数点形式へ変換されます。変換後の固定小数点値の整数部のうち、フレームバッファーのビットに対応しないビットはマスクされます。

現在のインデックスはいつでも更新できます。特に、glIndexiglBegin の呼び出しと、それに対応する glEnd の呼び出しの間でも呼び出すことができます。

次の関数は、glIndexi に関連する情報を取得します。

glGet に引数 GL_CURRENT_INDEX を指定

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp)

各言語での呼び出し定義

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

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

glIndexi = ctypes.windll.opengl32.glIndexi
glIndexi.restype = None
glIndexi.argtypes = [
    ctypes.c_int,  # c : INT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
	procglIndexi = opengl32.NewProc("glIndexi")
)

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

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

typedef glIndexiNative = Void Function(Int32);
typedef glIndexiDart = void Function(int);
final glIndexi = DynamicLibrary.open('OPENGL32.dll')
    .lookupFunction<glIndexiNative, glIndexiDart>('glIndexi');
// c : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure glIndexi(
  c: Integer   // INT
); stdcall;
  external 'OPENGL32.dll' name 'glIndexi';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "glIndexi"
  c_glIndexi :: Int32 -> IO ()
-- c : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let glindexi =
  foreign "glIndexi"
    (int32_t @-> returning void)
(* c : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library opengl32 (t "OPENGL32.dll"))
(cffi:use-foreign-library opengl32)

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