Part of the Khronos Group
OpenGL.org

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?

Threaded View

  1. #1
    Newbie Newbie
    Join Date
    Jan 2013
    Posts
    2

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

    I'm doing the tutorials from opengl-tutorial.org
    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:
          glEnableVertexAttribArray(2);
            glBindBuffer(GL_ARRAY_BUFFER, triangle_vertexbuffer);
            glVertexAttribPointer(
               2,
               3,
               GL_FLOAT,
               GL_FALSE,
               0,
               (void*)0
            );
     
            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 07:28 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
  •