Browse Source

Platform: WindowlessWglApplication cleanup.

Using std::unique_ptr instead of raw pointer, consistent private
variable naming.
pull/87/merge
Vladimír Vondruš 11 years ago
parent
commit
789eb8e47b
  1. 9
      src/Magnum/Platform/WindowlessWglApplication.cpp
  2. 3
      src/Magnum/Platform/WindowlessWglApplication.h

9
src/Magnum/Platform/WindowlessWglApplication.cpp

@ -25,7 +25,6 @@
#include "WindowlessWglApplication.h" #include "WindowlessWglApplication.h"
#include <windows.h>
#include <Corrade/Utility/Assert.h> #include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/Debug.h> #include <Corrade/Utility/Debug.h>
@ -64,7 +63,7 @@ WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, c
createContext(configuration); createContext(configuration);
} }
WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, std::nullptr_t): _window(arguments.window), _c(nullptr) {} WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, std::nullptr_t): _window(arguments.window) {}
void WindowlessWglApplication::createContext() { createContext({}); } void WindowlessWglApplication::createContext() { createContext({}); }
@ -73,7 +72,7 @@ void WindowlessWglApplication::createContext(const Configuration& configuration)
} }
bool WindowlessWglApplication::tryCreateContext(const Configuration&) { bool WindowlessWglApplication::tryCreateContext(const Configuration&) {
CORRADE_ASSERT(!_c, "Platform::WindowlessWglApplication::tryCreateContext(): context already created", false); CORRADE_ASSERT(!_context, "Platform::WindowlessWglApplication::tryCreateContext(): context already created", false);
/* Get device context */ /* Get device context */
_deviceContext = GetDC(_window); _deviceContext = GetDC(_window);
@ -114,12 +113,12 @@ bool WindowlessWglApplication::tryCreateContext(const Configuration&) {
return false; return false;
} }
_c = new Platform::Context; _context.reset(new Platform::Context);
return true; return true;
} }
WindowlessWglApplication::~WindowlessWglApplication() { WindowlessWglApplication::~WindowlessWglApplication() {
delete _c; _context.reset();
wglMakeCurrent(_deviceContext, nullptr); wglMakeCurrent(_deviceContext, nullptr);
wglDeleteContext(_renderingContext); wglDeleteContext(_renderingContext);

3
src/Magnum/Platform/WindowlessWglApplication.h

@ -29,6 +29,7 @@
* @brief Class @ref Magnum::Platform::WindowlessWglApplication, macro @ref MAGNUM_WINDOWLESSWGLAPPLICATION_MAIN() * @brief Class @ref Magnum::Platform::WindowlessWglApplication, macro @ref MAGNUM_WINDOWLESSWGLAPPLICATION_MAIN()
*/ */
#include <memory>
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#define WIN32_LEAN_AND_MEAN 1 #define WIN32_LEAN_AND_MEAN 1
#define VC_EXTRALEAN #define VC_EXTRALEAN
@ -162,7 +163,7 @@ class WindowlessWglApplication {
HDC _deviceContext; HDC _deviceContext;
HGLRC _renderingContext; HGLRC _renderingContext;
Platform::Context* _c; std::unique_ptr<Platform::Context> _context;
}; };
/** /**

Loading…
Cancel
Save