1 #ifndef B3G_WINDOW_INTERFACE_H
2 #define B3G_WINDOW_INTERFACE_H
3 
4 #ifdef __clang__
5 #pragma clang diagnostic push
6 #pragma clang diagnostic ignored "-Wpadded"
7 #if __has_warning("-Wzero-as-null-pointer-constant")
8 #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
9 #endif
10 #endif
11 
12 typedef void (*b3WheelCallback)(float deltax, float deltay);
13 typedef void (*b3ResizeCallback)( float width, float height);
14 typedef void (*b3MouseMoveCallback)( float x, float y);
15 typedef void (*b3MouseButtonCallback)(int button, int state, float x, float y);
16 typedef void (*b3KeyboardCallback)(int keycode, int state);
17 typedef void (*b3RenderCallback) ();
18 
19 enum {
20 	B3G_ESCAPE = 27,
21 	B3G_F1 = 0xff00,
22 	B3G_F2,
23 	B3G_F3,
24 	B3G_F4,
25 	B3G_F5,
26 	B3G_F6,
27 	B3G_F7,
28 	B3G_F8,
29 	B3G_F9,
30 	B3G_F10,
31 	B3G_F11,
32 	B3G_F12,
33 	B3G_F13,
34 	B3G_F14,
35 	B3G_F15,
36 	B3G_LEFT_ARROW,
37 	B3G_RIGHT_ARROW,
38 	B3G_UP_ARROW,
39 	B3G_DOWN_ARROW,
40 	B3G_PAGE_UP,
41 	B3G_PAGE_DOWN,
42 	B3G_END,
43 	B3G_HOME,
44 	B3G_INSERT,
45 	B3G_DELETE,
46 	B3G_BACKSPACE,
47 	B3G_SHIFT,
48 	B3G_CONTROL,
49 	B3G_ALT,
50 	B3G_RETURN
51 };
52 
53 struct b3gWindowConstructionInfo
54 {
55 		int m_width;
56 		int m_height;
57 		bool m_fullscreen;
58 		int m_colorBitsPerPixel;
59 		void* m_windowHandle;
60 		const char* m_title;
61 		int m_openglVersion;
62 
63 
64 		b3gWindowConstructionInfo(int width=1024, int height=768)
m_widthb3gWindowConstructionInfo65 		:m_width(width),
66 			m_height(height),
67 			m_fullscreen(false),
68 			m_colorBitsPerPixel(32),
69 			m_windowHandle(0),
70 			m_title("title"),
71 			m_openglVersion(3)
72 			{
73 			}
74 };
75 
76 
77 class CommonWindowInterface
78 {
79 	public:
80 
~CommonWindowInterface()81 		virtual ~CommonWindowInterface()
82 		{
83 		}
84 
createDefaultWindow(int width,int height,const char * title)85 		virtual void	createDefaultWindow(int width, int height, const char* title)
86 		{
87 			b3gWindowConstructionInfo ci(width,height);
88 			ci.m_title = title;
89 			createWindow(ci);
90 		}
91 
92 		virtual	void	createWindow(const b3gWindowConstructionInfo& ci)=0;
93 
94 		virtual void	closeWindow()=0;
95 
96 		virtual void	runMainLoop()=0;
97 		virtual	float	getTimeInSeconds()=0;
98 
99 		virtual bool	requestedExit() const = 0;
100 		virtual	void	setRequestExit() = 0;
101 
102 		virtual	void	startRendering()=0;
103 
104 		virtual	void	endRendering()=0;
105 
106 		virtual bool	isModifierKeyPressed(int key) = 0;
107 
108 		virtual void setMouseMoveCallback(b3MouseMoveCallback	mouseCallback)=0;
109 		virtual b3MouseMoveCallback getMouseMoveCallback()=0;
110 
111 		virtual void setMouseButtonCallback(b3MouseButtonCallback	mouseCallback)=0;
112 		virtual b3MouseButtonCallback getMouseButtonCallback()=0;
113 
114 		virtual void setResizeCallback(b3ResizeCallback	resizeCallback)=0;
115 		virtual b3ResizeCallback getResizeCallback()=0;
116 
117 		virtual void setWheelCallback(b3WheelCallback wheelCallback)=0;
118 		virtual b3WheelCallback getWheelCallback()=0;
119 
120 		virtual void setKeyboardCallback( b3KeyboardCallback	keyboardCallback)=0;
121 		virtual b3KeyboardCallback	getKeyboardCallback()=0;
122 
123 		virtual void setRenderCallback( b3RenderCallback renderCallback) = 0;
124 
125 		virtual void setWindowTitle(const char* title)=0;
126 
127 		virtual	float	getRetinaScale() const =0;
128 		virtual	void	setAllowRetina(bool allow) =0;
129 
130         virtual int   getWidth() const = 0;
131         virtual int   getHeight() const = 0;
132 
133         virtual int fileOpenDialog(char* fileName, int maxFileNameLength) = 0;
134 
135 };
136 
137 #ifdef __clang__
138 #pragma clang diagnostic pop
139 #endif
140 
141 #endif //B3G_WINDOW_INTERFACE_H
142