[DEV] test...

This commit is contained in:
Edouard DUPIN 2020-05-21 23:38:10 +02:00
parent a9899d82e7
commit 49aae1461e
20 changed files with 2751 additions and 837 deletions

View File

@ -11,795 +11,65 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-assimp-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-assimp-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-assimp-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-assimp.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-bgfx-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-bgfx-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-bgfx-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-bgfx.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-bullet-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-bullet-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-bullet-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-bullet.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-cuda-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-cuda-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-cuda.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-driftfx-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-driftfx-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-driftfx-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-driftfx.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-egl-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-egl-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-egl.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-glfw-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-glfw-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-glfw-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-glfw.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-jawt-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-jawt-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-jawt.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-jemalloc-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-jemalloc-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-jemalloc-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-jemalloc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-libdivide-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-libdivide-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-libdivide-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-libdivide.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-llvm-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-llvm-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-llvm-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-llvm.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-lmdb-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-lmdb-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-lmdb-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-lmdb.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-lz4-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-lz4-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-lz4-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-lz4.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-meow-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-meow-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-meow-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-meow.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-meshoptimizer-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-meshoptimizer-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-meshoptimizer-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-meshoptimizer.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nanovg-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nanovg-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nanovg-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nanovg.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nfd-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nfd-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nfd-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nfd.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nuklear-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nuklear-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nuklear-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-nuklear.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-odbc-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-odbc-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-odbc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-openal-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-openal-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-openal-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-openal.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opencl-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opencl-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opencl.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opengl-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opengl-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opengl-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opengl.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opengles-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opengles-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opengles-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opengles.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-openvr-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-openvr-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-openvr-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-openvr.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opus-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opus-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opus-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-opus.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-par-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-par-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-par-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-par.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-remotery-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-remotery-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-remotery-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-remotery.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-rpmalloc-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-rpmalloc-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-rpmalloc-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-rpmalloc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-shaderc-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-shaderc-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-shaderc-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-shaderc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-spvc-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-spvc-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-spvc-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-spvc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-sse-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-sse-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-sse-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-sse.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-stb-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-stb-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-stb-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-stb.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tinyexr-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tinyexr-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tinyexr-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tinyexr.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tinyfd-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tinyfd-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tinyfd-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tinyfd.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tootle-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tootle-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tootle-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-tootle.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-vma-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-vma-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-vma-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-vma.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-vulkan-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-vulkan-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-vulkan.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-xxhash-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-xxhash-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-xxhash-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-xxhash.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-yoga-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-yoga-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-yoga-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-yoga.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-zstd-javadoc.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-zstd-natives-linux.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-zstd-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-zstd.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl3-awt-0.1.7.jar" sourcepath="lib/lwjgl3-awt-0.1.7-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl/lwjgl-jawt.jar" sourcepath="lib/lwjgl/lwjgl-jawt-sources.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>

BIN
lib/jogamp-fat.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/lwjgl3-awt-0.1.7.jar Normal file

Binary file not shown.

View File

@ -61,7 +61,7 @@ public class Player extends Entity {
} else if (DisplayManager.isKeyDown('s')) {
this.currentSpeed = -RUN_SPEED;
} else {
this.currentSpeed = 0;
this.currentSpeed = 0;
}
if (DisplayManager.isKeyDown('d') && DisplayManager.isKeyDown('a')) {
this.currentTurnSpeed = 0;
@ -75,22 +75,6 @@ public class Player extends Entity {
if (DisplayManager.isKeyDown(' ')) {
this.jump();
}
//System.out.println("position = " + super.getPosition());
/*
if (DisplayManager.isKeyDown('d')) {
position.x += 0.8f;
}
if (DisplayManager.isKeyDown('a')) {
position.x -= 0.8f;
}
if (DisplayManager.isKeyDown('q')) {
position.y += 0.8f;
}
if (DisplayManager.isKeyDown('z')) {
position.y -= 0.8f;
}
*/
}
}

View File

@ -11,15 +11,20 @@ open module Tutorial {
requires transitive org.lwjgl.glfw.natives;
requires transitive org.lwjgl.assimp;
requires transitive org.lwjgl.assimp.natives;
requires transitive org.lwjgl.openal;
requires transitive org.lwjgl.openal.natives;
// requires transitive org.lwjgl.openal;
// requires transitive org.lwjgl.openal.natives;
requires transitive org.lwjgl.stb;
requires transitive org.lwjgl.stb.natives;
requires transitive org.lwjgl.jawt;
//requires transitive org.lwjgl.opengl.awt;
requires transitive org.lwjgl.opengl;
requires transitive org.lwjgl.opengl.natives;
requires org.lwjgl.openvr;
//requires org.lwjgl.openvr;
//requires transitive jogamp.fat;
requires java.desktop;
requires pngdecoder;
requires lwjgl3.awt;
}

View File

