Код: Выделить всё
#include
#include
#include
glm::mat4 vMat, mMat, mvMat;
Код: Выделить всё
void applyMatrices(GLFWwindow* window){
mvLoc = glGetUniformLocation(renderingProgram, "mv_matrix");
projLoc = glGetUniformLocation(renderingProgram, "proj_matrix");
glfwGetFramebufferSize(window, &width, &height);
aspect = (float)width / (float)height;
projMat = glm::perspective(1.0472f, aspect, 0.1f, 1000.0f);
// glm::mat4(1.0f) : an identity matrix
vMat = glm::translate(glm::mat4(1.0f), glm::vec3(-1.0f, -1.0f, -1.0f));
mMat = glm::translate(glm::mat4(1.0f), glm::vec3(1.0f, 1.0f, 1.0f));
mvMat = vMat * mMat;
glUniformMatrix4fv(mvLoc, 1, GL_FALSE, glm::value_ptr(mvMat));
glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projMat));
}
void display(GLFWwindow* window, double currentTime) {
...
applyMatrices(window);
...
}
int main() {
...
while (!glfwWindowShouldClose(window)) {
display(window, glfwGetTime());
...
}
...
}
Код: Выделить всё
mvMat = vMat * mMat;
Код: Выделить всё
In file included from C:.../Project/dependencies/glm/glm/glm.hpp:120,
from C:\Users\...\Project\src\main.cpp:5:
c:\users\...\project\dependencies\glm\glm\detail\type_mat4x4.inl:
In instantiation of 'constexpr glm::mat glm::operator*(const glm::mat&, const glm::mat&) [with T = float; glm::qualifier Q = (glm::qualifier)0u]':
C:\Users\...\Project\src\main.cpp:150:20: required from here
c:\users\...\project\dependencies\glm\glm\detail\type_mat4x4.inl:642:19: error: uninitialized variable 'Result' in 'constexpr' function
mat Result;
^~~~~~
Я попробовал инициировать все три матрицы **заранее** следующим образом:
Код: Выделить всё
glm::mat4 vMat = glm::mat4(1.0f);
glm::mat4 mMat = glm::mat4(1.0f);
glm::mat4 mvMat = glm::mat4(1.0f);
Подробнее здесь: https://stackoverflow.com/questions/791 ... iplication