Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

opengl code

By: a guest on Jan 8th, 2012  |  syntax: OpenGL Shading  |  size: 2.06 KB  |  views: 318  |  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. void drawBody(int textureindex)
  2. {
  3.         GLdouble car[7][2] = { {-1.93,0.3}, {-1.95,0.4}, {-2.2,0.6}, {-2.6,0.6}, {-2.82,0.4}, {-2.8,0.3}, {-2.78,0.0} };
  4.         GLUtesselator *tess = gluNewTess(); // create a tessellator
  5.  
  6.     glEnable(GL_TEXTURE_2D);
  7.     glBindTexture(GL_TEXTURE_2D, textureLib[textureindex]);
  8.  
  9.     glBegin(GL_POLYGON);
  10.  
  11.     glTexCoord2f( 0.0 , 0.0 ); glVertex2f(-1.0 , 0.0 );
  12.     glTexCoord2f(-0.97, 0.0 ); glVertex2f(-1.97, 0.0 );
  13.  
  14.     // Wheel arch
  15.         gluTessBeginContour(tess);
  16.         {
  17.                 gluTessVertex(tess, car[0], car[0]);
  18.         gluTessVertex(tess, car[1], car[1]);
  19.         gluTessVertex(tess, car[2], car[2]);
  20.         gluTessVertex(tess, car[3], car[3]);
  21.                 gluTessVertex(tess, car[4], car[4]);
  22.                 gluTessVertex(tess, car[5], car[5]);
  23.                 gluTessVertex(tess, car[6], car[6]);
  24.         }
  25.     gluTessEndContour(tess);
  26.     // Front of car
  27.     glTexCoord2f(-2.8 , 0.0 ); glVertex2f(-3.8 , 0.0 );
  28.     glTexCoord2f(-2.7 , 0.2 ); glVertex2f(-3.7 , 0.2 );
  29.     glTexCoord2f(-2.8 , 0.4 ); glVertex2f(-3.8 , 0.4 );
  30.     glTexCoord2f(-1.8 , 0.7 ); glVertex2f(-2.8 , 0.7 );
  31.     glTexCoord2f(-1.4 , 0.7 ); glVertex2f(-2.4 , 0.7 );
  32.  
  33.     // Windscreen
  34.     glTexCoord2f( 0.0 , 1.0 ); glVertex2f(-1.0 , 1.0 );
  35.     glTexCoord2f( 1.5 , 1.05); glVertex2f( 0.5 , 1.05);
  36.     glTexCoord2f( 3.3 , 0.8 ); glVertex2f( 2.3 , 0.8 );
  37.  
  38.     // Rear bumper
  39.     glTexCoord2f( 3.15, 0.5 ); glVertex2f( 2.15, 0.5 );
  40.     glTexCoord2f( 3.15, 0.3 ); glVertex2f( 2.15, 0.3 );
  41.     glTexCoord2f( 3.35, 0.3 ); glVertex2f( 2.35, 0.3 );
  42.     glTexCoord2f( 3.0 , 0.0 ); glVertex2f( 2.0 , 0.0 );
  43.     glTexCoord2f( 2.83, 0.0 ); glVertex2f( 1.83, 0.0 );
  44.  
  45.     // Wheel arch
  46.     glTexCoord2f( 2.85, 0.3 ); glVertex2f( 1.85, 0.3 );
  47.     glTexCoord2f( 2.86, 0.4 ); glVertex2f( 1.86, 0.4 );
  48.     glTexCoord2f( 2.6 , 0.6 ); glVertex2f( 1.6 , 0.6 );
  49.     glTexCoord2f( 2.2 , 0.6 ); glVertex2f( 1.2 , 0.6 );
  50.     glTexCoord2f( 2.0 , 0.4 ); glVertex2f( 1.0 , 0.4 );
  51.     glTexCoord2f( 2.0 , 0.3 ); glVertex2f( 1.0 , 0.3 );
  52.     glTexCoord2f( 2.05, 0.0 ); glVertex2f( 1.05, 0.0 );
  53.  
  54.     glEnd();
  55.     glDisable(GL_TEXTURE_2D);
  56. }