null_window.c 8.03 KB
Newer Older
Camilla Berglund's avatar
Camilla Berglund committed
1
//========================================================================
2
// GLFW 3.3 - www.glfw.org
Camilla Berglund's avatar
Camilla Berglund committed
3
4
//------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc.
Camilla Löwy's avatar
Camilla Löwy committed
5
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
Camilla Berglund's avatar
Camilla Berglund committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
//    claim that you wrote the original software. If you use this software
//    in a product, an acknowledgment in the product documentation would
//    be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
//    be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
//    distribution.
//
//========================================================================
27
28
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
Jason Daly's avatar
Jason Daly committed
29
30
31
32

#include "internal.h"


Camilla Berglund's avatar
Camilla Berglund committed
33
34
static int createNativeWindow(_GLFWwindow* window,
                              const _GLFWwndconfig* wndconfig)
Jason Daly's avatar
Jason Daly committed
35
{
36
37
    window->null.width = wndconfig->width;
    window->null.height = wndconfig->height;
Jason Daly's avatar
Jason Daly committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51

    return GLFW_TRUE;
}


//////////////////////////////////////////////////////////////////////////
//////                       GLFW platform API                      //////
//////////////////////////////////////////////////////////////////////////

int _glfwPlatformCreateWindow(_GLFWwindow* window,
                              const _GLFWwndconfig* wndconfig,
                              const _GLFWctxconfig* ctxconfig,
                              const _GLFWfbconfig* fbconfig)
{
52
    if (!createNativeWindow(window, wndconfig))
Jason Daly's avatar
Jason Daly committed
53
54
        return GLFW_FALSE;

Camilla Berglund's avatar
Camilla Berglund committed
55
56
    if (ctxconfig->client != GLFW_NO_API)
    {
Camilla Löwy's avatar
Camilla Löwy committed
57
58
        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API ||
            ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
59
60
61
62
63
64
65
66
        {
            if (!_glfwInitOSMesa())
                return GLFW_FALSE;
            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
                return GLFW_FALSE;
        }
        else
        {
67
            _glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available");
Camilla Berglund's avatar
Camilla Berglund committed
68
            return GLFW_FALSE;
69
        }
Camilla Berglund's avatar
Camilla Berglund committed
70
    }
Jason Daly's avatar
Jason Daly committed
71
72
73
74
75
76
77
78
79
80

    return GLFW_TRUE;
}

void _glfwPlatformDestroyWindow(_GLFWwindow* window)
{
    if (window->context.destroy)
        window->context.destroy(window);
}

Camilla Berglund's avatar
Camilla Berglund committed
81
82
83
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
{
}
Jason Daly's avatar
Jason Daly committed
84
85

void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count,
Camilla Berglund's avatar
Camilla Berglund committed
86
87
88
                                const GLFWimage* images)
{
}
Jason Daly's avatar
Jason Daly committed
89
90
91
92
93

void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
                                   _GLFWmonitor* monitor,
                                   int xpos, int ypos,
                                   int width, int height,
Camilla Berglund's avatar
Camilla Berglund committed
94
95
96
                                   int refreshRate)
{
}
Jason Daly's avatar
Jason Daly committed
97
98
99
100
101

void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
{
}

Camilla Berglund's avatar
Camilla Berglund committed
102
103
104
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
{
}
Jason Daly's avatar
Jason Daly committed
105
106
107

void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
{
Camilla Berglund's avatar
Camilla Berglund committed
108
    if (width)
109
        *width = window->null.width;
Camilla Berglund's avatar
Camilla Berglund committed
110
    if (height)
111
        *height = window->null.height;
Jason Daly's avatar
Jason Daly committed
112
113
114
115
}

void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{
116
117
    window->null.width = width;
    window->null.height = height;
Jason Daly's avatar
Jason Daly committed
118
119
120
121
}

void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
                                      int minwidth, int minheight,
