利用鍵盤左右鍵使映像左右移動,上下鍵使映像的兩個紋理可見度比例上下調整

來源:互聯網
上載者:User

標籤:映像   左右移動   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 }

 

利用鍵盤左右鍵使映像左右移動,上下鍵使映像的兩個紋理可見度比例上下調整

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.