Guest User

Untitled

a guest
Apr 19th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.28 KB | None | 0 0
  1. public void draw()
  2.     {
  3.         try
  4.         {
  5.             glEnable(GL_TEXTURE_2D);
  6.             glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  7.  
  8.             Color.white.bind();
  9.             _texture.bind();
  10.  
  11.                 GL11.glBegin(GL11.GL_QUADS);
  12.  
  13.                 float x = _position.getX();
  14.                 float y = -_position.getY();
  15.                 float z = _position.getZ();
  16.                 float s = _size; // s should be radius
  17.  
  18.                 // Front Face
  19.                 GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(x - s, y - s, z + s);  // Bottom Left Of The Texture and Quad
  20.                 GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(x + s, y - s, z + s);  // Bottom Right Of The Texture and Quad
  21.                 GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(x + s, y + s, z + s);  // Top Right Of The Texture and Quad
  22.                 GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(x - s, y + s, z + s);  // Top Left Of The Texture and Quad
  23.                 // Back Face
  24.                 GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(x - s, y - s, z - s);  // Bottom Right Of The Texture and Quad
  25.                 GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(x - s, y + s, z - s);  // Top Right Of The Texture and Quad
  26.                 GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(x + s, y + s, z - s);  // Top Left Of The Texture and Quad
  27.                 GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(x + s, y - s, z - s);  // Bottom Left Of The Texture and Quad
  28.                 // Top Face
  29.                 GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(x - s, y + s, z - s);  // Top Left Of The Texture and Quad
  30.                 GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(x - s, y + s, z + s);  // Bottom Left Of The Texture and Quad
  31.                 GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(x + s, y + s, z + s);  // Bottom Right Of The Texture and Quad
  32.                 GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(x + s, y + s, z - s);  // Top Right Of The Texture and Quad
  33.                 // Bottom Face
  34.                 GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(x - s, y - s, z - s);  // Top Right Of The Texture and Quad
  35.                 GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(x + s, y - s, z - s);  // Top Left Of The Texture and Quad
  36.                 GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(x + s, y - s, z + s);  // Bottom Left Of The Texture and Quad
  37.                 GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(x - s, y - s, z + s);  // Bottom Right Of The Texture and Quad
  38.                 // Right face
  39.                 GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(x + s, y - s, z - s);  // Bottom Right Of The Texture and Quad
  40.                 GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(x + s, y + s, z - s);  // Top Right Of The Texture and Quad
  41.                 GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(x + s, y + s, z + s);  // Top Left Of The Texture and Quad
  42.                 GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(x + s, y - s, z + s);  // Bottom Left Of The Texture and Quad
  43.                 // Left Face
  44.                 GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(x - s, y - s, z - s);  // Bottom Left Of The Texture and Quad
  45.                 GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(x - s, y - s, z + s);  // Bottom Right Of The Texture and Quad
  46.                 GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(x - s, y + s, z + s);  // Top Right Of The Texture and Quad
  47.                 GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(x - s, y + s, z - s);  // Top Left Of The Texture and Quad
  48.                 // Top Face
  49.                 GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(x - s, y + s, z - s);  // Top Left Of The Texture and Quad
  50.                 GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(x - s, y + s, z + s);  // Bottom Left Of The Texture and Quad
  51.                 GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(x + s, y + s, z + s);  // Bottom Right Of The Texture and Quad
  52.                 GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(x + s, y + s, z - s);  // Top Right Of The Texture and Quad
  53.             GL11.glEnd();
  54.  
  55.             GL11.glDisable(GL_TEXTURE_2D);
  56.         }
  57.         catch(Exception e)
  58.         {
  59.             System.out.println("This never happens");
  60.         }
  61.     }
Add Comment
Please, Sign In to add comment