BsWin32Context.cpp 874 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #ifndef _WIN32_WINNT
  4. #define _WIN32_WINNT 0x0500
  5. #endif
  6. #include "Win32/BsWin32Context.h"
  7. #include "Error/BsException.h"
  8. namespace bs { namespace ct
  9. {
  10. Win32Context::Win32Context(HDC hdc, HGLRC glrc, bool ownsContext):
  11. mHDC(hdc), mGlrc(glrc), mOwnsContext(ownsContext)
  12. {
  13. }
  14. Win32Context::~Win32Context()
  15. {
  16. if (mOwnsContext)
  17. releaseContext();
  18. }
  19. void Win32Context::setCurrent()
  20. {
  21. wglMakeCurrent(mHDC, mGlrc);
  22. }
  23. void Win32Context::endCurrent()
  24. {
  25. wglMakeCurrent(0, 0);
  26. }
  27. void Win32Context::releaseContext()
  28. {
  29. if (mGlrc != 0)
  30. {
  31. wglDeleteContext(mGlrc);
  32. mGlrc = 0;
  33. mHDC = 0;
  34. }
  35. }
  36. }}