@ -1,7 +1,9 @@
package org.atriaSoft.gale;
import org.atriaSoft.gale.context.Context;
import org.atriaSoft.gale.context.LWJGL.ContextLWJGL;
//import org.atriaSoft.gale.context.JOGL.ContextJOGL;
import org.atriaSoft.gale.context.LWJG_AWT.ContextLWJGL_AWT;
//import org.atriaSoft.gale.context.LWJGL.ContextLWJGL;
public class Gale {
/**
@ -21,8 +23,9 @@ public class Gale {
Context context = null;
String request = "";
context = ContextLWJGL.create(application, arg);
//context = ContextLWJGL.create(application, arg);
//context = ContextJOGL.create(application, arg);
context = ContextLWJGL_AWT.create(application, arg);
if (context == null) {
Log.error("Can not allocate the interface of the GUI ...");
return -1;

View File

@ -0,0 +1,881 @@
package org.atriaSoft.gale.backend3d;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
//import org.lwjgl.BufferUtils;
//import org.lwjgl.opengl.GL11;
//import org.lwjgl.opengl.GL13;
//import org.lwjgl.opengl.GL15;
//import org.lwjgl.opengl.GL20;
//import org.lwjgl.opengl.GL30;
import org.atriaSoft.etk.math.Matrix4f;
import org.atriaSoft.etk.math.Vector2f;
import org.atriaSoft.etk.math.Vector2i;
import org.atriaSoft.etk.math.Vector3f;
import org.atriaSoft.etk.math.Vector3i;
import org.atriaSoft.etk.Color;
import org.atriaSoft.gale.Log;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GL3;
public class OpenGL_jogl {
static final boolean DEBUG = false; // TODO: externalize this ...
static final boolean CHECKERROROPENGL = false; // TODO: externalize this ...
static final boolean DIRECT_MODE = false; // TODO: externalize this ...
static GL glInterface = null;
public static void checkGlError(String op) {
// int localLine = Thread.currentThread().getStackTrace()[2].getLineNumber();
// if (CHECKERROROPENGL == true) {
// boolean hasError = false;
// for (int error = GL.glGetError(); error!=null; error = GL.glGetError()) {
// Log.error("after " + op + "():" + localLine + " glError(" + error + ")");
// hasError = true;
// }
// if (hasError == true) {
// Log.critical("plop");
// }
// for (GLint error = glGetError(); error; error = glGetError()) {
// Log.error("after " + op + "() glError (" + error + ")");
// }
// }
}
private static List<Matrix4f> matrixList = new ArrayList<Matrix4f>();
private static Matrix4f matrixCamera = new Matrix4f();
private static int programId = 0;
// We map all the flag, but not all is supported by all platform...
public static enum Flag {
flag_blend, //!< If enabled, blend the computed fragment color values with the values in the color buffers.
//See glBlendFunc.
flag_clipDistanceI, //!< If enabled, clip geometry against user-defined half space i.
flag_colorLogigOP, //!< If enabled, apply the currently selected logical operation to the computed fragment color and color buffer values. See glLogicOp.
flag_cullFace, //!< If enabled, cull polygons based on their winding in window coordinates. See glCullFace.
flag_debugOutput, //!< If enabled, debug messages are produced by a debug context. When disabled, the debug message log is silenced. Note that in a non-debug context, very few, if any messages might be produced, even when GLDEBUGOUTPUT is enabled.
flag_debugOutputSynchronous, //!< If enabled, debug messages are produced synchronously by a debug context. If disabled, debug messages may be produced asynchronously. In particular, they may be delayed relative to the execution of GL commands, and the debug callback function may be called from a thread other than that in which the commands are executed. See glDebugMessageCallback.
flag_depthClamp, //!< If enabled, the -wcdzcdwc plane equation is ignored by view volume clipping (effectively, there is no near or far plane clipping). See glDepthRange.
flag_depthTest, //!< If enabled, do depth comparisons and update the depth buffer. Note that even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. See glDepthFunc and glDepthRange.
flag_dither, //!< If enabled, dither color components or indices before they are written to the color buffer.
flag_framebufferSRGB, //!< If enabled and the value of GLFRAMEBUFFERATTACHMENTCOLORENCODING for the framebuffer attachment corresponding to the destination buffer is GLSRGB, the R, G, and B destination color values (after conversion from fixed-point to floating-point) are considered to be encoded for the sRGB color space and hence are linearized prior to their use in blending.
flag_lineSmooth, //!< If enabled, draw lines with correct filtering. Otherwise, draw aliased lines. See glLineWidth.
flag_multisample, //!< If enabled, use multiple fragment samples in computing the final color of a pixel. See glSampleCoverage.
flag_polygonOffsetFill, //!< If enabled, and if the polygon is rendered in GLFILL mode, an offset is added to depth values of a polygon's fragments before the depth comparison is performed. See glPolygonOffset.
flag_polygonOffsetLine, //!< If enabled, and if the polygon is rendered in GLLINE mode, an offset is added to depth values of a polygon's fragments before the depth comparison is performed. See glPolygonOffset.
flag_polygonOffsetPoint, //!< If enabled, an offset is added to depth values of a polygon's fragments before the depth comparison is performed, if the polygon is rendered in GLPOINT mode. See glPolygonOffset.
flag_polygonSmooth, //!< If enabled, draw polygons with proper filtering. Otherwise, draw aliased polygons. For correct antialiased polygons, an alpha buffer is needed and the polygons must be sorted front to back.
flag_primitiveRestart, //!< enables primitive restarting. If enabled, any one of the draw commands which transfers a set of generic attribute array elements to the GL will restart the primitive when the index of the vertex is equal to the primitive restart index. See glPrimitiveRestartIndex.
flag_primitiveRestartFixedIndex, //!< enables primitive restarting with a fixed index. If enabled, any one of the draw commands which transfers a set of generic attribute array elements to the GL will restart the primitive when the index of the vertex is equal to the fixed primitive index for the specified index type. The fixed index is equal to 2n1 where n is equal to 8 for GLUNSIGNEDBYTE, 16 for GLUNSIGNEDSHORT and 32 for GLUNSIGNEDINT.
flag_sampleAlphaToCoverage, //!< If enabled, compute a temporary coverage value where each bit is determined by the alpha value at the corresponding sample location. The temporary coverage value is then ANDed with the fragment coverage value.
flag_sampleAlphaToOne, //!< If enabled, each sample alpha value is replaced by the maximum representable alpha value.
flag_sampleCoverage, //!< If enabled, the fragment's coverage is ANDed with the temporary coverage value. If GLSAMPLECOVERAGEINVERT is set to GLTRUE, invert the coverage value. See glSampleCoverage.
flag_sampleShading, //!< If enabled, the active fragment shader is run once for each covered sample, or at fraction of this rate as determined by the current value of GLMINSAMPLESHADINGVALUE. See glMinSampleShading.
flag_sampleMask, //!< If enabled, the sample coverage mask generated for a fragment during rasterization will be ANDed with the value of GLSAMPLEMASKVALUE before shading occurs. See glSampleMaski.
flag_scissorTest, //!< If enabled, discard fragments that are outside the scissor rectangle. See glScissor.
flag_stencilTest, //!< If enabled, do stencil testing and update the stencil buffer. See glStencilFunc and glStencilOp. GLTEXTURECUBEMAPSEAMLESS = 1+0, //!< If enabled, cubemap textures are sampled such that when linearly sampling from the border between two adjacent faces, texels from both faces are used to generate the final sample value. When disabled, texels from only a single face are used to ruct the final sample value.
flag_programPointSize, //!< If enabled and a vertex or geometry shader is active, then the derived point size is taken from the (potentially clipped) shader builtin gthis.PointSize and clamped to the implementation-dependent point size range.
flag_texture2D, //!<
flag_alphaTest, //!<
flag_fog,
flag_back
};
public enum RenderMode {
point,
line,
lineStrip, //!< Not supported in GALE (TODO : Later)
lineLoop,
triangle,
triangleStrip, //!< Not supported in GALE (TODO : Later)
triangleFan, //!< Not supported in GALE (TODO : Later)
quad, //!< Not supported in OpenGL-ES2
quadStrip, //!< Not supported in OpenGL-ES2
polygon //!< Not supported in OpenGL-ES2
};
private static final Map<RenderMode, Integer> convertRenderMode = Map.of(
RenderMode.point, GL.GL_POINTS,
RenderMode.line, GL.GL_LINES,
RenderMode.lineStrip, GL.GL_LINE_STRIP,
RenderMode.lineLoop, GL.GL_LINE_LOOP,
RenderMode.triangle, GL.GL_TRIANGLES,
RenderMode.triangleStrip, GL.GL_TRIANGLE_STRIP,
RenderMode.triangleFan, GL.GL_TRIANGLE_FAN,
RenderMode.quad, GL2.GL_QUADS,
RenderMode.quadStrip, GL2.GL_QUAD_STRIP,
RenderMode.polygon, GL2.GL_POLYGON
);
private static Map<Flag, Integer> basicFlag;
public static class StateFlag {
public boolean current = false;
public boolean mustBeSet = false;
}
private static boolean flagsStatesChange = false;
private static Map<Flag, StateFlag> flagsStates = new HashMap<Flag, StateFlag>();
public enum Usage {
streamDraw,
staticDraw,
dynamicDraw
}
public static Map<Usage, Integer> convertUsage;
static {
flagsStates.put(Flag.flag_blend, new StateFlag());
flagsStates.put(Flag.flag_clipDistanceI, new StateFlag());
flagsStates.put(Flag.flag_colorLogigOP, new StateFlag());
flagsStates.put(Flag.flag_cullFace, new StateFlag());
flagsStates.put(Flag.flag_debugOutput, new StateFlag());
flagsStates.put(Flag.flag_debugOutputSynchronous, new StateFlag());
flagsStates.put(Flag.flag_depthClamp, new StateFlag());
flagsStates.put(Flag.flag_depthTest, new StateFlag());
flagsStates.put(Flag.flag_dither, new StateFlag());
flagsStates.put(Flag.flag_framebufferSRGB, new StateFlag());
flagsStates.put(Flag.flag_lineSmooth, new StateFlag());
flagsStates.put(Flag.flag_multisample, new StateFlag());
flagsStates.put(Flag.flag_polygonOffsetFill, new StateFlag());
flagsStates.put(Flag.flag_polygonOffsetLine, new StateFlag());
flagsStates.put(Flag.flag_polygonOffsetPoint, new StateFlag());
flagsStates.put(Flag.flag_polygonSmooth, new StateFlag());
flagsStates.put(Flag.flag_primitiveRestart, new StateFlag());
flagsStates.put(Flag.flag_primitiveRestartFixedIndex, new StateFlag());
flagsStates.put(Flag.flag_sampleAlphaToCoverage, new StateFlag());
flagsStates.put(Flag.flag_sampleAlphaToOne, new StateFlag());
flagsStates.put(Flag.flag_sampleCoverage, new StateFlag());
flagsStates.put(Flag.flag_sampleShading, new StateFlag());
flagsStates.put(Flag.flag_sampleMask, new StateFlag());
flagsStates.put(Flag.flag_scissorTest, new StateFlag());
flagsStates.put(Flag.flag_stencilTest, new StateFlag());
flagsStates.put(Flag.flag_programPointSize, new StateFlag());
flagsStates.put(Flag.flag_texture2D, new StateFlag());
flagsStates.put(Flag.flag_alphaTest, new StateFlag());
flagsStates.put(Flag.flag_fog, new StateFlag());
flagsStates.put(Flag.flag_back, new StateFlag());
basicFlag = new HashMap<Flag, Integer>();
basicFlag.put(Flag.flag_blend, GL.GL_BLEND);
// basicFlag.put(Flag.flag_clipDistanceI, GL_CLIP_DISTANCE0);
// basicFlag.put(Flag.flag_colorLogigOP, GL_COLOR_LOGIC_OP);
basicFlag.put(Flag.flag_cullFace, GL.GL_CULL_FACE);
// basicFlag.put(Flag.flag_debugOutput, GLDEBUGOUTPUT);
// basicFlag.put(Flag.flag_debugOutputSynchronous, GLDEBUGOUTPUTSYNCHRONOUS);
// basicFlag.put(Flag.flag_depthClamp, GLDEPTHCLAMP);
basicFlag.put(Flag.flag_depthTest, GL.GL_DEPTH_TEST);
basicFlag.put(Flag.flag_dither, GL.GL_DITHER);
// basicFlag.put(Flag.flag_framebufferSRGB, GLFRAMEBUFFERSRGB);
// basicFlag.put(Flag.flag_lineSmooth, GLLINESMOOTH);
// basicFlag.put(Flag.flag_multisample, GLMULTISAMPLE);
basicFlag.put(Flag.flag_polygonOffsetFill, GL.GL_POLYGON_OFFSET_FILL);
// basicFlag.put(Flag.flag_polygonOffsetLine, GLPOLYGONOFFSETLINE);
// basicFlag.put(Flag.flag_polygonOffsetPoint, GLPOLYGONOFFSETPOINT);
// basicFlag.put(Flag.flag_polygonSmooth, GLPOLYGONSMOOTH);
// basicFlag.put(Flag.flag_primitiveRestart, GLPRIMITIVERESTART);
// basicFlag.put(Flag.flag_primitiveRestartFixedIndex, GLPRIMITIVERESTARTFIXEDINDEX);
basicFlag.put(Flag.flag_sampleAlphaToCoverage, GL.GL_SAMPLE_ALPHA_TO_COVERAGE);
// basicFlag.put(Flag.flag_sampleAlphaToOne, GLSAMPLEALPHATOONE);
basicFlag.put(Flag.flag_sampleCoverage, GL3.GL_SAMPLE_COVERAGE);
// basicFlag.put(Flag.flag_sampleShading, GLSAMPLESHADING);
// basicFlag.put(Flag.flag_sampleMask, GLSAMPLEMASK);
basicFlag.put(Flag.flag_scissorTest, GL.GL_SCISSOR_TEST);
basicFlag.put(Flag.flag_stencilTest, GL3.GL_STENCIL_TEST);
// basicFlag.put(Flag.flag_programPointSize, GLPROGRAMPOINTSIZE);
basicFlag.put(Flag.flag_texture2D, GL.GL_TEXTURE_2D);
// basicFlag.put(Flag.flag_alphaTest, GLALPHATEST);
// basicFlag.put(Flag.flag_fog, GLFOG);
basicFlag.put(Flag.flag_back, GL.GL_BACK);
convertUsage = new HashMap<Usage, Integer>();
convertUsage.put(Usage.streamDraw, GL2.GL_STREAM_DRAW);
convertUsage.put(Usage.staticDraw, GL2.GL_STATIC_DRAW);
convertUsage.put(Usage.dynamicDraw, GL2.GL_DYNAMIC_DRAW);
}
private static void clearFlagState() {
for (Map.Entry<Flag, StateFlag> elem: flagsStates.entrySet()) {
elem.getValue().current = false;
elem.getValue().mustBeSet = false;
}
}
public static void resetFlagState() {
for (Map.Entry<Flag, StateFlag> elem: flagsStates.entrySet()) {
elem.getValue().mustBeSet = false;
}
flagsStatesChange = true;
}
private static Map<Long, Boolean> threadHasContext = new HashMap<Long, Boolean>();
/**
* @brief Get the current thread context status.
* @return true The threflagsStates.putn access to openGL.flagsStates.put(Flag.@return false The Thread Can not access to OpenGL.
*/
public static boolean hasContext() {
long curentThreadId = Thread.currentThread().getId();
if (threadHasContext.containsKey(curentThreadId) == false) {
return false;
}
return threadHasContext.get(curentThreadId);;
}
/**
* @brief must be called by the thread that has openGl context to notify the system
* @note Call @ref gale::openGL::threadHasNoMoreContext when ended
*/
public static void threadHasContext() {
long curentThreadId = Thread.currentThread().getId();
threadHasContext.put(curentThreadId, true);
}
public static void setGlobalGLContext(GL context) {
glInterface = context;
}
/**
* @brief At the end of the thread exection, set the thead has no more openGL cotext
*/
public static void threadHasNoMoreContext() {
long curentThreadId = Thread.currentThread().getId();
threadHasContext.remove(curentThreadId);
}
/**
* @brief Lock the openGL context for one user only == > better to keep flags and other things ...
*/
public static void lock() {
//mutexOpenGl().lock();
matrixList.clear();
Matrix4f tmpMat = Matrix4f.identity();
matrixList.add(tmpMat);
matrixCamera.setIdentity();
clearFlagState();
programId = -1;
}
/**
* @brief Un-lock the openGL context for an other user...
*/
public static void unLock() {
//mutexOpenGl().unLock();
}
/**
* @brief When you will done an opengl rendering, you might call this reset matrix first. It remove all the stach of the matrix pushed.
* @param[in] newOne the default matrix that might be set for the graphic card for renderer. if too more pop will be done, this is the last that mmight survived
*/
public static void setBasicMatrix( Matrix4f newOne) {
if (matrixList.size()!=1) {
Log.error("matrix is not corect size in the stack : " + matrixList.size());
}
matrixList.clear();
matrixList.add(newOne);
}
/**
* @brief this funtion configure the current use matrix for the renderer (call @ref Push before, and @ref Pop when no more needed).
* @param[in] newOne The new current matrix use for the render.
* @note We did not use opengl standard system, due to the fact that is not supported in opengl ES-2
*/
public static void setMatrix( Matrix4f newOne) {
if (matrixList.size() == 0) {
Log.error("set matrix list is not corect size in the stack : " + matrixList.size());
matrixList.add(newOne);
return;
}
matrixList.set(matrixList.size()-1, newOne);
}
/**
* @brief store current matrix in the matrix stack.
*/
public static void push() {
if (matrixList.size() == 0) {
Log.error("set matrix list is not corect size in the stack : " + matrixList.size());
matrixList.add(Matrix4f.identity());
return;
}
Matrix4f tmp = matrixList.get(matrixList.size()-1);
matrixList.add(tmp);
}
/**
* @brief remove the current matrix and get the last one from the matrix stack.
*/
public static void pop() {
if (matrixList.size() <= 1) {
Log.error("set matrix list is not corect size in the stack : " + matrixList.size());
matrixList.clear();
matrixList.add(Matrix4f.identity());
matrixCamera.setIdentity();
return;
}
matrixList.remove(matrixList.size()-1);
matrixCamera.setIdentity();
}
/**
* @brief get a reference on the current matrix destinate to opengl renderer.
* @return The requested matrix.
*/
public static Matrix4f getMatrix() {
if (matrixList.size() == 0) {
Log.error("set matrix list is not corect size in the stack : " + matrixList.size());
matrixList.add(Matrix4f.identity());
}
return matrixList.get(matrixList.size()-1);
}
/**
* @brief get a reference on the current matrix camera destinate to opengl renderer.
* @return The requested matrix.
*/
public static Matrix4f getCameraMatrix(){
return matrixCamera;
}
/**
* @brief set a reference on the current camera to opengl renderer.
* @param[in] newOne The requested matrix.
*/
public static void setCameraMatrix( Matrix4f newOne){
matrixCamera = newOne;
}
/**
* @brief
*/
public static void finish(){
programId = -1;
}
/**
* @brief
*/
public static void flush(){
programId = -1;
glInterface.glFlush();
//checkGlError("glFlush");
//Log.info("========================" );
//Log.info("== FLUSH OPEN GL ==" );
//Log.info("========================");
}
/**
* @brief
*/
public static void swap(){
}
public static void setViewPort( Vector2i start, Vector2i stop){
//Log.info("setViewport " + start + " " + stop);
glInterface.glViewport(start.x, start.y, stop.x, stop.y);
checkGlError("glViewport");
}
public static void setViewPort( Vector2f start, Vector2f stop){
//Log.info("setViewport " + start + " " + stop);
glInterface.glViewport((int)start.x, (int)start.y, (int)stop.x, (int)stop.y);
checkGlError("glViewport");
}
/**
* @brief Specifies the clear color value When clear is requested
* @param[in] value to set [0..1]
*/
public static void clearColor(Color color) {
glInterface.glClearColor(color.r, color.g, color.b, color.a);
checkGlError("glClearColor");
}
/**
* @brief Specifies the depth value used when the depth buffer is cleared. The initial value is 1.
* @param[in] value to set [0..1]
*/
public static void clearDepth(float value) {
glInterface.glClearDepth(value);
checkGlError("glClearDepth");
}
/**
* @brief Specifies the index used by clear to clear the stencil buffer. s is masked with 2 m - 1 , where m is the number of bits in the stencil buffer.
* @param[in] value
*/
public static void clearStencil(int value) {
glInterface.glClearStencil(value);
checkGlError("glClearStencil");
}
public static enum ClearFlag {
clearFlag_colorBuffer, //!< Indicates the buffers currently enabled for color writing.
clearFlag_depthBuffer, //!< Indicates the depth buffer.
clearFlag_stencilBuffer //!< Indicates the stencil buffer.
}
private static final Map<ClearFlag, Integer> basicFlagClear = Map.of(
ClearFlag.clearFlag_colorBuffer, GL.GL_COLOR_BUFFER_BIT,
ClearFlag.clearFlag_depthBuffer, GL.GL_DEPTH_BUFFER_BIT,
ClearFlag.clearFlag_stencilBuffer, GL.GL_STENCIL_BUFFER_BIT );
/**
* @brief clear sets the bitplane area of the window to values previously selected by clearColor, clearDepth, and clearStencil. Multiple color buffers can be cleared simultaneously by selecting more than one buffer at a time using drawBuffer.
* The pixel ownership test, the scissor test, dithering, and the buffer writemasks affect the operation of clear. The scissor box bounds the cleared region. Alpha function, blend function, logical operation, stenciling, texture mapping, and depth-buffering are ignored by clear.
* @param[in] flags This is the bitwise OR of several values indicating which buffer is to be cleared.
*/
public static void clear(ClearFlag flag){
glInterface.glClear(basicFlagClear.get(flag));
checkGlError("glClear");
}
/**
* @brief enable a flag on the system
* @param[in] flagID The flag requested
*/
public static void enable(Flag flagID){
//Log.info("Enable : " + flagID);
if (DIRECT_MODE) {
glInterface.glEnable(basicFlag.get(flagID));
checkGlError("glEnable");
} else {
//Log.debug("Enable FLAGS = " + this.flagsStates);
flagsStates.get(flagID).mustBeSet = true;
flagsStatesChange = true;
//Log.debug(" == >" + this.flagsStates);
}
}
/**
* @brief disable a flag on the system
* @param[in] flagID The flag requested
*/
public static void disable(Flag flagID) {
//Log.info("Disable : " + flagID);
if (DIRECT_MODE) {
glInterface.glDisable(basicFlag.get(flagID));
checkGlError("glDisable");
} else {
//Log.debug("Disable FLAGS = " + this.flagsStates);
flagsStates.get(flagID).mustBeSet = false;
flagsStatesChange = true;
//Log.debug(" == >" + this.flagsStates);
}
}
/**
* @brieg update all the internal flag needed to be set from tre previous element set ...
*/
public static void updateAllFlags() {
if (DIRECT_MODE) {
return;
}
// check if flags has change :
if (flagsStatesChange == false) {
return;
}
flagsStatesChange = false;
for (Map.Entry<Flag, StateFlag> elem: flagsStates.entrySet()) {
StateFlag value = elem.getValue();
if (value.current != value.mustBeSet) {
value.current = value.mustBeSet;
if (value.current == true) {
glInterface.glEnable(basicFlag.get(elem.getKey()));
checkGlError("glEnable");
//Log.info(" enable : " + elem.getKey() + " " + basicFlag.get(elem.getKey()));
} else {
glInterface.glDisable(basicFlag.get(elem.getKey()));
checkGlError("glDisable");
//Log.info(" disable : " + elem.getKey());
}
}
}
}
/**
* @brief enable Texture on the system
* @param[in] flagID The flag requested
*/
public static void activeTexture(int flagID) {
if (programId >= 0) {
GL13.glActiveTexture(flagID);
checkGlError("glActiveTexture");
} else {
if (DEBUG) {
Log.error("try to bind texture with no program set");
}
}
}
/**
* @brief disable Texture on the system
* @param[in] flagID The flag requested
*/
// TODO : rename Disable
public static void desActiveTexture(int flagID) {
// if (this.programId >= 0) {
//
// }
}
/**
* @brief draw a specific array == > this enable mode difference ...
*/
// public static void drawArrays(RenderMode mode, int first, int count) {
// if (this.programId >= 0) {
// updateAllFlags();
// glInterface.glDrawArrays(convertRenderMode.get(mode), first, count);
// checkGlError("glDrawArrays");
// }
// }
// public static void drawElements(RenderMode mode, List<Integer> indices) {
// if (this.programId >= 0) {
// updateAllFlags();
// //Log.debug("Request draw of " + indices.size() + "elements");
// GL15.glDrawElements(convertRenderMode.get(mode), indices.size(), GL.GL_UNSIGNED_INT);//, &indices[0]);
// checkGlError("glDrawElements");
// }
// }
// public static void drawElements16(RenderMode mode, List<int> indices) {
// if (this.programId >= 0) {
// updateAllFlags();
// glInterface.glDrawElements(convertRenderMode.get(mode), indices.size(), GLUNSIGNEDSHORT, &indices[0]);
// checkGlError("glDrawElements");
// }
// }
// public static void drawElements8 (enum renderMode mode, List<int> indices) {
// if (this.programId >= 0) {
// updateAllFlags();
// glInterface.glDrawElements(convertRenderMode[int(mode)], indices.size(), GLUNSIGNEDBYTE, &indices[0]);
// checkGlError("glDrawElements");
// }
// }
/**
* @brief Use openGL program
* @param[in] id Id of the program that might be used
*/
public static void programUse(int id) {
//Log.verbose("USE prog : " + id);
// note : In normal openGL case, the system might call with the program ID and at the end with 0,
// here, we wrap this use to prevent over call of glUseProgram == > then we set -1 when the
// user no more use this program, and just stop grnerating. (chen 0 == > this is an errored program ...
if (id == -1) {
// not used == > because it is unneded
return;
}
if (programId != id) {
programId = id;
glInterface.glUseProgram(programId);
}
checkGlError("glUseProgram");
}
public static void programUnUse(int id) {
// nothing to do ...
}
public static void reset() {
if (DIRECT_MODE) {
Log.error("TODO: ...");
} else {
clearFlagState();
programId = -1;
updateAllFlags();
}
}
public static boolean genBuffers(int[] buffers) {
if (buffers.length == 0) {
Log.warning("try to generate vector buffer with size 0");
return true;
}
Log.info("Create N=" + buffers.length + " Buffer");
glInterface.glGenBuffers(buffers);
checkGlError("glGenBuffers");
boolean hasError = false;
for (int iii=0; iii<buffers.length; iii++) {
if (buffers[iii] == 0) {
Log.error("[" + iii + "] error to create a buffer id=" + buffers[iii]);
hasError = true;
}
}
return hasError;
}
public static boolean deleteBuffers(int[] buffers) {
if (buffers.length == 0) {
Log.warning("try to delete vector buffer with size 0");
return true;
}
// TODO: Check if we are in the correct thread
glInterface.glDeleteBuffers(buffers);
checkGlError("glDeleteBuffers");
for (int iii=0; iii<buffers.length; iii++) {
buffers[iii] = -1;
}
return true;
}
public static boolean bindBuffer(int bufferId){
glInterface.glBindBuffer(GL2.GL_ARRAY_BUFFER, bufferId);
checkGlError("glBindBuffer");
return true;
}
private static FloatBuffer storeDataInFloatBuffer(float[] data) {
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();
return buffer;
}
public static boolean bufferData(float[] data, Usage usage) {
FloatBuffer buffer = storeDataInFloatBuffer(data);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, convertUsage.get(usage));
checkGlError("glBufferData");
return true;
}
public static boolean unbindBuffer() {
glInterface.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0);
checkGlError("glBindBuffer(0)");
return true;
}
public static void vertexAttribPointerFloat(int id, int size) {
glInterface.glVertexAttribPointer(id, size, GL.GL_FLOAT, false, 0, 0);
checkGlError("glVertexAttribPointer");
}
/* Shader wrapping : */
public static enum ShaderType {
vertex,
fragment
};
protected static StringBuilder readLocalFile(String name) {
StringBuilder fileSource = new StringBuilder();
try {
BufferedReader reader = new BufferedReader(new FileReader(name));
String line;
while((line = reader.readLine()) != null) {
fileSource.append(line).append("\n");
}
reader.close();
} catch(IOException e) {
Log.error("Could not read the file!");
e.printStackTrace();
System.exit(-1);
}
return fileSource;
}
private static int shaderCreate(ShaderType type) {
int shaderId = 0;
if (type == ShaderType.vertex) {
Log.verbose("create shader: VERTEX");
shaderId = glInterface.glCreateShader(GL2.GL_VERTEX_SHADER);
} else if (type == ShaderType.fragment) {
Log.verbose("create shader: FRAGMENT");
shaderId = glInterface.glCreateShader(GL2.GL_FRAGMENT_SHADER);
} else {
Log.error("create shader with wrong type ...");
return -1;
}
Log.verbose("create shader: ... (done)");
if (shaderId == 0) {
Log.error("glCreateShader return error ...");
checkGlError("glCreateShader");
return -1;
}
return shaderId;
}
public static int shaderLoad(String file, ShaderType type) {
System.out.println("Load shader: '" + file + "'");
StringBuilder shaderSource = readLocalFile(file);
int shaderID = shaderCreate(type);
glInterface.glShaderSource(shaderID, shaderSource);
glInterface.glCompileShader(shaderID);
if (glInterface.glGetShaderi(shaderID, GL2.GL_COMPILE_STATUS) == GL.GL_FALSE) {
Log.error(glInterface.glGetShaderInfoLog(shaderID, 500));
Log.error("Could not compile the shader");
return -1;
}
return shaderID;
}
public static void shaderRemove(int shader) {
if (shader < 0) {
return;
}
// TODO: Check if we are in the correct thread
glInterface.glDeleteShader(shader);
checkGlError("glDeleteShader");
}
// ------------------------------------------------------------------------------------
// -- Open GL program ...
// ------------------------------------------------------------------------------------
public static int programCreate() {
int programId = glInterface.glCreateProgram();
if (programId == 0) {
Log.error("program creation return error ...");
checkGlError("glCreateProgram");
return -1;
}
Log.debug("Create program with oglID=" + programId);
return programId;
}
public static void programRemove(int prog) {
if (prog < 0) {
return;
}
// TODO: Check if we are in the correct thread
glInterface.glDeleteProgram(prog);
checkGlError("glDeleteProgram");
}
public static boolean programAttach(int prog, int shader) {
if (prog < 0) {
Log.error("wrong program ID");
return false;
}
if (shader < 0) {
Log.error("wrong shader ID");
return false;
}
glInterface.glAttachShader(prog, shader);
checkGlError("glAttachShader");
return true;
}
public static boolean programDetach(int prog, int shader) {
if (prog < 0) {
Log.error("wrong program ID");
return false;
}
if (shader < 0) {
Log.error("wrong shader ID");
return false;
}
glInterface.glDetachShader(prog, shader);
checkGlError("glDetachShader");
return true;
}
public static boolean programCompile(int prog) {
if (prog < 0) {
Log.error("wrong program ID");
return false;
}
GL2.glLinkProgram(prog);
checkGlError("glLinkProgram");
GL2.glValidateProgram(prog);
// GLint linkStatus = GLFALSE;
// glGetProgramiv(GLint(prog), GLLINKSTATUS, linkStatus);
// checkGlError("glGetProgramiv");
// if (linkStatus != GLTRUE) {
// GLint bufLength = 0;
// this.bufferDisplayError[0] = '\0';
// glGetProgramInfoLog(GLint(prog), LOGOGLINTERNALBUFFERLEN, bufLength, this.bufferDisplayError);
// char tmpLog[256];
// int idOut=0;
// Log.error("Could not compile 'PROGRAM':");
// for (sizet iii=0; iii<LOGOGLINTERNALBUFFERLEN ; iii++) {
// tmpLog[idOut] = this.bufferDisplayError[iii];
// if ( tmpLog[idOut] == '\n'
// || tmpLog[idOut] == '\0'
// || idOut >= 256) {
// tmpLog[idOut] = '\0';
// Log.error(" == > " + tmpLog);
// idOut=0;
// } else {
// idOut++;
// }
// if (this.bufferDisplayError[iii] == '\0') {
// break;
// }
// }
// if (idOut != 0) {
// tmpLog[idOut] = '\0';
// Log.error(" == > " + tmpLog);
// }
// return false;
// }
return true;
}
public static void programBindAttribute(int prog, int attribute, String variableName) {
if (prog < 0) {
Log.error("wrong program ID");
return;
}
GL2.glBindAttribLocation(prog, attribute, variableName);
}
public static int programGetAttributeLocation(int prog, String name) {
if (prog < 0) {
Log.error("wrong program ID");
return -1;
}
if (name.length() == 0) {
Log.error("wrong name of attribure");
return -1;
}int val = GL2.glGetAttribLocation(prog, name);
if (val < 0) {
checkGlError("glGetAttribLocation");
Log.warning("glGetAttribLocation('" + name + "') = " + val);
return -1;
}
return val;
}
public static int programGetUniformLocation(int prog, String name) {
if (prog < 0) {
Log.error("wrong program ID");
return -1;
}
if (name.length() == 0) {
Log.error("wrong name of uniform");
return -1;
}
int val = GL2.glGetUniformLocation(prog, name);
if (val == GL2.GL_INVALID_VALUE) {
checkGlError("glGetUniformLocation");
Log.warning("glGetUniformLocation('" + name + "') = GL_INVALID_VALUE");
} else if (val == GL2.GL_INVALID_OPERATION) {
checkGlError("glGetUniformLocation");
Log.warning("glGetUniformLocation('" + name + "') = GL_INVALID_OPERATION");
} else if (val < 0) {
checkGlError("glGetUniformLocation");
Log.warning("glGetUniformLocation('" + name + "') = " + val);
}
return val;
};
public static void programLoadUniformFloat(int location, float value) {
GL2.glUniform1f(location, value);
}
public static void programLoadUniformFloat(int location, float value, float value2) {
GL2.glUniform2f(location, value, value2);
}
public static void programLoadUniformFloat(int location, float value, float value2, float value3) {
GL2.glUniform3f(location, value, value2, value3);
}
public static void programLoadUniformFloat(int location, float value, float value2, float value3, float value4) {
GL2.glUniform4f(location, value, value2, value3, value4);
}
public static void programLoadUniformInt(int location, int value) {
GL2.glUniform1i(location, value);
}
public static void programLoadUniformInt(int location, int value, int value2) {
GL2.glUniform2i(location, value, value2);
}
public static void programLoadUniformInt(int location, int value, int value2, int value3) {
GL2.glUniform3i(location, value, value2, value3);
}
public static void programLoadUniformInt(int location, int value, int value2, int value3, int value4) {
GL2.glUniform4i(location, value, value2, value3, value4);
}
public static void programLoadUniformColor(int location, Color value) {
GL2.glUniform3f(location, value.r, value.g, value.b);
}
public static void programLoadUniformVector(int location, Vector3f value) {
GL2.glUniform3f(location, value.x, value.y, value.z);
}
public static void programLoadUniformVector(int location, Vector3i value) {
GL2.glUniform3i(location, value.x, value.y, value.z);
}
public static void programLoadUniformVector(int location, Vector2f value) {
GL2.glUniform2f(location, value.x, value.y);
}
public static void programLoadUniformVector(int location, Vector2i value) {
GL2.glUniform2i(location, value.x, value.y);
}
public static void programLoadUniformBoolean(int location, boolean value) {
//System.out.println("set value " + value + " " + (value==true?1.0f:0.0f));
GL2.glUniform1f(location, value==true?1.0f:0.0f);
}
public static void programLoadUniformMatrix(int location, Matrix4f value) {
GL2.glUniformMatrix4fv(location, true, value.getTable());
}
public static void programLoadUniformMatrix(int location, Matrix4f value, boolean transpose) {
GL2.glUniformMatrix4fv(location, transpose, value.getTable());
}
public static void drawElements(RenderMode mode, int vertexCount) {
glInterface.glDrawElements(convertRenderMode.get(mode), vertexCount, GL.GL_UNSIGNED_INT, 0);
}
}

View File

@ -733,6 +733,7 @@ public abstract class Context {
* @param[in] _forcedPosition the position where the mouse might be reset at every events ...
*/
public void grabPointerEvents(boolean _status, Vector2f _forcedPosition) { };
public boolean isGrabPointerEvents() { return false; };
/**
* @brief set the cursor display type.
* @param[in] _newCursor selected new cursor.

View File

@ -0,0 +1,722 @@
package org.atriaSoft.gale.context.JOGL;
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Timer;
import java.util.TimerTask;
//import net.java.games.jogl.GLCanvas;
//import net.java.games.jogl.GLCapabilities;
//import net.java.games.jogl.GLDrawableFactory;
import static com.jogamp.opengl.GL.*;
import static com.jogamp.opengl.GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT;
import static com.jogamp.opengl.fixedfunc.GLLightingFunc.GL_COLOR_MATERIAL;
import static com.jogamp.opengl.fixedfunc.GLLightingFunc.GL_FLAT;
import static com.jogamp.opengl.fixedfunc.GLLightingFunc.GL_LIGHT0;
import static com.jogamp.opengl.fixedfunc.GLLightingFunc.GL_LIGHTING;
import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_MODELVIEW;
import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_PROJECTION;
import java.nio.IntBuffer;
import org.atriaSoft.etk.Uri;
import org.atriaSoft.etk.math.Vector2f;
import org.atriaSoft.gale.Application;
import org.atriaSoft.gale.Fps;
import org.atriaSoft.gale.backend3d.OpenGL;
import org.atriaSoft.gale.context.Context;
import org.atriaSoft.gale.key.KeyKeyboard;
import org.atriaSoft.gale.key.KeySpecial;
import org.atriaSoft.gale.key.KeyStatus;
import org.atriaSoft.gale.key.KeyType;
import org.atriaSoft.gameEngine.Log;
//import org.lwjgl.Version;
//import org.lwjgl.glfw.GLFWErrorCallback;
//import org.lwjgl.glfw.GLFWVidMode;
//import org.lwjgl.opengl.GL;
//import org.lwjgl.system.MemoryStack;
import com.jogamp.opengl.DefaultGLCapabilitiesChooser;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLDrawableFactory;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLOffscreenAutoDrawable;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.glu.GLU;
import com.jogamp.opengl.glu.GLUquadric;
import renderEngine.DisplayManagerDraw;
public class ContextJOGL extends Context {
private GLOffscreenAutoDrawable drawable = null;
private boolean[] inputIsPressed = new boolean[MAX_MANAGE_INPUT];
private Vector2f cursorPos = new Vector2f(0, 0);
private static final int WIDTH = 800;
private static final int HEIGHT = 600;
private static final String TITLE = "Gale basic UI";
private static long lastFrameTime;
private static float delta;
private Vector2f lastPositionGrab = null; // is null when grabbing is disable ...
private Fps fps = new Fps("Main Loop", true);
private DisplayManagerDraw drawer = null;
private static double whellOffsetY;
private static double whellOffsetX;
private static boolean rightButtonStateDown = false;
private static boolean leftButtonStateDown = false;
private static double lastMousePositionX = 0;
private static double lastMousePositionY = 0;
private static double currentMousePositionX = 0;
private static double currentMousePositionY = 0;
// The window handle
private long window = 0;
private KeySpecial guiKeyBoardMode = new KeySpecial();
private GL2 gl;
private GLU glu;
private Frame frame;
public ContextJOGL(Application application, String[] args) {
super(application, args);
System.out.println("Hello JOGL !");
initWindows();
// // This line is critical for LWJGL's interoperation with GLFW's
// // OpenGL context, or any context that is managed externally.
// // LWJGL detects the context that is current in the current thread,
// // creates the GLCapabilities instance and makes the OpenGL
// // bindings available for use.
// GL.createCapabilities();
// // Set the clear color
// glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
// glViewport(0, 0, (int)application.getSize().x, (int)application.getSize().y);
start2ndThreadProcessing();
}
public void setDrawer(DisplayManagerDraw drawer) {
this.drawer = drawer;
}
// public static Vector2f getSize() {
// return new Vector2f(WIDTH, HEIGHT);
// }
public void unInit() {
// // Free the window callbacks and destroy the window
// glfwFreeCallbacks(window);
// glfwDestroyWindow(window);
//
// // Terminate GLFW and free the error callback
// glfwTerminate();
// glfwSetErrorCallback(null).free();
}
private void initWindows() {
GLProfile glprofile = GLProfile.getDefault();
GLCapabilities glcapabilities = new GLCapabilities( glprofile );
final GLCanvas glcanvas = new GLCanvas( glcapabilities );
glcanvas.addGLEventListener( new GLEventListener() {
@Override
public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) {
//OneTriangle.setup( glautodrawable.getGL().getGL2(), width, height );
}
@Override
public void init( GLAutoDrawable glautodrawable ) {
}
@Override
public void dispose( GLAutoDrawable glautodrawable ) {
}
@Override
public void display( GLAutoDrawable glautodrawable ) {
//OneTriangle.render( glautodrawable.getGL().getGL2(), glautodrawable.getSurfaceWidth(), glautodrawable.getSurfaceHeight() );
}
});
final Frame frame = new Frame( "One Triangle AWT" );
frame.add( glcanvas );
frame.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent windowevent ) {
frame.remove( glcanvas );
frame.dispose();
System.exit( 0 );
}
});
frame.setSize( 640, 480 );
frame.setVisible( true );
OpenGL.setGlobalGLContext(glcanvas.getGL());
// // Make the new window
//
// frame = new Frame("CMSC427 - Project 1");
//
// GLProfile glp = GLProfile.getDefault();
// GLCapabilities caps = new GLCapabilities(glp);
// caps.setHardwareAccelerated(true);
// caps.setDoubleBuffered(false);
// caps.setAlphaBits(8);
// caps.setRedBits(8);
// caps.setBlueBits(8);
// caps.setGreenBits(8);
// caps.setOnscreen(false);
// GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
// drawable = factory.createOffscreenAutoDrawable(
// factory.getDefaultDevice(),
// caps,
// new DefaultGLCapabilitiesChooser(),
// 100,
// 100);
// drawable.display();
// drawable.getContext().makeCurrent();
// gl = drawable.getGL().getGL2();
// gl.glClearDepth(1.0f);
// gl.glDepthFunc(GL_LEQUAL);
// gl.glEnable(GL_DEPTH_TEST);
// gl.glShadeModel(GL_FLAT);
// gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
// glu = GLU.createGLU(gl);
// GLUquadric quadratic = glu.gluNewQuadric();
// glu.gluQuadricNormals(quadratic, GLU.GLU_SMOOTH);
// glu.gluQuadricTexture(quadratic, true);
// gl.glEnable(GL_COLOR_MATERIAL);
// gl.glDisable(GL_TEXTURE_2D);
//
// frame.add(drawable);
// // Setup an error callback. The default implementation
// // will print the error message in System.err.
// GLFWErrorCallback.createPrint(System.err).set();
//
// // Initialize GLFW. Most GLFW functions will not work before doing this.
// if ( !glfwInit() ) {
// throw new IllegalStateException("Unable to initialize GLFW");
// }
// // Configure GLFW
// glfwDefaultWindowHints(); // optional, the current window hints are already the default
// glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
// glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // the window will be resizable
//
// // Create the window
// window = glfwCreateWindow((int)application.getSize().x, (int)application.getSize().y, application.getTitle(), NULL, NULL);
// if ( window == 0 ) {
// throw new RuntimeException("Failed to create the GLFW window");
// }
// // Setup a key callback. It will be called every time a key is pressed, repeated or released.
// // https://www.glfw.org/docs/latest/input_guide.html
// glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
// this.keyCallback(window, key, scancode, action, mods);
// });
// glfwSetWindowSizeCallback(window, (windows, sizeX, sizeY) -> {
// this.windowSizeCallback(window, sizeX, sizeY);
// });
//
// glfwSetCharCallback(window, (window, key) -> {
// this.charCallback(window, key);
// });
//
// glfwSetCursorPosCallback(window, (window, xpos, ypos) -> {
// this.cursorPosCallback(window, xpos, ypos);
// });
//
// glfwSetMouseButtonCallback(window, (window, button, action, mods) -> {
// this.mouseCallback(window, button, action, mods);
// });
//
// glfwSetScrollCallback(window, (window, xoffset, yoffset) -> {
// this.scrollCallback(window, xoffset, yoffset);
// });
//
//
// // Get the thread stack and push a new frame
// try ( MemoryStack stack = stackPush() ) {
// IntBuffer pWidth = stack.mallocInt(1); // int*
// IntBuffer pHeight = stack.mallocInt(1); // int*
//
// // Get the window size passed to glfwCreateWindow
// glfwGetWindowSize(window, pWidth, pHeight);
//
// // Get the resolution of the primary monitor
// GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
//
// // Center the window
// glfwSetWindowPos(
// window,
// (vidmode.width() - pWidth.get(0)) / 2,
// (vidmode.height() - pHeight.get(0)) / 2
// );
// } // the stack frame is popped automatically
//
// // Make the OpenGL context current
// glfwMakeContextCurrent(window);
// // Enable v-sync
// glfwSwapInterval(1);
//
// // Make the window visible
// glfwShowWindow(window);
lastFrameTime = getCurrentTime();
}
// private void windowSizeCallback(long window2, int sizeX, int sizeY) {
// OS_Resize(new Vector2f(sizeX, sizeY));
// }
//
//
// private void charCallback(long window, int key) {;
// Log.error("keyboard char " + key + " " + (char)key);
// }
// private void keyCallback(long window, int key, int scancode, int action, int mods) {
// boolean find = true;
// boolean thisIsAReapeateKey = false; // TODO detect this ...
// KeyKeyboard keyInput = KeyKeyboard.unknow;
// Log.error("keyboard input " + key + " " + scancode);
// switch (key) {
// //case 328: // keypad
// case GLFW_KEY_UP: keyInput = KeyKeyboard.up; break;
// //case 324: // keypad
// case GLFW_KEY_LEFT: keyInput = KeyKeyboard.left; break;
// //case 326: // keypad
// case GLFW_KEY_RIGHT: keyInput = KeyKeyboard.right; break;
// //case 323: // keypad
// case GLFW_KEY_DOWN: keyInput = KeyKeyboard.down; break;
// case 329: // keypad
// case GLFW_KEY_PAGE_UP: keyInput = KeyKeyboard.pageUp; break;
// case 323: // keypad
// case GLFW_KEY_PAGE_DOWN: keyInput = KeyKeyboard.pageDown; break;
// case 327: // keypad
// case GLFW_KEY_HOME: keyInput = KeyKeyboard.start; break;
// case 321: // keypad
// case GLFW_KEY_END: keyInput = KeyKeyboard.end; break;
// case GLFW_KEY_PRINT_SCREEN: keyInput = KeyKeyboard.stopDefil; break;
// case GLFW_KEY_PAUSE: keyInput = KeyKeyboard.wait; break;
// case 320: // keypad
// case GLFW_KEY_INSERT:
// keyInput = KeyKeyboard.insert;
// if(action == GLFW_RELEASE) {
// if (guiKeyBoardMode.getInsert() == true) {
// guiKeyBoardMode.setInsert(false);
// } else {
// guiKeyBoardMode.setInsert(true);
// }
// }
// break;
// //case 84: keyInput = KeyboardCenter; break; // Keypad
// case GLFW_KEY_F1: keyInput = KeyKeyboard.f1; break;
// case GLFW_KEY_F2: keyInput = KeyKeyboard.f2; break;
// case GLFW_KEY_F3: keyInput = KeyKeyboard.f3; break;
// case GLFW_KEY_F4: keyInput = KeyKeyboard.f4; break;
// case GLFW_KEY_F5: keyInput = KeyKeyboard.f5; break;
// case GLFW_KEY_F6: keyInput = KeyKeyboard.f6; break;
// case GLFW_KEY_F7: keyInput = KeyKeyboard.f7; break;
// case GLFW_KEY_F8: keyInput = KeyKeyboard.f8; break;
// case GLFW_KEY_F9: keyInput = KeyKeyboard.f9; break;
// case GLFW_KEY_F10: keyInput = KeyKeyboard.f10; break;
// case GLFW_KEY_F11: keyInput = KeyKeyboard.f11; break;
// case GLFW_KEY_F12: keyInput = KeyKeyboard.f12; break;
// case GLFW_KEY_CAPS_LOCK: keyInput = KeyKeyboard.capLock; guiKeyBoardMode.setCapsLock (action == GLFW_PRESS); break;
// case GLFW_KEY_LEFT_SHIFT: keyInput = KeyKeyboard.shiftLeft; guiKeyBoardMode.setShiftLeft (action == GLFW_PRESS); break;
// case GLFW_KEY_RIGHT_SHIFT: keyInput = KeyKeyboard.shiftRight; guiKeyBoardMode.setShiftRight(action == GLFW_PRESS); break;
// case GLFW_KEY_LEFT_CONTROL: keyInput = KeyKeyboard.ctrlLeft; guiKeyBoardMode.setCtrlLeft (action == GLFW_PRESS); break;
// case GLFW_KEY_RIGHT_CONTROL: keyInput = KeyKeyboard.ctrlRight; guiKeyBoardMode.setCtrlRight (action == GLFW_PRESS); break;
// case GLFW_KEY_LEFT_SUPER: keyInput = KeyKeyboard.metaLeft; guiKeyBoardMode.setMetaLeft (action == GLFW_PRESS); break;
// case GLFW_KEY_RIGHT_SUPER: keyInput = KeyKeyboard.metaRight; guiKeyBoardMode.setMetaRight (action == GLFW_PRESS); break;
// case GLFW_KEY_LEFT_ALT: keyInput = KeyKeyboard.altLeft; guiKeyBoardMode.setAltLeft (action == GLFW_PRESS); break;
// case GLFW_KEY_RIGHT_ALT: keyInput = KeyKeyboard.altRight; guiKeyBoardMode.setAltRight (action == GLFW_PRESS); break;
// case GLFW_KEY_MENU: keyInput = KeyKeyboard.contextMenu; break;
// case GLFW_KEY_NUM_LOCK: keyInput = KeyKeyboard.numLock; guiKeyBoardMode.setNumLock (action == GLFW_PRESS); break;
// case GLFW_KEY_DELETE: // Suppr on keypad
// find = false;
// if(guiKeyBoardMode.getNumLock() == true){
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action == GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// '.');
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action != GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// '.');
// }
// } else {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action == GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)0x7F);
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action != GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)0x7F);
// }
// }
// break;
// case GLFW_KEY_TAB: // special case for TAB
// find = false;
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action == GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)0x09);
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action!=GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)0x09);
// }
// break;
// case GLFW_KEY_A:
// case GLFW_KEY_B:
// case GLFW_KEY_C:
// case GLFW_KEY_D:
// case GLFW_KEY_E:
// case GLFW_KEY_F:
// case GLFW_KEY_G:
// case GLFW_KEY_H:
// case GLFW_KEY_I:
// case GLFW_KEY_J:
// case GLFW_KEY_K:
// case GLFW_KEY_L:
// case GLFW_KEY_M:
// case GLFW_KEY_N:
// case GLFW_KEY_O:
// case GLFW_KEY_P:
// case GLFW_KEY_Q:
// case GLFW_KEY_R:
// case GLFW_KEY_S:
// case GLFW_KEY_T:
// case GLFW_KEY_U:
// case GLFW_KEY_V:
// case GLFW_KEY_W:
// case GLFW_KEY_X:
// case GLFW_KEY_Y:
// case GLFW_KEY_Z:
// {
// find = false;
// int tmpKey = key-GLFW_KEY_A + (int)'a';
// if (guiKeyBoardMode.getCapsLock() == true || guiKeyBoardMode.getShift() == true) {
// tmpKey += (int)'A' - (int)'a';
// }
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action==GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)tmpKey);
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action!=GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)tmpKey);
// }
// break;
// }
// case GLFW_KEY_1:
// case GLFW_KEY_2:
// case GLFW_KEY_3:
// case GLFW_KEY_4:
// case GLFW_KEY_5:
// case GLFW_KEY_6:
// case GLFW_KEY_7:
// case GLFW_KEY_8:
// case GLFW_KEY_9:
// case GLFW_KEY_0:
// {
// find = false;
// int tmpKey = key-GLFW_KEY_0 + (int)'0';
//// if (guiKeyBoardMode.getCapsLock() == true || guiKeyBoardMode.getShift() == true) {
//// tmpKey += (int)'A' - (int)'a';
//// }
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action==GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)tmpKey);
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action!=GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)tmpKey);
// }
// }
// default:
// find = false;
//// {
//// char buf[11];
//// //GALE_DEBUG("Keycode: " << event.xkey.keycode);
//// // change keystate for simple reson of the ctrl error...
//// int32_t keyStateSave = event.xkey.state;
//// if (event.xkey.state & (1<<2) ) {
//// event.xkey.state = event.xkey.state & 0xFFFFFFFB;
//// }
//// KeySym keysym;
//// Status status = 0;
//// //int count = Xutf8LookupString(m_xic, (XKeyPressedEvent*)&event, buf, 10, &keysym, &status);
//// int count = Xutf8LookupString(m_xic, &event.xkey, buf, 10, &keysym, &status);
//// // retreave real keystate
//// event.xkey.state = keyStateSave;
//// buf[count] = '\0';
//// // Replace \r error ...
//// if (buf[0] == '\r') {
//// buf[0] = '\n';
//// buf[1] = '\0';
//// }
//// if (count >= 0) {
//// // repeated kay from previous element :
//// if (count > 0) {
//// // transform it in unicode
//// m_lastKeyPressed = utf8::convertChar32(buf);
//// }
//// X11_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << m_lastKeyPressed);
//// OS_setKeyboard(m_guiKeyBoardMode,
//// gale::key::keyboard::character,
//// (event.type==KeyPress?gale::key::status::down:gale::key::status::up),
//// thisIsAReapeateKey,
//// m_lastKeyPressed);
//// if (thisIsAReapeateKey == true) {
//// OS_setKeyboard(m_guiKeyBoardMode,
//// gale::key::keyboard::character,
//// (event.type!=KeyPress?gale::key::status::down:gale::key::status::up),
//// thisIsAReapeateKey,
//// m_lastKeyPressed);
//// }
//// } else {
//// GALE_WARNING("Unknow event Key : " << event.xkey.keycode << " res='" << buf << "' repeate=" << thisIsAReapeateKey);
//// }
//// }
//// break;
// }
// if (find == true) {
// OS_setKeyboard(guiKeyBoardMode,
// keyInput,
// (action == GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey);
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// keyInput,
// (action!=GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey);
// }
// }
//// if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE ) {
//// glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
//// }
// }
// private void cursorPosCallback(long window, double xpos, double ypos) {
// if (lastPositionGrab != null) {
// cursorPos.x = lastPositionGrab.x - (float)xpos;
// cursorPos.y = -(lastPositionGrab.y - (float)ypos);
// lastPositionGrab.x = (float)xpos;
// lastPositionGrab.y = (float)ypos;
// } else {
// // TODO: use real size ... !!!!
// cursorPos.x = (float)xpos;
// cursorPos.y = /*m_currentHeight*/800.0f-(float)ypos;
// }
// // For compatibility of the Android system :
// boolean findOne = false;
// for (int iii=0; iii<MAX_MANAGE_INPUT; iii++) {
// if (inputIsPressed[iii] == true) {
// //Log.debug("X11 event: bt=" << iii << " " << event.type << " = \"MotionNotify\" (" << m_cursorEventX << "," << m_cursorEventY << ")");
// OS_SetInput(guiKeyBoardMode,
// KeyType.mouse,
// KeyStatus.move,
// iii,
// cursorPos);
// findOne = true;
// }
// }
// if (findOne == false) {
// //X11_DEBUG("X11 event: bt=" << 0 << " " << event.type << " = \"MotionNotify\" (" << m_cursorEventX << "," << m_cursorEventY << ")");
// OS_SetInput(guiKeyBoardMode,
// KeyType.mouse,
// KeyStatus.move,
// 0,
// cursorPos);
// }
// }
// private void scrollCallback(long window, double xoffset, double yoffset) {
// /*
// Log.error("scroll: " + xoffset + " " + yoffset);
// whellOffsetY += yoffset;
// whellOffsetX += xoffset;
// */
// if (yoffset<0) {
// inputIsPressed[5] = true;
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.down,
// 5,
// cursorPos);
// inputIsPressed[5] = false;
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.up,
// 5,
// cursorPos);
// } else if (yoffset>0) {
// inputIsPressed[4] = true;
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.down,
// 4,
// cursorPos);
// inputIsPressed[4] = false;
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.up,
// 4,
// cursorPos);
// }
// }
// private void mouseCallback(long window, int button, int action, int mods) {
// if (action == GLFW_PRESS) {
//// Log.info("mouse value: GLFW_PRESS " + action + " bt=" + button);
// if (button < MAX_MANAGE_INPUT) {
// inputIsPressed[button] = true;
// }
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.down,
// button,
// cursorPos);
// } else if (action == GLFW_RELEASE) {
//// Log.info("mouse value: GLFW_RELEASE" + action + " bt=" + button);
// leftButtonStateDown = false;
// if (button < MAX_MANAGE_INPUT) {
// inputIsPressed[button] = false;
// }
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.up,
// button,
// cursorPos);
//// } else {
//// Log.info("mouse value: ???" + action + " bt=" + button);
// }
// }
public static float getFrameTimeSecconds() {
return delta;
}
private static long getCurrentTime() {
return System.currentTimeMillis();
}
public static boolean isButtonRightDown() {
return rightButtonStateDown;
}
public static boolean isButtonLeftDown() {
return leftButtonStateDown;
}
public static float getDX() {
return (float) (currentMousePositionX-lastMousePositionX);
}
public static float getDY() {
return (float) (currentMousePositionY-lastMousePositionY);
}
public static float getDWheel() {
// TODO Auto-generated method stub
return (float) whellOffsetY;
}
@Override
public int run() {
// Run the rendering loop until the user has attempted to close
// the window or has pressed the ESCAPE key.
// while ( !glfwWindowShouldClose(window) ) {
// /*
// fps.tic();
// long currentFrameTime = getCurrentTime();
// delta = (currentFrameTime-lastFrameTime)/1000f;
// lastFrameTime = currentFrameTime;
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer
// if (this.drawer != null) {
// fps.incrementCounter();
// this.drawer.draw();
// }
// lastMousePositionX = currentMousePositionX;
// lastMousePositionY = currentMousePositionY;
// whellOffsetY = 0;
// whellOffsetY = 0;
// glfwSwapBuffers(window); // swap the color buffers
// // Poll for window events. The key callback above will only be
// // invoked during this call.
// glfwPollEvents();
// fps.toc();
// fps.draw();
// */
// OS_Draw(true);
// glfwSwapBuffers(window); // swap the color buffers
// glfwPollEvents();
// /*
// if (specialEventThatNeedARedraw == true) {
// X11_INFO("specialEventThatNeedARedraw = " << specialEventThatNeedARedraw);
// }
// hasDisplay = OS_Draw(specialEventThatNeedARedraw);
// if (hasDisplay == true) {
// // need to request it every time needed to have a redrawing (this can take some time if the application filter the drfaw periodicity)
// specialEventThatNeedARedraw = false;
// }
// */
// }
// System.exit(0);
return 0;
}
/****************************************************************************************/
@Override
public void setTitle(String title) {
// glfwSetWindowTitle(this.window, title);
}
@Override
public void setIcon(Uri inputFile) {
}
@Override
public void grabPointerEvents(boolean _status, Vector2f _forcedPosition) {
if (_status == true) {
// permit to leave the windows
//glfwSetInputMode(this.window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
// Not permit to leave the windows
// glfwSetInputMode(this.window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
lastPositionGrab = _forcedPosition.clone();
} else {
// glfwSetInputMode(this.window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
lastPositionGrab = null;
}
};
@Override
public boolean isGrabPointerEvents() { return lastPositionGrab != null; };
public static Context create(Application application, String[] arg) {
// TODO Auto-generated method stub
return new ContextJOGL(application, arg);
}
}

View File

@ -40,6 +40,7 @@ public class ContextLWJGL extends Context {
private static long lastFrameTime;
private static float delta;
private Vector2f lastPositionGrab = null; // is null when grabbing is disable ...
private Fps fps = new Fps("Main Loop", true);
@ -421,8 +422,16 @@ public class ContextLWJGL extends Context {
// }
}
private void cursorPosCallback(long window, double xpos, double ypos) {
cursorPos.x = (float)xpos;
cursorPos.y = /*m_currentHeight*/800.0f-(float)ypos;
if (lastPositionGrab != null) {
cursorPos.x = lastPositionGrab.x - (float)xpos;
cursorPos.y = -(lastPositionGrab.y - (float)ypos);
lastPositionGrab.x = (float)xpos;
lastPositionGrab.y = (float)ypos;
} else {
// TODO: use real size ... !!!!
cursorPos.x = (float)xpos;
cursorPos.y = /*m_currentHeight*/800.0f-(float)ypos;
}
// For compatibility of the Android system :
boolean findOne = false;
for (int iii=0; iii<MAX_MANAGE_INPUT; iii++) {
@ -577,10 +586,25 @@ public class ContextLWJGL extends Context {
public void setTitle(String title) {
glfwSetWindowTitle(this.window, title);
}
@Override
public void setIcon(Uri inputFile) {
}
@Override
public void grabPointerEvents(boolean _status, Vector2f _forcedPosition) {
if (_status == true) {
// permit to leave the windows
//glfwSetInputMode(this.window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
// Not permit to leave the windows
glfwSetInputMode(this.window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
lastPositionGrab = _forcedPosition.clone();
} else {
glfwSetInputMode(this.window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
lastPositionGrab = null;
}
};
@Override
public boolean isGrabPointerEvents() { return lastPositionGrab != null; };
public static Context create(Application application, String[] arg) {
// TODO Auto-generated method stub

View File

@ -0,0 +1,746 @@
package org.atriaSoft.gale.context.LWJG_AWT;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import java.nio.IntBuffer;
import org.atriaSoft.etk.Uri;
import org.atriaSoft.etk.math.Vector2f;
import org.atriaSoft.gale.Application;
import org.atriaSoft.gale.Fps;
import org.atriaSoft.gale.backend3d.OpenGL;
import org.atriaSoft.gale.context.Context;
import org.atriaSoft.gale.key.KeyKeyboard;
import org.atriaSoft.gale.key.KeySpecial;
import org.atriaSoft.gale.key.KeyStatus;
import org.atriaSoft.gale.key.KeyType;
import org.atriaSoft.gameEngine.Log;
import org.lwjgl.opengl.awt.AWTGLCanvas;
//import org.lwjgl.Version;
//import org.lwjgl.glfw.GLFWErrorCallback;
//import org.lwjgl.glfw.GLFWVidMode;
//import org.lwjgl.opengl.GL;
//import org.lwjgl.system.MemoryStack;
import org.lwjgl.opengl.awt.GLData;
import renderEngine.DisplayManagerDraw;
import static org.lwjgl.opengl.GL.*;
import static org.lwjgl.opengl.GL11.*;
public class ContextLWJGL_AWT extends Context implements MouseListener{
private boolean[] inputIsPressed = new boolean[MAX_MANAGE_INPUT];
private Vector2f cursorPos = new Vector2f(0, 0);
private static final int WIDTH = 800;
private static final int HEIGHT = 600;
private static final String TITLE = "Gale basic UI";
private static long lastFrameTime;
private static float delta;
private Vector2f lastPositionGrab = null; // is null when grabbing is disable ...
private Fps fps = new Fps("Main Loop", true);
private DisplayManagerDraw drawer = null;
private static double whellOffsetY;
private static double whellOffsetX;
private static boolean rightButtonStateDown = false;
private static boolean leftButtonStateDown = false;
private static double lastMousePositionX = 0;
private static double lastMousePositionY = 0;
private static double currentMousePositionX = 0;
private static double currentMousePositionY = 0;
// The window handle
private long window = 0;
private KeySpecial guiKeyBoardMode = new KeySpecial();
// Generic UI properties
private JFrame frame;
private GLData glData;
private AWTGLCanvas canvas;
public ContextLWJGL_AWT(Application application, String[] args) {
super(application, args);
System.out.println("Hello JOGL !");
initWindows();
// // This line is critical for LWJGL's interoperation with GLFW's
// // OpenGL context, or any context that is managed externally.
// // LWJGL detects the context that is current in the current thread,
// // creates the GLCapabilities instance and makes the OpenGL
// // bindings available for use.
// GL.createCapabilities();
// // Set the clear color
// glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
// glViewport(0, 0, (int)application.getSize().x, (int)application.getSize().y);
start2ndThreadProcessing();
}
public void setDrawer(DisplayManagerDraw drawer) {
this.drawer = drawer;
}
// public static Vector2f getSize() {
// return new Vector2f(WIDTH, HEIGHT);
// }
public void unInit() {
// // Free the window callbacks and destroy the window
// glfwFreeCallbacks(window);
// glfwDestroyWindow(window);
//
// // Terminate GLFW and free the error callback
// glfwTerminate();
// glfwSetErrorCallback(null).free();
}
private void initWindows() {
frame = new JFrame("Gale base");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.setPreferredSize(new Dimension(600, 600));
glData = new GLData();
glData.samples = 4;
glData.swapInterval = 0;
frame.addMouseListener(this);
frame.add(canvas = new AWTGLCanvas(glData) {
public void initGL() {
System.out.println("OpenGL version: " + effective.majorVersion + "." + effective.minorVersion + " (Profile: " + effective.profile + ")");
createCapabilities();
glClearColor(0.3f, 0.4f, 0.5f, 1);
}
public void paintGL() {
//Log.warning("Draw ... ");
int w = getWidth();
int h = getHeight();
float aspect = (float) w / h;
double now = System.currentTimeMillis() * 0.001;
float width = (float) Math.abs(Math.sin(now * 0.3));
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, w, h);
glBegin(GL_QUADS);
glColor3f(0.4f, 0.6f, 0.8f);
glVertex2f(-0.75f * width / aspect, 0.0f);
glVertex2f(0, -0.75f);
glVertex2f(+0.75f * width/ aspect, 0);
glVertex2f(0, +0.75f);
glEnd();
swapBuffers();
}
}, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
frame.transferFocus();
Runnable renderLoop = new Runnable() {
public void run() {
if (!canvas.isValid())
return;
canvas.render();
SwingUtilities.invokeLater(this);
}
};
SwingUtilities.invokeLater(renderLoop);
//OpenGL.setGlobalGLContext(glcanvas.getGL());
// // Make the new window
//
// frame = new Frame("CMSC427 - Project 1");
//
// GLProfile glp = GLProfile.getDefault();
// GLCapabilities caps = new GLCapabilities(glp);
// caps.setHardwareAccelerated(true);
// caps.setDoubleBuffered(false);
// caps.setAlphaBits(8);
// caps.setRedBits(8);
// caps.setBlueBits(8);
// caps.setGreenBits(8);
// caps.setOnscreen(false);
// GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
// drawable = factory.createOffscreenAutoDrawable(
// factory.getDefaultDevice(),
// caps,
// new DefaultGLCapabilitiesChooser(),
// 100,
// 100);
// drawable.display();
// drawable.getContext().makeCurrent();
// gl = drawable.getGL().getGL2();
// gl.glClearDepth(1.0f);
// gl.glDepthFunc(GL_LEQUAL);
// gl.glEnable(GL_DEPTH_TEST);
// gl.glShadeModel(GL_FLAT);
// gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
// glu = GLU.createGLU(gl);
// GLUquadric quadratic = glu.gluNewQuadric();
// glu.gluQuadricNormals(quadratic, GLU.GLU_SMOOTH);
// glu.gluQuadricTexture(quadratic, true);
// gl.glEnable(GL_COLOR_MATERIAL);
// gl.glDisable(GL_TEXTURE_2D);
//
// frame.add(drawable);
// // Setup an error callback. The default implementation
// // will print the error message in System.err.
// GLFWErrorCallback.createPrint(System.err).set();
//
// // Initialize GLFW. Most GLFW functions will not work before doing this.
// if ( !glfwInit() ) {
// throw new IllegalStateException("Unable to initialize GLFW");
// }
// // Configure GLFW
// glfwDefaultWindowHints(); // optional, the current window hints are already the default
// glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); // the window will stay hidden after creation
// glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // the window will be resizable
//
// // Create the window
// window = glfwCreateWindow((int)application.getSize().x, (int)application.getSize().y, application.getTitle(), NULL, NULL);
// if ( window == 0 ) {
// throw new RuntimeException("Failed to create the GLFW window");
// }
// // Setup a key callback. It will be called every time a key is pressed, repeated or released.
// // https://www.glfw.org/docs/latest/input_guide.html
// glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
// this.keyCallback(window, key, scancode, action, mods);
// });
// glfwSetWindowSizeCallback(window, (windows, sizeX, sizeY) -> {
// this.windowSizeCallback(window, sizeX, sizeY);
// });
//
// glfwSetCharCallback(window, (window, key) -> {
// this.charCallback(window, key);
// });
//
// glfwSetCursorPosCallback(window, (window, xpos, ypos) -> {
// this.cursorPosCallback(window, xpos, ypos);
// });
//
// glfwSetMouseButtonCallback(window, (window, button, action, mods) -> {
// this.mouseCallback(window, button, action, mods);
// });
//
// glfwSetScrollCallback(window, (window, xoffset, yoffset) -> {
// this.scrollCallback(window, xoffset, yoffset);
// });
//
//
// // Get the thread stack and push a new frame
// try ( MemoryStack stack = stackPush() ) {
// IntBuffer pWidth = stack.mallocInt(1); // int*
// IntBuffer pHeight = stack.mallocInt(1); // int*
//
// // Get the window size passed to glfwCreateWindow
// glfwGetWindowSize(window, pWidth, pHeight);
//
// // Get the resolution of the primary monitor
// GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
//
// // Center the window
// glfwSetWindowPos(
// window,
// (vidmode.width() - pWidth.get(0)) / 2,
// (vidmode.height() - pHeight.get(0)) / 2
// );
// } // the stack frame is popped automatically
//
// // Make the OpenGL context current
// glfwMakeContextCurrent(window);
// // Enable v-sync
// glfwSwapInterval(1);
//
// // Make the window visible
// glfwShowWindow(window);
lastFrameTime = getCurrentTime();
}
@Override
public void mouseClicked(MouseEvent e) {
System.out.println(e.getX());
System.out.println(e.getY());
Log.info("Mouse clicked:" + e.getX() + " " + e.getY());
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
Log.info("Mouse entered:" + e.getX() + " " + e.getY());
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
Log.info("Mouse exited:" + e.getX() + " " + e.getY());
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
Log.info("Mouse pressed:" + e.getX() + " " + e.getY());
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
Log.info("Mouse release:" + e.getX() + " " + e.getY());
}
// private void windowSizeCallback(long window2, int sizeX, int sizeY) {
// OS_Resize(new Vector2f(sizeX, sizeY));
// }
//
//
// private void charCallback(long window, int key) {;
// Log.error("keyboard char " + key + " " + (char)key);
// }
// private void keyCallback(long window, int key, int scancode, int action, int mods) {
// boolean find = true;
// boolean thisIsAReapeateKey = false; // TODO detect this ...
// KeyKeyboard keyInput = KeyKeyboard.unknow;
// Log.error("keyboard input " + key + " " + scancode);
// switch (key) {
// //case 328: // keypad
// case GLFW_KEY_UP: keyInput = KeyKeyboard.up; break;
// //case 324: // keypad
// case GLFW_KEY_LEFT: keyInput = KeyKeyboard.left; break;
// //case 326: // keypad
// case GLFW_KEY_RIGHT: keyInput = KeyKeyboard.right; break;
// //case 323: // keypad
// case GLFW_KEY_DOWN: keyInput = KeyKeyboard.down; break;
// case 329: // keypad
// case GLFW_KEY_PAGE_UP: keyInput = KeyKeyboard.pageUp; break;
// case 323: // keypad
// case GLFW_KEY_PAGE_DOWN: keyInput = KeyKeyboard.pageDown; break;
// case 327: // keypad
// case GLFW_KEY_HOME: keyInput = KeyKeyboard.start; break;
// case 321: // keypad
// case GLFW_KEY_END: keyInput = KeyKeyboard.end; break;
// case GLFW_KEY_PRINT_SCREEN: keyInput = KeyKeyboard.stopDefil; break;
// case GLFW_KEY_PAUSE: keyInput = KeyKeyboard.wait; break;
// case 320: // keypad
// case GLFW_KEY_INSERT:
// keyInput = KeyKeyboard.insert;
// if(action == GLFW_RELEASE) {
// if (guiKeyBoardMode.getInsert() == true) {
// guiKeyBoardMode.setInsert(false);
// } else {
// guiKeyBoardMode.setInsert(true);
// }
// }
// break;
// //case 84: keyInput = KeyboardCenter; break; // Keypad
// case GLFW_KEY_F1: keyInput = KeyKeyboard.f1; break;
// case GLFW_KEY_F2: keyInput = KeyKeyboard.f2; break;
// case GLFW_KEY_F3: keyInput = KeyKeyboard.f3; break;
// case GLFW_KEY_F4: keyInput = KeyKeyboard.f4; break;
// case GLFW_KEY_F5: keyInput = KeyKeyboard.f5; break;
// case GLFW_KEY_F6: keyInput = KeyKeyboard.f6; break;
// case GLFW_KEY_F7: keyInput = KeyKeyboard.f7; break;
// case GLFW_KEY_F8: keyInput = KeyKeyboard.f8; break;
// case GLFW_KEY_F9: keyInput = KeyKeyboard.f9; break;
// case GLFW_KEY_F10: keyInput = KeyKeyboard.f10; break;
// case GLFW_KEY_F11: keyInput = KeyKeyboard.f11; break;
// case GLFW_KEY_F12: keyInput = KeyKeyboard.f12; break;
// case GLFW_KEY_CAPS_LOCK: keyInput = KeyKeyboard.capLock; guiKeyBoardMode.setCapsLock (action == GLFW_PRESS); break;
// case GLFW_KEY_LEFT_SHIFT: keyInput = KeyKeyboard.shiftLeft; guiKeyBoardMode.setShiftLeft (action == GLFW_PRESS); break;
// case GLFW_KEY_RIGHT_SHIFT: keyInput = KeyKeyboard.shiftRight; guiKeyBoardMode.setShiftRight(action == GLFW_PRESS); break;
// case GLFW_KEY_LEFT_CONTROL: keyInput = KeyKeyboard.ctrlLeft; guiKeyBoardMode.setCtrlLeft (action == GLFW_PRESS); break;
// case GLFW_KEY_RIGHT_CONTROL: keyInput = KeyKeyboard.ctrlRight; guiKeyBoardMode.setCtrlRight (action == GLFW_PRESS); break;
// case GLFW_KEY_LEFT_SUPER: keyInput = KeyKeyboard.metaLeft; guiKeyBoardMode.setMetaLeft (action == GLFW_PRESS); break;
// case GLFW_KEY_RIGHT_SUPER: keyInput = KeyKeyboard.metaRight; guiKeyBoardMode.setMetaRight (action == GLFW_PRESS); break;
// case GLFW_KEY_LEFT_ALT: keyInput = KeyKeyboard.altLeft; guiKeyBoardMode.setAltLeft (action == GLFW_PRESS); break;
// case GLFW_KEY_RIGHT_ALT: keyInput = KeyKeyboard.altRight; guiKeyBoardMode.setAltRight (action == GLFW_PRESS); break;
// case GLFW_KEY_MENU: keyInput = KeyKeyboard.contextMenu; break;
// case GLFW_KEY_NUM_LOCK: keyInput = KeyKeyboard.numLock; guiKeyBoardMode.setNumLock (action == GLFW_PRESS); break;
// case GLFW_KEY_DELETE: // Suppr on keypad
// find = false;
// if(guiKeyBoardMode.getNumLock() == true){
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action == GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// '.');
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action != GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// '.');
// }
// } else {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action == GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)0x7F);
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action != GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)0x7F);
// }
// }
// break;
// case GLFW_KEY_TAB: // special case for TAB
// find = false;
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action == GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)0x09);
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action!=GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)0x09);
// }
// break;
// case GLFW_KEY_A:
// case GLFW_KEY_B:
// case GLFW_KEY_C:
// case GLFW_KEY_D:
// case GLFW_KEY_E:
// case GLFW_KEY_F:
// case GLFW_KEY_G:
// case GLFW_KEY_H:
// case GLFW_KEY_I:
// case GLFW_KEY_J:
// case GLFW_KEY_K:
// case GLFW_KEY_L:
// case GLFW_KEY_M:
// case GLFW_KEY_N:
// case GLFW_KEY_O:
// case GLFW_KEY_P:
// case GLFW_KEY_Q:
// case GLFW_KEY_R:
// case GLFW_KEY_S:
// case GLFW_KEY_T:
// case GLFW_KEY_U:
// case GLFW_KEY_V:
// case GLFW_KEY_W:
// case GLFW_KEY_X:
// case GLFW_KEY_Y:
// case GLFW_KEY_Z:
// {
// find = false;
// int tmpKey = key-GLFW_KEY_A + (int)'a';
// if (guiKeyBoardMode.getCapsLock() == true || guiKeyBoardMode.getShift() == true) {
// tmpKey += (int)'A' - (int)'a';
// }
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action==GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)tmpKey);
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action!=GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)tmpKey);
// }
// break;
// }
// case GLFW_KEY_1:
// case GLFW_KEY_2:
// case GLFW_KEY_3:
// case GLFW_KEY_4:
// case GLFW_KEY_5:
// case GLFW_KEY_6:
// case GLFW_KEY_7:
// case GLFW_KEY_8:
// case GLFW_KEY_9:
// case GLFW_KEY_0:
// {
// find = false;
// int tmpKey = key-GLFW_KEY_0 + (int)'0';
//// if (guiKeyBoardMode.getCapsLock() == true || guiKeyBoardMode.getShift() == true) {
//// tmpKey += (int)'A' - (int)'a';
//// }
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action==GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)tmpKey);
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// KeyKeyboard.character,
// (action!=GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey,
// (char)tmpKey);
// }
// }
// default:
// find = false;
//// {
//// char buf[11];
//// //GALE_DEBUG("Keycode: " << event.xkey.keycode);
//// // change keystate for simple reson of the ctrl error...
//// int32_t keyStateSave = event.xkey.state;
//// if (event.xkey.state & (1<<2) ) {
//// event.xkey.state = event.xkey.state & 0xFFFFFFFB;
//// }
//// KeySym keysym;
//// Status status = 0;
//// //int count = Xutf8LookupString(m_xic, (XKeyPressedEvent*)&event, buf, 10, &keysym, &status);
//// int count = Xutf8LookupString(m_xic, &event.xkey, buf, 10, &keysym, &status);
//// // retreave real keystate
//// event.xkey.state = keyStateSave;
//// buf[count] = '\0';
//// // Replace \r error ...
//// if (buf[0] == '\r') {
//// buf[0] = '\n';
//// buf[1] = '\0';
//// }
//// if (count >= 0) {
//// // repeated kay from previous element :
//// if (count > 0) {
//// // transform it in unicode
//// m_lastKeyPressed = utf8::convertChar32(buf);
//// }
//// X11_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << m_lastKeyPressed);
//// OS_setKeyboard(m_guiKeyBoardMode,
//// gale::key::keyboard::character,
//// (event.type==KeyPress?gale::key::status::down:gale::key::status::up),
//// thisIsAReapeateKey,
//// m_lastKeyPressed);
//// if (thisIsAReapeateKey == true) {
//// OS_setKeyboard(m_guiKeyBoardMode,
//// gale::key::keyboard::character,
//// (event.type!=KeyPress?gale::key::status::down:gale::key::status::up),
//// thisIsAReapeateKey,
//// m_lastKeyPressed);
//// }
//// } else {
//// GALE_WARNING("Unknow event Key : " << event.xkey.keycode << " res='" << buf << "' repeate=" << thisIsAReapeateKey);
//// }
//// }
//// break;
// }
// if (find == true) {
// OS_setKeyboard(guiKeyBoardMode,
// keyInput,
// (action == GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey);
// if (thisIsAReapeateKey == true) {
// OS_setKeyboard(guiKeyBoardMode,
// keyInput,
// (action!=GLFW_PRESS?KeyStatus.down:KeyStatus.up),
// thisIsAReapeateKey);
// }
// }
//// if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE ) {
//// glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
//// }
// }
// private void cursorPosCallback(long window, double xpos, double ypos) {
// if (lastPositionGrab != null) {
// cursorPos.x = lastPositionGrab.x - (float)xpos;
// cursorPos.y = -(lastPositionGrab.y - (float)ypos);
// lastPositionGrab.x = (float)xpos;
// lastPositionGrab.y = (float)ypos;
// } else {
// // TODO: use real size ... !!!!
// cursorPos.x = (float)xpos;
// cursorPos.y = /*m_currentHeight*/800.0f-(float)ypos;
// }
// // For compatibility of the Android system :
// boolean findOne = false;
// for (int iii=0; iii<MAX_MANAGE_INPUT; iii++) {
// if (inputIsPressed[iii] == true) {
// //Log.debug("X11 event: bt=" << iii << " " << event.type << " = \"MotionNotify\" (" << m_cursorEventX << "," << m_cursorEventY << ")");
// OS_SetInput(guiKeyBoardMode,
// KeyType.mouse,
// KeyStatus.move,
// iii,
// cursorPos);
// findOne = true;
// }
// }
// if (findOne == false) {
// //X11_DEBUG("X11 event: bt=" << 0 << " " << event.type << " = \"MotionNotify\" (" << m_cursorEventX << "," << m_cursorEventY << ")");
// OS_SetInput(guiKeyBoardMode,
// KeyType.mouse,
// KeyStatus.move,
// 0,
// cursorPos);
// }
// }
// private void scrollCallback(long window, double xoffset, double yoffset) {
// /*
// Log.error("scroll: " + xoffset + " " + yoffset);
// whellOffsetY += yoffset;
// whellOffsetX += xoffset;
// */
// if (yoffset<0) {
// inputIsPressed[5] = true;
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.down,
// 5,
// cursorPos);
// inputIsPressed[5] = false;
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.up,
// 5,
// cursorPos);
// } else if (yoffset>0) {
// inputIsPressed[4] = true;
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.down,
// 4,
// cursorPos);
// inputIsPressed[4] = false;
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.up,
// 4,
// cursorPos);
// }
// }
// private void mouseCallback(long window, int button, int action, int mods) {
// if (action == GLFW_PRESS) {
//// Log.info("mouse value: GLFW_PRESS " + action + " bt=" + button);
// if (button < MAX_MANAGE_INPUT) {
// inputIsPressed[button] = true;
// }
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.down,
// button,
// cursorPos);
// } else if (action == GLFW_RELEASE) {
//// Log.info("mouse value: GLFW_RELEASE" + action + " bt=" + button);
// leftButtonStateDown = false;
// if (button < MAX_MANAGE_INPUT) {
// inputIsPressed[button] = false;
// }
// OS_SetInput(guiKeyBoardMode,KeyType.mouse,
// KeyStatus.up,
// button,
// cursorPos);
//// } else {
//// Log.info("mouse value: ???" + action + " bt=" + button);
// }
// }
public static float getFrameTimeSecconds() {
return delta;
}
private static long getCurrentTime() {
return System.currentTimeMillis();
}
public static boolean isButtonRightDown() {
return rightButtonStateDown;
}
public static boolean isButtonLeftDown() {
return leftButtonStateDown;
}
public static float getDX() {
return (float) (currentMousePositionX-lastMousePositionX);
}
public static float getDY() {
return (float) (currentMousePositionY-lastMousePositionY);
}
public static float getDWheel() {
// TODO Auto-generated method stub
return (float) whellOffsetY;
}
@Override
public int run() {
// Run the rendering loop until the user has attempted to close
// the window or has pressed the ESCAPE key.
// while ( !glfwWindowShouldClose(window) ) {
// /*
// fps.tic();
// long currentFrameTime = getCurrentTime();
// delta = (currentFrameTime-lastFrameTime)/1000f;
// lastFrameTime = currentFrameTime;
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer
// if (this.drawer != null) {
// fps.incrementCounter();
// this.drawer.draw();
// }
// lastMousePositionX = currentMousePositionX;
// lastMousePositionY = currentMousePositionY;
// whellOffsetY = 0;
// whellOffsetY = 0;
// glfwSwapBuffers(window); // swap the color buffers
// // Poll for window events. The key callback above will only be
// // invoked during this call.
// glfwPollEvents();
// fps.toc();
// fps.draw();
// */
// OS_Draw(true);
// glfwSwapBuffers(window); // swap the color buffers
// glfwPollEvents();
// /*
// if (specialEventThatNeedARedraw == true) {
// X11_INFO("specialEventThatNeedARedraw = " << specialEventThatNeedARedraw);
// }
// hasDisplay = OS_Draw(specialEventThatNeedARedraw);
// if (hasDisplay == true) {
// // need to request it every time needed to have a redrawing (this can take some time if the application filter the drfaw periodicity)
// specialEventThatNeedARedraw = false;
// }
// */
// }
// System.exit(0);
return 0;
}
/****************************************************************************************/
@Override
public void setTitle(String title) {
this.frame.setTitle(title);
}
@Override
public void setIcon(Uri inputFile) {
}
@Override
public void grabPointerEvents(boolean _status, Vector2f _forcedPosition) {
if (_status == true) {
// permit to leave the windows
//glfwSetInputMode(this.window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
// Not permit to leave the windows
// glfwSetInputMode(this.window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
lastPositionGrab = _forcedPosition.clone();
} else {
// glfwSetInputMode(this.window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
lastPositionGrab = null;
}
};
@Override
public boolean isGrabPointerEvents() { return lastPositionGrab != null; };
public static Context create(Application application, String[] arg) {
// TODO Auto-generated method stub
return new ContextLWJGL_AWT(application, arg);
}
}

View File

@ -16,11 +16,11 @@ import org.atriaSoft.gale.Log;
import org.atriaSoft.gale.backend3d.OpenGL;
import org.atriaSoft.gale.backend3d.OpenGL.Usage;
import org.atriaSoft.gameEngine.Material;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
//import org.lwjgl.BufferUtils;
//import org.lwjgl.opengl.GL11;
//import org.lwjgl.opengl.GL13;
//import org.lwjgl.opengl.GL15;
//import org.lwjgl.opengl.GL20;
@ -597,48 +597,48 @@ public class ResourceProgram extends Resource {
// event if it was 0 == > set it to prevent other use of the previous shader display ...
OpenGL.programUse(this.program);
}
/**
* @brief set the testure Id on the specify uniform element.
* @param[in] idElem Id of the uniform that might be sended.
* @param[in] textureOpenGlID Real openGL texture ID
*/
public void setTexture0(int idElem, int textureOpenGlID){
if (this.exist == false) {
return;
}
if ( idElem < 0
|| (long)idElem > this.elementList.size()) {
return;
}
if (this.elementList.get(idElem).isLinked == false) {
return;
}
OpenGL.activeTexture(GL13.GL_TEXTURE0);
// set the textureID
GL13.glBindTexture(GL13.GL_TEXTURE_2D, textureOpenGlID);
// set the texture on the uniform attribute
GL20.glUniform1i(this.elementList.get(idElem).elementId, /*GLTEXTURE*/0);
this.hasTexture = true;
}
public void setTexture1(int idElem, int textureOpenGlID) {
if (this.exist == false) {
return;
}
if ( idElem < 0
|| (long)idElem > this.elementList.size()) {
return;
}
if (this.elementList.get(idElem).isLinked == false) {
return;
}
OpenGL.activeTexture(GL13.GL_TEXTURE1);
// set the textureID
GL13.glBindTexture(GL13.GL_TEXTURE_2D, textureOpenGlID);
// set the texture on the uniform attribute
GL20.glUniform1i(this.elementList.get(idElem).elementId, /*GLTEXTURE*/1);
this.hasTexture1 = true;
}
// /**
// * @brief set the testure Id on the specify uniform element.
// * @param[in] idElem Id of the uniform that might be sended.
// * @param[in] textureOpenGlID Real openGL texture ID
// */
// public void setTexture0(int idElem, int textureOpenGlID){
//
// if (this.exist == false) {
// return;
// }
// if ( idElem < 0
// || (long)idElem > this.elementList.size()) {
// return;
// }
// if (this.elementList.get(idElem).isLinked == false) {
// return;
// }
// OpenGL.activeTexture(GL13.GL_TEXTURE0);
// // set the textureID
// GL13.glBindTexture(GL13.GL_TEXTURE_2D, textureOpenGlID);
// // set the texture on the uniform attribute
// GL20.glUniform1i(this.elementList.get(idElem).elementId, /*GLTEXTURE*/0);
// this.hasTexture = true;
// }
// public void setTexture1(int idElem, int textureOpenGlID) {
// if (this.exist == false) {
// return;
// }
// if ( idElem < 0
// || (long)idElem > this.elementList.size()) {
// return;
// }
// if (this.elementList.get(idElem).isLinked == false) {
// return;
// }
// OpenGL.activeTexture(GL13.GL_TEXTURE1);
// // set the textureID
// GL13.glBindTexture(GL13.GL_TEXTURE_2D, textureOpenGlID);
// // set the texture on the uniform attribute
// GL20.glUniform1i(this.elementList.get(idElem).elementId, /*GLTEXTURE*/1);
// this.hasTexture1 = true;
// }
/**
* @brief Stop the processing of this program
*/
@ -648,10 +648,10 @@ public class ResourceProgram extends Resource {
if (this.exist == false) {
return;
}
for (Integer it : this.listOfVBOUsed) {
GL20.glDisableVertexAttribArray(it);
}
this.listOfVBOUsed.clear();
// for (Integer it : this.listOfVBOUsed) {
// GL20.glDisableVertexAttribArray(it);
// }
// this.listOfVBOUsed.clear();
// no need to disable program == > this only generate perturbation on speed ...
OpenGL.programUse(-1);
}

View File

@ -0,0 +1,131 @@
package org.atriaSoft.gameEngine;
import org.atriaSoft.etk.math.Vector2f;
import org.atriaSoft.etk.math.Vector3f;
import org.atriaSoft.gale.Gale;
import org.atriaSoft.gale.event.EventEntry;
import org.atriaSoft.gale.event.EventInput;
import org.atriaSoft.gale.event.EventTime;
import org.atriaSoft.gale.key.KeyKeyboard;
import org.atriaSoft.gale.key.KeyStatus;
import org.atriaSoft.gameEngine.camera.Camera;
import org.atriaSoft.gameEngine.components.ComponentPlayer;
import org.atriaSoft.gameEngine.components.ComponentPosition;
import org.atriaSoft.gameEngine.components.ComponentPositionPlayer;
import renderEngine.DisplayManager;
public class ControlCameraPlayer implements ControlInterface {
private Camera camera;
private float distanceFromCenter = 20;
private float angleZ = 0;
private float pitch = 0;
private Entity playerEntity;
private Vector2f lastMousePosition = null;
private ComponentPositionPlayer playerPosition;
private ComponentPlayer player;
private boolean moveUp = false;
private boolean moveDown = false;
private boolean moveLeft = false;
private boolean moveRight = false;
public ControlCameraPlayer(Camera camera, Entity playerEntity) {
this.camera = camera;
this.playerEntity = playerEntity;
this.playerPosition = (ComponentPositionPlayer)this.playerEntity.getComponent("position");
this.player = (ComponentPlayer)this.playerEntity.getComponent("player");
}
private boolean getState(KeyStatus state, boolean previousState) {
if (state == KeyStatus.down) {
return true;
}
if (state == KeyStatus.up) {
return false;
}
return previousState;
}
@Override
public boolean onEventEntry(EventEntry event) {
if(event.getType() == KeyKeyboard.up) {
moveUp = getState(event.getStatus(), moveUp);
}
if(event.getType() == KeyKeyboard.left) {
moveLeft = getState(event.getStatus(), moveLeft);
}
if(event.getType() == KeyKeyboard.right) {
moveRight = getState(event.getStatus(), moveRight);
}
if(event.getType() == KeyKeyboard.down) {
moveDown = getState(event.getStatus(), moveDown);
}
return false;
}
@Override
public boolean onEventInput(EventInput event, Vector2f relativePosition) {
// Log.info("" + event);
// TODO Auto-generated method stub
if (event.getInputId() == 4) {
if (event.getStatus() == KeyStatus.down) {
distanceFromCenter -= 1;
}
return true;
} else if (event.getInputId() == 5) {
if (event.getStatus() == KeyStatus.down) {
distanceFromCenter += 1;
}
return true;
}
// TODO: check if grabbing is enable ...
// in grabbing mouse only:
if (Gale.getContext().isGrabPointerEvents() == false) {
return false;
}
if (event.getStatus() == KeyStatus.move) {
Vector2f delta = event.getPosition().clone();
//angleZ += delta.x;
//this.camera.setYaw(this.camera.getYaw() + (float)Math.toRadians(delta.x));
this.camera.setPitch(this.camera.getPitch() + (float)Math.toRadians(delta.y));
if (this.camera.getPitch()>0) {
this.camera.setPitch(0);
}
if (this.camera.getPitch()<-Math.PI) {
this.camera.setPitch((float)-Math.PI);
}
this.camera.setRoll(this.camera.getRoll() - (float)Math.toRadians(delta.x));
Log.info("Change camera: " + this.camera.getYaw() + " " + this.camera.getPitch());
if (this.camera.getRoll()>Math.PI) {
this.camera.setRoll(this.camera.getRoll()-(float)Math.PI*2.0f);
}
if (this.camera.getRoll()<-Math.PI) {
this.camera.setRoll(this.camera.getRoll()+(float)Math.PI*2.0f);
}
this.playerPosition.setAngles(new Vector3f(0,0,this.camera.getRoll()));
}
return false;
}
@Override
public void periodicCall(EventTime event) {
float speed = 0;
if (moveUp != moveDown) {
if (moveUp) {
speed = this.player.getRunSpeed();
} else {
speed = -this.player.getRunSpeed();
}
}
float distance = speed * event.getTimeDeltaCallSecond();
float dx = (float) (distance * Math.sin(this.playerPosition.getAngles().z));
float dy = (float) (distance * Math.cos(this.playerPosition.getAngles().z));
Log.error("update position ..." + dx + " " + dy);
this.playerPosition.getTransform().getPosition().x += dx;
this.playerPosition.getTransform().getPosition().y += dy;
this.camera.getPosition().x = this.playerPosition.getTransform().getPosition().x;
this.camera.getPosition().y = this.playerPosition.getTransform().getPosition().y;
this.camera.getPosition().z = this.playerPosition.getTransform().getPosition().z;
}
}

View File

@ -21,6 +21,7 @@ import org.atriaSoft.gameEngine.engines.EngineDynamicMeshs;
import org.atriaSoft.gameEngine.engines.EngineLight;
import org.atriaSoft.gameEngine.engines.EngineParticle;
import org.atriaSoft.gameEngine.engines.EnginePhysics;
import org.atriaSoft.gameEngine.engines.EnginePlayer;
//import org.atriaSoft.gameEngine.resource.Mesh;
public class Environement {
@ -41,6 +42,7 @@ public class Environement {
public Environement() {
// we add the 4 classical engines (the order is used to the global rendering cycle ...
addEngine(new EnginePlayer(this));
addEngine(new EnginePhysics(this));
addEngine(new EngineAI(this));
addEngine(new EngineDynamicMeshs(this));

View File

@ -0,0 +1,50 @@
package org.atriaSoft.gameEngine.components;
import org.atriaSoft.gameEngine.Component;
import org.atriaSoft.gameEngine.engines.EnginePlayer;
public class ComponentPlayer extends Component {
private float runSpeed = 35;
private float turnSpeed = (float)Math.toRadians(120);
private float jumpPower = 30;
public ComponentPlayer() {
}
@Override
public String getType() {
// TODO Auto-generated method stub
return EnginePlayer.ENGINE_NAME;
}
public void update(float timeStep) {
}
public float getRunSpeed() {
return runSpeed;
}
public void setRunSpeed(float runSpeed) {
this.runSpeed = runSpeed;
}
public float getTurnSpeed() {
return turnSpeed;
}
public void setTurnSpeed(float turnSpeed) {
this.turnSpeed = turnSpeed;
}
public float getJumpPower() {
return jumpPower;
}
public void setJumpPower(float jumpPower) {
this.jumpPower = jumpPower;
}
}

View File

@ -0,0 +1,29 @@
package org.atriaSoft.gameEngine.components;
import org.atriaSoft.etk.math.Transform3D;
import org.atriaSoft.etk.math.Vector3f;
public class ComponentPositionPlayer extends ComponentPosition {
private Vector3f angles = new Vector3f(0,0,0);
public ComponentPositionPlayer() {
super();
}
public ComponentPositionPlayer(Transform3D transform) {
super(transform);
// TODO: deduce angle of the player
}
public Vector3f getAngles() {
return angles;
}
public void setAngles(Vector3f angles) {
this.angles = angles;
// TODO: update transform3D
this.transform.getOrientation().setEulerAngles(this.angles);
}
}

View File

@ -0,0 +1,56 @@
package org.atriaSoft.gameEngine.engines;
import java.util.Vector;
import org.atriaSoft.gameEngine.Component;
import org.atriaSoft.gameEngine.Engine;
import org.atriaSoft.gameEngine.Environement;
import org.atriaSoft.gameEngine.Log;
import org.atriaSoft.gameEngine.camera.Camera;
import org.atriaSoft.gameEngine.components.ComponentPlayer;
public class EnginePlayer extends Engine {
public static final String ENGINE_NAME = "player";
private Vector<ComponentPlayer> components = new Vector<ComponentPlayer>();
public EnginePlayer(Environement env) {
super(env);
// TODO Auto-generated constructor stub
}
@Override
public void componentRemove(Component ref) {
components.remove(ref);
}
@Override
public void componentAdd(Component ref) {
if (ref instanceof ComponentPlayer == false) {
return;
}
components.add((ComponentPlayer)ref);
}
@Override
public void update(long deltaMili) {
for (ComponentPlayer it: components) {
it.update(deltaMili);
}
}
@Override
public void render(long deltaMili, Camera camera) {
// nothing to do ...
}
@Override
public void renderDebug(long deltaMili, Camera camera) {
// nothing to do ...
}
@Override
public String getType() {
// TODO Auto-generated method stub
return ENGINE_NAME;
}
}

View File

@ -8,9 +8,11 @@ import org.atriaSoft.etk.math.Transform3D;
import org.atriaSoft.etk.math.Vector2f;
import org.atriaSoft.etk.math.Vector3f;
import org.atriaSoft.gale.Application;
import org.atriaSoft.gale.Gale;
import org.atriaSoft.gale.backend3d.OpenGL;
import org.atriaSoft.gale.backend3d.OpenGL.Flag;
import org.atriaSoft.gale.context.Context;
import org.atriaSoft.gameEngine.ControlCameraPlayer;
import org.atriaSoft.gameEngine.ControlCameraSimple;
import org.atriaSoft.gameEngine.Entity;
import org.atriaSoft.gameEngine.Environement;
@ -21,7 +23,9 @@ import org.atriaSoft.gameEngine.camera.Camera;
import org.atriaSoft.gameEngine.components.ComponentLight;
import org.atriaSoft.gameEngine.components.ComponentLightSun;
import org.atriaSoft.gameEngine.components.ComponentMaterial;
import org.atriaSoft.gameEngine.components.ComponentPlayer;
import org.atriaSoft.gameEngine.components.ComponentPosition;
import org.atriaSoft.gameEngine.components.ComponentPositionPlayer;
import org.atriaSoft.gameEngine.components.ComponentRenderColoredStaticMesh;
import org.atriaSoft.gameEngine.components.ComponentRenderTexturedMaterialsStaticMesh;
import org.atriaSoft.gameEngine.components.ComponentRenderTexturedStaticMesh;
@ -41,16 +45,18 @@ public class LoxelApplication extends Application {
private Quaternion basicRotation = Quaternion.identity();
private Quaternion basicRotation2 = Quaternion.identity();
private boolean creationDone;
private ControlCameraSimple simpleControl;
private ControlCameraPlayer simpleControl;
private Material materialCube;
private ComponentPosition lightPosition;
private float angleLight = 0;
private MapVoxel map;
private ComponentPlayer objectPlayer;
public LoxelApplication(){
creationDone = false;
}
@Override
public void onCreate(Context _context) {
Gale.getContext().grabPointerEvents(true, new Vector2f(0,0));
env = new Environement();
this.canDraw = true;
setSize(new Vector2f(800, 600));
@ -67,7 +73,7 @@ public class LoxelApplication extends Application {
// add a cube to show where in the light ...
Entity localLight = new Entity(this.env);
lightPosition = new ComponentPosition(new Transform3D(new Vector3f(-10,-10,0)));
lightPosition = new ComponentPosition(new Transform3D(new Vector3f(-10,-10,17)));
localLight.addComponent(lightPosition);
localLight.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
localLight.addComponent(new ComponentTexture(new Uri("RES", "grass.png")));
@ -78,25 +84,26 @@ public class LoxelApplication extends Application {
env.addEntity(localLight);
Entity gird = new Entity(this.env);
gird.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0,0,0))));
gird.addComponent(new ComponentPosition(new Transform3D(new Vector3f(0,0,13))));
gird.addComponent(new ComponentStaticMesh(MeshGenerator.createGrid(5)));
gird.addComponent(new ComponentRenderColoredStaticMesh(
new Uri("DATA_EGE", "wireColor.vert"),
new Uri("DATA_EGE", "wireColor.frag")));
env.addEntity(gird);
Entity basicTree = new Entity(this.env);
objectPosition = new ComponentPosition(new Transform3D(new Vector3f(0,0,0)));
basicTree.addComponent(objectPosition);
materialCube = new Material();
basicTree.addComponent(new ComponentMaterial(materialCube));
basicTree.addComponent(new ComponentStaticMesh(new Uri("RES", "cube.obj")));
basicTree.addComponent(new ComponentTexture(new Uri("RES", "grass.png")));
basicTree.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(
new Uri("DATA", "basicMaterial.vert"),
new Uri("DATA", "basicMaterial.frag"),
(EngineLight)env.getEngine(EngineLight.ENGINE_NAME)));
env.addEntity(basicTree);
Entity player = new Entity(this.env);
objectPosition = new ComponentPositionPlayer(new Transform3D(new Vector3f(16,16,15)));
player.addComponent(objectPosition);
objectPlayer = new ComponentPlayer();
player.addComponent(objectPlayer);
player.addComponent(new ComponentMaterial(new Material()));
player.addComponent(new ComponentStaticMesh(new Uri("RES", "person.obj")));
player.addComponent(new ComponentTexture(new Uri("RES", "playerTexture.png")));
// player.addComponent(new ComponentRenderTexturedMaterialsStaticMesh(
// new Uri("DATA", "basicMaterial.vert"),
// new Uri("DATA", "basicMaterial.frag"),
// (EngineLight)env.getEngine(EngineLight.ENGINE_NAME)));
env.addEntity(player);
Camera mainView = new Camera();
@ -104,7 +111,7 @@ public class LoxelApplication extends Application {
mainView.setPitch((float)Math.PI*-0.25f);
mainView.setPosition(new Vector3f(0,-5,5));
this.simpleControl = new ControlCameraSimple(mainView);
this.simpleControl = new ControlCameraPlayer(mainView, player);
env.addControlInterface(simpleControl);
// start the engine.
@ -128,8 +135,8 @@ public class LoxelApplication extends Application {
//objectPosition.getTransform().applyRotation(basicRotation);
//objectPosition.getTransform().applyRotation(basicRotation2);
angleLight += 0.01;
lightPosition.getTransform().getPosition().x = (float)Math.cos(angleLight) * 7.0f;
lightPosition.getTransform().getPosition().y = (float)Math.sin(angleLight) * 7.0f;
lightPosition.getTransform().getPosition().x = 5 + (float)Math.cos(angleLight) * 7.0f;
lightPosition.getTransform().getPosition().y = 5 + (float)Math.sin(angleLight) * 7.0f;
env.periodicCall();
markDrawingIsNeeded();
}
@ -154,7 +161,7 @@ public class LoxelApplication extends Application {
OpenGL.setViewPort(new Vector2f(0,0), size);
// clear background
Color bgColor = new Color(0.0f, 1.0f, 0.0f, 1.0f);
Color bgColor = new Color(0.18f, 0.43f, 0.95f, 1.0f);
OpenGL.clearColor(bgColor);
// real clear request:
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
@ -179,6 +186,9 @@ public class LoxelApplication extends Application {
KeyKeyboard type,
Character value,
KeyStatus state) {
if (type == KeyKeyboard.f1 ) {
Gale.getContext().grabPointerEvents(false, new Vector2f(0,0));
}
env.onKeyboard(special, type, value, state);
}
}