ソース:

pre> import java.awt.Frame; import java.io.IOException; import java.lang.String; import java.lang.System;

import jgl.GL; import jgl.GLCanvas;

public class hello extends GLCanvas {

   public void display () {
	myGL.glClear (GL.GL_COLOR_BUFFER_BIT);
	myGL.glColor3f (1.0f, 0.0f, 0.0f);
	myGL.glBegin (GL.GL_POLYGON);
	myGL.glVertex3f (0.50f,0.75f,0.0f);
	myGL.glVertex3f (0.67f,0.32f,0.0f);
	myGL.glVertex3f (0.50f,0.45f,0.0f);
	myGL.glVertex3f (0.32f,0.32f,0.0f);
	myGL.glEnd ();
	
	myGL.glColor3f (0.0f, 0.0f, 1.0f);
	myGL.glBegin (GL.GL_POLYGON);
	myGL.glVertex3f (0.25f,0.60f,0.0f);
	myGL.glVertex3f (0.75f,0.60f,0.0f);
	myGL.glVertex3f (0.50f,0.45f,0.0f);
	myGL.glEnd ();
	myGL.glFlush ();
   }
   public void keyboard (char key, int x, int y) {
	switch (key) {
	    case 27:
		System.exit(0);
	    default:
		break;
	}
   }
   private void myinit () {
	myGL.glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
	myGL.glMatrixMode (GL.GL_PROJECTION);
	myGL.glLoadIdentity ();
	myGL.glOrtho (0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f);
   }
   public void init () {
	myUT.glutInitWindowSize (500, 500);
	myUT.glutInitWindowPosition (0, 0);
	myUT.glutCreateWindow (this);
	myinit ();
	myUT.glutDisplayFunc ("display");
	myUT.glutKeyboardFunc ("keyboard");
	myUT.glutMainLoop ();
   }
   static public void main (String args[]) throws IOException {
	Frame mainFrame = new Frame ();
	mainFrame.setSize (508, 527);
	hello mainCanvas = new hello ();
	mainCanvas.init();
	mainFrame.add (mainCanvas);
	mainFrame.setVisible (true);
   }

}

/pre>


ソフトウェア基礎演習2/03/最終レポート


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2013-06-20 (木) 14:45:27 (2344d)