Crazy Eddie's GUI System  ${CEGUI_VERSION}
CEGuiGLFWSharedBase.h
1 /***********************************************************************
2  created: 12/2/2012
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6 * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 ***************************************************************************/
27 #ifndef _CEGuiGLFWSharedBase_h_
28 #define _CEGuiGLFWSharedBase_h_
29 
30 #include "CEGUISamplesConfig.h"
31 #include "CEGUI/RendererModules/OpenGL/GL.h"
32 
33 #if CEGUI_USE_GLFW_VER == 3
34 # include <GLFW/glfw3.h>
35 # if (GLFW_VERSION_MINOR < 1) && (GLFW_VERSION_PATCH < 1)
36 # define GLFW_DONT_CARE -1
37 # endif
38 #elif CEGUI_USE_GLFW_VER == 2
39 # include <GL/glfw.h>
40 #else
41 # error Unsupported "CEGUI_GLFW_VER".
42 #endif
43 #include "CEGuiBaseApplication.h"
44 #include "CEGUI/MouseCursor.h"
45 
47 {
48 public:
50 
51 protected:
52  // implementation of base class abstract functions.
53  void run();
54  void destroyWindow();
55  void beginRendering(const float elapsed);
56  void endRendering();
57 
58  /*************************************************************************
59  Implementation Methods
60  *************************************************************************/
61  static void initGLFW();
62  static void createGLFWWindow();
63  static void setGLFWAppConfiguration();
64 
65  void drawFrame();
66 
67 #if GLFW_VERSION_MAJOR >= 3
68 
69  static void glfwKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
70  static void glfwCharCallback(GLFWwindow* window, unsigned codepoint);
71  static void glfwMouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
72  static void glfwScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
73  static void glfwCursorPosCallback(GLFWwindow* window, double xpos, double ypos);
74 
75  static void glfwWindowCloseCallback(GLFWwindow* window);
76  static void glfwWindowResizeCallback(GLFWwindow* window, int width, int height);
77 
78 #else // GLFW_VERSION_MAJOR <= 2
79 
80  static void GLFWCALL glfwKeyCallback(int key, int action);
81  static void GLFWCALL glfwCharCallback(int character, int action);
82  static void GLFWCALL glfwMouseButtonCallback(int key, int action);
83  static void GLFWCALL glfwMouseWheelCallback(int position);
84  static void GLFWCALL glfwMousePosCallback(int x, int y );
85 
86  static int GLFWCALL glfwWindowCloseCallback(void);
87  static void GLFWCALL glfwWindowResizeCallback(int width, int height);
88 
89 #endif
90 
91  static CEGUI::Key::Scan GlfwToCeguiKey(int glfwKey);
92  static CEGUI::MouseButton GlfwToCeguiMouseButton(int glfwButton);
93 
94  /*************************************************************************
95  Data fields
96  *************************************************************************/
97  static double d_frameTime;
98  static int d_modifiers;
99 
100  static bool d_windowSized;
101  static int d_newWindowWidth;
102  static int d_newWindowHeight;
103 
104  static bool d_mouseLeftWindow;
105  static bool d_mouseDisableCalled;
106  static double d_oldMousePosX;
107  static double d_oldMousePosY;
108 
109  static const char d_windowTitle[];
110 
111 #if GLFW_VERSION_MAJOR >= 3
112  static GLFWwindow* d_window;
113 #endif
114 };
115 
116 #endif // end of guard _CEGuiGLFWSharedBase_h_
Definition: CEGuiGLFWSharedBase.h:46
MouseButton
Enumeration of mouse buttons.
Definition: cegui/include/CEGUI/InputEvent.h:209
void destroyWindow()
The abstract function for destroying the renderer and the window.
Definition: CEGuiGLFWSharedBase.cpp:53
void endRendering()
Implementation function to perform required post-render operations.
Definition: CEGuiGLFW2SharedBase.cpp:70
void run()
The abstract function for running the application.
Definition: CEGuiGLFW2SharedBase.cpp:35
Base application abstract base class.
Definition: CEGuiBaseApplication.h:69
void beginRendering(const float elapsed)
Implementation function to perform required pre-render operations.
Definition: CEGuiGLFWSharedBase.cpp:59