import Graphics; import Graphics3D; import GUI; // Create graphics resource and 3D renderer int graphicsID = newGraphics( ); int rendererID = newGraphics3DRenderer( 800, 600, graphicsID ); // Create display window int windowID = newWindow( 0, 0, 800, 600, " Hello 3DCG ! " ); int labelID = newImageLabel( 0, 0, 800, 600, graphicsID ); mountComponent( labelID, windowID ); // Enable mouse-based camera control setGraphics3DDefaultEventHandler( rendererID, labelID ); // Set background color to black setGraphics3DColor( rendererID, 0, 0, 0, 255 ); // Generate and place the axis model int axis = newAxisModel( 3.0, 3.0, 3.0 ); mountModel( axis, rendererID ); // Animation loop bool mainLoopState = true; while( mainLoopState ) { sleep( 30 ); // Wait for 30 milliseconds paintGraphics3D( rendererID ); // Render 3DCG paintComponent( labelID ); // Refresh GUI paintComponent( windowID ); // Refresh GUI } exit(); // Exit program after breaking the loop // Called when the window is closed void onWindowClose( int id ) { mainLoopState = false; // Exit the loop }