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

wglGetCurrentContext

関数
現在のスレッドのOpenGLレンダリングコンテキストを取得する。
DLLOPENGL32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HGLRC wglGetCurrentContext(void);

パラメーターなし。戻り値: HGLRC

各言語での呼び出し定義

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

HGLRC wglGetCurrentContext(void);
[DllImport("OPENGL32.dll", ExactSpelling = true)]
static extern IntPtr wglGetCurrentContext();
<DllImport("OPENGL32.dll", ExactSpelling:=True)>
Public Shared Function wglGetCurrentContext() As IntPtr
End Function
Declare PtrSafe Function wglGetCurrentContext Lib "opengl32" () As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

wglGetCurrentContext = ctypes.windll.opengl32.wglGetCurrentContext
wglGetCurrentContext.restype = ctypes.c_void_p
wglGetCurrentContext.argtypes = []
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OPENGL32.dll')
wglGetCurrentContext = Fiddle::Function.new(
  lib['wglGetCurrentContext'],
  [],
  Fiddle::TYPE_VOIDP)
#[link(name = "opengl32")]
extern "system" {
    fn wglGetCurrentContext() -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OPENGL32.dll")]
public static extern IntPtr wglGetCurrentContext();
"@
$api = Add-Type -MemberDefinition $sig -Name 'OPENGL32_wglGetCurrentContext' -Namespace Win32 -PassThru
# $api::wglGetCurrentContext()
#uselib "OPENGL32.dll"
#func global wglGetCurrentContext "wglGetCurrentContext"
; wglGetCurrentContext   ; 戻り値は stat
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "OPENGL32.dll"
#cfunc global wglGetCurrentContext "wglGetCurrentContext"
; res = wglGetCurrentContext()
; HGLRC wglGetCurrentContext()
#uselib "OPENGL32.dll"
#cfunc global wglGetCurrentContext "wglGetCurrentContext"
; res = wglGetCurrentContext()
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
	procwglGetCurrentContext = opengl32.NewProc("wglGetCurrentContext")
)

r1, _, err := procwglGetCurrentContext.Call()
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HGLRC
function wglGetCurrentContext: THandle; stdcall;
  external 'OPENGL32.dll' name 'wglGetCurrentContext';
result := DllCall("OPENGL32\wglGetCurrentContext", "Ptr")
●wglGetCurrentContext() = DLL("OPENGL32.dll", "void* wglGetCurrentContext()")
# 呼び出し: wglGetCurrentContext()
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。