Camilla Berglund's avatar
Camilla Berglund committed
122
123
124
                                      int maxwidth, int maxheight)
{
}
Jason Daly's avatar
Jason Daly committed
125

Camilla Berglund's avatar
Camilla Berglund committed
126
127
128
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d)
{
}
Jason Daly's avatar
Jason Daly committed
129

Camilla Berglund's avatar
Camilla Berglund committed
130
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
Jason Daly's avatar
Jason Daly committed
131
{
Camilla Berglund's avatar
Camilla Berglund committed
132
    if (width)
133
        *width = window->null.width;
Camilla Berglund's avatar
Camilla Berglund committed
134
    if (height)
135
        *height = window->null.height;
Jason Daly's avatar
Jason Daly committed
136
137
}

Camilla Berglund's avatar
Camilla Berglund committed
138
139
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
                                     int* left, int* top,
Jason Daly's avatar
Jason Daly committed
140
141
142
143
                                     int* right, int* bottom)
{
}

Camilla Löwy's avatar
Camilla Löwy committed
144
145
146
147
148
149
150
151
152
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
                                        float* xscale, float* yscale)
{
    if (xscale)
        *xscale = 1.f;
    if (yscale)
        *yscale = 1.f;
}

Camilla Berglund's avatar
Camilla Berglund committed
153
154
155
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
}
Jason Daly's avatar
Jason Daly committed
156

Camilla Berglund's avatar
Camilla Berglund committed
157
158
159
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
{
}
Jason Daly's avatar
Jason Daly committed
160

Camilla Berglund's avatar
Camilla Berglund committed
161
162
163
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
{
}
Jason Daly's avatar
Jason Daly committed
164

Camilla Berglund's avatar
Camilla Berglund committed
165
166
167
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
{
    return GLFW_FALSE;
Jason Daly's avatar
Jason Daly committed
168
169
}

170
171
172
173
174
int _glfwPlatformWindowHovered(_GLFWwindow* window)
{
    return GLFW_FALSE;
}

175
176
177
178
179
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
{
    return GLFW_FALSE;
}

Camilla Löwy's avatar
Camilla Löwy committed
180
181
182
183
184
185
186
187
188
189
190
191
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
{
}

void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
{
}

void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
{
}

192
193
194
195
196
197
198
199
200
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
{
    return 1.f;
}

void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
{
}

201
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
202
203
204
{
}

205
GLFWbool _glfwPlatformRawMouseMotionSupported(void)
206
207
208
209
{
    return GLFW_FALSE;
}

Camilla Berglund's avatar
Camilla Berglund committed
210
211
212
void _glfwPlatformShowWindow(_GLFWwindow* window)
{
}
Jason Daly's avatar
Jason Daly committed
213

214
215
216
217
218

void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
{
}

Camilla Berglund's avatar
Camilla Berglund committed
219
220
221
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
{
}
Jason Daly's avatar
Jason Daly committed
222

Camilla Berglund's avatar
Camilla Berglund committed
223
224
225
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
}
Jason Daly's avatar
Jason Daly committed
226

Camilla Berglund's avatar
Camilla Berglund committed
227
228
229
void _glfwPlatformFocusWindow(_GLFWwindow* window)
{
}
Jason Daly's avatar
Jason Daly committed
230

Camilla Berglund's avatar
Camilla Berglund committed
231
232
233
234
int _glfwPlatformWindowFocused(_GLFWwindow* window)
{
    return GLFW_FALSE;
}
Jason Daly's avatar
Jason Daly committed
235

Camilla Berglund's avatar
Camilla Berglund committed
236
237
238
239
int _glfwPlatformWindowIconified(_GLFWwindow* window)
{
    return GLFW_FALSE;
}
Jason Daly's avatar
Jason Daly committed
240

