mirror of
https://github.com/glfw/glfw.git
synced 2024-11-14 02:31:46 +00:00
Merge branch 'master' into multi-display-support
Conflicts: src/fullscreen.c src/win32_window.c src/x11_fullscreen.c
This commit is contained in:
commit
ac57be060d
@ -228,6 +228,7 @@ int _glfwPlatformInit(void)
|
|||||||
// Save the original gamma ramp
|
// Save the original gamma ramp
|
||||||
_glfwLibrary.originalRampSize = CGDisplayGammaTableCapacity(CGMainDisplayID());
|
_glfwLibrary.originalRampSize = CGDisplayGammaTableCapacity(CGMainDisplayID());
|
||||||
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
||||||
|
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -118,9 +118,18 @@ GLFWAPI int glfwGetVideoModes(GLFWmonitor handle, GLFWvidmode* list, int maxcoun
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxcount <= 0 || list == NULL)
|
if (maxcount <= 0)
|
||||||
{
|
{
|
||||||
// TODO: Figure out if this is an error
|
_glfwSetError(GLFW_INVALID_VALUE,
|
||||||
|
"glfwGetVideoModes: Parameter 'maxcount' must be "
|
||||||
|
"greater than zero");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (list == NULL)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_INVALID_VALUE,
|
||||||
|
"glfwGetVideoModes: Parameter 'list' cannot be NULL");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,10 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "../include/GL/glfw3.h"
|
#include "../include/GL/glfw3.h"
|
||||||
|
|
||||||
|
// This path may need to be changed if you build GLFW using your own setup
|
||||||
|
// We ship and use our own copy of glext.h since GLFW uses fairly new
|
||||||
|
// extensions and not all operating systems come with an up-to-date version
|
||||||
#include "../support/GL/glext.h"
|
#include "../support/GL/glext.h"
|
||||||
|
|
||||||
#if defined(_GLFW_COCOA_NSGL)
|
#if defined(_GLFW_COCOA_NSGL)
|
||||||
|
@ -163,6 +163,7 @@ int _glfwPlatformInit(void)
|
|||||||
// Save the original gamma ramp
|
// Save the original gamma ramp
|
||||||
_glfwLibrary.originalRampSize = 256;
|
_glfwLibrary.originalRampSize = 256;
|
||||||
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
||||||
|
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
|
||||||
|
|
||||||
_glfwInitMonitors();
|
_glfwInitMonitors();
|
||||||
|
|
||||||
|
@ -43,6 +43,9 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
|
|
||||||
|
// This path may need to be changed if you build GLFW using your own setup
|
||||||
|
// We ship and use our own copy of wglext.h since GLFW uses fairly new
|
||||||
|
// extensions and not all operating systems come with an up-to-date version
|
||||||
#include "../support/GL/wglext.h"
|
#include "../support/GL/wglext.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Convert BPP to RGB bits based on "best guess"
|
// Convert BPP to RGB bits based on "best guess"
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -145,48 +146,6 @@ static void setForegroundWindow(HWND hWnd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Hide mouse cursor (lock it)
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void hideMouseCursor(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
ShowCursor(FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Show mouse cursor (unlock it)
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void showMouseCursor(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
// Un-capture cursor
|
|
||||||
ReleaseCapture();
|
|
||||||
|
|
||||||
// Release the cursor from the window
|
|
||||||
ClipCursor(NULL);
|
|
||||||
|
|
||||||
ShowCursor(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Capture mouse cursor
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void captureMouseCursor(_GLFWwindow* window)
|
|
||||||
{
|
|
||||||
RECT ClipWindowRect;
|
|
||||||
|
|
||||||
// Clip cursor to the window
|
|
||||||
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
|
|
||||||
ClipCursor(&ClipWindowRect);
|
|
||||||
|
|
||||||
// Capture cursor to user window
|
|
||||||
SetCapture(window->Win32.handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Returns the specified attribute of the specified pixel format
|
// Returns the specified attribute of the specified pixel format
|
||||||
// NOTE: Do not call this unless we have found WGL_ARB_pixel_format
|
// NOTE: Do not call this unless we have found WGL_ARB_pixel_format
|
||||||
@ -513,6 +472,50 @@ static GLboolean createContext(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Hide mouse cursor
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void hideMouseCursor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Capture mouse cursor
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void captureMouseCursor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
RECT ClipWindowRect;
|
||||||
|
|
||||||
|
ShowCursor(FALSE);
|
||||||
|
|
||||||
|
// Clip cursor to the window
|
||||||
|
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
|
||||||
|
ClipCursor(&ClipWindowRect);
|
||||||
|
|
||||||
|
// Capture cursor to user window
|
||||||
|
SetCapture(window->Win32.handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Show mouse cursor
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
static void showMouseCursor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
// Un-capture cursor
|
||||||
|
ReleaseCapture();
|
||||||
|
|
||||||
|
// Release the cursor from the window
|
||||||
|
ClipCursor(NULL);
|
||||||
|
|
||||||
|
ShowCursor(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Translates a Windows key to the corresponding GLFW key
|
// Translates a Windows key to the corresponding GLFW key
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -1903,6 +1906,7 @@ void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
|
|||||||
SetCursorPos(pos.x, pos.y);
|
SetCursorPos(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Set physical mouse cursor mode
|
// Set physical mouse cursor mode
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -45,21 +45,16 @@
|
|||||||
int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
|
int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
|
||||||
{
|
{
|
||||||
int i, match, bestmatch;
|
int i, match, bestmatch;
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
|
||||||
int sizecount, bestsize;
|
|
||||||
int ratecount, bestrate;
|
|
||||||
short* ratelist;
|
|
||||||
XRRScreenConfiguration* sc;
|
|
||||||
XRRScreenSize* sizelist;
|
|
||||||
#endif /*_GLFW_HAS_XRANDR*/
|
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
|
||||||
XF86VidModeModeInfo** modelist;
|
|
||||||
int bestmode, modecount;
|
|
||||||
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
|
||||||
|
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
|
int sizecount, bestsize;
|
||||||
|
int ratecount, bestrate;
|
||||||
|
short* ratelist;
|
||||||
|
XRRScreenConfiguration* sc;
|
||||||
|
XRRScreenSize* sizelist;
|
||||||
|
|
||||||
sc = XRRGetScreenInfo(_glfwLibrary.X11.display,
|
sc = XRRGetScreenInfo(_glfwLibrary.X11.display,
|
||||||
RootWindow(_glfwLibrary.X11.display, screen));
|
RootWindow(_glfwLibrary.X11.display, screen));
|
||||||
|
|
||||||
@ -108,7 +103,6 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free modelist
|
|
||||||
XRRFreeScreenConfigInfo(sc);
|
XRRFreeScreenConfigInfo(sc);
|
||||||
|
|
||||||
if (bestsize != -1)
|
if (bestsize != -1)
|
||||||
@ -118,6 +112,9 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
|
|||||||
else if (_glfwLibrary.X11.VidMode.available)
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
|
XF86VidModeModeInfo** modelist;
|
||||||
|
int bestmode, modecount;
|
||||||
|
|
||||||
// Get a list of all available display modes
|
// Get a list of all available display modes
|
||||||
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen,
|
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen,
|
||||||
&modecount, &modelist);
|
&modecount, &modelist);
|
||||||
@ -145,7 +142,6 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
|
|||||||
*height = modelist[bestmode]->vdisplay;
|
*height = modelist[bestmode]->vdisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free modelist
|
|
||||||
XFree(modelist);
|
XFree(modelist);
|
||||||
|
|
||||||
if (bestmode != -1)
|
if (bestmode != -1)
|
||||||
@ -167,18 +163,12 @@ int _glfwGetClosestVideoMode(int screen, int* width, int* height, int* rate)
|
|||||||
|
|
||||||
void _glfwSetVideoModeMODE(int screen, int mode, int rate)
|
void _glfwSetVideoModeMODE(int screen, int mode, int rate)
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
|
||||||
XRRScreenConfiguration* sc;
|
|
||||||
Window root;
|
|
||||||
#endif /*_GLFW_HAS_XRANDR*/
|
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
|
||||||
XF86VidModeModeInfo **modelist;
|
|
||||||
int modecount;
|
|
||||||
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
|
||||||
|
|
||||||
if (_glfwLibrary.X11.RandR.available)
|
if (_glfwLibrary.X11.RandR.available)
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
|
XRRScreenConfiguration* sc;
|
||||||
|
Window root;
|
||||||
|
|
||||||
root = RootWindow(_glfwLibrary.X11.display, screen);
|
root = RootWindow(_glfwLibrary.X11.display, screen);
|
||||||
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, root);
|
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, root);
|
||||||
|
|
||||||
@ -220,6 +210,9 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate)
|
|||||||
else if (_glfwLibrary.X11.VidMode.available)
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
|
XF86VidModeModeInfo **modelist;
|
||||||
|
int modecount;
|
||||||
|
|
||||||
// Get a list of all available display modes
|
// Get a list of all available display modes
|
||||||
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen,
|
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen,
|
||||||
&modecount, &modelist);
|
&modecount, &modelist);
|
||||||
@ -229,8 +222,7 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate)
|
|||||||
XF86VidModeLockModeSwitch(_glfwLibrary.X11.display, screen, 0);
|
XF86VidModeLockModeSwitch(_glfwLibrary.X11.display, screen, 0);
|
||||||
|
|
||||||
// Change the video mode to the desired mode
|
// Change the video mode to the desired mode
|
||||||
XF86VidModeSwitchToMode(_glfwLibrary.X11.display, screen,
|
XF86VidModeSwitchToMode(_glfwLibrary.X11.display, screen, modelist[mode]);
|
||||||
modelist[mode]);
|
|
||||||
|
|
||||||
// Set viewport to upper left corner (where our window will be)
|
// Set viewport to upper left corner (where our window will be)
|
||||||
XF86VidModeSetViewPort(_glfwLibrary.X11.display, screen, 0, 0);
|
XF86VidModeSetViewPort(_glfwLibrary.X11.display, screen, 0, 0);
|
||||||
@ -245,7 +237,6 @@ void _glfwSetVideoModeMODE(int screen, int mode, int rate)
|
|||||||
_glfwLibrary.X11.FS.modeChanged = GL_TRUE;
|
_glfwLibrary.X11.FS.modeChanged = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free mode list
|
|
||||||
XFree(modelist);
|
XFree(modelist);
|
||||||
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
}
|
}
|
||||||
@ -353,16 +344,13 @@ int _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, GLFWvidmode* list, int max
|
|||||||
int viscount, rgbcount, rescount;
|
int viscount, rgbcount, rescount;
|
||||||
int* rgbarray;
|
int* rgbarray;
|
||||||
struct _glfwResolution* resarray;
|
struct _glfwResolution* resarray;
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
|
||||||
XF86VidModeModeInfo** modelist;
|
|
||||||
int modecount, width, height;
|
|
||||||
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
|
||||||
|
|
||||||
// Get list of visuals
|
// Get list of visuals
|
||||||
vislist = XGetVisualInfo(_glfwLibrary.X11.display, 0, &dummy, &viscount);
|
vislist = XGetVisualInfo(_glfwLibrary.X11.display, 0, &dummy, &viscount);
|
||||||
if (vislist == NULL)
|
if (vislist == NULL)
|
||||||
{
|
{
|
||||||
// TODO: Figure out which error this is
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
|
"X11/GLX: Failed to retrieve the available visuals");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,6 +431,9 @@ int _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, GLFWvidmode* list, int max
|
|||||||
else if (_glfwLibrary.X11.VidMode.available)
|
else if (_glfwLibrary.X11.VidMode.available)
|
||||||
{
|
{
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
#if defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
|
XF86VidModeModeInfo** modelist;
|
||||||
|
int modecount, width, height;
|
||||||
|
|
||||||
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist);
|
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist);
|
||||||
|
|
||||||
resarray = (struct _glfwResolution*) _glfwMalloc(sizeof(struct _glfwResolution) * modecount);
|
resarray = (struct _glfwResolution*) _glfwMalloc(sizeof(struct _glfwResolution) * modecount);
|
||||||
@ -495,7 +486,6 @@ int _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, GLFWvidmode* list, int max
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free visuals list
|
|
||||||
XFree(vislist);
|
XFree(vislist);
|
||||||
|
|
||||||
_glfwFree(resarray);
|
_glfwFree(resarray);
|
||||||
@ -512,15 +502,9 @@ int _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, GLFWvidmode* list, int max
|
|||||||
void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
|
void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
|
||||||
{
|
{
|
||||||
int bpp;
|
int bpp;
|
||||||
#if defined(_GLFW_HAS_XF86VIDMODE)
|
|
||||||
XF86VidModeModeInfo** modelist;
|
|
||||||
int modecount;
|
|
||||||
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
|
||||||
|
|
||||||
// Get display depth
|
// Get and split display depth
|
||||||
bpp = DefaultDepth(_glfwLibrary.X11.display, _glfwLibrary.X11.screen);
|
bpp = DefaultDepth(_glfwLibrary.X11.display, _glfwLibrary.X11.screen);
|
||||||
|
|
||||||
// Convert BPP to RGB bits
|
|
||||||
_glfwSplitBPP(bpp, &mode->redBits, &mode->greenBits, &mode->blueBits);
|
_glfwSplitBPP(bpp, &mode->redBits, &mode->greenBits, &mode->blueBits);
|
||||||
|
|
||||||
if (_glfwLibrary.X11.FS.modeChanged)
|
if (_glfwLibrary.X11.FS.modeChanged)
|
||||||
|
@ -502,6 +502,7 @@ static void initGammaRamp(void)
|
|||||||
|
|
||||||
// Save the original gamma ramp
|
// Save the original gamma ramp
|
||||||
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
||||||
|
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,6 +41,9 @@
|
|||||||
#define GLX_GLXEXT_LEGACY
|
#define GLX_GLXEXT_LEGACY
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
|
|
||||||
|
// This path may need to be changed if you build GLFW using your own setup
|
||||||
|
// We ship and use our own copy of glxext.h since GLFW uses fairly new
|
||||||
|
// extensions and not all operating systems come with an up-to-date version
|
||||||
#include "../support/GL/glxext.h"
|
#include "../support/GL/glxext.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ static void window_size_callback(GLFWwindow window, int width, int height)
|
|||||||
static int window_close_callback(GLFWwindow window)
|
static int window_close_callback(GLFWwindow window)
|
||||||
{
|
{
|
||||||
printf("Close callback triggered\n");
|
printf("Close callback triggered\n");
|
||||||
window_handle = NULL;
|
closed = GL_TRUE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,10 @@ int main(void)
|
|||||||
|
|
||||||
glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300);
|
glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300);
|
||||||
|
|
||||||
glClearColor((GLclampf) (i & 1), (GLclampf) (i >> 1), 0.0, 0.0);
|
glClearColor((GLclampf) (i & 1),
|
||||||
|
(GLclampf) (i >> 1),
|
||||||
|
i ? 0.0 : 1.0,
|
||||||
|
0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (running)
|
while (running)
|
||||||
|
Loading…
Reference in New Issue
Block a user