OGLplus (0.52.0) a C++ wrapper for OpenGL

surface_wgl.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_NATIVE_SURFACE_1404232057_HPP
14 #define OGLPLUS_NATIVE_SURFACE_1404232057_HPP
15 // NOTE: the include guard is intentionally without the _WGL suffix so that
16 // different native surface implementation cannot be included simultaneously.
17 
18 #define OGLPLUS_NATIVE_WGL 1
19 
21 #include <Windows.h>
22 
23 namespace oglplus {
24 namespace native {
25 
28 {
29 private:
30  ::HDC _hdc;
31 
32  friend class ContextWGL;
33 
34  struct Current_ { };
35 
36  SurfaceWGL(Current_)
37  : _hdc(::wglGetCurrentDC())
38  {
39  if(!_hdc) HandleNoWGLDC();
40  }
41 public:
43 
48  static SurfaceWGL Current(void)
49  {
50  return SurfaceWGL(Current_());
51  }
52 
54  int Width(void) const
55  {
56  ::RECT rect;
57  if(::GetClientRect(::WindowFromDC(_hdc), &rect) == TRUE)
58  {
59  return rect.right - rect.left;
60  }
61  return 0;
62  }
63 
65  int Height(void) const
66  {
67  ::RECT rect;
68  if(::GetClientRect(::WindowFromDC(_hdc), &rect) == TRUE)
69  {
70  return rect.bottom - rect.top;
71  }
72  return 0;
73  }
74 
76  void SwapBuffers(void)
77  {
78  ::SwapBuffers(_hdc);
79  }
80 };
81 
82 typedef SurfaceWGL Surface;
83 
84 } // namespace native
85 } // namespace oglplus
86 
87 #endif // include guard
int Height(void) const
Returns the height of the surface.
Definition: surface_wgl.hpp:65
Wrapper for WGL (DC) surface handle.
Definition: surface_wgl.hpp:27
static SurfaceWGL Current(void)
Returns a wrapper for the currently bound WGL surface.
Definition: surface_wgl.hpp:48
Declaration of common functions used by WGL object wrappers.
void SwapBuffers(void)
Swaps the front and back buffers.
Definition: surface_wgl.hpp:76
Wrapper for a valid WGL context handle.
Definition: context_wgl.hpp:24
int Width(void) const
Returns the width of the surface.
Definition: surface_wgl.hpp:54

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