Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 26th, 2012  |  syntax: None  |  size: 1.61 KB  |  views: 60  |  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. //in init
  2.     glGenVertexArraysOES(1, &cubeVertexArray);
  3.     glBindVertexArrayOES(cubeVertexArray);
  4.    
  5.     glGenBuffers(1, &cubeIndexBuffer);
  6.     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cubeIndexBuffer);
  7.     glBufferData(GL_ELEMENT_ARRAY_BUFFER, NUM_IMAGE_OBJECT_INDEX*sizeof(GLushort), cubeIndices, GL_STATIC_DRAW);
  8.    
  9.     glGenBuffers(1, &cubeVertexBuffer);
  10.     glBindBuffer(GL_ARRAY_BUFFER, cubeVertexBuffer);
  11.     glBufferData(GL_ARRAY_BUFFER, NUM_IMAGE_OBJECT_VERTEX * 3 * 6 *sizeof(GLfloat), cubeVertices, GL_STATIC_DRAW);
  12.    
  13.     glGenBuffers(1, &cubeNormalBuffer);
  14.     glBindBuffer(GL_ARRAY_BUFFER, cubeNormalBuffer);
  15.     glBufferData(GL_ARRAY_BUFFER, NUM_IMAGE_OBJECT_VERTEX * 3 * 6 *sizeof(GLfloat), cubeNormals, GL_STATIC_DRAW);
  16.    
  17.     glGenBuffers(1, &cubeTextureBuffer);
  18.     glBindBuffer(GL_ARRAY_BUFFER, cubeTextureBuffer);
  19.     glBufferData(GL_ARRAY_BUFFER, NUM_IMAGE_OBJECT_VERTEX * 2 * 6 *sizeof(GLfloat), cubeTexCoords, GL_STATIC_DRAW);
  20.    
  21.     glBindVertexArrayOES(0);
  22.  
  23. //in render loop
  24.             glBindBuffer(GL_ARRAY_BUFFER, cubeVertexBuffer);
  25.             glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, 0);
  26.             glEnableVertexAttribArray(vertexHandle);
  27.            
  28.             glBindBuffer(GL_ARRAY_BUFFER, cubeNormalBuffer);
  29.             glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, 0);
  30.             glEnableVertexAttribArray(normalHandle);
  31.            
  32.             glBindBuffer(GL_ARRAY_BUFFER, cubeTextureBuffer);
  33.             glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, 0);
  34.             glEnableVertexAttribArray(textureCoordHandle);
clone this paste RAW Paste Data