1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
static void drawFloor(GL myGL , Texture2D texture, float scale ) {
float vertices[] = new float[] { 0,0 , 35,0 , 35,30 , 0,30 , 0,30 , 35,30 , 20,40 ,
0,40 , 0,40 , 135,40 , 135,66 , 0,66 ,
0,66 , 35,66 , 35,99 , 0,99 , 0,99 , 35,99 , 20,110 , 0,110,
0,110 , 178,110 , 178,129 , 0,129 , 36,129 , 178,129 , 178,139 , 36,139,
36,139 , 56,139 , 56,155 , 36,155 , 36,155 , 142,155 , 142,161 , 36,161,
0,161 , 142,161 , 142,183 , 0,183 };
FloatBuffer tmp = BufferUtil.newFloatBuffer( vertices.length );
for( int i = 0 ; i < vertices.length; i++ ) tmp.put( ( vertices[i] * scale ) );
tmp.rewind();
myGL.glEnableClientState( GL.GL_VERTEX_ARRAY );
myGL.glEnableClientState( GL.GL_TEXTURE_COORD_ARRAY );
// Les coordonnées vont 2 par 2
myGL.glVertexPointer( 2 , GL.GL_FLOAT , 0 , tmp );
myGL.glTexCoordPointer( 2 , GL.GL_FLOAT , 0 , tmp );
int SIZE_FLOAT = 4;
int indices[] = new int[ vertices.length];
for(int i = 0 ; i < vertices.length ; i++ ) indices[i] = i;//{ 0,1,2,3,4,5,6 };
IntBuffer indicesBuf = BufferUtil.newIntBuffer( indices.length);
indicesBuf.put( indices );
indicesBuf.rewind();
texture.bind();
myGL.glColor3f(0.86f,0.53f,0.43f);
myGL.glDisable( GL.GL_CULL_FACE );
myGL.glPushMatrix();
myGL.glTranslatef( 0 , 12.5f * scale , 0 );
myGL.glRotatef( -90,1,0,0);
myGL.glDrawElements(GL.GL_QUADS, vertices.length,GL.GL_UNSIGNED_INT, indicesBuf);
myGL.glPopMatrix();
myGL.glEnable( GL.GL_CULL_FACE );
} |
Partager