ホーム › Graphics.OpenGL › glGenTextures
glGenTextures
関数未使用のテクスチャオブジェクト名を生成する。
シグネチャ
// OPENGL32.dll
#include <windows.h>
void glGenTextures(
INT n,
DWORD* textures
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| n | INT | in | 生成するテクスチャ名の個数。 |
| textures | DWORD* | inout | 生成されたテクスチャ名を受け取る符号なし整数配列へのポインタ(出力)。 |
戻り値の型: void
各言語での呼び出し定義
// OPENGL32.dll
#include <windows.h>
void glGenTextures(
INT n,
DWORD* textures
);[DllImport("OPENGL32.dll", ExactSpelling = true)]
static extern void glGenTextures(
int n, // INT
ref uint textures // DWORD* in/out
);<DllImport("OPENGL32.dll", ExactSpelling:=True)>
Public Shared Sub glGenTextures(
n As Integer, ' INT
ByRef textures As UInteger ' DWORD* in/out
)
End Sub' n : INT
' textures : DWORD* in/out
Declare PtrSafe Sub glGenTextures Lib "opengl32" ( _
ByVal n As Long, _
ByRef textures As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
glGenTextures = ctypes.windll.opengl32.glGenTextures
glGenTextures.restype = None
glGenTextures.argtypes = [
ctypes.c_int, # n : INT
ctypes.POINTER(wintypes.DWORD), # textures : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OPENGL32.dll')
glGenTextures = Fiddle::Function.new(
lib['glGenTextures'],
[
Fiddle::TYPE_INT, # n : INT
Fiddle::TYPE_VOIDP, # textures : DWORD* in/out
],
Fiddle::TYPE_VOID)#[link(name = "opengl32")]
extern "system" {
fn glGenTextures(
n: i32, // INT
textures: *mut u32 // DWORD* in/out
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OPENGL32.dll")]
public static extern void glGenTextures(int n, ref uint textures);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OPENGL32_glGenTextures' -Namespace Win32 -PassThru
# $api::glGenTextures(n, textures)#uselib "OPENGL32.dll"
#func global glGenTextures "glGenTextures" sptr, sptr
; glGenTextures n, varptr(textures)
; n : INT -> "sptr"
; textures : DWORD* in/out -> "sptr"出力引数:
#uselib "OPENGL32.dll" #func global glGenTextures "glGenTextures" int, var ; glGenTextures n, textures ; n : INT -> "int" ; textures : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "OPENGL32.dll" #func global glGenTextures "glGenTextures" int, sptr ; glGenTextures n, varptr(textures) ; n : INT -> "int" ; textures : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void glGenTextures(INT n, DWORD* textures) #uselib "OPENGL32.dll" #func global glGenTextures "glGenTextures" int, var ; glGenTextures n, textures ; n : INT -> "int" ; textures : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void glGenTextures(INT n, DWORD* textures) #uselib "OPENGL32.dll" #func global glGenTextures "glGenTextures" int, intptr ; glGenTextures n, varptr(textures) ; n : INT -> "int" ; textures : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
procglGenTextures = opengl32.NewProc("glGenTextures")
)
// n (INT), textures (DWORD* in/out)
r1, _, err := procglGenTextures.Call(
uintptr(n),
uintptr(textures),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure glGenTextures(
n: Integer; // INT
textures: Pointer // DWORD* in/out
); stdcall;
external 'OPENGL32.dll' name 'glGenTextures';result := DllCall("OPENGL32\glGenTextures"
, "Int", n ; INT
, "Ptr", textures ; DWORD* in/out
, "Int") ; return: void●glGenTextures(n, textures) = DLL("OPENGL32.dll", "int glGenTextures(int, void*)")
# 呼び出し: glGenTextures(n, textures)
# n : INT -> "int"
# textures : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "opengl32" fn glGenTextures(
n: i32, // INT
textures: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) void;proc glGenTextures(
n: int32, # INT
textures: ptr uint32 # DWORD* in/out
) {.importc: "glGenTextures", stdcall, dynlib: "OPENGL32.dll".}pragma(lib, "opengl32");
extern(Windows)
void glGenTextures(
int n, // INT
uint* textures // DWORD* in/out
);ccall((:glGenTextures, "OPENGL32.dll"), stdcall, Cvoid,
(Int32, Ptr{UInt32}),
n, textures)
# n : INT -> Int32
# textures : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void glGenTextures(
int32_t n,
uint32_t* textures);
]]
local opengl32 = ffi.load("opengl32")
-- opengl32.glGenTextures(n, textures)
-- n : INT
-- textures : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('OPENGL32.dll');
const glGenTextures = lib.func('__stdcall', 'glGenTextures', 'void', ['int32_t', 'uint32_t *']);
// glGenTextures(n, textures)
// n : INT -> 'int32_t'
// textures : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("OPENGL32.dll", {
glGenTextures: { parameters: ["i32", "pointer"], result: "void" },
});
// lib.symbols.glGenTextures(n, textures)
// n : INT -> "i32"
// textures : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void glGenTextures(
int32_t n,
uint32_t* textures);
C, "OPENGL32.dll");
// $ffi->glGenTextures(n, textures);
// n : INT
// textures : DWORD* in/out
// 構造体/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 glGenTextures(
int n, // INT
IntByReference textures // DWORD* in/out
);
}@[Link("opengl32")]
lib LibOPENGL32
fun glGenTextures = glGenTextures(
n : Int32, # INT
textures : UInt32* # DWORD* in/out
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef glGenTexturesNative = Void Function(Int32, Pointer<Uint32>);
typedef glGenTexturesDart = void Function(int, Pointer<Uint32>);
final glGenTextures = DynamicLibrary.open('OPENGL32.dll')
.lookupFunction<glGenTexturesNative, glGenTexturesDart>('glGenTextures');
// n : INT -> Int32
// textures : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure glGenTextures(
n: Integer; // INT
textures: Pointer // DWORD* in/out
); stdcall;
external 'OPENGL32.dll' name 'glGenTextures';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "glGenTextures"
c_glGenTextures :: Int32 -> Ptr Word32 -> IO ()
-- n : INT -> Int32
-- textures : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let glgentextures =
foreign "glGenTextures"
(int32_t @-> (ptr uint32_t) @-> returning void)
(* n : INT -> int32_t *)
(* textures : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library opengl32 (t "OPENGL32.dll"))
(cffi:use-foreign-library opengl32)
(cffi:defcfun ("glGenTextures" gl-gen-textures :convention :stdcall) :void
(n :int32) ; INT
(textures :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $glGenTextures = Win32::API::More->new('OPENGL32',
'void glGenTextures(int n, LPVOID textures)');
# my $ret = $glGenTextures->Call($n, $textures);
# n : INT -> int
# textures : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。