BsWin32Context.cpp 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #ifndef _WIN32_WINNT
  5. #define _WIN32_WINNT 0x0500
  6. #endif
  7. #include "BsWin32Context.h"
  8. #include "BsException.h"
  9. namespace BansheeEngine
  10. {
  11. Win32Context::Win32Context(HDC hdc, HGLRC glrc, bool ownsContext):
  12. mHDC(hdc), mGlrc(glrc), mOwnsContext(ownsContext)
  13. {
  14. }
  15. Win32Context::~Win32Context()
  16. {
  17. if (mOwnsContext)
  18. releaseContext();
  19. }
  20. void Win32Context::setCurrent()
  21. {
  22. wglMakeCurrent(mHDC, mGlrc);
  23. }
  24. void Win32Context::endCurrent()
  25. {
  26. wglMakeCurrent(0, 0);
  27. }
  28. void Win32Context::releaseContext()
  29. {
  30. if (mGlrc != 0)
  31. {
  32. wglDeleteContext(mGlrc);
  33. mGlrc = 0;
  34. mHDC = 0;
  35. }
  36. }
  37. }