1// Copyright 2010-2012 The W32 Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build windows
6
7package w32
8
9import (
10	"syscall"
11	"unsafe"
12)
13
14var (
15	modopengl32 = syscall.NewLazyDLL("opengl32.dll")
16
17	procwglCreateContext      = modopengl32.NewProc("wglCreateContext")
18	procwglCreateLayerContext = modopengl32.NewProc("wglCreateLayerContext")
19	procwglDeleteContext      = modopengl32.NewProc("wglDeleteContext")
20	procwglGetProcAddress     = modopengl32.NewProc("wglGetProcAddress")
21	procwglMakeCurrent        = modopengl32.NewProc("wglMakeCurrent")
22	procwglShareLists         = modopengl32.NewProc("wglShareLists")
23)
24
25func WglCreateContext(hdc HDC) HGLRC {
26	ret, _, _ := procwglCreateContext.Call(
27		uintptr(hdc),
28	)
29
30	return HGLRC(ret)
31}
32
33func WglCreateLayerContext(hdc HDC, iLayerPlane int) HGLRC {
34	ret, _, _ := procwglCreateLayerContext.Call(
35		uintptr(hdc),
36		uintptr(iLayerPlane),
37	)
38
39	return HGLRC(ret)
40}
41
42func WglDeleteContext(hglrc HGLRC) bool {
43	ret, _, _ := procwglDeleteContext.Call(
44		uintptr(hglrc),
45	)
46
47	return ret == TRUE
48}
49
50func WglGetProcAddress(szProc string) uintptr {
51	ret, _, _ := procwglGetProcAddress.Call(
52		uintptr(unsafe.Pointer(syscall.StringBytePtr(szProc))),
53	)
54
55	return ret
56}
57
58func WglMakeCurrent(hdc HDC, hglrc HGLRC) bool {
59	ret, _, _ := procwglMakeCurrent.Call(
60		uintptr(hdc),
61		uintptr(hglrc),
62	)
63
64	return ret == TRUE
65}
66
67func WglShareLists(hglrc1, hglrc2 HGLRC) bool {
68	ret, _, _ := procwglShareLists.Call(
69		uintptr(hglrc1),
70		uintptr(hglrc2),
71	)
72
73	return ret == TRUE
74}
75