Skip to content

Instantly share code, notes, and snippets.

@kxbmap
Created October 29, 2010 10:15
Show Gist options
  • Save kxbmap/653279 to your computer and use it in GitHub Desktop.
Save kxbmap/653279 to your computer and use it in GitHub Desktop.
NEWT Window
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 NewtSample {
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){}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment