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

wglCreateContext

関数
デバイスコンテキストにOpenGLレンダリングコンテキストを作成する。
DLLOPENGL32.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

HGLRC wglCreateContext(
    HDC param0
);

パラメーター

名前方向
param0HDCin

戻り値の型: HGLRC

各言語での呼び出し定義

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

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

wglCreateContext = ctypes.windll.opengl32.wglCreateContext
wglCreateContext.restype = ctypes.c_void_p
wglCreateContext.argtypes = [
    wintypes.HANDLE,  # param0 : HDC
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	opengl32 = windows.NewLazySystemDLL("OPENGL32.dll")
	procwglCreateContext = opengl32.NewProc("wglCreateContext")
)

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