Advertisement
Guest User

Untitled

a guest
Jan 25th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1.  
  2. glGenBuffers(1, &vbo_triangle_colors);
  3.   glBindBuffer(GL_ARRAY_BUFFER, vbo_triangle_colors);
  4.   glBufferData(GL_ARRAY_BUFFER, sizeof(triangle_colors), triangle_colors, GL_STATIC_DRAW);
  5.  
  6.  
  7.   char* attribute_name = "v_color";
  8.   auto attribute_v_color = glGetAttribLocation(program->getHandle(), attribute_name);
  9.   if (attribute_v_color == -1)
  10.     fprintf(stderr, "Could not bind attribute %s\n", attribute_name);
  11.  
  12.  
  13.  
  14.   glEnableVertexAttribArray(attribute_v_color);
  15.   glBindBuffer(GL_ARRAY_BUFFER, vbo_triangle_colors);
  16.   glVertexAttribPointer(
  17.     attribute_v_color, // attribute
  18.     3,                 // number of elements per vertex, here (r,g,b)
  19.     GL_FLOAT,          // the type of each element
  20.     GL_FALSE,          // take our values as-is
  21.     0,                 // no extra data between each position
  22.     0                  // offset of first element
  23.   );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement