mirror of
https://github.com/glfw/glfw.git
synced 2026-09-18 22:55:46 +00:00
Merge branch 'master' into multi-monitor
Conflicts: .gitignore examples/CMakeLists.txt include/GL/glfw3.h src/CMakeLists.txt src/internal.h src/win32_platform.h src/win32_window.c src/x11_fullscreen.c src/x11_platform.h tests/listmodes.c
This commit is contained in:
Regular → Executable
+135
-180
@@ -33,55 +33,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Convert the specified UTF-8 string to a wide string
|
||||
//========================================================================
|
||||
|
||||
static WCHAR* createWideStringFromUTF8(const char* source)
|
||||
{
|
||||
WCHAR* target;
|
||||
int length;
|
||||
|
||||
length = MultiByteToWideChar(CP_UTF8, 0, source, -1, NULL, 0);
|
||||
if (!length)
|
||||
return NULL;
|
||||
|
||||
target = (WCHAR*) _glfwMalloc(sizeof(WCHAR) * (length + 1));
|
||||
|
||||
if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length + 1))
|
||||
{
|
||||
_glfwFree(target);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Convert BPP to RGB bits based on "best guess"
|
||||
//========================================================================
|
||||
|
||||
static void bpp2rgb(int bpp, int* r, int* g, int* b)
|
||||
{
|
||||
int delta;
|
||||
|
||||
// We assume that by 32 they really meant 24
|
||||
if (bpp == 32)
|
||||
bpp = 24;
|
||||
|
||||
// Convert "bits per pixel" to red, green & blue sizes
|
||||
|
||||
*r = *g = *b = bpp / 3;
|
||||
delta = bpp - (*r * 3);
|
||||
if (delta >= 1)
|
||||
*g = *g + 1;
|
||||
|
||||
if (delta == 2)
|
||||
*r = *r + 1;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Enable/disable minimize/restore animations
|
||||
//========================================================================
|
||||
@@ -197,38 +148,44 @@ static int getPixelFormatAttrib(_GLFWwindow* window, int pixelFormat, int attrib
|
||||
|
||||
static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
||||
{
|
||||
_GLFWfbconfig* result;
|
||||
_GLFWfbconfig* fbconfigs;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
int i, count;
|
||||
int i, available;
|
||||
|
||||
*found = 0;
|
||||
|
||||
if (window->WGL.ARB_pixel_format)
|
||||
count = getPixelFormatAttrib(window, 1, WGL_NUMBER_PIXEL_FORMATS_ARB);
|
||||
{
|
||||
available = getPixelFormatAttrib(window,
|
||||
1,
|
||||
WGL_NUMBER_PIXEL_FORMATS_ARB);
|
||||
}
|
||||
else
|
||||
{
|
||||
count = _glfw_DescribePixelFormat(window->WGL.DC,
|
||||
1,
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
NULL);
|
||||
available = DescribePixelFormat(window->WGL.DC,
|
||||
1,
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (!count)
|
||||
if (!available)
|
||||
{
|
||||
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "Win32/WGL: No pixel formats found");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = (_GLFWfbconfig*) _glfwMalloc(sizeof(_GLFWfbconfig) * count);
|
||||
if (!result)
|
||||
fbconfigs = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * available);
|
||||
if (!fbconfigs)
|
||||
{
|
||||
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
||||
"Win32/WGL: Failed to allocate _GLFWfbconfig array");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 1; i <= count; i++)
|
||||
for (i = 1; i <= available; i++)
|
||||
{
|
||||
_GLFWfbconfig* f = fbconfigs + *found;
|
||||
|
||||
if (window->WGL.ARB_pixel_format)
|
||||
{
|
||||
// Get pixel format attributes through WGL_ARB_pixel_format
|
||||
@@ -251,50 +208,35 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
||||
continue;
|
||||
}
|
||||
|
||||
result[*found].redBits =
|
||||
getPixelFormatAttrib(window, i, WGL_RED_BITS_ARB);
|
||||
result[*found].greenBits =
|
||||
getPixelFormatAttrib(window, i, WGL_GREEN_BITS_ARB);
|
||||
result[*found].blueBits =
|
||||
getPixelFormatAttrib(window, i, WGL_BLUE_BITS_ARB);
|
||||
result[*found].alphaBits =
|
||||
getPixelFormatAttrib(window, i, WGL_ALPHA_BITS_ARB);
|
||||
f->redBits = getPixelFormatAttrib(window, i, WGL_RED_BITS_ARB);
|
||||
f->greenBits = getPixelFormatAttrib(window, i, WGL_GREEN_BITS_ARB);
|
||||
f->blueBits = getPixelFormatAttrib(window, i, WGL_BLUE_BITS_ARB);
|
||||
f->alphaBits = getPixelFormatAttrib(window, i, WGL_ALPHA_BITS_ARB);
|
||||
|
||||
result[*found].depthBits =
|
||||
getPixelFormatAttrib(window, i, WGL_DEPTH_BITS_ARB);
|
||||
result[*found].stencilBits =
|
||||
getPixelFormatAttrib(window, i, WGL_STENCIL_BITS_ARB);
|
||||
f->depthBits = getPixelFormatAttrib(window, i, WGL_DEPTH_BITS_ARB);
|
||||
f->stencilBits = getPixelFormatAttrib(window, i, WGL_STENCIL_BITS_ARB);
|
||||
|
||||
result[*found].accumRedBits =
|
||||
getPixelFormatAttrib(window, i, WGL_ACCUM_RED_BITS_ARB);
|
||||
result[*found].accumGreenBits =
|
||||
getPixelFormatAttrib(window, i, WGL_ACCUM_GREEN_BITS_ARB);
|
||||
result[*found].accumBlueBits =
|
||||
getPixelFormatAttrib(window, i, WGL_ACCUM_BLUE_BITS_ARB);
|
||||
result[*found].accumAlphaBits =
|
||||
getPixelFormatAttrib(window, i, WGL_ACCUM_ALPHA_BITS_ARB);
|
||||
f->accumRedBits = getPixelFormatAttrib(window, i, WGL_ACCUM_RED_BITS_ARB);
|
||||
f->accumGreenBits = getPixelFormatAttrib(window, i, WGL_ACCUM_GREEN_BITS_ARB);
|
||||
f->accumBlueBits = getPixelFormatAttrib(window, i, WGL_ACCUM_BLUE_BITS_ARB);
|
||||
f->accumAlphaBits = getPixelFormatAttrib(window, i, WGL_ACCUM_ALPHA_BITS_ARB);
|
||||
|
||||
result[*found].auxBuffers =
|
||||
getPixelFormatAttrib(window, i, WGL_AUX_BUFFERS_ARB);
|
||||
result[*found].stereo =
|
||||
getPixelFormatAttrib(window, i, WGL_STEREO_ARB);
|
||||
f->auxBuffers = getPixelFormatAttrib(window, i, WGL_AUX_BUFFERS_ARB);
|
||||
f->stereo = getPixelFormatAttrib(window, i, WGL_STEREO_ARB);
|
||||
|
||||
if (window->WGL.ARB_multisample)
|
||||
{
|
||||
result[*found].samples =
|
||||
getPixelFormatAttrib(window, i, WGL_SAMPLES_ARB);
|
||||
}
|
||||
f->samples = getPixelFormatAttrib(window, i, WGL_SAMPLES_ARB);
|
||||
else
|
||||
result[*found].samples = 0;
|
||||
f->samples = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get pixel format attributes through old-fashioned PFDs
|
||||
|
||||
if (!_glfw_DescribePixelFormat(window->WGL.DC,
|
||||
i,
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
&pfd))
|
||||
if (!DescribePixelFormat(window->WGL.DC,
|
||||
i,
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
&pfd))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -315,32 +257,38 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
||||
if (pfd.iPixelType != PFD_TYPE_RGBA)
|
||||
continue;
|
||||
|
||||
result[*found].redBits = pfd.cRedBits;
|
||||
result[*found].greenBits = pfd.cGreenBits;
|
||||
result[*found].blueBits = pfd.cBlueBits;
|
||||
result[*found].alphaBits = pfd.cAlphaBits;
|
||||
f->redBits = pfd.cRedBits;
|
||||
f->greenBits = pfd.cGreenBits;
|
||||
f->blueBits = pfd.cBlueBits;
|
||||
f->alphaBits = pfd.cAlphaBits;
|
||||
|
||||
result[*found].depthBits = pfd.cDepthBits;
|
||||
result[*found].stencilBits = pfd.cStencilBits;
|
||||
f->depthBits = pfd.cDepthBits;
|
||||
f->stencilBits = pfd.cStencilBits;
|
||||
|
||||
result[*found].accumRedBits = pfd.cAccumRedBits;
|
||||
result[*found].accumGreenBits = pfd.cAccumGreenBits;
|
||||
result[*found].accumBlueBits = pfd.cAccumBlueBits;
|
||||
result[*found].accumAlphaBits = pfd.cAccumAlphaBits;
|
||||
f->accumRedBits = pfd.cAccumRedBits;
|
||||
f->accumGreenBits = pfd.cAccumGreenBits;
|
||||
f->accumBlueBits = pfd.cAccumBlueBits;
|
||||
f->accumAlphaBits = pfd.cAccumAlphaBits;
|
||||
|
||||
result[*found].auxBuffers = pfd.cAuxBuffers;
|
||||
result[*found].stereo = (pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE;
|
||||
f->auxBuffers = pfd.cAuxBuffers;
|
||||
f->stereo = (pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE;
|
||||
|
||||
// PFD pixel formats do not support FSAA
|
||||
result[*found].samples = 0;
|
||||
f->samples = 0;
|
||||
}
|
||||
|
||||
result[*found].platformID = i;
|
||||
f->platformID = i;
|
||||
|
||||
(*found)++;
|
||||
}
|
||||
|
||||
return result;
|
||||
if (*found == 0)
|
||||
{
|
||||
free(fbconfigs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fbconfigs;
|
||||
}
|
||||
|
||||
|
||||
@@ -359,14 +307,14 @@ static GLboolean createContext(_GLFWwindow* window,
|
||||
if (wndconfig->share)
|
||||
share = wndconfig->share->WGL.context;
|
||||
|
||||
if (!_glfw_DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(pfd), &pfd))
|
||||
if (!DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(pfd), &pfd))
|
||||
{
|
||||
_glfwSetError(GLFW_OPENGL_UNAVAILABLE,
|
||||
"Win32/WGL: Failed to retrieve PFD for selected pixel format");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (!_glfw_SetPixelFormat(window->WGL.DC, pixelFormat, &pfd))
|
||||
if (!SetPixelFormat(window->WGL.DC, pixelFormat, &pfd))
|
||||
{
|
||||
_glfwSetError(GLFW_OPENGL_UNAVAILABLE,
|
||||
"Win32/WGL: Failed to set selected pixel format");
|
||||
@@ -500,7 +448,7 @@ static GLboolean createContext(_GLFWwindow* window,
|
||||
// Hide mouse cursor
|
||||
//========================================================================
|
||||
|
||||
static void hideMouseCursor(_GLFWwindow* window)
|
||||
static void hideCursor(_GLFWwindow* window)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -509,7 +457,7 @@ static void hideMouseCursor(_GLFWwindow* window)
|
||||
// Capture mouse cursor
|
||||
//========================================================================
|
||||
|
||||
static void captureMouseCursor(_GLFWwindow* window)
|
||||
static void captureCursor(_GLFWwindow* window)
|
||||
{
|
||||
RECT ClipWindowRect;
|
||||
|
||||
@@ -528,7 +476,7 @@ static void captureMouseCursor(_GLFWwindow* window)
|
||||
// Show mouse cursor
|
||||
//========================================================================
|
||||
|
||||
static void showMouseCursor(_GLFWwindow* window)
|
||||
static void showCursor(_GLFWwindow* window)
|
||||
{
|
||||
// Un-capture cursor
|
||||
ReleaseCapture();
|
||||
@@ -835,7 +783,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
// The window was deactivated (or iconified, see above)
|
||||
|
||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||
showMouseCursor(window);
|
||||
showCursor(window);
|
||||
|
||||
if (window->mode == GLFW_FULLSCREEN)
|
||||
{
|
||||
@@ -858,7 +806,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
// The window was activated
|
||||
|
||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
|
||||
captureMouseCursor(window);
|
||||
captureCursor(window);
|
||||
|
||||
if (window->mode == GLFW_FULLSCREEN)
|
||||
{
|
||||
@@ -919,7 +867,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
if (_glfwLibrary.charCallback)
|
||||
translateChar(window, (DWORD) wParam, (DWORD) lParam);
|
||||
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_KEYUP:
|
||||
@@ -934,7 +882,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
else
|
||||
_glfwInputKey(window, translateKey(wParam, lParam), GLFW_RELEASE);
|
||||
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
@@ -1013,14 +961,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
int newMouseX, newMouseY;
|
||||
int newCursorX, newCursorY;
|
||||
|
||||
// Get signed (!) mouse position
|
||||
newMouseX = (int)((short)LOWORD(lParam));
|
||||
newMouseY = (int)((short)HIWORD(lParam));
|
||||
// Get signed (!) cursor position
|
||||
newCursorX = (int)((short)LOWORD(lParam));
|
||||
newCursorY = (int)((short)HIWORD(lParam));
|
||||
|
||||
if (newMouseX != window->Win32.oldMouseX ||
|
||||
newMouseY != window->Win32.oldMouseY)
|
||||
if (newCursorX != window->Win32.oldCursorX ||
|
||||
newCursorY != window->Win32.oldCursorY)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
@@ -1029,28 +977,48 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
if (_glfwLibrary.activeWindow != window)
|
||||
return 0;
|
||||
|
||||
x = newMouseX - window->Win32.oldMouseX;
|
||||
y = newMouseY - window->Win32.oldMouseY;
|
||||
x = newCursorX - window->Win32.oldCursorX;
|
||||
y = newCursorY - window->Win32.oldCursorY;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = newMouseX;
|
||||
y = newMouseY;
|
||||
x = newCursorX;
|
||||
y = newCursorY;
|
||||
}
|
||||
|
||||
window->Win32.oldMouseX = newMouseX;
|
||||
window->Win32.oldMouseY = newMouseY;
|
||||
window->Win32.oldCursorX = newCursorX;
|
||||
window->Win32.oldCursorY = newCursorY;
|
||||
window->Win32.cursorCentered = GL_FALSE;
|
||||
|
||||
_glfwInputCursorMotion(window, x, y);
|
||||
}
|
||||
|
||||
if (!window->Win32.cursorInside)
|
||||
{
|
||||
TRACKMOUSEEVENT tme;
|
||||
ZeroMemory(&tme, sizeof(tme));
|
||||
tme.cbSize = sizeof(tme);
|
||||
tme.dwFlags = TME_LEAVE;
|
||||
tme.hwndTrack = window->Win32.handle;
|
||||
TrackMouseEvent(&tme);
|
||||
|
||||
window->Win32.cursorInside = GL_TRUE;
|
||||
_glfwInputCursorEnter(window, GL_TRUE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_MOUSELEAVE:
|
||||
{
|
||||
window->Win32.cursorInside = GL_FALSE;
|
||||
_glfwInputCursorEnter(window, GL_FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_MOUSEWHEEL:
|
||||
{
|
||||
_glfwInputScroll(window, 0, (((int) wParam) >> 16) / WHEEL_DELTA);
|
||||
_glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1058,7 +1026,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
{
|
||||
// This message is only sent on Windows Vista and later
|
||||
|
||||
_glfwInputScroll(window, (((int) wParam) >> 16) / WHEEL_DELTA, 0);
|
||||
_glfwInputScroll(window, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA, 0.0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1291,13 +1259,13 @@ static int choosePixelFormat(_GLFWwindow* window, const _GLFWfbconfig* fbconfig)
|
||||
closest = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
|
||||
if (!closest)
|
||||
{
|
||||
_glfwFree(fbconfigs);
|
||||
free(fbconfigs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pixelFormat = (int) closest->platformID;
|
||||
|
||||
_glfwFree(fbconfigs);
|
||||
free(fbconfigs);
|
||||
fbconfigs = NULL;
|
||||
closest = NULL;
|
||||
|
||||
@@ -1314,7 +1282,7 @@ static int createWindow(_GLFWwindow* window,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
DWORD dwStyle, dwExStyle;
|
||||
int length, pixelFormat, fullWidth, fullHeight;
|
||||
int pixelFormat, fullWidth, fullHeight;
|
||||
RECT wa;
|
||||
POINT pos;
|
||||
WCHAR* wideTitle;
|
||||
@@ -1366,12 +1334,12 @@ static int createWindow(_GLFWwindow* window,
|
||||
else
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &wa, 0);
|
||||
|
||||
wideTitle = createWideStringFromUTF8(wndconfig->title);
|
||||
wideTitle = _glfwCreateWideStringFromUTF8(wndconfig->title);
|
||||
if (!wideTitle)
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
"glfwOpenWindow: Failed to convert title to wide string");
|
||||
return;
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
window->Win32.handle = CreateWindowEx(window->Win32.dwExStyle,
|
||||
@@ -1392,7 +1360,7 @@ static int createWindow(_GLFWwindow* window,
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
_glfwFree(wideTitle);
|
||||
free(wideTitle);
|
||||
|
||||
window->WGL.DC = GetDC(window->Win32.handle);
|
||||
if (!window->WGL.DC)
|
||||
@@ -1413,11 +1381,11 @@ static int createWindow(_GLFWwindow* window,
|
||||
|
||||
initWGLExtensions(window);
|
||||
|
||||
// Initialize mouse position data
|
||||
// Initialize cursor position data
|
||||
GetCursorPos(&pos);
|
||||
ScreenToClient(window->Win32.handle, &pos);
|
||||
window->Win32.oldMouseX = window->cursorPosX = pos.x;
|
||||
window->Win32.oldMouseY = window->cursorPosY = pos.y;
|
||||
window->Win32.oldCursorX = window->cursorPosX = pos.x;
|
||||
window->Win32.oldCursorY = window->cursorPosY = pos.y;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
@@ -1475,6 +1443,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||
GLboolean recreateContext = GL_FALSE;
|
||||
|
||||
window->Win32.desiredRefreshRate = wndconfig->refreshRate;
|
||||
window->resizable = wndconfig->resizable;
|
||||
|
||||
if (!_glfwLibrary.Win32.classAtom)
|
||||
{
|
||||
@@ -1613,7 +1582,7 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
||||
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
{
|
||||
WCHAR* wideTitle = createWideStringFromUTF8(title);
|
||||
WCHAR* wideTitle = _glfwCreateWideStringFromUTF8(title);
|
||||
if (!wideTitle)
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
@@ -1623,7 +1592,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
|
||||
SetWindowText(window->Win32.handle, wideTitle);
|
||||
|
||||
_glfwFree(wideTitle);
|
||||
free(wideTitle);
|
||||
}
|
||||
|
||||
|
||||
@@ -1633,29 +1602,10 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
|
||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
{
|
||||
//int bpp, refresh;
|
||||
int newMode = 0;
|
||||
GLboolean sizeChanged = GL_FALSE;
|
||||
|
||||
if (window->mode == GLFW_FULLSCREEN)
|
||||
{
|
||||
// Get some info about the current mode
|
||||
|
||||
DEVMODE dm;
|
||||
|
||||
dm.dmSize = sizeof(DEVMODE);
|
||||
//if (EnumDisplaySettings(NULL, window->Win32.modeID, &dm))
|
||||
//{
|
||||
// We need to keep BPP the same for the OpenGL context to keep working
|
||||
//bpp = dm.dmBitsPerPel;
|
||||
|
||||
// Get closest match for target video mode
|
||||
//refresh = window->Win32.desiredRefreshRate;
|
||||
//newMode = _glfwGetClosestVideoModeBPP(&width, &height, &bpp, &refresh);
|
||||
//}
|
||||
//else
|
||||
//newMode = window->Win32.modeID;
|
||||
|
||||
if (width > window->width || height > window->height)
|
||||
{
|
||||
// The new video mode is larger than the current one, so we resize
|
||||
@@ -1667,8 +1617,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
sizeChanged = GL_TRUE;
|
||||
}
|
||||
|
||||
//if (newMode != window->Win32.modeID)
|
||||
//_glfwSetVideoModeMODE(newMode);
|
||||
// TODO: Change video mode
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1692,7 +1641,13 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
||||
{
|
||||
SetWindowPos(window->Win32.handle, HWND_TOP, x, y, 0, 0,
|
||||
RECT rect;
|
||||
|
||||
GetClientRect(window->Win32.handle, &rect);
|
||||
AdjustWindowRectEx(&rect, window->Win32.dwStyle, FALSE, window->Win32.dwExStyle);
|
||||
|
||||
SetWindowPos(window->Win32.handle, HWND_TOP,
|
||||
x + rect.left, y + rect.top, 0, 0,
|
||||
SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
|
||||
}
|
||||
|
||||
@@ -1730,7 +1685,7 @@ void _glfwPlatformRefreshWindowParams(void)
|
||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||
|
||||
// Obtain a detailed description of current pixel format
|
||||
pixelFormat = _glfw_GetPixelFormat(window->WGL.DC);
|
||||
pixelFormat = GetPixelFormat(window->WGL.DC);
|
||||
|
||||
if (window->WGL.ARB_pixel_format)
|
||||
{
|
||||
@@ -1784,8 +1739,8 @@ void _glfwPlatformRefreshWindowParams(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
_glfw_DescribePixelFormat(window->WGL.DC, pixelFormat,
|
||||
sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
||||
DescribePixelFormat(window->WGL.DC, pixelFormat,
|
||||
sizeof(PIXELFORMATDESCRIPTOR), &pfd);
|
||||
|
||||
// Is current OpenGL context accelerated?
|
||||
window->accelerated = (pfd.dwFlags & PFD_GENERIC_ACCELERATED) ||
|
||||
@@ -1835,14 +1790,14 @@ void _glfwPlatformPollEvents(void)
|
||||
window = _glfwLibrary.activeWindow;
|
||||
if (window)
|
||||
{
|
||||
window->Win32.cursorCentered = GL_TRUE;
|
||||
window->Win32.oldMouseX = window->width / 2;
|
||||
window->Win32.oldMouseY = window->height / 2;
|
||||
window->Win32.cursorCentered = GL_FALSE;
|
||||
window->Win32.oldCursorX = window->width / 2;
|
||||
window->Win32.oldCursorY = window->height / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//window->Win32.oldMouseX = window->cursorPosX;
|
||||
//window->Win32.oldMouseY = window->cursorPosY;
|
||||
//window->Win32.oldCursorX = window->cursorPosX;
|
||||
//window->Win32.oldCursorY = window->cursorPosY;
|
||||
}
|
||||
|
||||
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
@@ -1899,9 +1854,9 @@ void _glfwPlatformPollEvents(void)
|
||||
if (window->cursorMode == GLFW_CURSOR_CAPTURED &&
|
||||
!window->Win32.cursorCentered)
|
||||
{
|
||||
_glfwPlatformSetMouseCursorPos(window,
|
||||
window->width / 2,
|
||||
window->height / 2);
|
||||
_glfwPlatformSetCursorPos(window,
|
||||
window->width / 2,
|
||||
window->height / 2);
|
||||
window->Win32.cursorCentered = GL_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1921,10 +1876,10 @@ void _glfwPlatformWaitEvents(void)
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set physical mouse cursor position
|
||||
// Set physical cursor position
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y)
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y)
|
||||
{
|
||||
POINT pos;
|
||||
|
||||
@@ -1946,13 +1901,13 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||
switch (mode)
|
||||
{
|
||||
case GLFW_CURSOR_NORMAL:
|
||||
showMouseCursor(window);
|
||||
showCursor(window);
|
||||
break;
|
||||
case GLFW_CURSOR_HIDDEN:
|
||||
hideMouseCursor(window);
|
||||
hideCursor(window);
|
||||
break;
|
||||
case GLFW_CURSOR_CAPTURED:
|
||||
captureMouseCursor(window);
|
||||
captureCursor(window);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user