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

gluSphere

関数
クワドリックを用いて球を描画する。
DLLGLU32.dll呼出規約winapi

シグネチャ

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

void gluSphere(
    GLUquadric* qobj,
    DOUBLE radius,
    INT slices,
    INT stacks
);

パラメーター

名前方向説明
qobjGLUquadric*inout描画に用いる二次曲面オブジェクトへのポインタ。
radiusDOUBLEin球の半径。
slicesINTin経度方向の分割数(細分数)。
stacksINTin緯度方向の分割数(積層数)。

戻り値の型: void

各言語での呼び出し定義

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

void gluSphere(
    GLUquadric* qobj,
    DOUBLE radius,
    INT slices,
    INT stacks
);
[DllImport("GLU32.dll", ExactSpelling = true)]
static extern void gluSphere(
    ref IntPtr qobj,   // GLUquadric* in/out
    double radius,   // DOUBLE
    int slices,   // INT
    int stacks   // INT
);
<DllImport("GLU32.dll", ExactSpelling:=True)>
Public Shared Sub gluSphere(
    ByRef qobj As IntPtr,   ' GLUquadric* in/out
    radius As Double,   ' DOUBLE
    slices As Integer,   ' INT
    stacks As Integer   ' INT
)
End Sub
' qobj : GLUquadric* in/out
' radius : DOUBLE
' slices : INT
' stacks : INT
Declare PtrSafe Sub gluSphere Lib "glu32" ( _
    ByRef qobj As LongPtr, _
    ByVal radius 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

gluSphere = ctypes.windll.glu32.gluSphere
gluSphere.restype = None
gluSphere.argtypes = [
    ctypes.c_void_p,  # qobj : GLUquadric* in/out
    ctypes.c_double,  # radius : DOUBLE
    ctypes.c_int,  # slices : INT
    ctypes.c_int,  # stacks : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GLU32.dll')
gluSphere = Fiddle::Function.new(
  lib['gluSphere'],
  [
    Fiddle::TYPE_VOIDP,  # qobj : GLUquadric* in/out
    Fiddle::TYPE_DOUBLE,  # radius : DOUBLE
    Fiddle::TYPE_INT,  # slices : INT
    Fiddle::TYPE_INT,  # stacks : INT
  ],
  Fiddle::TYPE_VOID)
#[link(name = "glu32")]
extern "system" {
    fn gluSphere(
        qobj: *mut isize,  // GLUquadric* in/out
        radius: 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 gluSphere(ref IntPtr qobj, double radius, int slices, int stacks);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GLU32_gluSphere' -Namespace Win32 -PassThru
# $api::gluSphere(qobj, radius, slices, stacks)
#uselib "GLU32.dll"
#func global gluSphere "gluSphere" sptr, double, sptr, sptr
; gluSphere varptr(qobj), radius, slices, stacks
; qobj : GLUquadric* in/out -> "sptr"
; radius : DOUBLE -> "double"
; slices : INT -> "sptr"
; stacks : INT -> "sptr"
出力引数:
#uselib "GLU32.dll"
#func global gluSphere "gluSphere" var, double, int, int
; gluSphere qobj, radius, slices, stacks
; qobj : GLUquadric* in/out -> "var"
; radius : DOUBLE -> "double"
; slices : INT -> "int"
; stacks : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void gluSphere(GLUquadric* qobj, DOUBLE radius, INT slices, INT stacks)
#uselib "GLU32.dll"
#func global gluSphere "gluSphere" var, double, int, int
; gluSphere qobj, radius, slices, stacks
; qobj : GLUquadric* in/out -> "var"
; radius : DOUBLE -> "double"
; slices : INT -> "int"
; stacks : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"math"
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	glu32 = windows.NewLazySystemDLL("GLU32.dll")
	procgluSphere = glu32.NewProc("gluSphere")
)

// qobj (GLUquadric* in/out), radius (DOUBLE), slices (INT), stacks (INT)
r1, _, err := procgluSphere.Call(
	uintptr(qobj),
	uintptr(math.Float64bits(radius)),
	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 gluSphere(
  qobj: Pointer;   // GLUquadric* in/out
  radius: Double;   // DOUBLE
  slices: Integer;   // INT
  stacks: Integer   // INT
); stdcall;
  external 'GLU32.dll' name 'gluSphere';
result := DllCall("GLU32\gluSphere"
    , "Ptr", qobj   ; GLUquadric* in/out
    , "Double", radius   ; DOUBLE
    , "Int", slices   ; INT
    , "Int", stacks   ; INT
    , "Int")   ; return: void
●gluSphere(qobj, radius, slices, stacks) = DLL("GLU32.dll", "int gluSphere(void*, double, int, int)")
# 呼び出し: gluSphere(qobj, radius, slices, stacks)
# qobj : GLUquadric* in/out -> "void*"
# radius : DOUBLE -> "double"
# slices : INT -> "int"
# stacks : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "glu32" fn gluSphere(
    qobj: [*c]isize, // GLUquadric* in/out
    radius: f64, // DOUBLE
    slices: i32, // INT
    stacks: i32 // INT
) callconv(std.os.windows.WINAPI) void;
proc gluSphere(
    qobj: ptr int,  # GLUquadric* in/out
    radius: float64,  # DOUBLE
    slices: int32,  # INT
    stacks: int32  # INT
) {.importc: "gluSphere", stdcall, dynlib: "GLU32.dll".}
pragma(lib, "glu32");
extern(Windows)
void gluSphere(
    ptrdiff_t* qobj,   // GLUquadric* in/out
    double radius,   // DOUBLE
    int slices,   // INT
    int stacks   // INT
);
ccall((:gluSphere, "GLU32.dll"), stdcall, Cvoid,
      (Ptr{Int}, Float64, Int32, Int32),
      qobj, radius, slices, stacks)
# qobj : GLUquadric* in/out -> Ptr{Int}
# radius : DOUBLE -> Float64
# slices : INT -> Int32
# stacks : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void gluSphere(
    intptr_t* qobj,
    double radius,
    int32_t slices,
    int32_t stacks);
]]
local glu32 = ffi.load("glu32")
-- glu32.gluSphere(qobj, radius, slices, stacks)
-- qobj : GLUquadric* in/out
-- radius : DOUBLE
-- slices : INT
-- stacks : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('GLU32.dll');
const gluSphere = lib.func('__stdcall', 'gluSphere', 'void', ['intptr_t *', 'double', 'int32_t', 'int32_t']);
// gluSphere(qobj, radius, slices, stacks)
// qobj : GLUquadric* in/out -> 'intptr_t *'
// radius : DOUBLE -> 'double'
// slices : INT -> 'int32_t'
// stacks : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("GLU32.dll", {
  gluSphere: { parameters: ["pointer", "f64", "i32", "i32"], result: "void" },
});
// lib.symbols.gluSphere(qobj, radius, slices, stacks)
// qobj : GLUquadric* in/out -> "pointer"
// radius : DOUBLE -> "f64"
// slices : INT -> "i32"
// stacks : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void gluSphere(
    intptr_t* qobj,
    double radius,
    int32_t slices,
    int32_t stacks);
