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

gluBuild2DMipmaps

関数
2次元テクスチャのミップマップ群を生成する。
DLLGLU32.dll呼出規約winapi

シグネチャ

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

INT gluBuild2DMipmaps(
    DWORD target,
    INT components,
    INT width,
    INT height,
    DWORD format,
    DWORD type,
    const void* data
);

パラメーター

名前方向説明
targetDWORDin対象テクスチャ。通常GL_TEXTURE_2D。
componentsINTinテクスチャの色成分数(1〜4)または内部形式。
widthINTin元画像の幅(テクセル数)。
heightINTin元画像の高さ(テクセル数)。
formatDWORDinピクセルデータの色形式。GL_RGBAなど。
typeDWORDinピクセルデータの型。GL_UNSIGNED_BYTEなど。
datavoid*inミップマップ生成元の画像データへのポインタ。

戻り値の型: INT

各言語での呼び出し定義

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

INT gluBuild2DMipmaps(
    DWORD target,
    INT components,
    INT width,
    INT height,
    DWORD format,
    DWORD type,
    const void* data
);
[DllImport("GLU32.dll", ExactSpelling = true)]
static extern int gluBuild2DMipmaps(
    uint target,   // DWORD
    int components,   // INT
    int width,   // INT
    int height,   // INT
    uint format,   // DWORD
    uint type,   // DWORD
    IntPtr data   // void*
);
<DllImport("GLU32.dll", ExactSpelling:=True)>
Public Shared Function gluBuild2DMipmaps(
    target As UInteger,   ' DWORD
    components As Integer,   ' INT
    width As Integer,   ' INT
    height As Integer,   ' INT
    format As UInteger,   ' DWORD
    type As UInteger,   ' DWORD
    data As IntPtr   ' void*
) As Integer
End Function
' target : DWORD
' components : INT
' width : INT
' height : INT
' format : DWORD
' type : DWORD
' data : void*
Declare PtrSafe Function gluBuild2DMipmaps Lib "glu32" ( _
    ByVal target As Long, _
    ByVal components As Long, _
    ByVal width As Long, _
    ByVal height As Long, _
    ByVal format As Long, _
    ByVal type As Long, _
    ByVal data As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

gluBuild2DMipmaps = ctypes.windll.glu32.gluBuild2DMipmaps
gluBuild2DMipmaps.restype = ctypes.c_int
gluBuild2DMipmaps.argtypes = [
    wintypes.DWORD,  # target : DWORD
    ctypes.c_int,  # components : INT
    ctypes.c_int,  # width : INT
    ctypes.c_int,  # height : INT
    wintypes.DWORD,  # format : DWORD
    wintypes.DWORD,  # type : DWORD
    ctypes.POINTER(None),  # data : void*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GLU32.dll')
gluBuild2DMipmaps = Fiddle::Function.new(
  lib['gluBuild2DMipmaps'],
  [
    -Fiddle::TYPE_INT,  # target : DWORD
    Fiddle::TYPE_INT,  # components : INT
    Fiddle::TYPE_INT,  # width : INT
    Fiddle::TYPE_INT,  # height : INT
    -Fiddle::TYPE_INT,  # format : DWORD
    -Fiddle::TYPE_INT,  # type : DWORD
    Fiddle::TYPE_VOIDP,  # data : void*
  ],
  Fiddle::TYPE_INT)
#[link(name = "glu32")]
extern "system" {
    fn gluBuild2DMipmaps(
        target: u32,  // DWORD
        components: i32,  // INT
        width: i32,  // INT
        height: i32,  // INT
        format: u32,  // DWORD
        type: u32,  // DWORD
        data: *const ()  // void*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GLU32.dll")]
public static extern int gluBuild2DMipmaps(uint target, int components, int width, int height, uint format, uint type, IntPtr data);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GLU32_gluBuild2DMipmaps' -Namespace Win32 -PassThru
# $api::gluBuild2DMipmaps(target, components, width, height, format, type, data)
#uselib "GLU32.dll"
#func global gluBuild2DMipmaps "gluBuild2DMipmaps" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; gluBuild2DMipmaps target, components, width, height, format, type, data   ; 戻り値は stat
; target : DWORD -> "sptr"
; components : INT -> "sptr"
; width : INT -> "sptr"
; height : INT -> "sptr"
; format : DWORD -> "sptr"
; type : DWORD -> "sptr"
; data : void* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GLU32.dll"
#cfunc global gluBuild2DMipmaps "gluBuild2DMipmaps" int, int, int, int, int, int, sptr
; res = gluBuild2DMipmaps(target, components, width, height, format, type, data)
; target : DWORD -> "int"
; components : INT -> "int"
; width : INT -> "int"
; height : INT -> "int"
; format : DWORD -> "int"
; type : DWORD -> "int"
; data : void* -> "sptr"
; INT gluBuild2DMipmaps(DWORD target, INT components, INT width, INT height, DWORD format, DWORD type, void* data)
#uselib "GLU32.dll"
#cfunc global gluBuild2DMipmaps "gluBuild2DMipmaps" int, int, int, int, int, int, intptr
; res = gluBuild2DMipmaps(target, components, width, height, format, type, data)
; target : DWORD -> "int"
; components : INT -> "int"
; width : INT -> "int"
; height : INT -> "int"
; format : DWORD -> "int"
; type : DWORD -> "int"
; data : void* -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	glu32 = windows.NewLazySystemDLL("GLU32.dll")
	procgluBuild2DMipmaps = glu32.NewProc("gluBuild2DMipmaps")
)

// target (DWORD), components (INT), width (INT), height (INT), format (DWORD), type (DWORD), data (void*)
r1, _, err := procgluBuild2DMipmaps.Call(
	uintptr(target),
	uintptr(components),
	uintptr(width),
	uintptr(height),
	uintptr(format),
	uintptr(type),
	uintptr(data),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function gluBuild2DMipmaps(
  target: DWORD;   // DWORD
  components: Integer;   // INT
  width: Integer;   // INT
  height: Integer;   // INT
  format: DWORD;   // DWORD
  type: DWORD;   // DWORD
  data: Pointer   // void*
): Integer; stdcall;
  external 'GLU32.dll' name 'gluBuild2DMipmaps';
result := DllCall("GLU32\gluBuild2DMipmaps"
    , "UInt", target   ; DWORD
    , "Int", components   ; INT
    , "Int", width   ; INT
    , "Int", height   ; INT
    , "UInt", format   ; DWORD
    , "UInt", type   ; DWORD
    , "Ptr", data   ; void*
    , "Int")   ; return: INT
●gluBuild2DMipmaps(target, components, width, height, format, type, data) = DLL("GLU32.dll", "int gluBuild2DMipmaps(dword, int, int, int, dword, dword, void*)")
# 呼び出し: gluBuild2DMipmaps(target, components, width, height, format, type, data)
# target : DWORD -> "dword"
# components : INT -> "int"
# width : INT -> "int"
# height : INT -> "int"
# format : DWORD -> "dword"
# type : DWORD -> "dword"
# data : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef gluBuild2DMipmapsNative = Int32 Function(Uint32, Int32, Int32, Int32, Uint32, Uint32, Pointer<Void>);
typedef gluBuild2DMipmapsDart = int Function(int, int, int, int, int, int, Pointer<Void>);
final gluBuild2DMipmaps = DynamicLibrary.open('GLU32.dll')
    .lookupFunction<gluBuild2DMipmapsNative, gluBuild2DMipmapsDart>('gluBuild2DMipmaps');
// target : DWORD -> Uint32
// components : INT -> Int32
// width : INT -> Int32
// height : INT -> Int32
// format : DWORD -> Uint32
// type : DWORD -> Uint32
// data : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function gluBuild2DMipmaps(
  target: DWORD;   // DWORD
  components: Integer;   // INT
  width: Integer;   // INT
  height: Integer;   // INT
  format: DWORD;   // DWORD
  type: DWORD;   // DWORD
  data: Pointer   // void*
): Integer; stdcall;
  external 'GLU32.dll' name 'gluBuild2DMipmaps';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "gluBuild2DMipmaps"
  c_gluBuild2DMipmaps :: Word32 -> Int32 -> Int32 -> Int32 -> Word32 -> Word32 -> Ptr () -> IO Int32
-- target : DWORD -> Word32
-- components : INT -> Int32
-- width : INT -> Int32
-- height : INT -> Int32
-- format : DWORD -> Word32
-- type : DWORD -> Word32
-- data : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let glubuild2dmipmaps =
  foreign "gluBuild2DMipmaps"
    (uint32_t @-> int32_t @-> int32_t @-> int32_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* target : DWORD -> uint32_t *)
(* components : INT -> int32_t *)
(* width : INT -> int32_t *)
(* height : INT -> int32_t *)
(* format : DWORD -> uint32_t *)
(* type : DWORD -> uint32_t *)
(* data : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library glu32 (t "GLU32.dll"))
(cffi:use-foreign-library glu32)

(cffi:defcfun ("gluBuild2DMipmaps" glu-build2-dmipmaps :convention :stdcall) :int32
  (target :uint32)   ; DWORD
  (components :int32)   ; INT
  (width :int32)   ; INT
  (height :int32)   ; INT
  (format :uint32)   ; DWORD
  (type :uint32)   ; DWORD
  (data :pointer))   ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $gluBuild2DMipmaps = Win32::API::More->new('GLU32',
    'int gluBuild2DMipmaps(DWORD target, int components, int width, int height, DWORD format, DWORD type, LPVOID data)');
# my $ret = $gluBuild2DMipmaps->Call($target, $components, $width, $height, $format, $type, $data);
# target : DWORD -> DWORD
# components : INT -> int
# width : INT -> int
# height : INT -> int
# format : DWORD -> DWORD
# type : DWORD -> DWORD
# data : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。