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

glLineStipple

関数
破線描画用のスティップルパターンを設定する。
DLLOPENGL32.dll呼出規約winapi

シグネチャ

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

void glLineStipple(
    INT factor,
    WORD pattern
);

パラメーター

名前方向説明
factorINTinスティップルパターンを各ビット繰り返す倍率。1〜256にクランプされる。
patternWORDin線分の描画パターンを表す16ビットのビット列。1のビットが描画される。

戻り値の型: void

各言語での呼び出し定義

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

void glLineStipple(
    INT factor,
    WORD pattern
);
[DllImport("OPENGL32.dll", ExactSpelling = true)]
static extern void glLineStipple(
    int factor,   // INT
    ushort pattern   // WORD
);
<DllImport("OPENGL32.dll", ExactSpelling:=True)>
Public Shared Sub glLineStipple(
    factor As Integer,   ' INT
    pattern As UShort   ' WORD
)
End Sub
' factor : INT
' pattern : WORD
Declare PtrSafe Sub glLineStipple Lib "opengl32" ( _
    ByVal factor As Long, _
    ByVal pattern As Integer)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

glLineStipple = ctypes.windll.opengl32.glLineStipple
glLineStipple.restype = None
glLineStipple.argtypes = [
    ctypes.c_int,  # factor : INT
    ctypes.c_ushort,  # pattern : WORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OPENGL32.dll')
glLineStipple = Fiddle::Function.new(
  lib['glLineStipple'],
  [
    Fiddle::TYPE_INT,  # factor : INT
    -Fiddle::TYPE_SHORT,  # pattern : WORD
  ],
  Fiddle::TYPE_VOID)
#[link(name = "opengl32")]
extern "system" {
    fn glLineStipple(
        factor: i32,  // INT
        pattern: u16  // WORD
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OPENGL32.dll")]
public static extern void glLineStipple(int factor, ushort pattern);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OPENGL32_glLineStipple' -Namespace Win32 -PassThru
# $api::glLineStipple(factor, pattern)
#uselib "OPENGL32.dll"
#func global glLineStipple "glLineStipple" sptr, sptr
; glLineStipple factor, pattern
; factor : INT -> "sptr"
; pattern : WORD -> "sptr"
#uselib "OPENGL32.dll"
#func global glLineStipple "glLineStipple" int, int
; glLineStipple factor, pattern
; factor : INT -> "int"
; pattern : WORD -> "int"
; void glLineStipple(INT factor, WORD pattern)
#uselib "OPENGL32.dll"
#func global glLineStipple "glLineStipple" int, int
; glLineStipple factor, pattern
; factor : INT -> "int"
; pattern : WORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
	procglLineStipple = opengl32.NewProc("glLineStipple")
)

// factor (INT), pattern (WORD)
r1, _, err := procglLineStipple.Call(
	uintptr(factor),
	uintptr(pattern),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure glLineStipple(
  factor: Integer;   // INT
  pattern: Word   // WORD
); stdcall;
  external 'OPENGL32.dll' name 'glLineStipple';
result := DllCall("OPENGL32\glLineStipple"
    , "Int", factor   ; INT
    , "UShort", pattern   ; WORD
    , "Int")   ; return: void
●glLineStipple(factor, pattern) = DLL("OPENGL32.dll", "int glLineStipple(int, int)")
# 呼び出し: glLineStipple(factor, pattern)
# factor : INT -> "int"
# pattern : WORD -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef glLineStippleNative = Void Function(Int32, Uint16);
typedef glLineStippleDart = void Function(int, int);
final glLineStipple = DynamicLibrary.open('OPENGL32.dll')
    .lookupFunction<glLineStippleNative, glLineStippleDart>('glLineStipple');
// factor : INT -> Int32
// pattern : WORD -> Uint16
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure glLineStipple(
  factor: Integer;   // INT
  pattern: Word   // WORD
); stdcall;
  external 'OPENGL32.dll' name 'glLineStipple';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "glLineStipple"
  c_glLineStipple :: Int32 -> Word16 -> IO ()
-- factor : INT -> Int32
-- pattern : WORD -> Word16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let gllinestipple =
  foreign "glLineStipple"
    (int32_t @-> uint16_t @-> returning void)
(* factor : INT -> int32_t *)
(* pattern : WORD -> uint16_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library opengl32 (t "OPENGL32.dll"))
(cffi:use-foreign-library opengl32)

(cffi:defcfun ("glLineStipple" gl-line-stipple :convention :stdcall) :void
  (factor :int32)   ; INT
  (pattern :uint16))   ; WORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $glLineStipple = Win32::API::More->new('OPENGL32',
    'void glLineStipple(int factor, WORD pattern)');
# my $ret = $glLineStipple->Call($factor, $pattern);
# factor : INT -> int
# pattern : WORD -> WORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。