イントロダクション
ゲームというより、タスク・スケジュール・ロードマップ管理アプリケーションの作成を行います。(Swingの扱い方やオブジェクト指向についてもやります)
使うのはJOGL (Java版のOpenGL)です。土台になるのはSwingです。つまり画面の外側はSwingで内側(コンポーネント)はJOGLで表示します。
Introduction
I will create a Task, Schedule and Roadmap Manager using java. (I will write Swing and Object-orientation).
And Using Swing and JOGL(OpenGL in java). I mean that Swing create Frame of view, JOGL create Content of view.
インストール(how to Install)
こちらのページを参考にやります。( see this page)
インストール方法(How to install)
https://www.tutorialspoint.com/jogl/jogl_installation.htm
ダウンロード(Download)
http://jogamp.org/deployment/jogamp-current/archive/
ダウンロードするファイル一覧(List of download)
- jogamp-all-platforms.7z
- glugen-javadoc.7z
- jogl-javadocs.7z
1〜3のファイルにビルドパスを通す(Set to buildpath in Eclipse)
- gluegenrt.jar
- jogl-all.jar
- gluegen-rt-natives-macXXX.jar
- jogl-all-natives-macXXX
ついでなので、LWJGLのファイルもビルドパスを通します。ファイルのダウンロードはこちら JOGLはこのフレームワークに同梱されています。
1.Eclipseの設定を開きます。
2.Java-BuildPath-UserLibralyを開きます。
3.ライブラリを作成します。(Newボタンを押下)
そして、Editを押下してライブラリにLWJGLのファイルを全部追加します。
※頭に「lwjgl-」がついているファイル全てです。
サンプルコード:ここのページからコピーしたものをちょいと修正(赤文字)
Sample Code : little bit change source from this page (red charactor is changed)
package zenryokuservice.gui.mtm; import javax.swing.JFrame; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.awt.GLCanvas; public class MultiTaskManager implements GLEventListener { public void display(GLAutoDrawable arg0) { // method body } public void dispose(GLAutoDrawable arg0) { //method body } public void init(GLAutoDrawable arg0) { // method body } public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { // method body } public static void main(String[] args) { //getting the capabilities object of GL2 profile final GLProfile profile = GLProfile.get(GLProfile.GL2); GLCapabilities capabilities = new GLCapabilities(profile); // The canvas final GLCanvas glcanvas = new GLCanvas(capabilities); MultiTaskManager b = new MultiTaskManager(); glcanvas.addGLEventListener(b); glcanvas.setSize(400, 400); //creating frame final JFrame frame = new JFrame (" Basic Frame"); //adding canvas to it frame.getContentPane().add(glcanvas); frame.setSize(frame.getContentPane().getPreferredSize()); // It's impotant this is mwaning "window close and stop JVM" frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }//end of main }//end of classimport
実行した時のキャプチャ
次回(Next)
実際に描画をやってみます。実際には2D描画です。
I will create program for draw 2D Line.
[rakuten ids="advancedselect:10000013"]