My ruby code is as follows

include Java

Dir[File.expand_path "#{File.dirname(__FILE__)}/../libs/\*.jar"].each { |x| require x; puts "go"}

module LibGDX
        include_package "com.badlogic.gdx"
        include_package "com.badlogic.gdx.backends.lwjgl"
        include_package "com.badlogic.gdx.graphics"

class Game
        include LibGDX::ApplicationListener

        @LOG = Game.java.simple_name

        def create
                LibGDX::Gdx.app.log(@LOG, "Is a thing")

        def resize width, height
                LibGDX::Gdx.app.log(@LOG, "Resizing game to #{width} by #{height}")

        def render
                LibGDX::Gdx.gl.glClearColor(0, 0, 0, 0)

        def pause
                LibGDX::Gdx.app.log(@LOG, "Pausing")

        def resume
                LibGDX::Gdx.app.log(@LOG, "resuming")

    def dispose
            LibGDX::Gdx.app.log(@LOG, "disposing")

listener = Game.new

width = 800
height = 600

useOpenglES2 = false;

game = LibGDX::LwjglApplication.new(listener, "Game", width, height, useOpenglES2)

If I run this through jruby it works just fine but if I package it up with warble it skips all of the Game class's initialization and tells "AL lib: alc_cleanup: 1 device not closed" and stops.

Does anyone know the proper way to build a libGDX project with jruby and warble?

P.S. I know this seems like a very localized problem but I'm asking how to use jruby and libgdx with warble using my program as an example so... I think it's more broad then it seems... still getting used to stackexchange.


I found out that libGDX runs on a separate thread than the one warble uses to call the jruby interpreter. All I needed to do was add an infinite while loop to the main Ruby file and it works. Even closes at the right time somehow.

If anyone knows a better way to keep a thread open until all threads are done please let me know.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.