OGLplus (0.52.0) a C++ wrapper for OpenGL

context_wgl.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_NATIVE_CONTEXT_1404232057_HPP
14 #define OGLPLUS_NATIVE_CONTEXT_1404232057_HPP
15 // NOTE: the include guard is intentionally without the _WGL suffix so that
16 // different native context implementation cannot be included simultaneously.
17 
19 
20 namespace oglplus {
21 namespace native {
22 
25 {
26 private:
27  ::HGLRC _context;
28 
29  friend ::HGLRC GetHGLRC(const ContextWGL&);
30 
31  struct Current_ { };
32 
33  ContextWGL(Current_)
34  : _context(::wglGetCurrentContext())
35  {
36  if(!_context) HandleNoWGLRC();
37  }
38 public:
40 
45  static ContextWGL Current(void)
46  {
47  return ContextWGL(Current_());
48  }
49 
51  void MakeCurrent(const SurfaceWGL& surface)
52  {
53  ::wglMakeCurrent(surface._hdc, _context);
54  }
55 
57  void Release(void)
58  {
59  ::wglMakeCurrent(::HDC(0), ::HGLRC(0));
60  }
61 };
62 
63 inline ::HGLRC GetHGLRC(const ContextWGL& cwgl)
64 {
65  return cwgl._context;
66 }
67 
68 typedef ContextWGL Context;
69 
70 } // namespace native
71 } // namespace oglplus
72 
73 #endif // include guard
Wrapper for WGL (DC) surface handle.
Definition: surface_wgl.hpp:27
Wrapper for native current WGL/OpenGL surface.
void MakeCurrent(const SurfaceWGL &surface)
Makes the context current on this thread.
Definition: context_wgl.hpp:51
Wrapper for a valid WGL context handle.
Definition: context_wgl.hpp:24
void Release(void)
Releases the current context without binding a new one.
Definition: context_wgl.hpp:57
static ContextWGL Current(void)
Returns a wrapper for the currently bound WGL context.
Definition: context_wgl.hpp:45

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).