Wise&mystical  1.0
Project about Europe
Loading...
Searching...
No Matches
null_monitor.c
Go to the documentation of this file.
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>
6//
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.
10//
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:
14//
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.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27// It is fine to use C99 in this file because it will not be built with VS
28//========================================================================
29
30#include "internal.h"
31
32#include <stdlib.h>
33#include <string.h>
34#include <math.h>
35
36// The the sole (fake) video mode of our (sole) fake monitor
37//
38static GLFWvidmode getVideoMode(void)
39{
40 GLFWvidmode mode;
41 mode.width = 1920;
42 mode.height = 1080;
43 mode.redBits = 8;
44 mode.greenBits = 8;
45 mode.blueBits = 8;
46 mode.refreshRate = 60;
47 return mode;
48}
49
53
55{
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));
62}
63
67
69{
70 _glfwFreeGammaArrays(&monitor->null.ramp);
71}
72
73void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
74{
75 if (xpos)
76 *xpos = 0;
77 if (ypos)
78 *ypos = 0;
79}
80
82 float* xscale, float* yscale)
83{
84 if (xscale)
85 *xscale = 1.f;
86 if (yscale)
87 *yscale = 1.f;
88}
89
91 int* xpos, int* ypos,
92 int* width, int* height)
93{
94 const GLFWvidmode mode = getVideoMode();
95
96 if (xpos)
97 *xpos = 0;
98 if (ypos)
99 *ypos = 10;
100 if (width)
101 *width = mode.width;
102 if (height)
103 *height = mode.height - 10;
104}
105
107{
108 GLFWvidmode* mode = calloc(1, sizeof(GLFWvidmode));
109 *mode = getVideoMode();
110 *found = 1;
111 return mode;
112}
113
115{
116 *mode = getVideoMode();
117}
118
120{
121 if (!monitor->null.ramp.size)
122 {
123 _glfwAllocGammaArrays(&monitor->null.ramp, 256);
124
125 for (unsigned int i = 0; i < monitor->null.ramp.size; i++)
126 {
127 const float gamma = 2.2f;
128 float value;
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);
132
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;
136 }
137 }
138
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);
143 return GLFW_TRUE;
144}
145
147{
148 if (monitor->null.ramp.size != ramp->size)
149 {
151 "Null: Gamma ramp size must match current ramp size");
152 return;
153 }
154
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);
158}
159
#define GLFW_CONNECTED
Definition: glfw3.h:1230
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
Definition: glfw3.h:758
#define GLFW_TRUE
One.
Definition: glfw3.h:310
void _glfwInputError(int code, const char *format,...)
Definition: init.c:160
float _glfw_fminf(float a, float b)
Definition: init.c:129
void _glfwInputMonitor(_GLFWmonitor *monitor, int action, int placement)
Definition: monitor.c:97
#define _GLFW_INSERT_FIRST
Definition: internal.h:51
void _glfwFreeGammaArrays(GLFWgammaramp *ramp)
Definition: monitor.c:206
_GLFWmonitor * _glfwAllocMonitor(const char *name, int widthMM, int heightMM)
Definition: monitor.c:167
int GLFWbool
Definition: internal.h:61
void _glfwAllocGammaArrays(GLFWgammaramp *ramp, unsigned int size)
Definition: monitor.c:196
void _glfwPlatformFreeMonitor(_GLFWmonitor *monitor)
Definition: null_monitor.c:68
void _glfwPollMonitorsNull(void)
Definition: null_monitor.c:54
GLFWvidmode * _glfwPlatformGetVideoModes(_GLFWmonitor *monitor, int *found)
Definition: null_monitor.c:106
void _glfwPlatformGetVideoMode(_GLFWmonitor *monitor, GLFWvidmode *mode)
Definition: null_monitor.c:114
void _glfwPlatformSetGammaRamp(_GLFWmonitor *monitor, const GLFWgammaramp *ramp)
Definition: null_monitor.c:146
void _glfwPlatformGetMonitorPos(_GLFWmonitor *monitor, int *xpos, int *ypos)
Definition: null_monitor.c:73
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor *monitor, GLFWgammaramp *ramp)
Definition: null_monitor.c:119
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor *monitor, float *xscale, float *yscale)
Definition: null_monitor.c:81
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor *monitor, int *xpos, int *ypos, int *width, int *height)
Definition: null_monitor.c:90
Gamma ramp.
Definition: glfw3.h:1826
unsigned short * red
Definition: glfw3.h:1829
unsigned short * blue
Definition: glfw3.h:1835
unsigned int size
Definition: glfw3.h:1838
unsigned short * green
Definition: glfw3.h:1832
Video mode type.
Definition: glfw3.h:1792
int greenBits
Definition: glfw3.h:1804
int redBits
Definition: glfw3.h:1801
int width
Definition: glfw3.h:1795
int refreshRate
Definition: glfw3.h:1810
int height
Definition: glfw3.h:1798
int blueBits
Definition: glfw3.h:1807