1 //========================================================================
2 // GLFW 3.4 - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2016 Google Inc.
5 // Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
7 // This software is provided 'as-is', without any express or implied
8 // warranty. In no event will the authors be held liable for any damages
9 // arising from the use of this software.
11 // Permission is granted to anyone to use this software for any purpose,
12 // including commercial applications, and to alter it and redistribute it
13 // freely, subject to the following restrictions:
15 // 1. The origin of this software must not be misrepresented; you must not
16 // claim that you wrote the original software. If you use this software
17 // in a product, an acknowledgment in the product documentation would
18 // be appreciated but is not required.
20 // 2. Altered source versions must be plainly marked as such, and must not
21 // be misrepresented as being the original software.
23 // 3. This notice may not be removed or altered from any source
26 //========================================================================
27 // It is fine to use C99 in this file because it will not be built with VS
28 //========================================================================
36 // The the sole (fake) video mode of our (sole) fake monitor
38 static GLFWvidmode getVideoMode(void)
46 mode.refreshRate = 60;
50 //////////////////////////////////////////////////////////////////////////
51 ////// GLFW internal API //////
52 //////////////////////////////////////////////////////////////////////////
54 void _glfwPollMonitorsNull(void)
56 const float dpi = 141.f;
57 const GLFWvidmode mode = getVideoMode();
58 _GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0",
59 (int) (mode.width * 25.4f / dpi),
60 (int) (mode.height * 25.4f / dpi));
61 _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
64 //////////////////////////////////////////////////////////////////////////
65 ////// GLFW platform API //////
66 //////////////////////////////////////////////////////////////////////////
68 void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
70 _glfwFreeGammaArrays(&monitor->null.ramp);
73 void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
81 void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
82 float* xscale, float* yscale)
90 void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
92 int* width, int* height)
94 const GLFWvidmode mode = getVideoMode();
103 *height = mode.height - 10;
106 GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
108 GLFWvidmode* mode = calloc(1, sizeof(GLFWvidmode));
109 *mode = getVideoMode();
114 void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
116 *mode = getVideoMode();
119 GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
121 if (!monitor->null.ramp.size)
123 _glfwAllocGammaArrays(&monitor->null.ramp, 256);
125 for (unsigned int i = 0; i < monitor->null.ramp.size; i++)
127 const float gamma = 2.2f;
129 value = i / (float) (monitor->null.ramp.size - 1);
130 value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
131 value = _glfw_fminf(value, 65535.f);
133 monitor->null.ramp.red[i] = (unsigned short) value;
134 monitor->null.ramp.green[i] = (unsigned short) value;
135 monitor->null.ramp.blue[i] = (unsigned short) value;
139 _glfwAllocGammaArrays(ramp, monitor->null.ramp.size);
140 memcpy(ramp->red, monitor->null.ramp.red, sizeof(short) * ramp->size);
141 memcpy(ramp->green, monitor->null.ramp.green, sizeof(short) * ramp->size);
142 memcpy(ramp->blue, monitor->null.ramp.blue, sizeof(short) * ramp->size);
146 void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
148 if (monitor->null.ramp.size != ramp->size)
150 _glfwInputError(GLFW_PLATFORM_ERROR,
151 "Null: Gamma ramp size must match current ramp size");
155 memcpy(monitor->null.ramp.red, ramp->red, sizeof(short) * ramp->size);
156 memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size);
157 memcpy(monitor->null.ramp.blue, ramp->blue, sizeof(short) * ramp->size);