crumbly

02-22-2013, 02:28 PM

Hi,

I'm came over a problem which I can't figure out. I want to move the camera position but nothing happens. I looked over some code examples but I still have no idea whats going wrong. Could somebody give me a hint? =/

Thanks. =)

void MainWindow::display()

{

glUseProgram(program);

//setup model matrix

glm::mat4 model = glm::mat4(1.0f);

model *= glm::mat4(1.0f);

//setup view matrix

glm::mat4 view = glm::mat4(1.0f);

view *= glm::lookAt(glm::vec3(0.0f, 0.0f, 10.0f), //eye

glm::vec3(0.0f, 0.0f, 0.0f), //center

glm::vec3(0.0f, 1.0f, 0.0f)); //up-vector

//setup projection matrix - [fovy, aspect, zNear, zFar]

glm::mat4 projection = glm::mat4(1.0f);

projection *= glm::perspective(45.0f, 1.0f, 0.1f, 20.0f);

//calculate matrix

glm::mat4 vertrexTransform = projection * view * model;

//send our matrices to the shader

glUniformMatrix4fv(glGetUniformLocation(program, uniform_mvp), 1, GL_FALSE, glm::value_ptr(vertrexTransform));

glClearColor(0.0, 0.0, 0.0, 1.0);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glEnableVertexAttribArray(verticesLocation);

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

glDrawArrays(GL_TRIANGLES, 0, 3);

glDisableVertexAttribArray(verticesLocation);

glutSwapBuffers();

}

GLSL:

#version 330

in vec3 vertices;

uniform mat4 ModelViewProjectionMatrix;

void main(void)

{

gl_Position = ModelViewProjectionMatrix * vec4(vertices, 1.0);

}

I'm came over a problem which I can't figure out. I want to move the camera position but nothing happens. I looked over some code examples but I still have no idea whats going wrong. Could somebody give me a hint? =/

Thanks. =)

void MainWindow::display()

{

glUseProgram(program);

//setup model matrix

glm::mat4 model = glm::mat4(1.0f);

model *= glm::mat4(1.0f);

//setup view matrix

glm::mat4 view = glm::mat4(1.0f);

view *= glm::lookAt(glm::vec3(0.0f, 0.0f, 10.0f), //eye

glm::vec3(0.0f, 0.0f, 0.0f), //center

glm::vec3(0.0f, 1.0f, 0.0f)); //up-vector

//setup projection matrix - [fovy, aspect, zNear, zFar]

glm::mat4 projection = glm::mat4(1.0f);

projection *= glm::perspective(45.0f, 1.0f, 0.1f, 20.0f);

//calculate matrix

glm::mat4 vertrexTransform = projection * view * model;

//send our matrices to the shader

glUniformMatrix4fv(glGetUniformLocation(program, uniform_mvp), 1, GL_FALSE, glm::value_ptr(vertrexTransform));

glClearColor(0.0, 0.0, 0.0, 1.0);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glEnableVertexAttribArray(verticesLocation);

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

glDrawArrays(GL_TRIANGLES, 0, 3);

glDisableVertexAttribArray(verticesLocation);

glutSwapBuffers();

}

GLSL:

#version 330

in vec3 vertices;

uniform mat4 ModelViewProjectionMatrix;

void main(void)

{

gl_Position = ModelViewProjectionMatrix * vec4(vertices, 1.0);

}