OGLplus (0.52.0) a C++ wrapper for OpenGL

context_glx.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 _GLX 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  ::Display* _display;
28  ::GLXContext _context;
29 
30  friend ::Display* GetGLXDisplay(const ContextGLX&);
31  friend ::GLXContext GetGLXContext(const ContextGLX&);
32 
33  struct Current_ { };
34 
35  ContextGLX(Current_)
36  : _display(::glXGetCurrentDisplay())
37  , _context(::glXGetCurrentContext())
38  {
39  if(!_display) HandleNoGLXDisplay();
40  if(!_context) HandleNoGLXContext();
41  }
42 public:
44 
49  static ContextGLX Current(void)
50  {
51  return ContextGLX(Current_());
52  }
53 
55  void MakeCurrent(const SurfaceGLX& surface)
56  {
57  ::glXMakeCurrent(
58  _display,
59  surface._drawable,
60  _context
61  );
62  }
63 
65  void Release(void)
66  {
67  ::glXMakeCurrent(
68  _display,
69  ::GLXDrawable(0),
70  ::GLXContext(0)
71  );
72  }
73 };
74 
75 inline ::Display* GetGLXDisplay(const ContextGLX& cglx)
76 {
77  return cglx._display;
78 }
79 
80 inline ::GLXContext GetGLXContext(const ContextGLX& cglx)
81 {
82  return cglx._context;
83 }
84 
85 typedef ContextGLX Context;
86 
87 } // namespace native
88 } // namespace oglplus
89 
90 #endif // include guard
static ContextGLX Current(void)
Returns a wrapper for the currently bound GLX context.
Definition: context_glx.hpp:49
Wrapper for native current GLX/OpenGL surface.
Wrapper for a valid GLX context handle.
Definition: context_glx.hpp:24
void Release(void)
Releases the current context without binding a new one.
Definition: context_glx.hpp:65
Wrapper for GLX (drawable) surface handle.
Definition: surface_glx.hpp:27
void MakeCurrent(const SurfaceGLX &surface)
Makes the context current on this thread.
Definition: context_glx.hpp:55

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).