mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-06 06:36:29 +08:00
Improve UI for one-button mouse.
This commit is contained in:
parent
7aa09d1c1d
commit
9e2f479270
@ -167,17 +167,22 @@ void keyboardFunc(GLFWwindow *window, int key, int scancode, int action,
|
|||||||
(void)mods;
|
(void)mods;
|
||||||
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
|
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
|
||||||
// Close window
|
// Close window
|
||||||
if (key == GLFW_KEY_Q || key == GLFW_KEY_ESCAPE)
|
if (key == GLFW_KEY_Q || key == GLFW_KEY_ESCAPE) {
|
||||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clickFunc(GLFWwindow *window, int button, int action, int mods) {
|
void clickFunc(GLFWwindow *window, int button, int action, int mods) {
|
||||||
(void)mods;
|
|
||||||
double x, y;
|
double x, y;
|
||||||
glfwGetCursorPos(window, &x, &y);
|
glfwGetCursorPos(window, &x, &y);
|
||||||
|
|
||||||
if (button == GLFW_MOUSE_BUTTON_LEFT) {
|
bool shiftPressed = (mods & GLFW_MOD_SHIFT);
|
||||||
|
bool ctrlPressed = (mods & GLFW_MOD_CONTROL);
|
||||||
|
|
||||||
|
if ((button == GLFW_MOUSE_BUTTON_LEFT) && (!shiftPressed) && (!ctrlPressed)) {
|
||||||
mouseLeftPressed = true;
|
mouseLeftPressed = true;
|
||||||
if (action == GLFW_PRESS) {
|
if (action == GLFW_PRESS) {
|
||||||
int id = -1;
|
int id = -1;
|
||||||
@ -189,14 +194,14 @@ void clickFunc(GLFWwindow *window, int button, int action, int mods) {
|
|||||||
mouseLeftPressed = false;
|
mouseLeftPressed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (button == GLFW_MOUSE_BUTTON_RIGHT) {
|
if ((button == GLFW_MOUSE_BUTTON_RIGHT) || ((button == GLFW_MOUSE_BUTTON_LEFT) && ctrlPressed)) {
|
||||||
if (action == GLFW_PRESS) {
|
if (action == GLFW_PRESS) {
|
||||||
mouseRightPressed = true;
|
mouseRightPressed = true;
|
||||||
} else if (action == GLFW_RELEASE) {
|
} else if (action == GLFW_RELEASE) {
|
||||||
mouseRightPressed = false;
|
mouseRightPressed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (button == GLFW_MOUSE_BUTTON_MIDDLE) {
|
if ((button == GLFW_MOUSE_BUTTON_MIDDLE) || ((button == GLFW_MOUSE_BUTTON_LEFT) && shiftPressed)) {
|
||||||
if (action == GLFW_PRESS) {
|
if (action == GLFW_PRESS) {
|
||||||
mouseMiddlePressed = true;
|
mouseMiddlePressed = true;
|
||||||
} else if (action == GLFW_RELEASE) {
|
} else if (action == GLFW_RELEASE) {
|
||||||
@ -368,6 +373,7 @@ static void SetupCurvesState(tinygltf::Scene &scene, GLuint progId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("has_curves = %d\n", has_curves);
|
||||||
|
|
||||||
if (!has_curves) {
|
if (!has_curves) {
|
||||||
continue;
|
continue;
|
||||||
@ -503,6 +509,7 @@ void DrawMesh(tinygltf::Scene &scene, const tinygltf::Mesh &mesh) {
|
|||||||
glBindTexture(GL_TEXTURE_2D, gMeshState[mesh.name].diffuseTex[i]);
|
glBindTexture(GL_TEXTURE_2D, gMeshState[mesh.name].diffuseTex[i]);
|
||||||
|
|
||||||
for (; it != itEnd; it++) {
|
for (; it != itEnd; it++) {
|
||||||
|
assert(scene.accessors.find(it->second) != scene.accessors.end());
|
||||||
const tinygltf::Accessor &accessor = scene.accessors[it->second];
|
const tinygltf::Accessor &accessor = scene.accessors[it->second];
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, gBufferState[accessor.bufferView].vb);
|
glBindBuffer(GL_ARRAY_BUFFER, gBufferState[accessor.bufferView].vb);
|
||||||
CheckErrors("bind buffer");
|
CheckErrors("bind buffer");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user