| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | #include "internal.h" |
| 29 | |
| 30 | #include <stdlib.h> |
| 31 | #include <string.h> |
| 32 | #include <math.h> |
| 33 | |
| 34 | |
| 35 | |
| 36 | static GLFWvidmode getVideoMode(void) |
| 37 | { |
| 38 | GLFWvidmode mode; |
| 39 | mode.width = 1920; |
| 40 | mode.height = 1080; |
| 41 | mode.redBits = 8; |
| 42 | mode.greenBits = 8; |
| 43 | mode.blueBits = 8; |
| 44 | mode.refreshRate = 60; |
| 45 | return mode; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | void _glfwPollMonitorsNull(void) |
| 53 | { |
| 54 | const float dpi = 141.f; |
| 55 | const GLFWvidmode mode = getVideoMode(); |
| 56 | _GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0", |
| 57 | (int) (mode.width * 25.4f / dpi), |
| 58 | (int) (mode.height * 25.4f / dpi)); |
| 59 | _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST); |
| 60 | } |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | void _glfwFreeMonitorNull(_GLFWmonitor* monitor) |
| 67 | { |
| 68 | _glfwFreeGammaArrays(&monitor->null.ramp); |
| 69 | } |
| 70 | |
| 71 | void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos) |
| 72 | { |
| 73 | if (xpos) |
| 74 | *xpos = 0; |
| 75 | if (ypos) |
| 76 | *ypos = 0; |
| 77 | } |
| 78 | |
| 79 | void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, |
| 80 | float* xscale, float* yscale) |
| 81 | { |
| 82 | if (xscale) |
| 83 | *xscale = 1.f; |
| 84 | if (yscale) |
| 85 | *yscale = 1.f; |
| 86 | } |
| 87 | |
| 88 | void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, |
| 89 | int* xpos, int* ypos, |
| 90 | int* width, int* height) |
| 91 | { |
| 92 | const GLFWvidmode mode = getVideoMode(); |
| 93 | |
| 94 | if (xpos) |
| 95 | *xpos = 0; |
| 96 | if (ypos) |
| 97 | *ypos = 10; |
| 98 | if (width) |
| 99 | *width = mode.width; |
| 100 | if (height) |
| 101 | *height = mode.height - 10; |
| 102 | } |
| 103 | |
| 104 | GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found) |
| 105 | { |
| 106 | GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode)); |
| 107 | *mode = getVideoMode(); |
| 108 | *found = 1; |
| 109 | return mode; |
| 110 | } |
| 111 | |
| 112 | GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode) |
| 113 | { |
| 114 | *mode = getVideoMode(); |
| 115 | return GLFW_TRUE; |
| 116 | } |
| 117 | |
| 118 | GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp) |
| 119 | { |
| 120 | if (!monitor->null.ramp.size) |
| 121 | { |
| 122 | unsigned int i; |
| 123 | |
| 124 | _glfwAllocGammaArrays(&monitor->null.ramp, 256); |
| 125 | |
| 126 | for (i = 0; i < monitor->null.ramp.size; i++) |
| 127 | { |
| 128 | const float gamma = 2.2f; |
| 129 | float value; |
| 130 | value = i / (float) (monitor->null.ramp.size - 1); |
| 131 | value = powf(value, 1.f / gamma) * 65535.f + 0.5f; |
| 132 | value = fminf(value, 65535.f); |
| 133 | |
| 134 | monitor->null.ramp.red[i] = (unsigned short) value; |
| 135 | monitor->null.ramp.green[i] = (unsigned short) value; |
| 136 | monitor->null.ramp.blue[i] = (unsigned short) value; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | _glfwAllocGammaArrays(ramp, monitor->null.ramp.size); |
| 141 | memcpy(ramp->red, monitor->null.ramp.red, sizeof(short) * ramp->size); |
| 142 | memcpy(ramp->green, monitor->null.ramp.green, sizeof(short) * ramp->size); |
| 143 | memcpy(ramp->blue, monitor->null.ramp.blue, sizeof(short) * ramp->size); |
| 144 | return GLFW_TRUE; |
| 145 | } |
| 146 | |
| 147 | void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) |
| 148 | { |
| 149 | if (monitor->null.ramp.size != ramp->size) |
| 150 | { |
| 151 | _glfwInputError(GLFW_PLATFORM_ERROR, |
| 152 | "Null: Gamma ramp size must match current ramp size"); |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | memcpy(monitor->null.ramp.red, ramp->red, sizeof(short) * ramp->size); |
| 157 | memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size); |
| 158 | memcpy(monitor->null.ramp.blue, ramp->blue, sizeof(short) * ramp->size); |
| 159 | } |
| 160 | |