Guest User

Untitled

a guest
Jun 8th, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. // Called by Rocket when it wants to render geometry that it does not wish to optimise.
  2. void ShellRenderInterfaceOpenGL::RenderGeometry(Rocket::Core::Vertex* vertices, int ROCKET_UNUSED(num_vertices), int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation)
  3. {
  4.     glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
  5.     glPushAttrib(GL_ALL_ATTRIB_BITS);
  6.  
  7.     glPushMatrix();
  8.     glTranslatef(translation.x, translation.y, 0);
  9.  
  10.     glVertexPointer(2, GL_FLOAT, sizeof(Rocket::Core::Vertex), &vertices[0].position);
  11.     glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Rocket::Core::Vertex), &vertices[0].colour);
  12.  
  13.     if (!texture)
  14.     {
  15.         glDisable(GL_TEXTURE_2D);
  16.         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  17.     }
  18.     else
  19.     {
  20.         glEnable(GL_TEXTURE_2D);
  21.         glBindTexture(GL_TEXTURE_2D, (GLuint) texture);
  22.         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  23.         glTexCoordPointer(2, GL_FLOAT, sizeof(Rocket::Core::Vertex), &vertices[0].tex_coord);
  24.     }
  25.  
  26.         glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
  27.     glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices);
  28.  
  29.     glPopMatrix();
  30.     glPopAttrib ();
  31.     glPopClientAttrib ();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment