码迷,mamicode.com
首页 > 移动开发 > 详细

利用键盘左右键使图像左右移动,上下键使图像的两个纹理可见度比例上下调整

时间:2018-09-03 22:31:01      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:图像   左右移动   col   color   控制   val   down   利用   cape   

利用键盘左右键使图像左右移动,

glm::mat4 trans;
        trans = glm::translate(trans, glm::vec3(translation, 0.0f, 0.0f));
        glUniformMatrix4fv(glGetUniformLocation(ourShader.ID, "transform"), 1, GL_FALSE, glm::value_ptr(trans));
 1 void processInput(GLFWwindow* window)
 2 {
 3     if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
 4         glfwSetWindowShouldClose(window, true);
 5 if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS)
 6     {
 7         translation -= 0.001f;
 8         if (translation <= -0.5f)
 9             translation = -0.5f;
10     }
11 
12     if (glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS)
13     {
14         translation += 0.001f;
15         if (translation >= 0.5f)
16             translation = 0.5f;
17     }
18 }

上下键使图像的两个纹理可见度比例上下调整

 1 ourShader.setFloat("mixValue", mixValue);
 2 void processInput(GLFWwindow* window)
 3 {
 4     if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
 5         glfwSetWindowShouldClose(window, true);
 6 
 7     //用键盘上下键控制两个纹理的可见度比例
 8     if (glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS)
 9     {
10         mixValue += 0.001f;
11         if (mixValue >= 1.0f)
12             mixValue = 1.0f;
13     }
14     if (glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS)
15     {
16         mixValue -= 0.001f;
17         if (mixValue <= 0.0f)
18             mixValue = 0.0f;
19     }
20 }

 

利用键盘左右键使图像左右移动,上下键使图像的两个纹理可见度比例上下调整

标签:图像   左右移动   col   color   控制   val   down   利用   cape   

原文地址:https://www.cnblogs.com/hi3254014978/p/9581460.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!