C, "GLU32.dll");
// $ffi->gluSphere(qobj, radius, slices, stacks);
// qobj : GLUquadric* in/out
// radius : 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 gluSphere(
        LongByReference qobj,   // GLUquadric* in/out
        double radius,   // DOUBLE
        int slices,   // INT
        int stacks   // INT
    );
}
@[Link("glu32")]
lib LibGLU32
  fun gluSphere = gluSphere(
    qobj : LibC::SSizeT*,   # GLUquadric* in/out
    radius : 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 gluSphereNative = Void Function(Pointer<IntPtr>, Double, Int32, Int32);
typedef gluSphereDart = void Function(Pointer<IntPtr>, double, int, int);
final gluSphere = DynamicLibrary.open('GLU32.dll')
    .lookupFunction<gluSphereNative, gluSphereDart>('gluSphere');
// qobj : GLUquadric* in/out -> Pointer<IntPtr>
// radius : DOUBLE -> Double
// slices : INT -> Int32
// stacks : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure gluSphere(
  qobj: Pointer;   // GLUquadric* in/out
  radius: Double;   // DOUBLE
  slices: Integer;   // INT
  stacks: Integer   // INT
); stdcall;
  external 'GLU32.dll' name 'gluSphere';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "gluSphere"
  c_gluSphere :: Ptr CIntPtr -> CDouble -> Int32 -> Int32 -> IO ()
-- qobj : GLUquadric* in/out -> Ptr CIntPtr
-- radius : DOUBLE -> CDouble
-- slices : INT -> Int32
-- stacks : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let glusphere =
  foreign "gluSphere"
    ((ptr intptr_t) @-> double @-> int32_t @-> int32_t @-> returning void)
(* qobj : GLUquadric* in/out -> (ptr intptr_t) *)
(* radius : 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 ("gluSphere" glu-sphere :convention :stdcall) :void
  (qobj :pointer)   ; GLUquadric* in/out
  (radius :double)   ; DOUBLE
  (slices :int32)   ; INT
  (stacks :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $gluSphere = Win32::API::More->new('GLU32',
    'void gluSphere(LPVOID qobj, double radius, int slices, int stacks)');
# my $ret = $gluSphere->Call($qobj, $radius, $slices, $stacks);
# qobj : GLUquadric* in/out -> LPVOID
# radius : DOUBLE -> double
# slices : INT -> int
# stacks : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。