NRE_GraphicsDriver.hpp
Go to the documentation of this file.
1 
10  #pragma once
11 
12  #include <cstdlib>
13  #include <iostream>
14 
15  #define GLEW_STATIC
16 
17  #ifdef GLEW_STATIC
18  #define GLEWAPI extern
19  #else
20  #ifdef GLEW_BUILD
21  #define GLEWAPI extern __declspec(dllexport)
22  #else
23  #define GLEWAPI extern __declspec(dllimport)
24  #endif
25  #endif
26 
27  #include <GL/glew.h>
28 
29  #ifdef _WIN32 // Windows
30  #include <Windows.h>
31  #include <wingdi.h>
32  #include <GL/wglew.h>
33  #elif __linux__ // Linux
34  #include <X11/Xlib.h>
35  #include <X11/Xatom.h>
36  #include <GL/glxew.h>
37  #else
38  #error "Not Supported Yet or Unknown compiler"
39  #endif
40 
41  #include <Utility/UnorderedMap/NRE_UnorderedMap.hpp>
42  #include <Utility/Singleton/NRE_Singleton.hpp>
43  #include <Utility/Id/NRE_Id.hpp>
44 
49  namespace NRE {
54  namespace Graphics {
55 
56  typedef std::size_t Id;
57 
58  #ifdef _WIN32 // Windows
59  typedef HWND NativeWindowType;
60  #elif __linux__ // Linux
61  typedef Window NativeWindowType;
62  #endif
63 
68  class GraphicsDriver : public Utility::Singleton<GraphicsDriver> {
69  friend Utility::Singleton<GraphicsDriver>;
70  private : // Fields
71  #ifdef __linux__ // Linux
72  Display* display;
73  Atom closeAtom;
74  #endif
75  Utility::UnorderedMap<NativeWindowType, Id> windows;
77  public : // Methods
78  //## Move Constructor ##//
83  GraphicsDriver(GraphicsDriver && drv) = delete;
84 
85  //## Deconstructor ##//
90 
91  //## Getter ##//
92  #ifdef __linux__ // Linux
93 
96  Display* getDisplay();
100  Atom& getCloseAtom();
101  #endif
102 
107  void registerWindow(NativeWindowType window, Id id);
112  void unregisterWindow(NativeWindowType window);
118  Id findId(NativeWindowType window) const;
119 
120  //## Assignment Operator ##//
126  GraphicsDriver& operator =(GraphicsDriver && drv) = delete;
127 
128  private : // Methods
129  //## Constructor ##//
133  GraphicsDriver();
134 
135  };
136  }
137  }
138 
139  #include "NRE_GraphicsDriver.tpp"
140  #ifdef _WIN32 // Windows
141  #include "../../../OS/Windows/Graphics/Driver/NRE_WindowsGraphicsDriver.tpp"
142  #elif __linux__ // Linux
143  #include "../../../OS/Linux/Graphics/Driver/NRE_LinuxGraphicsDriver.tpp"
144  #endif
Manage the os-dependant graphics driver.
Definition: NRE_GraphicsDriver.hpp:68
GraphicsDriver & operator=(GraphicsDriver &&drv)=delete
void unregisterWindow(NativeWindowType window)
The NearlyRealEngine&#39;s global namespace.
Graphics&#39; API.
void registerWindow(NativeWindowType window, Id id)
Id findId(NativeWindowType window) const
Definition: NRE_GraphicsDriver.cpp:15