NEWTでウィンドウ作成

JOGLのdemosやチュートリアルから引っ張ってきてScalaの書式にしただけだけども。

import javax.media.opengl.{ GLAutoDrawable, GLProfile, GLCapabilities, GLEventListener }
import com.jogamp.newt.event.{ WindowAdapter, WindowEvent }
import com.jogamp.newt.opengl.GLWindow
import com.jogamp.opengl.util.FPSAnimator

object NewtTest {
  def main(args : Array[String]){
    GLProfile.initSingleton()
    run()
  }

  def run() {
    try {
      val glp = GLProfile.getDefault
      val caps = new GLCapabilities(glp)

      val window = GLWindow.create(caps)
      window.setUndecorated(false)
      window.setSize(800, 600)

      val animator = new FPSAnimator(window, 60)
      window.addWindowListener(new WindowAdapter(){
        override def windowDestroyNotify(e : WindowEvent){
          animator.stop()
          System.exit(0)
        }
      })
      window.addGLEventListener(listener)

      window.setVisible(true)
      window.setTitle("NEWT Window Test")
      animator.start()
    } catch {
      case e =>
        e.printStackTrace()
        System.exit(1)
    }
  }

  object listener extends GLEventListener {
    def init(drawable : GLAutoDrawable){}
    def dispose(drawable : GLAutoDrawable){}
    def display(drawable : GLAutoDrawable){}
    def reshape(drawable : GLAutoDrawable, x : Int, y : Int, w : Int, h : Int){}
  }
}

setVisibleやった後じゃないとsetTitleが効かないのは何故だろう?

次はActorの練習にAnimatorを自前で書いてみたいな。