mirror of
https://github.com/glfw/glfw.git
synced 2025-10-05 06:06:36 +00:00
Merge
This commit is contained in:
commit
2e514c6b19
1
.gitignore
vendored
1
.gitignore
vendored
@ -82,3 +82,4 @@ tests/title
|
|||||||
tests/vulkan
|
tests/vulkan
|
||||||
tests/windows
|
tests/windows
|
||||||
|
|
||||||
|
/build
|
||||||
|
@ -38,13 +38,14 @@ add_executable(particles WIN32 MACOSX_BUNDLE particles.c ${ICON} ${TINYCTHREAD}
|
|||||||
add_executable(simple WIN32 MACOSX_BUNDLE simple.c ${ICON} ${GLAD})
|
add_executable(simple WIN32 MACOSX_BUNDLE simple.c ${ICON} ${GLAD})
|
||||||
add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD})
|
add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD})
|
||||||
add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD})
|
add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD})
|
||||||
|
add_executable(pen WIN32 MACOSX_BUNDLE pen.c ${ICON} ${GLAD})
|
||||||
|
|
||||||
target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}")
|
target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}")
|
||||||
if (RT_LIBRARY)
|
if (RT_LIBRARY)
|
||||||
target_link_libraries(particles "${RT_LIBRARY}")
|
target_link_libraries(particles "${RT_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(WINDOWS_BINARIES boing gears heightmap particles simple splitview wave)
|
set(WINDOWS_BINARIES boing gears heightmap particles simple splitview wave pen)
|
||||||
set(CONSOLE_BINARIES offscreen)
|
set(CONSOLE_BINARIES offscreen)
|
||||||
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
||||||
@ -64,6 +65,7 @@ if (APPLE)
|
|||||||
set_target_properties(simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple")
|
set_target_properties(simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple")
|
||||||
set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView")
|
set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView")
|
||||||
set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
|
set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
|
||||||
|
set_target_properties(pen PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Pen")
|
||||||
|
|
||||||
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
|
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
|
||||||
RESOURCE glfw.icns
|
RESOURCE glfw.icns
|
||||||
|
173
examples/pen.c
Normal file
173
examples/pen.c
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
//========================================================================
|
||||||
|
// Simple GLFW example
|
||||||
|
// Copyright (c) Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would
|
||||||
|
// be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
// be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source
|
||||||
|
// distribution.
|
||||||
|
//
|
||||||
|
//========================================================================
|
||||||
|
//! [code]
|
||||||
|
|
||||||
|
#include <glad/glad.h>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
#include "linmath.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
float x, y;
|
||||||
|
float r, g, b;
|
||||||
|
} vertices[3] =
|
||||||
|
{
|
||||||
|
{ -0.6f, -0.4f, 1.f, 0.f, 0.f },
|
||||||
|
{ 0.6f, -0.4f, 0.f, 1.f, 0.f },
|
||||||
|
{ 0.f, 0.6f, 0.f, 0.f, 1.f }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* vertex_shader_text =
|
||||||
|
"#version 110\n"
|
||||||
|
"uniform mat4 MVP;\n"
|
||||||
|
"attribute vec3 vCol;\n"
|
||||||
|
"attribute vec2 vPos;\n"
|
||||||
|
"varying vec3 color;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n"
|
||||||
|
" color = vCol;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const char* fragment_shader_text =
|
||||||
|
"#version 110\n"
|
||||||
|
"varying vec3 color;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_FragColor = vec4(color, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static void error_callback(int error, const char* description)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error: %s\n", description);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||||
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pen_callback(GLFWwindow* window, double pressure, int x, int y)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "pressure -- %f --\n", pressure);
|
||||||
|
fprintf (stderr, "xPosition -- %d --\n", x);
|
||||||
|
fprintf(stderr, "yPosition -- %d --\n", y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
GLFWwindow* window;
|
||||||
|
GLuint vertex_buffer, vertex_shader, fragment_shader, program;
|
||||||
|
GLint mvp_location, vpos_location, vcol_location;
|
||||||
|
|
||||||
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
|
if (!glfwInit())
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
|
|
||||||
|
window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
glfwSetPenPressureCallback(window, pen_callback);
|
||||||
|
|
||||||
|
glfwMakeContextCurrent(window);
|
||||||
|
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
|
||||||
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
|
// NOTE: OpenGL error checks have been omitted for brevity
|
||||||
|
|
||||||
|
glGenBuffers(1, &vertex_buffer);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
vertex_shader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL);
|
||||||
|
glCompileShader(vertex_shader);
|
||||||
|
|
||||||
|
fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
glShaderSource(fragment_shader, 1, &fragment_shader_text, NULL);
|
||||||
|
glCompileShader(fragment_shader);
|
||||||
|
|
||||||
|
program = glCreateProgram();
|
||||||
|
glAttachShader(program, vertex_shader);
|
||||||
|
glAttachShader(program, fragment_shader);
|
||||||
|
glLinkProgram(program);
|
||||||
|
|
||||||
|
mvp_location = glGetUniformLocation(program, "MVP");
|
||||||
|
vpos_location = glGetAttribLocation(program, "vPos");
|
||||||
|
vcol_location = glGetAttribLocation(program, "vCol");
|
||||||
|
|
||||||
|
glEnableVertexAttribArray(vpos_location);
|
||||||
|
glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE,
|
||||||
|
sizeof(vertices[0]), (void*) 0);
|
||||||
|
glEnableVertexAttribArray(vcol_location);
|
||||||
|
glVertexAttribPointer(vcol_location, 3, GL_FLOAT, GL_FALSE,
|
||||||
|
sizeof(vertices[0]), (void*) (sizeof(float) * 2));
|
||||||
|
|
||||||
|
while (!glfwWindowShouldClose(window))
|
||||||
|
{
|
||||||
|
float ratio;
|
||||||
|
int width, height;
|
||||||
|
mat4x4 m, p, mvp;
|
||||||
|
|
||||||
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
|
ratio = width / (float) height;
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
mat4x4_identity(m);
|
||||||
|
mat4x4_rotate_Z(m, m, (float) glfwGetTime());
|
||||||
|
mat4x4_ortho(p, -ratio, ratio, -1.f, 1.f, 1.f, -1.f);
|
||||||
|
mat4x4_mul(mvp, p, m);
|
||||||
|
|
||||||
|
glUseProgram(program);
|
||||||
|
glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp);
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||||
|
|
||||||
|
glfwSwapBuffers(window);
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
glfwDestroyWindow(window);
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [code]
|
@ -507,6 +507,8 @@ extern "C" {
|
|||||||
|
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
|
/*! @} */
|
||||||
|
|
||||||
/*! @defgroup buttons Mouse buttons
|
/*! @defgroup buttons Mouse buttons
|
||||||
* @brief Mouse button IDs.
|
* @brief Mouse button IDs.
|
||||||
*
|
*
|
||||||
@ -1277,6 +1279,24 @@ typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
|
|||||||
*/
|
*/
|
||||||
typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
|
typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
|
||||||
|
|
||||||
|
/*! @brief The function signature for pen callbacks.
|
||||||
|
*
|
||||||
|
* This is the function signature for pen callback functions.
|
||||||
|
*
|
||||||
|
* @param[in] window The window that received the event.
|
||||||
|
* @param[in] pressure The [pen pressure](@ref pressure) that was pressed or
|
||||||
|
* released.
|
||||||
|
* @param[in] the x (horizontal point) coordinate of the point location of the pen.
|
||||||
|
* @param[in] the y (vertical point) coordinate of the point location of the pen.
|
||||||
|
* *
|
||||||
|
* @sa @ref input_pen_pressure
|
||||||
|
* @sa @ref glfwSetPenPressureCallback
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef void(*GLFWpenpressurefun)(GLFWwindow*, double, int, int);
|
||||||
|
|
||||||
/*! @brief The function signature for cursor position callbacks.
|
/*! @brief The function signature for cursor position callbacks.
|
||||||
*
|
*
|
||||||
* This is the function signature for cursor position callback functions.
|
* This is the function signature for cursor position callback functions.
|
||||||
@ -1349,6 +1369,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
|
|||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
|
typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
|
||||||
|
|
||||||
/*! @brief The function signature for Unicode character callbacks.
|
/*! @brief The function signature for Unicode character callbacks.
|
||||||
@ -3821,7 +3842,32 @@ GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
|
|||||||
*
|
*
|
||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
|
GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button);
|
||||||
|
|
||||||
|
/*! @brief Returns the last reported state of a pen button for the specified
|
||||||
|
* window.
|
||||||
|
*
|
||||||
|
* This function returns the last state reported for the specified pen button
|
||||||
|
* to the specified window. The returned state is one of `GLFW_PRESS` or
|
||||||
|
* `GLFW_RELEASE`.
|
||||||
|
*
|
||||||
|
* @param[in] window The desired window.
|
||||||
|
* @param[in] button The desired [pen button](@ref pen buttons).
|
||||||
|
* @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
|
* GLFW_INVALID_ENUM.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref input_pen_button
|
||||||
|
*
|
||||||
|
* @since Added in version 1.0.
|
||||||
|
* @glfw3 Added window handle parameter.
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI int glfwGetPenPressure(GLFWwindow* handle);
|
||||||
|
|
||||||
/*! @brief Retrieves the position of the cursor relative to the client area of
|
/*! @brief Retrieves the position of the cursor relative to the client area of
|
||||||
* the window.
|
* the window.
|
||||||
@ -4159,6 +4205,27 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods
|
|||||||
* @ingroup input
|
* @ingroup input
|
||||||
*/
|
*/
|
||||||
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
|
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
|
||||||
|
/*! @brief Sets the pen callback.
|
||||||
|
*
|
||||||
|
* This function sets the pen callback of the specified window, which
|
||||||
|
* is called when a pen is pressed or released.
|
||||||
|
**
|
||||||
|
* @param[in] window The window whose callback to set.
|
||||||
|
* @param[in] cbfun The new callback, or `NULL` to remove the currently set
|
||||||
|
* callback.
|
||||||
|
* @return The previously set callback, or `NULL` if no callback was set or the
|
||||||
|
* library had not been [initialized](@ref intro_init).
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref input_pen_pressure
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI GLFWpenpressurefun glfwSetPenPressureCallback(GLFWwindow* window, GLFWpenpressurefun cbfun);
|
||||||
|
|
||||||
/*! @brief Sets the cursor position callback.
|
/*! @brief Sets the cursor position callback.
|
||||||
*
|
*
|
||||||
|
34
src/input.c
34
src/input.c
@ -232,6 +232,16 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
|||||||
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
|
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwInputPenPressure(_GLFWwindow* window, double pressure, int x, int y)
|
||||||
|
{
|
||||||
|
window->penPressure = pressure;
|
||||||
|
window->penXposition = x;
|
||||||
|
window->penYposition = y;
|
||||||
|
|
||||||
|
if (window->callbacks.penPressure)
|
||||||
|
window->callbacks.penPressure((GLFWwindow*)window, pressure, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
||||||
{
|
{
|
||||||
if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
|
if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
|
||||||
@ -513,6 +523,19 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
|
|||||||
return (int) window->mouseButtons[button];
|
return (int) window->mouseButtons[button];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************PEN**************************************************/
|
||||||
|
GLFWAPI int glfwGetPenPressure(GLFWwindow* handle)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*)handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||||
|
|
||||||
|
return window->penPressure;
|
||||||
|
}
|
||||||
|
/**************************PEN***************************************************/
|
||||||
|
|
||||||
GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
@ -708,6 +731,17 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
|||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI GLFWpenpressurefun glfwSetPenPressureCallback(GLFWwindow* handle,
|
||||||
|
GLFWpenpressurefun cbfun)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*)handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.penPressure, cbfun);
|
||||||
|
return cbfun;
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
||||||
GLFWcursorposfun cbfun)
|
GLFWcursorposfun cbfun)
|
||||||
{
|
{
|
||||||
|
@ -417,6 +417,9 @@ struct _GLFWwindow
|
|||||||
|
|
||||||
GLFWbool stickyKeys;
|
GLFWbool stickyKeys;
|
||||||
GLFWbool stickyMouseButtons;
|
GLFWbool stickyMouseButtons;
|
||||||
|
double penPressure;
|
||||||
|
int penXposition;
|
||||||
|
int penYposition;
|
||||||
int cursorMode;
|
int cursorMode;
|
||||||
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
|
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
|
||||||
char keys[GLFW_KEY_LAST + 1];
|
char keys[GLFW_KEY_LAST + 1];
|
||||||
@ -435,6 +438,7 @@ struct _GLFWwindow
|
|||||||
GLFWwindowmaximizefun maximize;
|
GLFWwindowmaximizefun maximize;
|
||||||
GLFWframebuffersizefun fbsize;
|
GLFWframebuffersizefun fbsize;
|
||||||
GLFWmousebuttonfun mouseButton;
|
GLFWmousebuttonfun mouseButton;
|
||||||
|
GLFWpenpressurefun penPressure;
|
||||||
GLFWcursorposfun cursorPos;
|
GLFWcursorposfun cursorPos;
|
||||||
GLFWcursorenterfun cursorEnter;
|
GLFWcursorenterfun cursorEnter;
|
||||||
GLFWscrollfun scroll;
|
GLFWscrollfun scroll;
|
||||||
@ -818,6 +822,15 @@ void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
|
|||||||
*/
|
*/
|
||||||
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
|
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
|
||||||
|
|
||||||
|
/*! @brief Notifies shared code of a pen click event.
|
||||||
|
* @param[in] window The window that received the event.
|
||||||
|
* @param[in] pressure when the pen was pressed.
|
||||||
|
* @param[in] x (horizontal point) coordinate of the point location of the pen.
|
||||||
|
* @param[in] y (vertical point) coordinate of the point location of the pen.
|
||||||
|
* @ingroup event
|
||||||
|
*/
|
||||||
|
void _glfwInputPenPressure(_GLFWwindow* window, double pressure, int x, int y);
|
||||||
|
|
||||||
/*! @brief Notifies shared code of a cursor motion event.
|
/*! @brief Notifies shared code of a cursor motion event.
|
||||||
* @param[in] window The window that received the event.
|
* @param[in] window The window that received the event.
|
||||||
* @param[in] xpos The new x-coordinate of the cursor, relative to the left
|
* @param[in] xpos The new x-coordinate of the cursor, relative to the left
|
||||||
|
@ -49,13 +49,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GLFW requires Windows XP or later
|
// GLFW requires Windows XP or later
|
||||||
#if WINVER < 0x0501
|
#if WINVER < 0x0604
|
||||||
#undef WINVER
|
#undef WINVER
|
||||||
#define WINVER 0x0501
|
#define WINVER 0x0604
|
||||||
#endif
|
#endif
|
||||||
#if _WIN32_WINNT < 0x0501
|
#if _WIN32_WINNT < 0x0604
|
||||||
#undef _WIN32_WINNT
|
#undef _WIN32_WINNT
|
||||||
#define _WIN32_WINNT 0x0501
|
#define _WIN32_WINNT 0x0604
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// GLFW uses DirectInput8 interfaces
|
// GLFW uses DirectInput8 interfaces
|
||||||
@ -104,7 +104,7 @@
|
|||||||
#define _WIN32_WINNT_WINBLUE 0x0602
|
#define _WIN32_WINNT_WINBLUE 0x0602
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if WINVER < 0x0601
|
#if WINVER < 0x0400
|
||||||
typedef struct tagCHANGEFILTERSTRUCT
|
typedef struct tagCHANGEFILTERSTRUCT
|
||||||
{
|
{
|
||||||
DWORD cbSize;
|
DWORD cbSize;
|
||||||
@ -116,7 +116,7 @@ typedef struct tagCHANGEFILTERSTRUCT
|
|||||||
#endif
|
#endif
|
||||||
#endif /*Windows 7*/
|
#endif /*Windows 7*/
|
||||||
|
|
||||||
#if WINVER < 0x0600
|
#if WINVER > 0x0400 //Changed from 0x0600 to 0x0400
|
||||||
#define DWM_BB_ENABLE 0x00000001
|
#define DWM_BB_ENABLE 0x00000001
|
||||||
#define DWM_BB_BLURREGION 0x00000002
|
#define DWM_BB_BLURREGION 0x00000002
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -31,8 +31,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <WinUser.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#define _GLFW_KEY_INVALID -2
|
#define _GLFW_KEY_INVALID -2
|
||||||
|
|
||||||
@ -124,11 +126,11 @@ static HICON createIcon(const GLFWimage* image,
|
|||||||
|
|
||||||
dc = GetDC(NULL);
|
dc = GetDC(NULL);
|
||||||
color = CreateDIBSection(dc,
|
color = CreateDIBSection(dc,
|
||||||
(BITMAPINFO*) &bi,
|
(BITMAPINFO*)&bi,
|
||||||
DIB_RGB_COLORS,
|
DIB_RGB_COLORS,
|
||||||
(void**) &target,
|
(void**)&target,
|
||||||
NULL,
|
NULL,
|
||||||
(DWORD) 0);
|
(DWORD)0);
|
||||||
ReleaseDC(NULL, dc);
|
ReleaseDC(NULL, dc);
|
||||||
|
|
||||||
if (!color)
|
if (!color)
|
||||||
@ -203,7 +205,7 @@ static void getFullWindowSize(DWORD style, DWORD exStyle,
|
|||||||
static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
|
static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
|
||||||
{
|
{
|
||||||
int xoff, yoff;
|
int xoff, yoff;
|
||||||
const float ratio = (float) window->numer / (float) window->denom;
|
const float ratio = (float)window->numer / (float)window->denom;
|
||||||
|
|
||||||
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
|
getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
|
||||||
0, 0, &xoff, &yoff);
|
0, 0, &xoff, &yoff);
|
||||||
@ -212,17 +214,17 @@ static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
|
|||||||
edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT)
|
edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT)
|
||||||
{
|
{
|
||||||
area->bottom = area->top + yoff +
|
area->bottom = area->top + yoff +
|
||||||
(int) ((area->right - area->left - xoff) / ratio);
|
(int)((area->right - area->left - xoff) / ratio);
|
||||||
}
|
}
|
||||||
else if (edge == WMSZ_TOPLEFT || edge == WMSZ_TOPRIGHT)
|
else if (edge == WMSZ_TOPLEFT || edge == WMSZ_TOPRIGHT)
|
||||||
{
|
{
|
||||||
area->top = area->bottom - yoff -
|
area->top = area->bottom - yoff -
|
||||||
(int) ((area->right - area->left - xoff) / ratio);
|
(int)((area->right - area->left - xoff) / ratio);
|
||||||
}
|
}
|
||||||
else if (edge == WMSZ_TOP || edge == WMSZ_BOTTOM)
|
else if (edge == WMSZ_TOP || edge == WMSZ_BOTTOM)
|
||||||
{
|
{
|
||||||
area->right = area->left + xoff +
|
area->right = area->left + xoff +
|
||||||
(int) ((area->bottom - area->top - yoff) * ratio);
|
(int)((area->bottom - area->top - yoff) * ratio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,8 +251,8 @@ static GLFWbool cursorInClientArea(_GLFWwindow* window)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
GetClientRect(window->win32.handle, &area);
|
GetClientRect(window->win32.handle, &area);
|
||||||
ClientToScreen(window->win32.handle, (POINT*) &area.left);
|
ClientToScreen(window->win32.handle, (POINT*)&area.left);
|
||||||
ClientToScreen(window->win32.handle, (POINT*) &area.right);
|
ClientToScreen(window->win32.handle, (POINT*)&area.right);
|
||||||
|
|
||||||
return PtInRect(&area, pos);
|
return PtInRect(&area, pos);
|
||||||
}
|
}
|
||||||
@ -278,8 +280,8 @@ static void updateClipRect(_GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
RECT clipRect;
|
RECT clipRect;
|
||||||
GetClientRect(window->win32.handle, &clipRect);
|
GetClientRect(window->win32.handle, &clipRect);
|
||||||
ClientToScreen(window->win32.handle, (POINT*) &clipRect.left);
|
ClientToScreen(window->win32.handle, (POINT*)&clipRect.left);
|
||||||
ClientToScreen(window->win32.handle, (POINT*) &clipRect.right);
|
ClientToScreen(window->win32.handle, (POINT*)&clipRect.right);
|
||||||
ClipCursor(&clipRect);
|
ClipCursor(&clipRect);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -297,8 +299,8 @@ static void updateWindowStyles(const _GLFWwindow* window)
|
|||||||
|
|
||||||
GetClientRect(window->win32.handle, &rect);
|
GetClientRect(window->win32.handle, &rect);
|
||||||
AdjustWindowRectEx(&rect, style, FALSE, getWindowExStyle(window));
|
AdjustWindowRectEx(&rect, style, FALSE, getWindowExStyle(window));
|
||||||
ClientToScreen(window->win32.handle, (POINT*) &rect.left);
|
ClientToScreen(window->win32.handle, (POINT*)&rect.left);
|
||||||
ClientToScreen(window->win32.handle, (POINT*) &rect.right);
|
ClientToScreen(window->win32.handle, (POINT*)&rect.right);
|
||||||
SetWindowLongW(window->win32.handle, GWL_STYLE, style);
|
SetWindowLongW(window->win32.handle, GWL_STYLE, style);
|
||||||
SetWindowPos(window->win32.handle, HWND_TOP,
|
SetWindowPos(window->win32.handle, HWND_TOP,
|
||||||
rect.left, rect.top,
|
rect.left, rect.top,
|
||||||
@ -316,7 +318,7 @@ static void updateFramebufferTransparency(const _GLFWwindow* window)
|
|||||||
if (_glfwIsCompositionEnabledWin32())
|
if (_glfwIsCompositionEnabledWin32())
|
||||||
{
|
{
|
||||||
HRGN region = CreateRectRgn(0, 0, -1, -1);
|
HRGN region = CreateRectRgn(0, 0, -1, -1);
|
||||||
DWM_BLURBEHIND bb = {0};
|
DWM_BLURBEHIND bb = { 0 };
|
||||||
bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
|
bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
|
||||||
bb.hRgnBlur = region;
|
bb.hRgnBlur = region;
|
||||||
bb.fEnable = TRUE;
|
bb.fEnable = TRUE;
|
||||||
@ -524,13 +526,13 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
{
|
{
|
||||||
if (wParam == DBT_DEVICEARRIVAL)
|
if (wParam == DBT_DEVICEARRIVAL)
|
||||||
{
|
{
|
||||||
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
|
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*)lParam;
|
||||||
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||||
_glfwDetectJoystickConnectionWin32();
|
_glfwDetectJoystickConnectionWin32();
|
||||||
}
|
}
|
||||||
else if (wParam == DBT_DEVICEREMOVECOMPLETE)
|
else if (wParam == DBT_DEVICEREMOVECOMPLETE)
|
||||||
{
|
{
|
||||||
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
|
DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*)lParam;
|
||||||
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||||
_glfwDetectJoystickDisconnectionWin32();
|
_glfwDetectJoystickDisconnectionWin32();
|
||||||
}
|
}
|
||||||
@ -561,6 +563,68 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_POINTERDOWN:
|
||||||
|
case WM_POINTERUPDATE:
|
||||||
|
case WM_POINTERUP:
|
||||||
|
{
|
||||||
|
POINTER_TOUCH_INFO touchInfo;
|
||||||
|
POINTER_PEN_INFO penInfo;
|
||||||
|
POINTER_INFO pointerInfo;
|
||||||
|
UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
|
||||||
|
POINTER_INPUT_TYPE pointerType = PT_POINTER;
|
||||||
|
|
||||||
|
// default to unhandled to enable call to DefWindowProc
|
||||||
|
BOOL fHandled = FALSE;
|
||||||
|
|
||||||
|
// Retrieve common pointer information
|
||||||
|
if (!GetPointerType(pointerId, &pointerType))
|
||||||
|
{
|
||||||
|
// failure, call
|
||||||
|
GetLastError();
|
||||||
|
// set PT_POINTER to fall to default case below
|
||||||
|
pointerType = PT_POINTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (pointerType)
|
||||||
|
{
|
||||||
|
case (PT_PEN):
|
||||||
|
//Retrieve pen information
|
||||||
|
if (!GetPointerPenInfo(pointerId, &penInfo))
|
||||||
|
{
|
||||||
|
// failure, call
|
||||||
|
GetLastError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// success, process penInfo
|
||||||
|
// We change the pen pressure which is given normalized to a range between 0 and 1024
|
||||||
|
// to a normalized value in [0..1]
|
||||||
|
double pressure = (double)penInfo.pressure /(double) 1024;
|
||||||
|
int xPos = GET_X_LPARAM(lParam);
|
||||||
|
int yPos = GET_Y_LPARAM(lParam);
|
||||||
|
if (IS_POINTER_INCONTACT_WPARAM(wParam))
|
||||||
|
{
|
||||||
|
_glfwInputPenPressure(window, pressure, xPos, yPos);
|
||||||
|
}
|
||||||
|
// mark as handled to skip call to DefWindowProc
|
||||||
|
fHandled = TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if (!GetPointerInfo(pointerId, &pointerInfo))
|
||||||
|
{
|
||||||
|
// failure.
|
||||||
|
GetLastError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// success, proceed with pointerInfo.
|
||||||
|
// fHandled = HandleGenericPointerMessage(&pointerInfo);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_CAPTURECHANGED:
|
case WM_CAPTURECHANGED:
|
||||||
{
|
{
|
||||||
// HACK: Disable the cursor once the caption button action has been
|
// HACK: Disable the cursor once the caption button action has been
|
||||||
@ -653,7 +717,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain);
|
_glfwInputChar(window, (unsigned int)wParam, getKeyMods(), plain);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,7 +843,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
case WM_INPUT:
|
case WM_INPUT:
|
||||||
{
|
{
|
||||||
UINT size;
|
UINT size;
|
||||||
HRAWINPUT ri = (HRAWINPUT) lParam;
|
HRAWINPUT ri = (HRAWINPUT)lParam;
|
||||||
RAWINPUT* data;
|
RAWINPUT* data;
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
|
|
||||||
@ -788,7 +852,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
|
GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
|
||||||
if (size > (UINT) _glfw.win32.rawInputSize)
|
if (size > (UINT)_glfw.win32.rawInputSize)
|
||||||
{
|
{
|
||||||
free(_glfw.win32.rawInput);
|
free(_glfw.win32.rawInput);
|
||||||
_glfw.win32.rawInput = calloc(size, 1);
|
_glfw.win32.rawInput = calloc(size, 1);
|
||||||
@ -798,7 +862,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
size = _glfw.win32.rawInputSize;
|
size = _glfw.win32.rawInputSize;
|
||||||
if (GetRawInputData(ri, RID_INPUT,
|
if (GetRawInputData(ri, RID_INPUT,
|
||||||
_glfw.win32.rawInput, &size,
|
_glfw.win32.rawInput, &size,
|
||||||
sizeof(RAWINPUTHEADER)) == (UINT) -1)
|
sizeof(RAWINPUTHEADER)) == (UINT)-1)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Win32: Failed to retrieve raw input data");
|
"Win32: Failed to retrieve raw input data");
|
||||||
@ -835,7 +899,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
{
|
{
|
||||||
_glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);
|
_glfwInputScroll(window, 0.0, (SHORT)HIWORD(wParam) / (double)WHEEL_DELTA);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -843,7 +907,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
{
|
{
|
||||||
// This message is only sent on Windows Vista and later
|
// This message is only sent on Windows Vista and later
|
||||||
// NOTE: The X-axis is inverted for consistency with macOS and X11
|
// NOTE: The X-axis is inverted for consistency with macOS and X11
|
||||||
_glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
|
_glfwInputScroll(window, -((SHORT)HIWORD(wParam) / (double)WHEEL_DELTA), 0.0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,14 +986,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyAspectRatio(window, (int) wParam, (RECT*) lParam);
|
applyAspectRatio(window, (int)wParam, (RECT*)lParam);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_GETMINMAXINFO:
|
case WM_GETMINMAXINFO:
|
||||||
{
|
{
|
||||||
int xoff, yoff;
|
int xoff, yoff;
|
||||||
MINMAXINFO* mmi = (MINMAXINFO*) lParam;
|
MINMAXINFO* mmi = (MINMAXINFO*)lParam;
|
||||||
|
|
||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
break;
|
break;
|
||||||
@ -1023,7 +1087,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputDrop(window, count, (const char**) paths);
|
_glfwInputDrop(window, count, (const char**)paths);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
free(paths[i]);
|
free(paths[i]);
|
||||||
@ -1032,9 +1096,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
DragFinish(drop);
|
DragFinish(drop);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the GLFW window
|
// Creates the GLFW window
|
||||||
@ -1134,7 +1198,7 @@ GLFWbool _glfwRegisterWindowClassWin32(void)
|
|||||||
ZeroMemory(&wc, sizeof(wc));
|
ZeroMemory(&wc, sizeof(wc));
|
||||||
wc.cbSize = sizeof(wc);
|
wc.cbSize = sizeof(wc);
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||||
wc.lpfnWndProc = (WNDPROC) windowProc;
|
wc.lpfnWndProc = (WNDPROC)windowProc;
|
||||||
wc.hInstance = GetModuleHandleW(NULL);
|
wc.hInstance = GetModuleHandleW(NULL);
|
||||||
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
|
||||||
wc.lpszClassName = _GLFW_WNDCLASSNAME;
|
wc.lpszClassName = _GLFW_WNDCLASSNAME;
|
||||||
@ -1288,12 +1352,12 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bigIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICON);
|
bigIcon = (HICON)GetClassLongPtrW(window->win32.handle, GCLP_HICON);
|
||||||
smallIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICONSM);
|
smallIcon = (HICON)GetClassLongPtrW(window->win32.handle, GCLP_HICONSM);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMessage(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM) bigIcon);
|
SendMessage(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM)bigIcon);
|
||||||
SendMessage(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM) smallIcon);
|
SendMessage(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM)smallIcon);
|
||||||
|
|
||||||
if (window->win32.bigIcon)
|
if (window->win32.bigIcon)
|
||||||
DestroyIcon(window->win32.bigIcon);
|
DestroyIcon(window->win32.bigIcon);
|
||||||
@ -1672,7 +1736,7 @@ void _glfwPlatformWaitEvents(void)
|
|||||||
|
|
||||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||||
{
|
{
|
||||||
MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS);
|
MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD)(timeout * 1e3), QS_ALLEVENTS);
|
||||||
|
|
||||||
_glfwPlatformPollEvents();
|
_glfwPlatformPollEvents();
|
||||||
}
|
}
|
||||||
@ -1699,7 +1763,7 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
|||||||
|
|
||||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
||||||
{
|
{
|
||||||
POINT pos = { (int) xpos, (int) ypos };
|
POINT pos = { (int)xpos, (int)ypos };
|
||||||
|
|
||||||
// Store the new position so it can be recognized later
|
// Store the new position so it can be recognized later
|
||||||
window->win32.lastCursorPosX = pos.x;
|
window->win32.lastCursorPosX = pos.x;
|
||||||
@ -1763,7 +1827,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
|||||||
const GLFWimage* image,
|
const GLFWimage* image,
|
||||||
int xhot, int yhot)
|
int xhot, int yhot)
|
||||||
{
|
{
|
||||||
cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE);
|
cursor->win32.handle = (HCURSOR)createIcon(image, xhot, yhot, GLFW_FALSE);
|
||||||
if (!cursor->win32.handle)
|
if (!cursor->win32.handle)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
@ -1787,7 +1851,7 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
|||||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||||
{
|
{
|
||||||
if (cursor->win32.handle)
|
if (cursor->win32.handle)
|
||||||
DestroyIcon((HICON) cursor->win32.handle);
|
DestroyIcon((HICON)cursor->win32.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||||
@ -1946,7 +2010,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
|||||||
|
|
||||||
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
|
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*)handle;
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
return window->win32.handle;
|
return window->win32.handle;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include <WinUser.h>
|
||||||
|
#include <windowsx.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user