Jump to content
  • Advertisement
Sign in to follow this  

Why does this ordering matter? uniformMatrix4fv update issue?

This topic is 2057 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So, I've got a couple of scenes I'm drawing (a custom mouse cursor and my map).  I've got a separate camera object that can be moved around to change what part of the map I'm looking at, I want to keep the camera separate because once I start putting objects on my map, I want them to use the same camera but a (slightly) different GLSL program.  Anyway, the way I'm doing it now is the camera is linked to the scene via a function that sends the MVP matrix from the camera to the scene.  Here's that function:


void MapScene::updateMVP(const glm::mat4 &mvp){
    m_sProg.getUniformLocation("mvp", m_worldUniform);
    glUniformMatrix4fv(m_worldUniform, 1, GL_FALSE, glm::value_ptr(mvp));
    if(GL_NO_ERROR != glGetError())
        std::cerr << "Could not write MVP!\n";


This code works, for the most part.  I initialize my scenes and my camera, but if I don't do it in a specific order, I don't get the right results.  I initially didn't have the "useProgram();" call at the beginning of the updateMVP() function, but now that I do, I don't know why this won't work.  Here's what I write to get the desired results:




If I put initCamera() at the bottom of this, I get just a tiny amount of the map to show (about the size of the mouse).  initCamera() just sets projection, model and view matrices as you normally would and then sends an updateMVP() call to my mapScene.  The crazy thing is, I call the updateMVP function during the render loop too, before I render any of my scenes.  Any ideas?  I can only think it's because of the 2d scene for the mouse, or just that it's a different program, but I don't understand why that would be a problem since the mapScene's shader program is set to be used before I try to do anything (I also don't get any of those cerr messages from a bad MVP write).


Any help would be appreciated.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!