mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
Ripped out horribly broken refresh rate mess.
This commit is contained in:
parent
23c6def880
commit
52dac79219
@ -500,44 +500,40 @@ extern "C" {
|
|||||||
* @see glfwWindowHint
|
* @see glfwWindowHint
|
||||||
*/
|
*/
|
||||||
#define GLFW_STENCIL_BITS 0x00021005
|
#define GLFW_STENCIL_BITS 0x00021005
|
||||||
/*! @brief The monitor refresh rate.
|
|
||||||
* @see glfwWindowHint glfwGetWindowParam
|
|
||||||
*/
|
|
||||||
#define GLFW_REFRESH_RATE 0x00021006
|
|
||||||
/*! @brief The bit depth of the red component of the accumulation buffer.
|
/*! @brief The bit depth of the red component of the accumulation buffer.
|
||||||
* @see glfwWindowHint
|
* @see glfwWindowHint
|
||||||
*/
|
*/
|
||||||
#define GLFW_ACCUM_RED_BITS 0x00021007
|
#define GLFW_ACCUM_RED_BITS 0x00021006
|
||||||
/*! @brief The bit depth of the red component of the accumulation buffer.
|
/*! @brief The bit depth of the red component of the accumulation buffer.
|
||||||
* @see glfwWindowHint
|
* @see glfwWindowHint
|
||||||
*/
|
*/
|
||||||
#define GLFW_ACCUM_GREEN_BITS 0x00021008
|
#define GLFW_ACCUM_GREEN_BITS 0x00021007
|
||||||
/*! @brief The bit depth of the red component of the accumulation buffer.
|
/*! @brief The bit depth of the red component of the accumulation buffer.
|
||||||
* @see glfwWindowHint
|
* @see glfwWindowHint
|
||||||
*/
|
*/
|
||||||
#define GLFW_ACCUM_BLUE_BITS 0x00021009
|
#define GLFW_ACCUM_BLUE_BITS 0x00021008
|
||||||
/*! @brief The bit depth of the red component of the accumulation buffer.
|
/*! @brief The bit depth of the red component of the accumulation buffer.
|
||||||
* @see glfwWindowHint
|
* @see glfwWindowHint
|
||||||
*/
|
*/
|
||||||
#define GLFW_ACCUM_ALPHA_BITS 0x0002100A
|
#define GLFW_ACCUM_ALPHA_BITS 0x00021009
|
||||||
/*! @brief The number of auxiliary buffers.
|
/*! @brief The number of auxiliary buffers.
|
||||||
* @see glfwWindowHint
|
* @see glfwWindowHint
|
||||||
*/
|
*/
|
||||||
#define GLFW_AUX_BUFFERS 0x0002100B
|
#define GLFW_AUX_BUFFERS 0x0002100A
|
||||||
/*! @brief @c GL_TRUE for stereo rendering, or @c GL_FALSE otherwise.
|
/*! @brief @c GL_TRUE for stereo rendering, or @c GL_FALSE otherwise.
|
||||||
* @see glfwWindowHint
|
* @see glfwWindowHint
|
||||||
*/
|
*/
|
||||||
#define GLFW_STEREO 0x0002100C
|
#define GLFW_STEREO 0x0002100B
|
||||||
/*! @brief The number of samples used for default framebuffer multisampling, or
|
/*! @brief The number of samples used for default framebuffer multisampling, or
|
||||||
* zero to disable multisampling.
|
* zero to disable multisampling.
|
||||||
* @see glfwWindowHint
|
* @see glfwWindowHint
|
||||||
*/
|
*/
|
||||||
#define GLFW_FSAA_SAMPLES 0x0002100E
|
#define GLFW_FSAA_SAMPLES 0x0002100C
|
||||||
/*! @brief @c GL_TRUE if the framebuffer should be sRGB capable, or @c GL_FALSE
|
/*! @brief @c GL_TRUE if the framebuffer should be sRGB capable, or @c GL_FALSE
|
||||||
* otherwise.
|
* otherwise.
|
||||||
* @see glfwWindowHint
|
* @see glfwWindowHint
|
||||||
*/
|
*/
|
||||||
#define GLFW_SRGB_CAPABLE 0x0002100F
|
#define GLFW_SRGB_CAPABLE 0x0002100D
|
||||||
|
|
||||||
/*! @brief The @link clients client API @endlink to create a context for.
|
/*! @brief The @link clients client API @endlink to create a context for.
|
||||||
* @see glfwWindowHint glfwGetWindowParam
|
* @see glfwWindowHint glfwGetWindowParam
|
||||||
@ -1146,11 +1142,6 @@ GLFWAPI void glfwDefaultWindowHints(void);
|
|||||||
* specify the desired bit depths of the various components of the default
|
* specify the desired bit depths of the various components of the default
|
||||||
* framebuffer.
|
* framebuffer.
|
||||||
*
|
*
|
||||||
* The @ref GLFW_REFRESH_RATE hint specifies the desired monitor refresh rate,
|
|
||||||
* in Hz, of the video mode for a fullscreen window, or zero to let the system
|
|
||||||
* choose a suitable refresh rate. If a windowed mode window is created, this
|
|
||||||
* hint is ignored.
|
|
||||||
*
|
|
||||||
* The @ref GLFW_ACCUM_RED_BITS, @ref GLFW_ACCUM_GREEN_BITS, @ref
|
* The @ref GLFW_ACCUM_RED_BITS, @ref GLFW_ACCUM_GREEN_BITS, @ref
|
||||||
* GLFW_ACCUM_BLUE_BITS and @ref GLFW_ACCUM_ALPHA_BITS hints specify the
|
* GLFW_ACCUM_BLUE_BITS and @ref GLFW_ACCUM_ALPHA_BITS hints specify the
|
||||||
* desired bit depths of the various components of the accumulation buffer.
|
* desired bit depths of the various components of the accumulation buffer.
|
||||||
@ -1400,9 +1391,6 @@ GLFWAPI GLFWmonitor glfwGetWindowMonitor(GLFWwindow window);
|
|||||||
* The @ref GLFW_CLOSE_REQUESTED property indicates whether the window has been
|
* The @ref GLFW_CLOSE_REQUESTED property indicates whether the window has been
|
||||||
* requested by the user to close.
|
* requested by the user to close.
|
||||||
*
|
*
|
||||||
* The @ref GLFW_REFRESH_RATE property will be replaced when the @c
|
|
||||||
* multi-monitor branch is merged.
|
|
||||||
*
|
|
||||||
* The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y properties indicate the
|
* The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y properties indicate the
|
||||||
* screen position, in pixels, of the upper-left corner of the window's client
|
* screen position, in pixels, of the upper-left corner of the window's client
|
||||||
* area.
|
* area.
|
||||||
|
@ -139,13 +139,12 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode)
|
|||||||
// Change the current video mode
|
// Change the current video mode
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp, int* refreshRate)
|
GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp)
|
||||||
{
|
{
|
||||||
CGDisplayModeRef bestMode = NULL;
|
CGDisplayModeRef bestMode = NULL;
|
||||||
CFArrayRef modes;
|
CFArrayRef modes;
|
||||||
CFIndex count, i;
|
CFIndex count, i;
|
||||||
unsigned int leastSizeDiff = UINT_MAX;
|
unsigned int leastSizeDiff = UINT_MAX;
|
||||||
double leastRateDiff = DBL_MAX;
|
|
||||||
|
|
||||||
modes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL);
|
modes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL);
|
||||||
count = CFArrayGetCount(modes);
|
count = CFArrayGetCount(modes);
|
||||||
@ -177,23 +176,11 @@ GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp, int* refreshRate)
|
|||||||
((modeWidth - *width) * (modeWidth - *width) +
|
((modeWidth - *width) * (modeWidth - *width) +
|
||||||
(modeHeight - *height) * (modeHeight - *height));
|
(modeHeight - *height) * (modeHeight - *height));
|
||||||
|
|
||||||
double rateDiff;
|
if (sizeDiff < leastSizeDiff)
|
||||||
|
|
||||||
if (*refreshRate > 0)
|
|
||||||
rateDiff = fabs(CGDisplayModeGetRefreshRate(mode) - *refreshRate);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If no refresh rate was specified, then they're all the same
|
|
||||||
rateDiff = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((sizeDiff < leastSizeDiff) ||
|
|
||||||
(sizeDiff == leastSizeDiff && (rateDiff < leastRateDiff)))
|
|
||||||
{
|
{
|
||||||
bestMode = mode;
|
bestMode = mode;
|
||||||
|
|
||||||
leastSizeDiff = sizeDiff;
|
leastSizeDiff = sizeDiff;
|
||||||
leastRateDiff = rateDiff;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ void _glfwInitJoysticks(void);
|
|||||||
void _glfwTerminateJoysticks(void);
|
void _glfwTerminateJoysticks(void);
|
||||||
|
|
||||||
// Fullscreen
|
// Fullscreen
|
||||||
GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp, int* refreshRate);
|
GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp);
|
||||||
void _glfwRestoreVideoMode(void);
|
void _glfwRestoreVideoMode(void);
|
||||||
|
|
||||||
// OpenGL support
|
// OpenGL support
|
||||||
|
@ -772,13 +772,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
int bpp = colorBits + fbconfig->alphaBits;
|
int bpp = colorBits + fbconfig->alphaBits;
|
||||||
|
|
||||||
if (!_glfwSetVideoMode(&window->width,
|
if (!_glfwSetVideoMode(&window->width, &window->height, &bpp))
|
||||||
&window->height,
|
|
||||||
&bpp,
|
|
||||||
&window->refreshRate))
|
|
||||||
{
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
_glfwPlatformShowWindow(window);
|
_glfwPlatformShowWindow(window);
|
||||||
[[window->NS.object contentView] enterFullScreenMode:[NSScreen mainScreen]
|
[[window->NS.object contentView] enterFullScreenMode:[NSScreen mainScreen]
|
||||||
@ -885,14 +880,6 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
|
|||||||
_glfwInputWindowVisibility(window, GL_FALSE);
|
_glfwInputWindowVisibility(window, GL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Write back window parameters into GLFW window structure
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformRefreshWindowParams(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Poll for new window and input events
|
// Poll for new window and input events
|
||||||
|
@ -91,7 +91,6 @@ struct _GLFWhints
|
|||||||
int alphaBits;
|
int alphaBits;
|
||||||
int depthBits;
|
int depthBits;
|
||||||
int stencilBits;
|
int stencilBits;
|
||||||
int refreshRate;
|
|
||||||
int accumRedBits;
|
int accumRedBits;
|
||||||
int accumGreenBits;
|
int accumGreenBits;
|
||||||
int accumBlueBits;
|
int accumBlueBits;
|
||||||
@ -123,7 +122,6 @@ struct _GLFWhints
|
|||||||
struct _GLFWwndconfig
|
struct _GLFWwndconfig
|
||||||
{
|
{
|
||||||
const char* title;
|
const char* title;
|
||||||
int refreshRate;
|
|
||||||
GLboolean resizable;
|
GLboolean resizable;
|
||||||
GLboolean visible;
|
GLboolean visible;
|
||||||
int positionX;
|
int positionX;
|
||||||
@ -182,7 +180,6 @@ struct _GLFWwindow
|
|||||||
int mode; // GLFW_WINDOWED or GLFW_FULLSCREEN
|
int mode; // GLFW_WINDOWED or GLFW_FULLSCREEN
|
||||||
GLboolean resizable; // GL_TRUE if user may resize this window
|
GLboolean resizable; // GL_TRUE if user may resize this window
|
||||||
GLboolean visible; // GL_TRUE if this window is visible
|
GLboolean visible; // GL_TRUE if this window is visible
|
||||||
int refreshRate; // monitor refresh rate
|
|
||||||
void* userPointer;
|
void* userPointer;
|
||||||
_GLFWmonitor* monitor;
|
_GLFWmonitor* monitor;
|
||||||
|
|
||||||
@ -341,7 +338,6 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window);
|
|||||||
_GLFWwindow* _glfwPlatformGetCurrentContext(void);
|
_GLFWwindow* _glfwPlatformGetCurrentContext(void);
|
||||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window);
|
void _glfwPlatformSwapBuffers(_GLFWwindow* window);
|
||||||
void _glfwPlatformSwapInterval(int interval);
|
void _glfwPlatformSwapInterval(int interval);
|
||||||
void _glfwPlatformRefreshWindowParams(_GLFWwindow* window);
|
|
||||||
int _glfwPlatformExtensionSupported(const char* extension);
|
int _glfwPlatformExtensionSupported(const char* extension);
|
||||||
GLFWglproc _glfwPlatformGetProcAddress(const char* procname);
|
GLFWglproc _glfwPlatformGetProcAddress(const char* procname);
|
||||||
|
|
||||||
|
@ -45,19 +45,18 @@
|
|||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Return closest video mode by dimensions, refresh rate and bits per pixel
|
// Return closest video mode by dimensions and bits per pixel
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static GLboolean getClosestVideoMode(int* width, int* height,
|
static GLboolean getClosestVideoMode(int* width, int* height,
|
||||||
int* bpp, int* refreshRate,
|
int* bpp, GLboolean exactBPP)
|
||||||
GLboolean exactBPP)
|
|
||||||
{
|
{
|
||||||
int mode, bestWidth = 0, bestHeight = 0, bestBPP = 0, bestRate = 0;
|
int mode, bestWidth = 0, bestHeight = 0, bestBPP = 0;
|
||||||
unsigned int sizeDiff, rateDiff, leastSizeDiff, leastRateDiff;
|
unsigned int sizeDiff, leastSizeDiff;
|
||||||
GLboolean foundMode = GL_FALSE;
|
GLboolean foundMode = GL_FALSE;
|
||||||
DEVMODE dm;
|
DEVMODE dm;
|
||||||
|
|
||||||
leastSizeDiff = leastRateDiff = UINT_MAX;
|
leastSizeDiff = UINT_MAX;
|
||||||
|
|
||||||
for (mode = 0; ; mode++)
|
for (mode = 0; ; mode++)
|
||||||
{
|
{
|
||||||
@ -74,29 +73,15 @@ static GLboolean getClosestVideoMode(int* width, int* height,
|
|||||||
(dm.dmPelsHeight - *height) *
|
(dm.dmPelsHeight - *height) *
|
||||||
(dm.dmPelsHeight - *height));
|
(dm.dmPelsHeight - *height));
|
||||||
|
|
||||||
if (*refreshRate > 0)
|
// We match BPP first, then screen area
|
||||||
{
|
|
||||||
rateDiff = (dm.dmDisplayFrequency - *refreshRate) *
|
|
||||||
(dm.dmDisplayFrequency - *refreshRate);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If no refresh rate was specified, then they're all the same
|
|
||||||
rateDiff = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We match first BPP, then screen area and last refresh rate
|
if ((sizeDiff < leastSizeDiff) || (sizeDiff == leastSizeDiff))
|
||||||
|
|
||||||
if ((sizeDiff < leastSizeDiff) ||
|
|
||||||
(sizeDiff == leastSizeDiff && (rateDiff < leastRateDiff)))
|
|
||||||
{
|
{
|
||||||
bestWidth = dm.dmPelsWidth;
|
bestWidth = dm.dmPelsWidth;
|
||||||
bestHeight = dm.dmPelsHeight;
|
bestHeight = dm.dmPelsHeight;
|
||||||
bestBPP = dm.dmBitsPerPel;
|
bestBPP = dm.dmBitsPerPel;
|
||||||
bestRate = dm.dmDisplayFrequency;
|
|
||||||
|
|
||||||
leastSizeDiff = sizeDiff;
|
leastSizeDiff = sizeDiff;
|
||||||
leastRateDiff = rateDiff;
|
|
||||||
|
|
||||||
foundMode = GL_TRUE;
|
foundMode = GL_TRUE;
|
||||||
}
|
}
|
||||||
@ -109,11 +94,6 @@ static GLboolean getClosestVideoMode(int* width, int* height,
|
|||||||
*height = bestHeight;
|
*height = bestHeight;
|
||||||
*bpp = bestBPP;
|
*bpp = bestBPP;
|
||||||
|
|
||||||
// Only save the found refresh rate if the client requested a specific
|
|
||||||
// rate; otherwise keep it at zero to let Windows select the best rate
|
|
||||||
if (*refreshRate > 0)
|
|
||||||
*refreshRate = bestRate;
|
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,19 +107,17 @@ static GLboolean getClosestVideoMode(int* width, int* height,
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwSetVideoMode(int* width, int* height,
|
void _glfwSetVideoMode(int* width, int* height,
|
||||||
int* bpp, int* refreshRate,
|
int* bpp, GLboolean exactBPP)
|
||||||
GLboolean exactBPP)
|
|
||||||
{
|
{
|
||||||
DEVMODE dm;
|
DEVMODE dm;
|
||||||
int closestWidth, closestHeight, closestBPP, closestRate;
|
int closestWidth, closestHeight, closestBPP;
|
||||||
|
|
||||||
closestWidth = *width;
|
closestWidth = *width;
|
||||||
closestHeight = *height;
|
closestHeight = *height;
|
||||||
closestBPP = *bpp;
|
closestBPP = *bpp;
|
||||||
closestRate = *refreshRate;
|
|
||||||
|
|
||||||
if (getClosestVideoMode(&closestWidth, &closestHeight,
|
if (getClosestVideoMode(&closestWidth, &closestHeight,
|
||||||
&closestBPP, &closestRate, exactBPP))
|
&closestBPP, exactBPP))
|
||||||
{
|
{
|
||||||
dm.dmSize = sizeof(DEVMODE);
|
dm.dmSize = sizeof(DEVMODE);
|
||||||
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
|
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
|
||||||
@ -147,18 +125,11 @@ void _glfwSetVideoMode(int* width, int* height,
|
|||||||
dm.dmPelsHeight = closestHeight;
|
dm.dmPelsHeight = closestHeight;
|
||||||
dm.dmBitsPerPel = closestBPP;
|
dm.dmBitsPerPel = closestBPP;
|
||||||
|
|
||||||
if (*refreshRate > 0)
|
|
||||||
{
|
|
||||||
dm.dmFields |= DM_DISPLAYFREQUENCY;
|
|
||||||
dm.dmDisplayFrequency = closestRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL)
|
if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL)
|
||||||
{
|
{
|
||||||
*width = closestWidth;
|
*width = closestWidth;
|
||||||
*height = closestHeight;
|
*height = closestHeight;
|
||||||
*bpp = closestBPP;
|
*bpp = closestBPP;
|
||||||
*refreshRate = closestRate;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -166,10 +137,9 @@ void _glfwSetVideoMode(int* width, int* height,
|
|||||||
dm.dmSize = sizeof(DEVMODE);
|
dm.dmSize = sizeof(DEVMODE);
|
||||||
EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &dm);
|
EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &dm);
|
||||||
|
|
||||||
*width = dm.dmPelsWidth;
|
*width = dm.dmPelsWidth;
|
||||||
*height = dm.dmPelsHeight;
|
*height = dm.dmPelsHeight;
|
||||||
*bpp = dm.dmBitsPerPel;
|
*bpp = dm.dmBitsPerPel;
|
||||||
*refreshRate = dm.dmDisplayFrequency;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,6 @@ typedef struct _GLFWwindowWin32
|
|||||||
DWORD dwExStyle; // --"--
|
DWORD dwExStyle; // --"--
|
||||||
|
|
||||||
// Various platform specific internal variables
|
// Various platform specific internal variables
|
||||||
int desiredRefreshRate; // Desired vertical monitor refresh rate
|
|
||||||
GLboolean cursorCentered;
|
GLboolean cursorCentered;
|
||||||
GLboolean cursorInside;
|
GLboolean cursorInside;
|
||||||
int oldCursorX, oldCursorY;
|
int oldCursorX, oldCursorY;
|
||||||
@ -169,7 +168,6 @@ typedef struct _GLFWlibraryWin32
|
|||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int bitsPerPixel;
|
int bitsPerPixel;
|
||||||
int refreshRate;
|
|
||||||
} monitor;
|
} monitor;
|
||||||
|
|
||||||
// Timer data
|
// Timer data
|
||||||
@ -227,9 +225,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
|
|||||||
const _GLFWfbconfig* fbconfig);
|
const _GLFWfbconfig* fbconfig);
|
||||||
|
|
||||||
// Fullscreen support
|
// Fullscreen support
|
||||||
void _glfwSetVideoMode(int* width, int* height,
|
void _glfwSetVideoMode(int* width, int* height, int* bpp, GLboolean exactBPP);
|
||||||
int* bpp, int* refreshRate,
|
|
||||||
GLboolean exactBPP);
|
|
||||||
void _glfwRestoreVideoMode(void);
|
void _glfwRestoreVideoMode(void);
|
||||||
|
|
||||||
|
|
||||||
|
@ -377,7 +377,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
_glfwSetVideoMode(&_glfwLibrary.Win32.monitor.width,
|
_glfwSetVideoMode(&_glfwLibrary.Win32.monitor.width,
|
||||||
&_glfwLibrary.Win32.monitor.height,
|
&_glfwLibrary.Win32.monitor.height,
|
||||||
&_glfwLibrary.Win32.monitor.bitsPerPixel,
|
&_glfwLibrary.Win32.monitor.bitsPerPixel,
|
||||||
&_glfwLibrary.Win32.monitor.refreshRate,
|
|
||||||
GL_TRUE);
|
GL_TRUE);
|
||||||
|
|
||||||
_glfwLibrary.Win32.monitor.modeChanged = GL_TRUE;
|
_glfwLibrary.Win32.monitor.modeChanged = GL_TRUE;
|
||||||
@ -868,8 +867,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
window->Win32.desiredRefreshRate = wndconfig->refreshRate;
|
|
||||||
|
|
||||||
if (!_glfwLibrary.Win32.classAtom)
|
if (!_glfwLibrary.Win32.classAtom)
|
||||||
{
|
{
|
||||||
_glfwLibrary.Win32.classAtom = registerWindowClass();
|
_glfwLibrary.Win32.classAtom = registerWindowClass();
|
||||||
@ -885,13 +882,11 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
_glfwLibrary.Win32.monitor.width = window->width;
|
_glfwLibrary.Win32.monitor.width = window->width;
|
||||||
_glfwLibrary.Win32.monitor.height = window->height;
|
_glfwLibrary.Win32.monitor.height = window->height;
|
||||||
_glfwLibrary.Win32.monitor.refreshRate = wndconfig->refreshRate;
|
|
||||||
_glfwLibrary.Win32.monitor.bitsPerPixel = bpp;
|
_glfwLibrary.Win32.monitor.bitsPerPixel = bpp;
|
||||||
|
|
||||||
_glfwSetVideoMode(&_glfwLibrary.Win32.monitor.width,
|
_glfwSetVideoMode(&_glfwLibrary.Win32.monitor.width,
|
||||||
&_glfwLibrary.Win32.monitor.height,
|
&_glfwLibrary.Win32.monitor.height,
|
||||||
&_glfwLibrary.Win32.monitor.bitsPerPixel,
|
&_glfwLibrary.Win32.monitor.bitsPerPixel,
|
||||||
&_glfwLibrary.Win32.monitor.refreshRate,
|
|
||||||
GL_FALSE);
|
GL_FALSE);
|
||||||
|
|
||||||
_glfwLibrary.Win32.monitor.modeChanged = GL_TRUE;
|
_glfwLibrary.Win32.monitor.modeChanged = GL_TRUE;
|
||||||
@ -1069,28 +1064,6 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Write back window parameters into GLFW window structure
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformRefreshWindowParams(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
DEVMODE dm;
|
|
||||||
|
|
||||||
ZeroMemory(&dm, sizeof(DEVMODE));
|
|
||||||
dm.dmSize = sizeof(DEVMODE);
|
|
||||||
|
|
||||||
if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
|
|
||||||
{
|
|
||||||
window->refreshRate = dm.dmDisplayFrequency;
|
|
||||||
if (window->refreshRate <= 1)
|
|
||||||
window->refreshRate = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
window->refreshRate = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Poll for new window and input events
|
// Poll for new window and input events
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
47
src/window.c
47
src/window.c
@ -241,21 +241,20 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
|||||||
fbconfig.sRGB = _glfwLibrary.hints.sRGB ? GL_TRUE : GL_FALSE;
|
fbconfig.sRGB = _glfwLibrary.hints.sRGB ? GL_TRUE : GL_FALSE;
|
||||||
|
|
||||||
// Set up desired window config
|
// Set up desired window config
|
||||||
wndconfig.title = title;
|
wndconfig.title = title;
|
||||||
wndconfig.refreshRate = Max(_glfwLibrary.hints.refreshRate, 0);
|
wndconfig.resizable = _glfwLibrary.hints.resizable ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.resizable = _glfwLibrary.hints.resizable ? GL_TRUE : GL_FALSE;
|
wndconfig.visible = _glfwLibrary.hints.visible ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.visible = _glfwLibrary.hints.visible ? GL_TRUE : GL_FALSE;
|
wndconfig.positionX = _glfwLibrary.hints.positionX;
|
||||||
wndconfig.positionX = _glfwLibrary.hints.positionX;
|
wndconfig.positionY = _glfwLibrary.hints.positionY;
|
||||||
wndconfig.positionY = _glfwLibrary.hints.positionY;
|
wndconfig.clientAPI = _glfwLibrary.hints.clientAPI;
|
||||||
wndconfig.clientAPI = _glfwLibrary.hints.clientAPI;
|
wndconfig.glMajor = _glfwLibrary.hints.glMajor;
|
||||||
wndconfig.glMajor = _glfwLibrary.hints.glMajor;
|
wndconfig.glMinor = _glfwLibrary.hints.glMinor;
|
||||||
wndconfig.glMinor = _glfwLibrary.hints.glMinor;
|
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
|
wndconfig.glDebug = _glfwLibrary.hints.glDebug ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.glDebug = _glfwLibrary.hints.glDebug ? GL_TRUE : GL_FALSE;
|
wndconfig.glProfile = _glfwLibrary.hints.glProfile;
|
||||||
wndconfig.glProfile = _glfwLibrary.hints.glProfile;
|
wndconfig.glRobustness = _glfwLibrary.hints.glRobustness;
|
||||||
wndconfig.glRobustness = _glfwLibrary.hints.glRobustness;
|
wndconfig.monitor = (_GLFWmonitor*) monitor;
|
||||||
wndconfig.monitor = (_GLFWmonitor*) monitor;
|
wndconfig.share = (_GLFWwindow*) share;
|
||||||
wndconfig.share = (_GLFWwindow*) share;
|
|
||||||
|
|
||||||
// Check the OpenGL bits of the window config
|
// Check the OpenGL bits of the window config
|
||||||
if (!_glfwIsValidContextConfig(&wndconfig))
|
if (!_glfwIsValidContextConfig(&wndconfig))
|
||||||
@ -295,9 +294,6 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the actual (as opposed to requested) window parameters
|
|
||||||
_glfwPlatformRefreshWindowParams(window);
|
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
// Cache the actual (as opposed to requested) context parameters
|
// Cache the actual (as opposed to requested) context parameters
|
||||||
@ -404,9 +400,6 @@ GLFWAPI void glfwWindowHint(int target, int hint)
|
|||||||
case GLFW_STENCIL_BITS:
|
case GLFW_STENCIL_BITS:
|
||||||
_glfwLibrary.hints.stencilBits = hint;
|
_glfwLibrary.hints.stencilBits = hint;
|
||||||
break;
|
break;
|
||||||
case GLFW_REFRESH_RATE:
|
|
||||||
_glfwLibrary.hints.refreshRate = hint;
|
|
||||||
break;
|
|
||||||
case GLFW_ACCUM_RED_BITS:
|
case GLFW_ACCUM_RED_BITS:
|
||||||
_glfwLibrary.hints.accumRedBits = hint;
|
_glfwLibrary.hints.accumRedBits = hint;
|
||||||
break;
|
break;
|
||||||
@ -593,13 +586,6 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformSetWindowSize(window, width, height);
|
_glfwPlatformSetWindowSize(window, width, height);
|
||||||
|
|
||||||
if (window->monitor)
|
|
||||||
{
|
|
||||||
// Refresh window parameters (may have changed due to changed video
|
|
||||||
// modes)
|
|
||||||
_glfwPlatformRefreshWindowParams(window);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -642,9 +628,6 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformRestoreWindow(window);
|
_glfwPlatformRestoreWindow(window);
|
||||||
|
|
||||||
if (window->monitor)
|
|
||||||
_glfwPlatformRefreshWindowParams(window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -712,8 +695,6 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
|
|||||||
return window->iconified;
|
return window->iconified;
|
||||||
case GLFW_CLOSE_REQUESTED:
|
case GLFW_CLOSE_REQUESTED:
|
||||||
return window->closeRequested;
|
return window->closeRequested;
|
||||||
case GLFW_REFRESH_RATE:
|
|
||||||
return window->refreshRate;
|
|
||||||
case GLFW_RESIZABLE:
|
case GLFW_RESIZABLE:
|
||||||
return window->resizable;
|
return window->resizable;
|
||||||
case GLFW_VISIBLE:
|
case GLFW_VISIBLE:
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
// Finds the video mode closest in size to the specified desired size
|
// Finds the video mode closest in size to the specified desired size
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
int _glfwGetClosestVideoMode(int* width, int* height, int* rate)
|
int _glfwGetClosestVideoMode(int* width, int* height)
|
||||||
{
|
{
|
||||||
int i, match, bestmatch;
|
int i, match, bestmatch;
|
||||||
|
|
||||||
@ -51,8 +51,6 @@ int _glfwGetClosestVideoMode(int* width, int* height, int* rate)
|
|||||||
{
|
{
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
int sizecount, bestsize;
|
int sizecount, bestsize;
|
||||||
int ratecount, bestrate;
|
|
||||||
short* ratelist;
|
|
||||||
XRRScreenConfiguration* sc;
|
XRRScreenConfiguration* sc;
|
||||||
XRRScreenSize* sizelist;
|
XRRScreenSize* sizelist;
|
||||||
|
|
||||||
@ -81,26 +79,6 @@ int _glfwGetClosestVideoMode(int* width, int* height, int* rate)
|
|||||||
// Report width & height of best matching mode
|
// Report width & height of best matching mode
|
||||||
*width = sizelist[bestsize].width;
|
*width = sizelist[bestsize].width;
|
||||||
*height = sizelist[bestsize].height;
|
*height = sizelist[bestsize].height;
|
||||||
|
|
||||||
if (*rate > 0)
|
|
||||||
{
|
|
||||||
ratelist = XRRConfigRates(sc, bestsize, &ratecount);
|
|
||||||
|
|
||||||
bestrate = -1;
|
|
||||||
bestmatch = INT_MAX;
|
|
||||||
for (i = 0; i < ratecount; i++)
|
|
||||||
{
|
|
||||||
match = abs(ratelist[i] - *rate);
|
|
||||||
if (match < bestmatch)
|
|
||||||
{
|
|
||||||
bestmatch = match;
|
|
||||||
bestrate = ratelist[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bestrate != -1)
|
|
||||||
*rate = bestrate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XRRFreeScreenConfigInfo(sc);
|
XRRFreeScreenConfigInfo(sc);
|
||||||
@ -122,7 +100,7 @@ int _glfwGetClosestVideoMode(int* width, int* height, int* rate)
|
|||||||
// Change the current video mode
|
// Change the current video mode
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwSetVideoModeMODE(int mode, int rate)
|
void _glfwSetVideoModeMODE(int mode)
|
||||||
{
|
{
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
@ -145,27 +123,12 @@ void _glfwSetVideoModeMODE(int mode, int rate)
|
|||||||
_glfwLibrary.X11.FS.modeChanged = GL_TRUE;
|
_glfwLibrary.X11.FS.modeChanged = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rate > 0)
|
XRRSetScreenConfig(_glfwLibrary.X11.display,
|
||||||
{
|
sc,
|
||||||
// Set desired configuration
|
root,
|
||||||
XRRSetScreenConfigAndRate(_glfwLibrary.X11.display,
|
mode,
|
||||||
sc,
|
RR_Rotate_0,
|
||||||
root,
|
CurrentTime);
|
||||||
mode,
|
|
||||||
RR_Rotate_0,
|
|
||||||
(short) rate,
|
|
||||||
CurrentTime);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Set desired configuration
|
|
||||||
XRRSetScreenConfig(_glfwLibrary.X11.display,
|
|
||||||
sc,
|
|
||||||
root,
|
|
||||||
mode,
|
|
||||||
RR_Rotate_0,
|
|
||||||
CurrentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
XRRFreeScreenConfigInfo(sc);
|
XRRFreeScreenConfigInfo(sc);
|
||||||
#endif /*_GLFW_HAS_XRANDR*/
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
@ -177,15 +140,15 @@ void _glfwSetVideoModeMODE(int mode, int rate)
|
|||||||
// Change the current video mode
|
// Change the current video mode
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwSetVideoMode(int* width, int* height, int* rate)
|
void _glfwSetVideoMode(int* width, int* height)
|
||||||
{
|
{
|
||||||
int bestmode;
|
int bestmode;
|
||||||
|
|
||||||
// Find a best match mode
|
// Find a best match mode
|
||||||
bestmode = _glfwGetClosestVideoMode(width, height, rate);
|
bestmode = _glfwGetClosestVideoMode(width, height);
|
||||||
|
|
||||||
// Change mode
|
// Change mode
|
||||||
_glfwSetVideoModeMODE(bestmode, *rate);
|
_glfwSetVideoModeMODE(bestmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,9 +252,9 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||||||
void _glfwDestroyContext(_GLFWwindow* window);
|
void _glfwDestroyContext(_GLFWwindow* window);
|
||||||
|
|
||||||
// Fullscreen support
|
// Fullscreen support
|
||||||
int _glfwGetClosestVideoMode(int* width, int* height, int* rate);
|
int _glfwGetClosestVideoMode(int* width, int* height);
|
||||||
void _glfwSetVideoModeMODE(int mode, int rate);
|
void _glfwSetVideoModeMODE(int mode);
|
||||||
void _glfwSetVideoMode(int* width, int* height, int* rate);
|
void _glfwSetVideoMode(int* width, int* height);
|
||||||
void _glfwRestoreVideoMode(void);
|
void _glfwRestoreVideoMode(void);
|
||||||
|
|
||||||
// Joystick input
|
// Joystick input
|
||||||
|
@ -339,8 +339,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
|
|||||||
_glfwLibrary.X11.saver.changed = GL_TRUE;
|
_glfwLibrary.X11.saver.changed = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwSetVideoMode(&window->width, &window->height,
|
_glfwSetVideoMode(&window->width, &window->height);
|
||||||
&window->refreshRate);
|
|
||||||
|
|
||||||
if (_glfwLibrary.X11.hasEWMH &&
|
if (_glfwLibrary.X11.hasEWMH &&
|
||||||
_glfwLibrary.X11.wmState != None &&
|
_glfwLibrary.X11.wmState != None &&
|
||||||
@ -855,8 +854,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
const _GLFWfbconfig* fbconfig)
|
const _GLFWfbconfig* fbconfig)
|
||||||
{
|
{
|
||||||
window->refreshRate = wndconfig->refreshRate;
|
|
||||||
|
|
||||||
if (!_glfwCreateContext(window, wndconfig, fbconfig))
|
if (!_glfwCreateContext(window, wndconfig, fbconfig))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
@ -977,14 +974,12 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
int mode = 0, rate, sizeChanged = GL_FALSE;
|
int mode = 0, sizeChanged = GL_FALSE;
|
||||||
|
|
||||||
rate = window->refreshRate;
|
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
// Get the closest matching video mode for the specified window size
|
// Get the closest matching video mode for the specified window size
|
||||||
mode = _glfwGetClosestVideoMode(&width, &height, &rate);
|
mode = _glfwGetClosestVideoMode(&width, &height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window->resizable)
|
if (!window->resizable)
|
||||||
@ -1012,8 +1007,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
sizeChanged = GL_TRUE;
|
sizeChanged = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change video mode, keeping current refresh rate
|
_glfwSetVideoModeMODE(mode);
|
||||||
_glfwSetVideoModeMODE(mode, window->refreshRate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set window size (if not already changed)
|
// Set window size (if not already changed)
|
||||||
@ -1089,31 +1083,6 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Read back framebuffer parameters from the context
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwPlatformRefreshWindowParams(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
// Retrieve refresh rate if possible
|
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
|
||||||
{
|
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
|
||||||
XRRScreenConfiguration* sc;
|
|
||||||
|
|
||||||
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
|
||||||
window->refreshRate = XRRConfigCurrentRate(sc);
|
|
||||||
XRRFreeScreenConfigInfo(sc);
|
|
||||||
#endif /*_GLFW_HAS_XRANDR*/
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Zero means unknown according to the GLFW spec
|
|
||||||
window->refreshRate = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Poll for new window and input events
|
// Poll for new window and input events
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -63,7 +63,6 @@ static ParamGL gl_params[] =
|
|||||||
|
|
||||||
static ParamGLFW glfw_params[] =
|
static ParamGLFW glfw_params[] =
|
||||||
{
|
{
|
||||||
{ GLFW_REFRESH_RATE, "refresh rate" },
|
|
||||||
{ GLFW_CONTEXT_VERSION_MAJOR, "Context version major" },
|
{ GLFW_CONTEXT_VERSION_MAJOR, "Context version major" },
|
||||||
{ GLFW_CONTEXT_VERSION_MINOR, "Context version minor" },
|
{ GLFW_CONTEXT_VERSION_MINOR, "Context version minor" },
|
||||||
{ GLFW_OPENGL_FORWARD_COMPAT, "OpenGL forward compatible" },
|
{ GLFW_OPENGL_FORWARD_COMPAT, "OpenGL forward compatible" },
|
||||||
|
Loading…
Reference in New Issue
Block a user