| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #ifndef _WIN32_WINNT
- #define _WIN32_WINNT 0x0500
- #endif
- #include "Win32/BsWin32Context.h"
- #include "Error/BsException.h"
- namespace bs { namespace ct
- {
- Win32Context::Win32Context(HDC hdc, HGLRC glrc, bool ownsContext):
- mHDC(hdc), mGlrc(glrc), mOwnsContext(ownsContext)
- {
- }
- Win32Context::~Win32Context()
- {
- if (mOwnsContext)
- releaseContext();
- }
- void Win32Context::setCurrent(const RenderWindow& window)
- {
- if(wglMakeCurrent(mHDC, mGlrc) != TRUE)
- BS_EXCEPT(RenderingAPIException, "wglMakeCurrent failed: " + translateWGLError());
- }
- void Win32Context::endCurrent()
- {
- if(wglMakeCurrent(mHDC, 0) != TRUE)
- BS_EXCEPT(RenderingAPIException, "wglMakeCurrent failed: " + translateWGLError());
- }
- void Win32Context::releaseContext()
- {
- if (mGlrc != 0)
- {
- if(wglDeleteContext(mGlrc) != TRUE)
- BS_EXCEPT(RenderingAPIException, "wglDeleteContext failed: " + translateWGLError());
- mGlrc = 0;
- mHDC = 0;
- }
- }
- }}
|