Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: How do I draw more then 1 model using MPV and OpenGL 3.3?

  1. #1
    Newbie Newbie
    Join Date
    Jan 2013

    How do I draw more then 1 model using MPV and OpenGL 3.3?

    I'm doing the tutorials from
    On tutorial 4 it asked to do 2 models to show at the sime time on window. It said that just need to do the same thing that is done with the cube.
    So I've maintain the shadders and the "MP" from "MPV" and did another triangle, just by typing:

    Code cpp:
    mat4 triangle_Model = mat4(1.0f);
        mat4 triangle_MPV = Projection * View * triangle_Model;
        GLuint triangle_MatrixID = glGetUniformLocation(programID, "MPV");
        glUniformMatrix4fv(triangle_MatrixID, 1, GL_FALSE, &triangle_MPV[0][0]);
    //ProgamID is the same of the cube. I've tried to separate; but, still, doesn't worked
    static const GLfloat triangle_buffer_data[] = {
            -2.0f, -3.0f, 1.0f,
             2.0f, -3.0f, 1.0f,
             0.0f,  3.0f,-1.0f
        GLuint triangle_vertexbuffer;
        glGenBuffers(1, &triangle_vertexbuffer);
        glBindBuffer(GL_ARRAY_BUFFER, triangle_vertexbuffer);
        glBufferData(GL_ARRAY_BUFFER, sizeof(triangle_buffer_data), triangle_buffer_data, GL_STATIC_DRAW);

    and at the main loop:

    Code cpp:
            glBindBuffer(GL_ARRAY_BUFFER, triangle_vertexbuffer);
            glUniformMatrix4fv(triangle_MatrixID, 1 ,GL_FALSE, &triangle_MPV[0][0]);

    But the triangle doesn't appear. I've disabled the cube to see if it works, changed camera and everything.
    Can anyone help-me, please?

    PS1: same shadders as the tutorial ones.
    PS2: Sorry for my english, I'm from Brazil and speaks portuguese (we do not speak "brazilian" or spanish as some people from outside that I spook thought xD)
    Last edited by Dark Photon; 01-20-2013 at 06:28 PM.

  2. #2
    Newbie Newbie
    Join Date
    Jan 2013
    by the way, full code is here:
    ht tp:// pastebin . com/e6zWrnKM
    Sorry, the forum won't allow me to post a full link.

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Please use [code]...[/code] or [highlight=cpp]...[/highlight] tags around source code. Preserves the indentation and makes it much more readable.

    How do I draw more then 1 model using MPV and OpenGL 3.3?
    If you're using the same shader and you've already populated the MVP uniform, you can just re-launch it. Repopulating it with the same value won't hurt, but will just waste cycles.

    It worked with one model, right?
    Last edited by Dark Photon; 01-20-2013 at 06:34 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts