diff --git a/lime/app/Application.hx b/lime/app/Application.hx index 80baaba03..898ddd9d6 100644 --- a/lime/app/Application.hx +++ b/lime/app/Application.hx @@ -10,6 +10,9 @@ import lime.ui.*; import js.Browser; #elseif flash import flash.Lib; +#elseif java +import org.lwjgl.opengl.GL11; +import org.lwjgl.system.glfw.GLFW; #end @@ -87,6 +90,8 @@ class Application extends Module { #if (cpp || neko || nodejs) __handle = lime_application_create (null); + #elseif java + GLFW.glfwInit (); #end KeyEventManager.create (); @@ -220,6 +225,21 @@ class Application extends Module { Lib.current.stage.addEventListener (flash.events.Event.ENTER_FRAME, __triggerFrame); + #elseif java + + if (window != null) { + + while (GLFW.glfwWindowShouldClose (window.handle) == GL11.GL_FALSE) { + + __triggerFrame (); + + GLFW.glfwSwapBuffers (window.handle); + GLFW.glfwPollEvents (); + + } + + } + #end return 0; diff --git a/lime/graphics/Renderer.hx b/lime/graphics/Renderer.hx index b15460a1d..8573358e0 100644 --- a/lime/graphics/Renderer.hx +++ b/lime/graphics/Renderer.hx @@ -12,6 +12,9 @@ import lime.ui.Window; import js.html.webgl.RenderingContext; #elseif flash import flash.Lib; +#elseif java +import org.lwjgl.opengl.GLContext; +import org.lwjgl.system.glfw.GLFW; #end @@ -50,6 +53,11 @@ class Renderer { handle = lime_renderer_create (window.handle); + #elseif java + + GLFW.glfwMakeContextCurrent (window.handle); + GLContext.createFromCurrent (); + #end createContext (); @@ -132,7 +140,7 @@ class Renderer { } - #elseif (cpp || neko || nodejs) + #elseif (cpp || neko || nodejs || java) context = OPENGL (new GLRenderContext ()); diff --git a/lime/ui/Window.hx b/lime/ui/Window.hx index 8816e9ebe..521181c0e 100644 --- a/lime/ui/Window.hx +++ b/lime/ui/Window.hx @@ -14,6 +14,10 @@ import js.html.HtmlElement; import js.Browser; #elseif flash import flash.Lib; +#elseif java +import haxe.Int64; +import org.lwjgl.opengl.GL11; +import org.lwjgl.system.glfw.GLFW; #end @@ -51,6 +55,8 @@ class Window { #end #elseif (cpp || neko || nodejs) public var handle:Dynamic; + #elseif java + public var handle:Int64; #end private var setHeight:Int; @@ -197,6 +203,20 @@ class Window { handle = lime_window_create (application.__handle, width, height, flags, config.title); + #elseif java + + GLFW.glfwWindowHint (GLFW.GLFW_SAMPLES, config.antialiasing); + + if (config.borderless) GLFW.glfwWindowHint (GLFW.GLFW_DECORATED, GL11.GL_TRUE); + if (!config.depthBuffer) GLFW.glfwWindowHint (GLFW.GLFW_DEPTH_BITS, 0); + //if (config.fullscreen) GLFW.glfwWindowHint (GLFW.GLFW_DECORATED, GL11.GL_TRUE); + if (!config.resizable) GLFW.glfwWindowHint (GLFW.GLFW_RESIZABLE, GL11.GL_FALSE); + if (!config.stencilBuffer) GLFW.glfwWindowHint (GLFW.GLFW_STENCIL_BITS, 0); + + handle = GLFW.glfwCreateWindow (width, height, config.title, null, null); + + if (config.vsync) GLFW.glfwSwapInterval (1); + #end MouseEventManager.registerWindow (this); diff --git a/templates/java/lib/disruptor.jar b/templates/java/lib/disruptor.jar new file mode 100755 index 000000000..6f88adacd Binary files /dev/null and b/templates/java/lib/disruptor.jar differ diff --git a/templates/java/lib/lwjgl.jar b/templates/java/lib/lwjgl.jar new file mode 100755 index 000000000..b879edc17 Binary files /dev/null and b/templates/java/lib/lwjgl.jar differ diff --git a/templates/java/ndll/Linux/liblwjgl.so b/templates/java/ndll/Linux/liblwjgl.so new file mode 100755 index 000000000..b7d02f9f9 Binary files /dev/null and b/templates/java/ndll/Linux/liblwjgl.so differ diff --git a/templates/java/ndll/Linux/libopenal.so b/templates/java/ndll/Linux/libopenal.so new file mode 100755 index 000000000..7fd175496 Binary files /dev/null and b/templates/java/ndll/Linux/libopenal.so differ diff --git a/templates/java/ndll/Linux64/liblwjgl.so b/templates/java/ndll/Linux64/liblwjgl.so new file mode 100755 index 000000000..acf05a052 Binary files /dev/null and b/templates/java/ndll/Linux64/liblwjgl.so differ diff --git a/templates/java/ndll/Linux64/libopenal.so b/templates/java/ndll/Linux64/libopenal.so new file mode 100755 index 000000000..7fd175496 Binary files /dev/null and b/templates/java/ndll/Linux64/libopenal.so differ diff --git a/templates/java/ndll/Mac64/liblwjgl.dylib b/templates/java/ndll/Mac64/liblwjgl.dylib new file mode 100755 index 000000000..80951fa46 Binary files /dev/null and b/templates/java/ndll/Mac64/liblwjgl.dylib differ diff --git a/templates/java/ndll/Mac64/libopenal.dylib b/templates/java/ndll/Mac64/libopenal.dylib new file mode 100755 index 000000000..7a5913868 Binary files /dev/null and b/templates/java/ndll/Mac64/libopenal.dylib differ diff --git a/templates/java/ndll/Windows/OpenAL32.dll b/templates/java/ndll/Windows/OpenAL32.dll new file mode 100755 index 000000000..68cd4ee45 Binary files /dev/null and b/templates/java/ndll/Windows/OpenAL32.dll differ diff --git a/templates/java/ndll/Windows/lwjgl.dll b/templates/java/ndll/Windows/lwjgl.dll new file mode 100755 index 000000000..4615b4570 Binary files /dev/null and b/templates/java/ndll/Windows/lwjgl.dll differ diff --git a/tools/helpers/JavaHelper.hx b/tools/helpers/JavaHelper.hx new file mode 100644 index 000000000..3e894a8fe --- /dev/null +++ b/tools/helpers/JavaHelper.hx @@ -0,0 +1,17 @@ +package helpers; + + +import sys.io.File; + + +class JavaHelper { + + + public static function copyLibraries (templatePaths:Array , platformName:String, targetPath:String) { + + FileHelper.recursiveCopyTemplate (templatePaths, "java/ndll/" + platformName, targetPath); + + } + + +} diff --git a/tools/platforms/MacPlatform.hx b/tools/platforms/MacPlatform.hx index 17e1994ef..981e24968 100644 --- a/tools/platforms/MacPlatform.hx +++ b/tools/platforms/MacPlatform.hx @@ -7,6 +7,7 @@ import helpers.AssetHelper; import helpers.CPPHelper; import helpers.FileHelper; import helpers.IconHelper; +import helpers.JavaHelper; import helpers.NekoHelper; import helpers.NodeJSHelper; import helpers.PathHelper; @@ -14,6 +15,7 @@ import helpers.PlatformHelper; import helpers.ProcessHelper; import project.AssetType; import project.Architecture; +import project.Haxelib; import project.HXProject; import project.Platform; import project.PlatformTarget; @@ -110,10 +112,13 @@ class MacPlatform extends PlatformTarget { } else if (targetType == "java") { - ProcessHelper.runCommand ("", "haxe", [ hxml ]); + var libPath = PathHelper.combine (PathHelper.getHaxelib (new Haxelib ("lime")), "templates/java/lib/"); + + ProcessHelper.runCommand ("", "haxe", [ hxml, "-java-lib", libPath + "disruptor.jar", "-java-lib", libPath + "lwjgl.jar" ]); ProcessHelper.runCommand (targetDirectory + "/obj", "haxelib", [ "run", "hxjava", "hxjava_build.txt", "--haxe-version", "3103" ]); + FileHelper.recursiveCopy (targetDirectory + "/obj/lib", PathHelper.combine (executableDirectory, "lib")); FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".jar", PathHelper.combine (executableDirectory, project.app.file + ".jar")); - NekoHelper.copyLibraries (project.templatePaths, "Mac" + (is64 ? "64" : ""), executableDirectory); + JavaHelper.copyLibraries (project.templatePaths, "Mac" + (is64 ? "64" : ""), executableDirectory); } else if (targetType == "nodejs") {