This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 25th, 2013  |  syntax: C++  |  size: 0.86 KB  |  views: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.   );
clone this paste RAW Paste Data