opengl32.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. // +build windows
  5. package w32
  6. import (
  7. "syscall"
  8. "unsafe"
  9. )
  10. var (
  11. modopengl32 = syscall.NewLazyDLL("opengl32.dll")
  12. procwglCreateContext = modopengl32.NewProc("wglCreateContext")
  13. procwglCreateLayerContext = modopengl32.NewProc("wglCreateLayerContext")
  14. procwglDeleteContext = modopengl32.NewProc("wglDeleteContext")
  15. procwglGetProcAddress = modopengl32.NewProc("wglGetProcAddress")
  16. procwglMakeCurrent = modopengl32.NewProc("wglMakeCurrent")
  17. procwglShareLists = modopengl32.NewProc("wglShareLists")
  18. )
  19. func WglCreateContext(hdc HDC) HGLRC {
  20. ret, _, _ := procwglCreateContext.Call(
  21. uintptr(hdc),
  22. )
  23. return HGLRC(ret)
  24. }
  25. func WglCreateLayerContext(hdc HDC, iLayerPlane int) HGLRC {
  26. ret, _, _ := procwglCreateLayerContext.Call(
  27. uintptr(hdc),
  28. uintptr(iLayerPlane),
  29. )
  30. return HGLRC(ret)
  31. }
  32. func WglDeleteContext(hglrc HGLRC) bool {
  33. ret, _, _ := procwglDeleteContext.Call(
  34. uintptr(hglrc),
  35. )
  36. return ret == TRUE
  37. }
  38. func WglGetProcAddress(szProc string) uintptr {
  39. ret, _, _ := procwglGetProcAddress.Call(
  40. uintptr(unsafe.Pointer(syscall.StringBytePtr(szProc))),
  41. )
  42. return ret
  43. }
  44. func WglMakeCurrent(hdc HDC, hglrc HGLRC) bool {
  45. ret, _, _ := procwglMakeCurrent.Call(
  46. uintptr(hdc),
  47. uintptr(hglrc),
  48. )
  49. return ret == TRUE
  50. }
  51. func WglShareLists(hglrc1, hglrc2 HGLRC) bool {
  52. ret, _, _ := procwglShareLists.Call(
  53. uintptr(hglrc1),
  54. uintptr(hglrc2),
  55. )
  56. return ret == TRUE
  57. }