public
Created

LWJGL test

  • Download Gist
Frangipani.scala
Scala
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
object Frangipani {
// Add path to native libraries
val jarName = getClass.getProtectionDomain.getCodeSource.getLocation.getPath
val nativeDir = new File(new File(jarName).getParent, "natives").getPath
System.setProperty("org.lwjgl.librarypath", nativeDir)
 
def start() {
// Initialize the display
try {
Display.setDisplayMode(new DisplayMode(800, 600))
Display.create()
} catch {
case e: LWJGLException => {
e.printStackTrace()
System.exit(1)
}
}
 
// Call the loop
try {
loop()
} finally {
Display.destroy()
}
}
 
def loop() {
while(!Display.isCloseRequested) {
while(Keyboard.next()) {
println("Key pressed!") // Never reaches this part!
}
 
// Blank the screen
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT)
 
Display.update()
Display.sync(60)
}
}
 
def main(args: Array[String]) {
start()
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.