Solution TD N°1

La méthode Display doit contenir par exemple le code suivant :

   public void display( GLAutoDrawable drawable ) {

      final GL2 gl = drawable.getGL().getGL2();

     

      //drawing top

      gl.glBegin ( GL2.GL_LINES );

      gl.glVertex3f( -0.3f, 0.3f, 0 );

      gl.glVertex3f( 0.3f,0.3f, 0 );

      gl.glEnd();

     

      //drawing bottom

      gl.glBegin( GL2.GL_LINES );

      gl.glVertex3f( -0.3f,-0.3f, 0 );

      gl.glVertex3f( 0.3f,-0.3f, 0 );

      gl.glEnd();

     

      //drawing the right edge

      gl.glBegin( GL2.GL_LINES );

      gl.glVertex3f( -0.3f,0.3f, 0 );

      gl.glVertex3f( -0.3f,-0.3f, 0 );

      gl.glEnd();

     

      //drawing the left edge

      gl.glBegin( GL2.GL_LINES );

      gl.glVertex3f( 0.3f,0.3f,0 );

      gl.glVertex3f( 0.3f,-0.3f,0 );

      gl.glEnd();

     

      //building roof

      //building lft dia

      gl.glBegin( GL2.GL_LINES );

      gl.glVertex3f( 0f,0.6f, 0 );

      gl.glVertex3f( -0.3f,0.3f, 0 );

      gl.glEnd();

     

      //building rt dia

      gl.glBegin( GL2.GL_LINES );

      gl.glVertex3f( 0f,0.6f, 0 );

      gl.glVertex3f( 0.3f,0.3f, 0 );

      gl.glEnd();

     

      //building door

      //drawing top

      gl.glBegin ( GL2.GL_LINES );

      gl.glVertex3f( -0.05f, 0.05f, 0 );

      gl.glVertex3f( 0.05f, 0.05f, 0 );

      gl.glEnd();

     

      //drawing the left edge

      gl.glBegin ( GL2.GL_LINES );

      gl.glVertex3f( -0.05f, 0.05f, 0 );

      gl.glVertex3f( -0.05f, -0.3f, 0 );

      gl.glEnd();

     

      //drawing the right edge

      gl.glBegin ( GL2.GL_LINES );

      gl.glVertex3f( 0.05f, 0.05f, 0 );

      gl.glVertex3f( 0.05f, -0.3f, 0 );

      gl.glEnd();

   }

Le résultat visuel :

Modifié le: Thursday 16 April 2020, 14:38