ホーム › Graphics.OpenGL › glCopyTexImage2D
glCopyTexImage2D
関数フレームバッファから2次元テクスチャ画像へ複写する。
シグネチャ
// OPENGL32.dll
#include <windows.h>
void glCopyTexImage2D(
DWORD target,
INT level,
DWORD internalFormat,
INT x,
INT y,
INT width,
INT height,
INT border
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| target | DWORD | in | 対象テクスチャターゲット。GL_TEXTURE_2Dやキューブマップ各面を指定する。 |
| level | INT | in | ミップマップのレベル番号。0が基本イメージ。 |
| internalFormat | DWORD | in | テクスチャの内部格納フォーマット。GL_RGBやGL_RGBAなどの定数を指定する。 |
| x | INT | in | コピー元フレームバッファ矩形の左下隅X座標(ピクセル単位)。 |
| y | INT | in | コピー元フレームバッファ矩形の左下隅Y座標(ピクセル単位)。 |
| width | INT | in | テクスチャの幅(テクセル単位)。 |
| height | INT | in | テクスチャの高さ(テクセル単位)。 |
| border | INT | in | 境界の幅。0または1を指定する。 |
戻り値の型: void
各言語での呼び出し定義
// OPENGL32.dll
#include <windows.h>
void glCopyTexImage2D(
DWORD target,
INT level,
DWORD internalFormat,
INT x,
INT y,
INT width,
INT height,
INT border
);[DllImport("OPENGL32.dll", ExactSpelling = true)]
static extern void glCopyTexImage2D(
uint target, // DWORD
int level, // INT
uint internalFormat, // DWORD
int x, // INT
int y, // INT
int width, // INT
int height, // INT
int border // INT
);<DllImport("OPENGL32.dll", ExactSpelling:=True)>
Public Shared Sub glCopyTexImage2D(
target As UInteger, ' DWORD
level As Integer, ' INT
internalFormat As UInteger, ' DWORD
x As Integer, ' INT
y As Integer, ' INT
width As Integer, ' INT
height As Integer, ' INT
border As Integer ' INT
)
End Sub' target : DWORD
' level : INT
' internalFormat : DWORD
' x : INT
' y : INT
' width : INT
' height : INT
' border : INT
Declare PtrSafe Sub glCopyTexImage2D Lib "opengl32" ( _
ByVal target As Long, _
ByVal level As Long, _
ByVal internalFormat As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal width As Long, _
ByVal height As Long, _
ByVal border As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
glCopyTexImage2D = ctypes.windll.opengl32.glCopyTexImage2D
glCopyTexImage2D.restype = None
glCopyTexImage2D.argtypes = [
wintypes.DWORD, # target : DWORD
ctypes.c_int, # level : INT
wintypes.DWORD, # internalFormat : DWORD
ctypes.c_int, # x : INT
ctypes.c_int, # y : INT
ctypes.c_int, # width : INT
ctypes.c_int, # height : INT
ctypes.c_int, # border : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OPENGL32.dll')
glCopyTexImage2D = Fiddle::Function.new(
lib['glCopyTexImage2D'],
[
-Fiddle::TYPE_INT, # target : DWORD
Fiddle::TYPE_INT, # level : INT
-Fiddle::TYPE_INT, # internalFormat : DWORD
Fiddle::TYPE_INT, # x : INT
Fiddle::TYPE_INT, # y : INT
Fiddle::TYPE_INT, # width : INT
Fiddle::TYPE_INT, # height : INT
Fiddle::TYPE_INT, # border : INT
],
Fiddle::TYPE_VOID)#[link(name = "opengl32")]
extern "system" {
fn glCopyTexImage2D(
target: u32, // DWORD
level: i32, // INT
internalFormat: u32, // DWORD
x: i32, // INT
y: i32, // INT
width: i32, // INT
height: i32, // INT
border: i32 // INT
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OPENGL32.dll")]
public static extern void glCopyTexImage2D(uint target, int level, uint internalFormat, int x, int y, int width, int height, int border);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OPENGL32_glCopyTexImage2D' -Namespace Win32 -PassThru
# $api::glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border)#uselib "OPENGL32.dll"
#func global glCopyTexImage2D "glCopyTexImage2D" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; glCopyTexImage2D target, level, internalFormat, x, y, width, height, border
; target : DWORD -> "sptr"
; level : INT -> "sptr"
; internalFormat : DWORD -> "sptr"
; x : INT -> "sptr"
; y : INT -> "sptr"
; width : INT -> "sptr"
; height : INT -> "sptr"
; border : INT -> "sptr"#uselib "OPENGL32.dll"
#func global glCopyTexImage2D "glCopyTexImage2D" int, int, int, int, int, int, int, int
; glCopyTexImage2D target, level, internalFormat, x, y, width, height, border
; target : DWORD -> "int"
; level : INT -> "int"
; internalFormat : DWORD -> "int"
; x : INT -> "int"
; y : INT -> "int"
; width : INT -> "int"
; height : INT -> "int"
; border : INT -> "int"; void glCopyTexImage2D(DWORD target, INT level, DWORD internalFormat, INT x, INT y, INT width, INT height, INT border)
#uselib "OPENGL32.dll"
#func global glCopyTexImage2D "glCopyTexImage2D" int, int, int, int, int, int, int, int
; glCopyTexImage2D target, level, internalFormat, x, y, width, height, border
; target : DWORD -> "int"
; level : INT -> "int"
; internalFormat : DWORD -> "int"
; x : INT -> "int"
; y : INT -> "int"
; width : INT -> "int"
; height : INT -> "int"
; border : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
procglCopyTexImage2D = opengl32.NewProc("glCopyTexImage2D")
)
// target (DWORD), level (INT), internalFormat (DWORD), x (INT), y (INT), width (INT), height (INT), border (INT)
r1, _, err := procglCopyTexImage2D.Call(
uintptr(target),
uintptr(level),
uintptr(internalFormat),
uintptr(x),
uintptr(y),
uintptr(width),
uintptr(height),
uintptr(border),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure glCopyTexImage2D(
target: DWORD; // DWORD
level: Integer; // INT
internalFormat: DWORD; // DWORD
x: Integer; // INT
y: Integer; // INT
width: Integer; // INT
height: Integer; // INT
border: Integer // INT
); stdcall;
external 'OPENGL32.dll' name 'glCopyTexImage2D';result := DllCall("OPENGL32\glCopyTexImage2D"
, "UInt", target ; DWORD
, "Int", level ; INT
, "UInt", internalFormat ; DWORD
, "Int", x ; INT
, "Int", y ; INT
, "Int", width ; INT
, "Int", height ; INT
, "Int", border ; INT
, "Int") ; return: void●glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border) = DLL("OPENGL32.dll", "int glCopyTexImage2D(dword, int, dword, int, int, int, int, int)")
# 呼び出し: glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border)
# target : DWORD -> "dword"
# level : INT -> "int"
# internalFormat : DWORD -> "dword"
# x : INT -> "int"
# y : INT -> "int"
# width : INT -> "int"
# height : INT -> "int"
# border : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "opengl32" fn glCopyTexImage2D(
target: u32, // DWORD
level: i32, // INT
internalFormat: u32, // DWORD
x: i32, // INT
y: i32, // INT
width: i32, // INT
height: i32, // INT
border: i32 // INT
) callconv(std.os.windows.WINAPI) void;proc glCopyTexImage2D(
target: uint32, # DWORD
level: int32, # INT
internalFormat: uint32, # DWORD
x: int32, # INT
y: int32, # INT
width: int32, # INT
height: int32, # INT
border: int32 # INT
) {.importc: "glCopyTexImage2D", stdcall, dynlib: "OPENGL32.dll".}pragma(lib, "opengl32");
extern(Windows)
void glCopyTexImage2D(
uint target, // DWORD
int level, // INT
uint internalFormat, // DWORD
int x, // INT
int y, // INT
int width, // INT
int height, // INT
int border // INT
);ccall((:glCopyTexImage2D, "OPENGL32.dll"), stdcall, Cvoid,
(UInt32, Int32, UInt32, Int32, Int32, Int32, Int32, Int32),
target, level, internalFormat, x, y, width, height, border)
# target : DWORD -> UInt32
# level : INT -> Int32
# internalFormat : DWORD -> UInt32
# x : INT -> Int32
# y : INT -> Int32
# width : INT -> Int32
# height : INT -> Int32
# border : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void glCopyTexImage2D(
uint32_t target,
int32_t level,
uint32_t internalFormat,
int32_t x,
int32_t y,
int32_t width,
int32_t height,
int32_t border);
]]
local opengl32 = ffi.load("opengl32")
-- opengl32.glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border)
-- target : DWORD
-- level : INT
-- internalFormat : DWORD
-- x : INT
-- y : INT
-- width : INT
-- height : INT
-- border : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('OPENGL32.dll');
const glCopyTexImage2D = lib.func('__stdcall', 'glCopyTexImage2D', 'void', ['uint32_t', 'int32_t', 'uint32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t', 'int32_t']);
// glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border)
// target : DWORD -> 'uint32_t'
// level : INT -> 'int32_t'
// internalFormat : DWORD -> 'uint32_t'
// x : INT -> 'int32_t'
// y : INT -> 'int32_t'
// width : INT -> 'int32_t'
// height : INT -> 'int32_t'
// border : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("OPENGL32.dll", {
glCopyTexImage2D: { parameters: ["u32", "i32", "u32", "i32", "i32", "i32", "i32", "i32"], result: "void" },
});
// lib.symbols.glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border)
// target : DWORD -> "u32"
// level : INT -> "i32"
// internalFormat : DWORD -> "u32"
// x : INT -> "i32"
// y : INT -> "i32"
// width : INT -> "i32"
// height : INT -> "i32"
// border : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void glCopyTexImage2D(
uint32_t target,
int32_t level,
uint32_t internalFormat,
int32_t x,
int32_t y,
int32_t width,
int32_t height,
int32_t border);
C, "OPENGL32.dll");
// $ffi->glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
// target : DWORD
// level : INT
// internalFormat : DWORD
// x : INT
// y : INT
// width : INT
// height : INT
// border : 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 glCopyTexImage2D(
int target, // DWORD
int level, // INT
int internalFormat, // DWORD
int x, // INT
int y, // INT
int width, // INT
int height, // INT
int border // INT
);
}@[Link("opengl32")]
lib LibOPENGL32
fun glCopyTexImage2D = glCopyTexImage2D(
target : UInt32, # DWORD
level : Int32, # INT
internalFormat : UInt32, # DWORD
x : Int32, # INT
y : Int32, # INT
width : Int32, # INT
height : Int32, # INT
border : 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 glCopyTexImage2DNative = Void Function(Uint32, Int32, Uint32, Int32, Int32, Int32, Int32, Int32);
typedef glCopyTexImage2DDart = void Function(int, int, int, int, int, int, int, int);
final glCopyTexImage2D = DynamicLibrary.open('OPENGL32.dll')
.lookupFunction<glCopyTexImage2DNative, glCopyTexImage2DDart>('glCopyTexImage2D');
// target : DWORD -> Uint32
// level : INT -> Int32
// internalFormat : DWORD -> Uint32
// x : INT -> Int32
// y : INT -> Int32
// width : INT -> Int32
// height : INT -> Int32
// border : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure glCopyTexImage2D(
target: DWORD; // DWORD
level: Integer; // INT
internalFormat: DWORD; // DWORD
x: Integer; // INT
y: Integer; // INT
width: Integer; // INT
height: Integer; // INT
border: Integer // INT
); stdcall;
external 'OPENGL32.dll' name 'glCopyTexImage2D';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "glCopyTexImage2D"
c_glCopyTexImage2D :: Word32 -> Int32 -> Word32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO ()
-- target : DWORD -> Word32
-- level : INT -> Int32
-- internalFormat : DWORD -> Word32
-- x : INT -> Int32
-- y : INT -> Int32
-- width : INT -> Int32
-- height : INT -> Int32
-- border : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let glcopyteximage2d =
foreign "glCopyTexImage2D"
(uint32_t @-> int32_t @-> uint32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> int32_t @-> returning void)
(* target : DWORD -> uint32_t *)
(* level : INT -> int32_t *)
(* internalFormat : DWORD -> uint32_t *)
(* x : INT -> int32_t *)
(* y : INT -> int32_t *)
(* width : INT -> int32_t *)
(* height : INT -> int32_t *)
(* border : 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 ("glCopyTexImage2D" gl-copy-tex-image2-d :convention :stdcall) :void
(target :uint32) ; DWORD
(level :int32) ; INT
(internal-format :uint32) ; DWORD
(x :int32) ; INT
(y :int32) ; INT
(width :int32) ; INT
(height :int32) ; INT
(border :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $glCopyTexImage2D = Win32::API::More->new('OPENGL32',
'void glCopyTexImage2D(DWORD target, int level, DWORD internalFormat, int x, int y, int width, int height, int border)');
# my $ret = $glCopyTexImage2D->Call($target, $level, $internalFormat, $x, $y, $width, $height, $border);
# target : DWORD -> DWORD
# level : INT -> int
# internalFormat : DWORD -> DWORD
# x : INT -> int
# y : INT -> int
# width : INT -> int
# height : INT -> int
# border : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。