Camilla Berglund's avatar
Camilla Berglund committed
241
242
243
244
int _glfwPlatformWindowVisible(_GLFWwindow* window)
{
    return GLFW_FALSE;
}
Jason Daly's avatar
Jason Daly committed
245

Camilla Berglund's avatar
Camilla Berglund committed
246
247
248
void _glfwPlatformPollEvents(void)
{
}
Jason Daly's avatar
Jason Daly committed
249

Camilla Berglund's avatar
Camilla Berglund committed
250
251
252
void _glfwPlatformWaitEvents(void)
{
}
Jason Daly's avatar
Jason Daly committed
253

Camilla Berglund's avatar
Camilla Berglund committed
254
255
256
void _glfwPlatformWaitEventsTimeout(double timeout)
{
}
Jason Daly's avatar
Jason Daly committed
257

Camilla Berglund's avatar
Camilla Berglund committed
258
259
260
void _glfwPlatformPostEmptyEvent(void)
{
}
Jason Daly's avatar
Jason Daly committed
261

Camilla Berglund's avatar
Camilla Berglund committed
262
263
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
{
Jason Daly's avatar
Jason Daly committed
264
265
}

Camilla Berglund's avatar
Camilla Berglund committed
266
267
268
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
{
}
Jason Daly's avatar
Jason Daly committed
269

Camilla Berglund's avatar
Camilla Berglund committed
270
271
272
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
{
}
Jason Daly's avatar
Jason Daly committed
273

Camilla Berglund's avatar
Camilla Berglund committed
274
275
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
                              const GLFWimage* image,
Jason Daly's avatar
Jason Daly committed
276
277
                              int xhot, int yhot)
{
278
    return GLFW_TRUE;
Jason Daly's avatar
Jason Daly committed
279
280
281
282
}

int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{
283
    return GLFW_TRUE;
Jason Daly's avatar
Jason Daly committed
284
285
}

Camilla Berglund's avatar
Camilla Berglund committed
286
287
288
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
{
}
Jason Daly's avatar
Jason Daly committed
289

Camilla Berglund's avatar
Camilla Berglund committed
290
291
292
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
{
}
Jason Daly's avatar
Jason Daly committed
293

294
void _glfwPlatformSetClipboardString(const char* string)
Camilla Berglund's avatar
Camilla Berglund committed
295
296
{
}
Jason Daly's avatar
Jason Daly committed
297

298
const char* _glfwPlatformGetClipboardString(void)
Jason Daly's avatar
Jason Daly committed
299
300
301
302
{
    return NULL;
}

Camilla Löwy's avatar
Cleanup    
Camilla Löwy committed
303
const char* _glfwPlatformGetScancodeName(int scancode)
Camilla Berglund's avatar
Camilla Berglund committed
304
305
306
{
    return "";
}
Jason Daly's avatar
Jason Daly committed
307

Camilla Berglund's avatar
Camilla Berglund committed
308
309
310
311
312
313
314
315
316
int _glfwPlatformGetKeyScancode(int key)
{
    return -1;
}

void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{
}

Jason Daly's avatar
Jason Daly committed
317
318
319
320
321
322
323
324
325
326
327
328
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
                                                      VkPhysicalDevice device,
                                                      uint32_t queuefamily)
{
    return GLFW_FALSE;
}

VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
                                          _GLFWwindow* window,
                                          const VkAllocationCallbacks* allocator,
                                          VkSurfaceKHR* surface)
{
Camilla Berglund's avatar
Camilla Berglund committed
329
    // This seems like the most appropriate error to return here
Jason Daly's avatar
Jason Daly committed
330
331
332
    return VK_ERROR_INITIALIZATION_FAILED;
}

333
334
335
336
337
338
339
340
341
_GLFWusercontext* _glfwPlatformCreateUserContext(_GLFWwindow* window)
{
    if (window->context.osmesa.handle)
    {
        return _glfwCreateUserContextOSMesa(window);
    }

    return GLFW_FALSE;
}