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 <windows.h>
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/Debug.h>
@ -64,7 +63,7 @@ WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, c
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({}); }
@ -73,7 +72,7 @@ void WindowlessWglApplication::createContext(const Configuration& 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 */
_deviceContext = GetDC(_window);
@ -114,12 +113,12 @@ bool WindowlessWglApplication::tryCreateContext(const Configuration&) {
return false;
}
_c = new Platform::Context;
_context.reset(new Platform::Context);
return true;
}
WindowlessWglApplication::~WindowlessWglApplication() {
delete _c;
_context.reset();
wglMakeCurrent(_deviceContext, nullptr);
wglDeleteContext(_renderingContext);

3
src/Magnum/Platform/WindowlessWglApplication.h

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

Loading…
Cancel
Save