# openGL Vertex Projection does not work as expected

I try to render a simple grid using glBegin(GL_LINES). I have a class Camera, which provides values like this:

float farPlane = 100.0f;
float nearPlane= 0.1f;

float screenRatio = 1,42857; //width/height = 1000/700
float frustum = 70.0f;

glm::vec3 position = glm::vec3(3.0f, 3.0f, 3.0f);

glm::vec3 UP = glm::vec3(0.0f, 1.0f, 0.0f);
glm::mat4 view = glm::lookAt(position, position - glm::normalize(position), UP); // makes the lookAt vector always point towards (0, 0, 0)
glm::mat4 projection = glm::perspective(frustum, screenRatio, nearPlane, farPlane);


using the view and projection matrices, i transform every vertex from my Grid model and render it.

glm::mat4 viewProjectionMatrix = Graphic::camera->getViewProjectionMatrix(); // returns Camera::projection * Camera::view
glBegin(GL_LINES);
for (unsigned int i = 0; i < vertexNum; ++i) {
glColor3f(vertexArray[i].normal.x, vertexArray[i].normal.y, vertexArray[i].normal.z); // normal vector is used for color in this case
glm::vec4 translatedPosition(viewProjectionMatrix*gridTransformationMatrix*(glm::vec4(vertexArray[i].position, 1.0f)));
glVertex3f(translatedPosition.x, translatedPosition.y, translatedPosition.z);
}
glEnd();


but this is what i see when i move the camera along the line: (0,0,0) + u*(1,1,1) http://i.imgur.com/PrcDcLs.gifv (you can see the camera cooridnates in the console)

• Since you're handling the matrices manually but still sending the data to the fixed function pipeline, did you call glLoadIdentity() before drawing? – demanze Dec 18 '16 at 18:39
• No i didn´t. It does not change anything if i do. – stimulate Dec 18 '16 at 18:45
• How is viewProjectionMatrix calculated? – user253751 Dec 18 '16 at 21:34
• glm::mat4 Graphic::Camera::getViewProjectionMatrix() { return glm::mat4(projection * view); } – stimulate Dec 18 '16 at 22:17
• can it even be anywhere else in the code? i mean this is all opengl should need right? and i am sure that the grid is generated correctly, because i have used it before (with a geometry shader though, but this should not influence the perspective behavior should it?) – stimulate Dec 18 '16 at 22:27