ホーム › Graphics.OpenGL › gluCylinder
gluCylinder
関数クワドリックを用いて円柱や円錐を描画する。
シグネチャ
// GLU32.dll
#include <windows.h>
void gluCylinder(
GLUquadric* qobj,
DOUBLE baseRadius,
DOUBLE topRadius,
DOUBLE height,
INT slices,
INT stacks
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| qobj | GLUquadric* | inout | 描画に用いる二次曲面オブジェクトへのポインタ。 |
| baseRadius | DOUBLE | in | z=0側(底面)の半径。 |
| topRadius | DOUBLE | in | z=height側(上面)の半径。 |
| height | DOUBLE | in | 円柱の高さ(z軸方向)。 |
| slices | INT | in | 周方向の分割数(細分数)。 |
| stacks | INT | in | z軸方向の分割数(積層数)。 |
戻り値の型: void
各言語での呼び出し定義
// GLU32.dll
#include <windows.h>
void gluCylinder(
GLUquadric* qobj,
DOUBLE baseRadius,
DOUBLE topRadius,
DOUBLE height,
INT slices,
INT stacks
);[DllImport("GLU32.dll", ExactSpelling = true)]
static extern void gluCylinder(
ref IntPtr qobj, // GLUquadric* in/out
double baseRadius, // DOUBLE
double topRadius, // DOUBLE
double height, // DOUBLE
int slices, // INT
int stacks // INT
);<DllImport("GLU32.dll", ExactSpelling:=True)>
Public Shared Sub gluCylinder(
ByRef qobj As IntPtr, ' GLUquadric* in/out
baseRadius As Double, ' DOUBLE
topRadius As Double, ' DOUBLE
height As Double, ' DOUBLE
slices As Integer, ' INT
stacks As Integer ' INT
)
End Sub' qobj : GLUquadric* in/out
' baseRadius : DOUBLE
' topRadius : DOUBLE
' height : DOUBLE
' slices : INT
' stacks : INT
Declare PtrSafe Sub gluCylinder Lib "glu32" ( _
ByRef qobj As LongPtr, _
ByVal baseRadius As Double, _
ByVal topRadius As Double, _
ByVal height As Double, _
ByVal slices As Long, _
ByVal stacks As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
gluCylinder = ctypes.windll.glu32.gluCylinder
gluCylinder.restype = None
gluCylinder.argtypes = [
ctypes.c_void_p, # qobj : GLUquadric* in/out
ctypes.c_double, # baseRadius : DOUBLE
ctypes.c_double, # topRadius : DOUBLE
ctypes.c_double, # height : DOUBLE
ctypes.c_int, # slices : INT
ctypes.c_int, # stacks : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GLU32.dll')
gluCylinder = Fiddle::Function.new(
lib['gluCylinder'],
[
Fiddle::TYPE_VOIDP, # qobj : GLUquadric* in/out
Fiddle::TYPE_DOUBLE, # baseRadius : DOUBLE
Fiddle::TYPE_DOUBLE, # topRadius : DOUBLE
Fiddle::TYPE_DOUBLE, # height : DOUBLE
Fiddle::TYPE_INT, # slices : INT
Fiddle::TYPE_INT, # stacks : INT
],
Fiddle::TYPE_VOID)#[link(name = "glu32")]
extern "system" {
fn gluCylinder(
qobj: *mut isize, // GLUquadric* in/out
baseRadius: f64, // DOUBLE
topRadius: f64, // DOUBLE
height: f64, // DOUBLE
slices: i32, // INT
stacks: i32 // INT
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GLU32.dll")]
public static extern void gluCylinder(ref IntPtr qobj, double baseRadius, double topRadius, double height, int slices, int stacks);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GLU32_gluCylinder' -Namespace Win32 -PassThru
# $api::gluCylinder(qobj, baseRadius, topRadius, height, slices, stacks)#uselib "GLU32.dll"
#func global gluCylinder "gluCylinder" sptr, double, double, double, sptr, sptr
; gluCylinder varptr(qobj), baseRadius, topRadius, height, slices, stacks
; qobj : GLUquadric* in/out -> "sptr"
; baseRadius : DOUBLE -> "double"
; topRadius : DOUBLE -> "double"
; height : DOUBLE -> "double"
; slices : INT -> "sptr"
; stacks : INT -> "sptr"出力引数:
#uselib "GLU32.dll" #func global gluCylinder "gluCylinder" var, double, double, double, int, int ; gluCylinder qobj, baseRadius, topRadius, height, slices, stacks ; qobj : GLUquadric* in/out -> "var" ; baseRadius : DOUBLE -> "double" ; topRadius : DOUBLE -> "double" ; height : DOUBLE -> "double" ; slices : INT -> "int" ; stacks : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GLU32.dll" #func global gluCylinder "gluCylinder" sptr, double, double, double, int, int ; gluCylinder varptr(qobj), baseRadius, topRadius, height, slices, stacks ; qobj : GLUquadric* in/out -> "sptr" ; baseRadius : DOUBLE -> "double" ; topRadius : DOUBLE -> "double" ; height : DOUBLE -> "double" ; slices : INT -> "int" ; stacks : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void gluCylinder(GLUquadric* qobj, DOUBLE baseRadius, DOUBLE topRadius, DOUBLE height, INT slices, INT stacks) #uselib "GLU32.dll" #func global gluCylinder "gluCylinder" var, double, double, double, int, int ; gluCylinder qobj, baseRadius, topRadius, height, slices, stacks ; qobj : GLUquadric* in/out -> "var" ; baseRadius : DOUBLE -> "double" ; topRadius : DOUBLE -> "double" ; height : DOUBLE -> "double" ; slices : INT -> "int" ; stacks : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void gluCylinder(GLUquadric* qobj, DOUBLE baseRadius, DOUBLE topRadius, DOUBLE height, INT slices, INT stacks) #uselib "GLU32.dll" #func global gluCylinder "gluCylinder" intptr, double, double, double, int, int ; gluCylinder varptr(qobj), baseRadius, topRadius, height, slices, stacks ; qobj : GLUquadric* in/out -> "intptr" ; baseRadius : DOUBLE -> "double" ; topRadius : DOUBLE -> "double" ; height : DOUBLE -> "double" ; slices : INT -> "int" ; stacks : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"math"
"golang.org/x/sys/windows"
"unsafe"
)
var (
glu32 = windows.NewLazySystemDLL("GLU32.dll")
procgluCylinder = glu32.NewProc("gluCylinder")
)
// qobj (GLUquadric* in/out), baseRadius (DOUBLE), topRadius (DOUBLE), height (DOUBLE), slices (INT), stacks (INT)
r1, _, err := procgluCylinder.Call(
uintptr(qobj),
uintptr(math.Float64bits(baseRadius)),
uintptr(math.Float64bits(topRadius)),
uintptr(math.Float64bits(height)),
uintptr(slices),
uintptr(stacks),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void
// 注意: float/double 引数は proc.Call では XMM レジスタに渡せません。
// windows.SyscallN(proc.Addr(), math.Float64bits(x), ...) もしくは cgo を使用してください。procedure gluCylinder(
qobj: Pointer; // GLUquadric* in/out
baseRadius: Double; // DOUBLE
topRadius: Double; // DOUBLE
height: Double; // DOUBLE
slices: Integer; // INT
stacks: Integer // INT
); stdcall;
external 'GLU32.dll' name 'gluCylinder';result := DllCall("GLU32\gluCylinder"
, "Ptr", qobj ; GLUquadric* in/out
, "Double", baseRadius ; DOUBLE
, "Double", topRadius ; DOUBLE
, "Double", height ; DOUBLE
, "Int", slices ; INT
, "Int", stacks ; INT
, "Int") ; return: void●gluCylinder(qobj, baseRadius, topRadius, height, slices, stacks) = DLL("GLU32.dll", "int gluCylinder(void*, double, double, double, int, int)")
# 呼び出し: gluCylinder(qobj, baseRadius, topRadius, height, slices, stacks)
# qobj : GLUquadric* in/out -> "void*"
# baseRadius : DOUBLE -> "double"
# topRadius : DOUBLE -> "double"
# height : DOUBLE -> "double"
# slices : INT -> "int"
# stacks : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "glu32" fn gluCylinder(
qobj: [*c]isize, // GLUquadric* in/out
baseRadius: f64, // DOUBLE
topRadius: f64, // DOUBLE
height: f64, // DOUBLE
slices: i32, // INT
stacks: i32 // INT
) callconv(std.os.windows.WINAPI) void;proc gluCylinder(
qobj: ptr int, # GLUquadric* in/out
baseRadius: float64, # DOUBLE
topRadius: float64, # DOUBLE
height: float64, # DOUBLE
slices: int32, # INT
stacks: int32 # INT
) {.importc: "gluCylinder", stdcall, dynlib: "GLU32.dll".}pragma(lib, "glu32");
extern(Windows)
void gluCylinder(
ptrdiff_t* qobj, // GLUquadric* in/out
double baseRadius, // DOUBLE
double topRadius, // DOUBLE
double height, // DOUBLE
int slices, // INT
int stacks // INT
);ccall((:gluCylinder, "GLU32.dll"), stdcall, Cvoid,
(Ptr{Int}, Float64, Float64, Float64, Int32, Int32),
qobj, baseRadius, topRadius, height, slices, stacks)
# qobj : GLUquadric* in/out -> Ptr{Int}
# baseRadius : DOUBLE -> Float64
# topRadius : DOUBLE -> Float64
# height : DOUBLE -> Float64
# slices : INT -> Int32
# stacks : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void gluCylinder(
intptr_t* qobj,
double baseRadius,
double topRadius,
double height,
int32_t slices,
int32_t stacks);
]]
local glu32 = ffi.load("glu32")
-- glu32.gluCylinder(qobj, baseRadius, topRadius, height, slices, stacks)
-- qobj : GLUquadric* in/out
-- baseRadius : DOUBLE
-- topRadius : DOUBLE
-- height : DOUBLE
-- slices : INT
-- stacks : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('GLU32.dll');
const gluCylinder = lib.func('__stdcall', 'gluCylinder', 'void', ['intptr_t *', 'double', 'double', 'double', 'int32_t', 'int32_t']);
// gluCylinder(qobj, baseRadius, topRadius, height, slices, stacks)
// qobj : GLUquadric* in/out -> 'intptr_t *'
// baseRadius : DOUBLE -> 'double'
// topRadius : DOUBLE -> 'double'
// height : DOUBLE -> 'double'
// slices : INT -> 'int32_t'
// stacks : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("GLU32.dll", {
gluCylinder: { parameters: ["pointer", "f64", "f64", "f64", "i32", "i32"], result: "void" },
});
// lib.symbols.gluCylinder(qobj, baseRadius, topRadius, height, slices, stacks)
// qobj : GLUquadric* in/out -> "pointer"
// baseRadius : DOUBLE -> "f64"
// topRadius : DOUBLE -> "f64"
// height : DOUBLE -> "f64"
// slices : INT -> "i32"
// stacks : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void gluCylinder(
intptr_t* qobj,
double baseRadius,
double topRadius,
double height,
int32_t slices,
int32_t stacks);
C, "GLU32.dll");
// $ffi->gluCylinder(qobj, baseRadius, topRadius, height, slices, stacks);
// qobj : GLUquadric* in/out
// baseRadius : DOUBLE
// topRadius : DOUBLE
// height : DOUBLE
// slices : INT
// stacks : 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 Glu32 extends StdCallLibrary {
Glu32 INSTANCE = Native.load("glu32", Glu32.class);
void gluCylinder(
LongByReference qobj, // GLUquadric* in/out
double baseRadius, // DOUBLE
double topRadius, // DOUBLE
double height, // DOUBLE
int slices, // INT
int stacks // INT
);
}@[Link("glu32")]
lib LibGLU32
fun gluCylinder = gluCylinder(
qobj : LibC::SSizeT*, # GLUquadric* in/out
baseRadius : Float64, # DOUBLE
topRadius : Float64, # DOUBLE
height : Float64, # DOUBLE
slices : Int32, # INT
stacks : 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 gluCylinderNative = Void Function(Pointer<IntPtr>, Double, Double, Double, Int32, Int32);
typedef gluCylinderDart = void Function(Pointer<IntPtr>, double, double, double, int, int);
final gluCylinder = DynamicLibrary.open('GLU32.dll')
.lookupFunction<gluCylinderNative, gluCylinderDart>('gluCylinder');
// qobj : GLUquadric* in/out -> Pointer<IntPtr>
// baseRadius : DOUBLE -> Double
// topRadius : DOUBLE -> Double
// height : DOUBLE -> Double
// slices : INT -> Int32
// stacks : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure gluCylinder(
qobj: Pointer; // GLUquadric* in/out
baseRadius: Double; // DOUBLE
topRadius: Double; // DOUBLE
height: Double; // DOUBLE
slices: Integer; // INT
stacks: Integer // INT
); stdcall;
external 'GLU32.dll' name 'gluCylinder';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "gluCylinder"
c_gluCylinder :: Ptr CIntPtr -> CDouble -> CDouble -> CDouble -> Int32 -> Int32 -> IO ()
-- qobj : GLUquadric* in/out -> Ptr CIntPtr
-- baseRadius : DOUBLE -> CDouble
-- topRadius : DOUBLE -> CDouble
-- height : DOUBLE -> CDouble
-- slices : INT -> Int32
-- stacks : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let glucylinder =
foreign "gluCylinder"
((ptr intptr_t) @-> double @-> double @-> double @-> int32_t @-> int32_t @-> returning void)
(* qobj : GLUquadric* in/out -> (ptr intptr_t) *)
(* baseRadius : DOUBLE -> double *)
(* topRadius : DOUBLE -> double *)
(* height : DOUBLE -> double *)
(* slices : INT -> int32_t *)
(* stacks : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library glu32 (t "GLU32.dll"))
(cffi:use-foreign-library glu32)
(cffi:defcfun ("gluCylinder" glu-cylinder :convention :stdcall) :void
(qobj :pointer) ; GLUquadric* in/out
(base-radius :double) ; DOUBLE
(top-radius :double) ; DOUBLE
(height :double) ; DOUBLE
(slices :int32) ; INT
(stacks :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $gluCylinder = Win32::API::More->new('GLU32',
'void gluCylinder(LPVOID qobj, double baseRadius, double topRadius, double height, int slices, int stacks)');
# my $ret = $gluCylinder->Call($qobj, $baseRadius, $topRadius, $height, $slices, $stacks);
# qobj : GLUquadric* in/out -> LPVOID
# baseRadius : DOUBLE -> double
# topRadius : DOUBLE -> double
# height : DOUBLE -> double
# slices : INT -> int
# stacks : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。