ソース:

pre> import java.applet.Applet; import java.awt.Graphics;

import jgl.GL; import jgl.GLAUX;

public class simple_o extends Applet { GL myGL = new GL (); GLAUX myAUX = new GLAUX (myGL);

	public void update (Graphics g) {
	    // since using DOUBLEBUFFER mode, clear screen is not needed
	    // skip the clear screen command....
	    paint (g);
	}
	
	public void paint (Graphics g) {
	    // since JavaGL only offers DOUBLEBUFFER mode, call
	    // glXSwapBuffers at every "paint" time
	    myGL.glXSwapBuffers (g, this);
	}
	
	// "init" in Java is like "main" in C program
	public void init () {
	    // auxInitDisplayMode has not supported
	    myAUX.auxInitPosition (0, 0, 500, 500);
	    myAUX.auxInitWindow (this);
	
	    myGL.glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
	    myGL.glClear (GL.GL_COLOR_BUFFER_BIT);
	    myGL.glMatrixMode (GL.GL_PROJECTION);
	    myGL.glLoadIdentity ();
	    myGL.glOrtho (-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
	
	    myGL.glBegin (GL.GL_POLYGON);
	    myGL.glColor3f (0.5f, 1.0f, 0.5f);
	        myGL.glVertex2f (-0.5f, -0.5f);
	        myGL.glVertex2f (-0.1f,  0.5f);
	        myGL.glVertex2f (0.5f,  -0.5f);
	    myGL.glEnd ();
	
	    myGL.glBegin (GL.GL_POLYGON);
	    myGL.glColor3f (0.0f, 1.0f, 0.0f);
	    myGL.glVertex2f (0.6f, -0.1f);
	    myGL.glVertex2f (-0.1f,  0.5f);
	    myGL.glVertex2f (0.5f,  -0.5f);
	    myGL.glEnd ();
	
	    myGL.glFlush ();
	}
	

}

/pre>


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


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