I can't get the camera transforms to work with glm...
Probably just a silly thing I missed but I just can't find it... help?
glViewport(0, 0, m_width, m_height);
glClearColor(0.5f, 0.5f, 1.0f, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float fovy = 60.0f;
float aspect = m_width / float(m_height);
float znear = 0.1f;
float zfar = 100.0f;
glm::mat4 Mp = glm::perspective(fovy, aspect, znear, zfar);
glMultMatrixf(&Mp[0][0]);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glm::vec3 eye = glm::vec3(5, 5, 5);
glm::vec3 lookat = glm::vec3(0, 0, 0);
glm::vec3 up = glm::vec3(0, 1, 0);
glm::mat4 M = glm::lookAt(eye, lookat, up);
glMultMatrixf(&M[0][0]);
glBegin(GL_TRIANGLES);
glColor3f(1, 1, 1);
glVertex3f(-10,-10,-10);
glVertex3f(10,-10,-10);
glVertex3f(10, 10,-10);
glColor3f(1, 1, 0);
glVertex3f(-10,-10,-10);
glVertex3f(10, 10,-10);
glVertex3f(-10, 10,-10);
glEnd();
This gives the following output:
m_width = 1024, m_heigth = 768
question from:
https://stackoverflow.com/questions/65874625/example-with-camera-glm-opengl-immediate-mode 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…