//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). 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(0, 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; } } }}