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
    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)

  2. #2
    Newbie Newbie
    Join Date
    Jan 2013
    Posts
    2
    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
    Join Date
    Oct 2004
    Posts
    4,655
    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?

Similar Threads

  1. Draw a HSV Model in OpenGL
    By QuesterDesura in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-09-2014, 03:55 AM
  2. How to draw Google SketchUp model in my OpenGL app
    By manati in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-11-2009, 12:52 PM
  3. How to draw the cal3D model with VBO?
    By ehsan2004 in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 01-21-2007, 06:42 AM
  4. How to draw line model filled?
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-02-2005, 07:35 AM
  5. Draw mess 3D model
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-09-2003, 04:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean