mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Cleaned up wave example rotation control.
This commit is contained in:
parent
45eebb39fb
commit
3833a70b8d
@ -28,10 +28,8 @@
|
|||||||
GLfloat alpha = 210.f, beta = -70.f;
|
GLfloat alpha = 210.f, beta = -70.f;
|
||||||
GLfloat zoom = 2.f;
|
GLfloat zoom = 2.f;
|
||||||
|
|
||||||
GLboolean locked = GL_FALSE;
|
double cursorX;
|
||||||
|
double cursorY;
|
||||||
int cursorX;
|
|
||||||
int cursorY;
|
|
||||||
|
|
||||||
struct Vertex
|
struct Vertex
|
||||||
{
|
{
|
||||||
@ -321,13 +319,10 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
|
|||||||
if (action == GLFW_PRESS)
|
if (action == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||||
locked = GL_TRUE;
|
glfwGetCursorPos(window, &cursorX, &cursorY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
locked = GL_FALSE;
|
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -337,14 +332,14 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
|
|||||||
|
|
||||||
void cursor_position_callback(GLFWwindow* window, double x, double y)
|
void cursor_position_callback(GLFWwindow* window, double x, double y)
|
||||||
{
|
{
|
||||||
if (locked)
|
if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
|
||||||
{
|
{
|
||||||
alpha += (GLfloat) (x - cursorX) / 10.f;
|
alpha += (GLfloat) (x - cursorX) / 10.f;
|
||||||
beta += (GLfloat) (y - cursorY) / 10.f;
|
beta += (GLfloat) (y - cursorY) / 10.f;
|
||||||
}
|
|
||||||
|
|
||||||
cursorX = (int) x;
|
cursorX = x;
|
||||||
cursorY = (int) y;
|
cursorY = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user