Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. void drawModel(texModel mod, vect2D loc){
  2.  
  3.  
  4.    glUseProgram(texture2D);
  5.  
  6.    GLuint textureID = glGetUniformLocation(texture2D, "Texture");
  7.    glActiveTexture(GL_TEXTURE0);
  8.    glBindTexture(GL_TEXTURE_2D,mod.textureID);
  9.    glUniform1i(textureID,mod.textureID);
  10.  
  11.    glm::mat3 mvp = glm::mat3(1.0f,0.0f,loc.x,
  12.                              0.0f,1.0f,loc.y,
  13.                              0.0f,0.0f,1.0f);
  14.  
  15.    GLuint matrixID = glGetUniformLocation(vector2D, "MVP");
  16.    glUniformMatrix3fv(matrixID, 1, GL_TRUE, &mvp[0][0]);
  17.  
  18.    glEnableVertexAttribArray(0);//enable location 0 for points
  19.    glEnableVertexAttribArray(1);//enable location 1 for uv
  20.  
  21.    glBindBuffer(GL_ARRAY_BUFFER, mod.vertexID);
  22.  
  23.    glVertexAttribPointer( ///bind active buffer(polyID) to location
  24.          0,                  // attribute location
  25.          2,                  // size(of one element)
  26.          GL_FLOAT,           // type
  27.          GL_FALSE,           // normalized?
  28.          0,                  // stride
  29.          (void*)0            // array buffer offset
  30.    );
  31.  
  32.    glBindBuffer(GL_ARRAY_BUFFER, mod.uvID);
  33.  
  34.    glVertexAttribPointer( ///bind active buffer(polyID) to location
  35.          1,                  // attribute location
  36.          2,                  // size(of one element)
  37.          GL_FLOAT,           // type
  38.          GL_FALSE,           // normalized?
  39.          0,                  // stride
  40.          (void*)0            // array buffer offset
  41.    );
  42.  
  43.    glDrawArrays(GL_TRIANGLES,0,mod.numVert);
  44.  
  45.    return;
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement