Skip to content

Instantly share code, notes, and snippets.

@chrisyco
Created September 10, 2011 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisyco/1208003 to your computer and use it in GitHub Desktop.
Save chrisyco/1208003 to your computer and use it in GitHub Desktop.
LWJGL test
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()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment