BsWin32Context.cpp 659 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef _WIN32_WINNT
  2. #define _WIN32_WINNT 0x0500
  3. #endif
  4. #include "BsWin32Context.h"
  5. #include "BsException.h"
  6. namespace BansheeEngine
  7. {
  8. Win32Context::Win32Context(HDC hdc, HGLRC glrc, bool ownsContext):
  9. mHDC(hdc), mGlrc(glrc), mOwnsContext(ownsContext)
  10. {
  11. }
  12. Win32Context::~Win32Context()
  13. {
  14. if (mOwnsContext)
  15. releaseContext();
  16. }
  17. void Win32Context::setCurrent()
  18. {
  19. wglMakeCurrent(mHDC, mGlrc);
  20. }
  21. void Win32Context::endCurrent()
  22. {
  23. wglMakeCurrent(0, 0);
  24. }
  25. void Win32Context::releaseContext()
  26. {
  27. if (mGlrc != 0)
  28. {
  29. wglDeleteContext(mGlrc);
  30. mGlrc = 0;
  31. mHDC = 0;
  32. }
  33. }
  34. }