Compare commits
2 Commits
a9899d82e7
...
e72f6b3449
Author | SHA1 | Date | |
---|---|---|---|
e72f6b3449 | |||
49aae1461e |
750
.classpath
750
.classpath
@ -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
BIN
lib/jogamp-fat.jar
Normal file
Binary file not shown.
BIN
lib/lwjgl3-awt-0.1.7-javadoc.jar
Normal file
BIN
lib/lwjgl3-awt-0.1.7-javadoc.jar
Normal file
Binary file not shown.
BIN
lib/lwjgl3-awt-0.1.7-sources.jar
Normal file
BIN
lib/lwjgl3-awt-0.1.7-sources.jar
Normal file
Binary file not shown.
BIN
lib/lwjgl3-awt-0.1.7.jar
Normal file
BIN
lib/lwjgl3-awt-0.1.7.jar
Normal file
Binary file not shown.
BIN
res/person.blend
BIN
res/person.blend
Binary file not shown.
12
res/person_-xfw_zup.mtl
Normal file
12
res/person_-xfw_zup.mtl
Normal file
@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'person.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material
|
||||
Ns 225.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
1082
res/person_-xfw_zup.obj
Normal file
1082
res/person_-xfw_zup.obj
Normal file
File diff suppressed because it is too large
Load Diff
12
res/person_-yfw_zup.mtl
Normal file
12
res/person_-yfw_zup.mtl
Normal file
@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'person.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material
|
||||
Ns 225.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.000000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
1082
res/person_-yfw_zup.obj
Normal file
1082
res/person_-yfw_zup.obj
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 10 KiB |
@ -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;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
package org.atriaSoft.etk;
|
||||
|
||||
public class Color {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Color [r=" + r + ", g=" + g + ", b=" + b + ", a=" + a + "]";
|
||||
}
|
||||
public float r;
|
||||
public float g;
|
||||
public float b;
|
||||
|
@ -1,13 +1,16 @@
|
||||
package org.atriaSoft.etk.math;
|
||||
|
||||
public class Vector3f {
|
||||
public float x = 0;
|
||||
public float y = 0;
|
||||
public float z = 0;
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
/**
|
||||
* @brief Default contructor
|
||||
*/
|
||||
public Vector3f() {
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.z = 0;
|
||||
}
|
||||
/**
|
||||
* @brief Constructor from scalars
|
||||
|
@ -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;
|
||||
|
@ -15,6 +15,7 @@ import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL40;
|
||||
import org.atriaSoft.etk.math.Matrix4f;
|
||||
import org.atriaSoft.etk.math.Vector2f;
|
||||
import org.atriaSoft.etk.math.Vector2i;
|
||||
@ -492,13 +493,13 @@ public class OpenGL {
|
||||
/**
|
||||
* @brief draw a specific array == > this enable mode difference ...
|
||||
*/
|
||||
// public static void drawArrays(RenderMode mode, int first, int count) {
|
||||
// if (this.programId >= 0) {
|
||||
// updateAllFlags();
|
||||
// GL20.glDrawArrays(convertRenderMode.get(mode), first, count);
|
||||
// checkGlError("glDrawArrays");
|
||||
// }
|
||||
// }
|
||||
public static void drawArrays(RenderMode mode, int first, int count) {
|
||||
if (programId >= 0) {
|
||||
updateAllFlags();
|
||||
GL20.glDrawArrays(convertRenderMode.get(mode), first, count);
|
||||
checkGlError("glDrawArrays");
|
||||
}
|
||||
}
|
||||
// public static void drawElements(RenderMode mode, List<Integer> indices) {
|
||||
// if (this.programId >= 0) {
|
||||
// updateAllFlags();
|
||||
@ -837,7 +838,7 @@ public class OpenGL {
|
||||
}
|
||||
|
||||
public static void programLoadUniformColor(int location, Color value) {
|
||||
GL20.glUniform3f(location, value.r, value.g, value.b);
|
||||
GL20.glUniform4f(location, value.r, value.g, value.b, value.a);
|
||||
}
|
||||
|
||||
public static void programLoadUniformVector(int location, Vector3f value) {
|
||||
@ -868,5 +869,8 @@ public class OpenGL {
|
||||
public static void drawElements(RenderMode mode, int vertexCount) {
|
||||
GL11.glDrawElements(convertRenderMode.get(mode), vertexCount, GL11.GL_UNSIGNED_INT, 0);
|
||||
}
|
||||
public static void setDeathMask(boolean state) {
|
||||
GL40.glDepthMask(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
881
src/org/atriaSoft/gale/backend3d/OpenGL_jogl.java
Normal file
881
src/org/atriaSoft/gale/backend3d/OpenGL_jogl.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
@ -531,7 +531,7 @@ public abstract class Context {
|
||||
public void stop() {
|
||||
Log.warning("stop: NOT implemented for this platform...");
|
||||
}
|
||||
protected Vector2f windowsSize; //!< current size of the system
|
||||
protected Vector2f windowsSize = new Vector2f(0,0); //!< current size of the system
|
||||
/**
|
||||
* @brief get the current windows size
|
||||
* @return the current size ...
|
||||
@ -568,12 +568,16 @@ public abstract class Context {
|
||||
public void setSize( Vector2f _size){
|
||||
Log.info("setSize: NOT implemented ...");
|
||||
};
|
||||
protected boolean fullscreen = false;
|
||||
/**
|
||||
* @brief The application request a change of his current size force the fullscreen mode.
|
||||
* @param[in] _status status of the fullscreen mode.
|
||||
*/
|
||||
public void setFullScreen(boolean _status){
|
||||
Log.info("setFullScreen: NOT implemented ...");
|
||||
fullscreen = _status;
|
||||
};
|
||||
public boolean getFullScreen(){
|
||||
return fullscreen;
|
||||
};
|
||||
protected Vector2f windowsPos; //!< current size of the system
|
||||
/**
|
||||
@ -733,6 +737,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.
|
||||
|
722
src/org/atriaSoft/gale/context/JOGL/ContextJOGL.java
Normal file
722
src/org/atriaSoft/gale/context/JOGL/ContextJOGL.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
|
629
src/org/atriaSoft/gale/context/LWJG_AWT/ContextLWJGL_AWT.java
Normal file
629
src/org/atriaSoft/gale/context/LWJG_AWT/ContextLWJGL_AWT.java
Normal file
@ -0,0 +1,629 @@
|
||||
package org.atriaSoft.gale.context.LWJG_AWT;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.MemoryImageSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import java.awt.Robot;
|
||||
|
||||
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.GL11;
|
||||
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, MouseMotionListener, KeyListener, MouseWheelListener {
|
||||
private boolean[] inputIsPressed = new boolean[MAX_MANAGE_INPUT];
|
||||
private Vector2f decoratedWindowsSize = new Vector2f(0, 0);
|
||||
private Vector2f cursorPos = new Vector2f(0, 0);
|
||||
private Vector2f cursorSize = 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 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;
|
||||
private Robot robot = null;
|
||||
public ContextLWJGL_AWT(Application application, String[] args) {
|
||||
super(application, args);
|
||||
System.out.println("Hello JOGL !");
|
||||
initWindows();
|
||||
start2ndThreadProcessing();
|
||||
}
|
||||
|
||||
|
||||
public void setDrawer(DisplayManagerDraw drawer) {
|
||||
this.drawer = drawer;
|
||||
}
|
||||
|
||||
public void unInit() {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private void initWindows() {
|
||||
frame = new JFrame("Gale base");
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLayout(new BorderLayout());
|
||||
frame.setPreferredSize(new Dimension(800, 600));
|
||||
glData = new GLData();
|
||||
glData.samples = 4;
|
||||
glData.swapInterval = 0;
|
||||
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);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
public void paintGL() {
|
||||
//Log.warning("Draw ... ");
|
||||
int w = getWidth();
|
||||
int h = getHeight();
|
||||
if (decoratedWindowsSize.x != w || decoratedWindowsSize.y != h) {
|
||||
decoratedWindowsSize.x = w;
|
||||
decoratedWindowsSize.y = h;
|
||||
Rectangle bounds = canvas.getBounds();
|
||||
windowsSize.x = bounds.width;
|
||||
windowsSize.y = bounds.height;
|
||||
OS_Resize(windowsSize);
|
||||
}
|
||||
OS_Draw(true);
|
||||
swapBuffers();
|
||||
}
|
||||
}, BorderLayout.CENTER);
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
canvas.requestFocus();
|
||||
canvas.addMouseListener(this);
|
||||
canvas.addMouseMotionListener(this);
|
||||
canvas.addKeyListener(this);
|
||||
canvas.addMouseWheelListener(this);
|
||||
frame.transferFocus();
|
||||
|
||||
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());
|
||||
cursorPos.x = e.getX();
|
||||
cursorPos.y = e.getY();
|
||||
OS_SetInput(guiKeyBoardMode,
|
||||
KeyType.mouse,
|
||||
KeyStatus.enter,
|
||||
0,
|
||||
cursorPos);
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
//Log.info("Mouse exited:" + e.getX() + " " + e.getY());
|
||||
cursorPos.x = e.getX();
|
||||
cursorPos.y = e.getY();
|
||||
OS_SetInput(guiKeyBoardMode,
|
||||
KeyType.mouse,
|
||||
KeyStatus.leave,
|
||||
0,
|
||||
cursorPos);
|
||||
//this.frame.mouseMove(e, 200, 200);
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
Log.info("Mouse pressed:" + e.getX() + " " + e.getY());
|
||||
int button = e.getButton();
|
||||
cursorPos.x = e.getX();
|
||||
cursorPos.y = e.getY();
|
||||
if (button < MAX_MANAGE_INPUT) {
|
||||
inputIsPressed[button] = true;
|
||||
}
|
||||
OS_SetInput(guiKeyBoardMode,
|
||||
KeyType.mouse,
|
||||
KeyStatus.down,
|
||||
button,
|
||||
cursorPos);
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
//Log.info("Mouse release:" + e.getX() + " " + e.getY());
|
||||
// Log.info("mouse value: GLFW_RELEASE" + action + " bt=" + button);
|
||||
int button = e.getButton();
|
||||
cursorPos.x = e.getX();
|
||||
cursorPos.y = e.getY();
|
||||
if (button < MAX_MANAGE_INPUT) {
|
||||
inputIsPressed[button] = false;
|
||||
}
|
||||
OS_SetInput(guiKeyBoardMode,
|
||||
KeyType.mouse,
|
||||
KeyStatus.up,
|
||||
button,
|
||||
cursorPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
//Log.error("mouse drag ... " + e);
|
||||
mouseMoved(e);
|
||||
}
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
//Log.info("Mouse moved:" + e.getX() + " " + e.getY() + " " + e);
|
||||
if (this.robot != null) {
|
||||
Rectangle bounds = frame.getBounds();
|
||||
//Log.error(" " + bounds + " windows=" + windowsSize + " deco= " + decoratedWindowsSize);
|
||||
float refPosX = bounds.x + bounds.width/2;
|
||||
float refPosY = bounds.y + bounds.height/2;
|
||||
if (e.getXOnScreen() == (int)refPosX
|
||||
&& e.getYOnScreen() == (int)refPosY) {
|
||||
cursorPos.x = 0;
|
||||
cursorPos.y = 0;
|
||||
return;
|
||||
} else {
|
||||
//Log.error(" " + bounds + " windows=" + windowsSize + " deco= " + decoratedWindowsSize);
|
||||
cursorPos.x = -((float)e.getXOnScreen() - refPosX);
|
||||
cursorPos.y = (float)e.getYOnScreen() - refPosY;
|
||||
robot.mouseMove((int)refPosX, (int)refPosY);
|
||||
}
|
||||
Log.info("delta moved:" + cursorPos);
|
||||
} else {
|
||||
// TODO: use real size ... !!!!
|
||||
cursorPos.x = (float)e.getX();
|
||||
cursorPos.y = cursorSize.y - (float)e.getY();
|
||||
}
|
||||
// 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 List<Integer> pressedKey = new ArrayList<Integer>();
|
||||
|
||||
private int getUniqueIndex(KeyEvent e) {
|
||||
int internalKeyValue = e.getKeyCode();
|
||||
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
||||
internalKeyValue += 100000000;
|
||||
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
||||
internalKeyValue += 200000000;
|
||||
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD) {
|
||||
internalKeyValue += 300000000;
|
||||
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_STANDARD) {
|
||||
internalKeyValue += 400000000;
|
||||
}
|
||||
return internalKeyValue;
|
||||
}
|
||||
public void keyPressed(KeyEvent e) {
|
||||
int internalKeyValue = getUniqueIndex(e);
|
||||
int index = pressedKey.indexOf(internalKeyValue);
|
||||
if (index == -1) {
|
||||
pressedKey.add(internalKeyValue);
|
||||
}
|
||||
keyEvent(e, true, index != -1);
|
||||
}
|
||||
public void keyReleased(KeyEvent e) {
|
||||
int internalKeyValue = getUniqueIndex(e);
|
||||
int index = pressedKey.indexOf(internalKeyValue);
|
||||
if (index == -1) {
|
||||
pressedKey.remove(internalKeyValue);
|
||||
}
|
||||
keyEvent(e, false, false);
|
||||
}
|
||||
public void keyEvent(KeyEvent e, boolean pressed, boolean thisIsAReapeateKey) {
|
||||
//Log.info("event " + thisIsAReapeateKey + " " + e.getKeyCode() + " " + e);
|
||||
boolean find = true;
|
||||
KeyKeyboard keyInput = KeyKeyboard.unknow;
|
||||
//Log.error("keyboard input " + e.getWhen() + " " + e.getKeyCode() + " " + e.getKeyLocation());
|
||||
switch (e.getKeyCode()) {
|
||||
//case 328: // keypad
|
||||
case KeyEvent.VK_UP: keyInput = KeyKeyboard.up; break;
|
||||
//case 324: // keypad
|
||||
case KeyEvent.VK_LEFT: keyInput = KeyKeyboard.left; break;
|
||||
//case 326: // keypad
|
||||
case KeyEvent.VK_RIGHT: keyInput = KeyKeyboard.right; break;
|
||||
//case 323: // keypad
|
||||
case KeyEvent.VK_DOWN: keyInput = KeyKeyboard.down; break;
|
||||
//case 329: // keypad
|
||||
case KeyEvent.VK_PAGE_UP: keyInput = KeyKeyboard.pageUp; break;
|
||||
//case 323: // keypad
|
||||
case KeyEvent.VK_PAGE_DOWN: keyInput = KeyKeyboard.pageDown; break;
|
||||
//case 327: // keypad
|
||||
case KeyEvent.VK_HOME: keyInput = KeyKeyboard.start; break;
|
||||
//case 321: // keypad
|
||||
case KeyEvent.VK_END: keyInput = KeyKeyboard.end; break;
|
||||
case KeyEvent.VK_PRINTSCREEN:keyInput = KeyKeyboard.stopDefil; break;
|
||||
case KeyEvent.VK_PAUSE: keyInput = KeyKeyboard.wait; break;
|
||||
//case 320: // keypad
|
||||
case KeyEvent.VK_INSERT:
|
||||
keyInput = KeyKeyboard.insert;
|
||||
if(pressed == false) {
|
||||
if (guiKeyBoardMode.getInsert() == true) {
|
||||
guiKeyBoardMode.setInsert(false);
|
||||
} else {
|
||||
guiKeyBoardMode.setInsert(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
//case 84: keyInput = KeyboardCenter; break; // Keypad
|
||||
case KeyEvent.VK_F1: keyInput = KeyKeyboard.f1; break;
|
||||
case KeyEvent.VK_F2: keyInput = KeyKeyboard.f2; break;
|
||||
case KeyEvent.VK_F3: keyInput = KeyKeyboard.f3; break;
|
||||
case KeyEvent.VK_F4: keyInput = KeyKeyboard.f4; break;
|
||||
case KeyEvent.VK_F5: keyInput = KeyKeyboard.f5; break;
|
||||
case KeyEvent.VK_F6: keyInput = KeyKeyboard.f6; break;
|
||||
case KeyEvent.VK_F7: keyInput = KeyKeyboard.f7; break;
|
||||
case KeyEvent.VK_F8: keyInput = KeyKeyboard.f8; break;
|
||||
case KeyEvent.VK_F9: keyInput = KeyKeyboard.f9; break;
|
||||
case KeyEvent.VK_F10: keyInput = KeyKeyboard.f10; break;
|
||||
case KeyEvent.VK_F11: keyInput = KeyKeyboard.f11; break;
|
||||
case KeyEvent.VK_F12: keyInput = KeyKeyboard.f12; break;
|
||||
case KeyEvent.VK_CAPS_LOCK:
|
||||
keyInput = KeyKeyboard.capLock;
|
||||
guiKeyBoardMode.setCapsLock(pressed == true);
|
||||
break;
|
||||
case KeyEvent.VK_SHIFT:
|
||||
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
||||
keyInput = KeyKeyboard.shiftLeft; guiKeyBoardMode.setShiftLeft (pressed == true); break;
|
||||
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
|
||||
keyInput = KeyKeyboard.shiftLeft; guiKeyBoardMode.setShiftRight (pressed == true); break;
|
||||
}
|
||||
case KeyEvent.VK_CONTROL:
|
||||
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
||||
keyInput = KeyKeyboard.ctrlLeft; guiKeyBoardMode.setCtrlLeft (pressed == true); break;
|
||||
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
|
||||
keyInput = KeyKeyboard.ctrlRight; guiKeyBoardMode.setCtrlRight (pressed == true); break;
|
||||
}
|
||||
case KeyEvent.VK_META:
|
||||
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_LEFT) {
|
||||
keyInput = KeyKeyboard.metaLeft; guiKeyBoardMode.setMetaLeft (pressed == true); break;
|
||||
} else if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_RIGHT) {
|
||||
keyInput = KeyKeyboard.metaRight; guiKeyBoardMode.setMetaRight (pressed == true); break;
|
||||
}
|
||||
case KeyEvent.VK_ALT:
|
||||
keyInput = KeyKeyboard.altLeft;
|
||||
guiKeyBoardMode.setAltLeft(pressed == true);
|
||||
break;
|
||||
case KeyEvent.VK_ALT_GRAPH:
|
||||
keyInput = KeyKeyboard.altRight;
|
||||
guiKeyBoardMode.setAltRight(pressed == true);
|
||||
break;
|
||||
case KeyEvent.VK_CONTEXT_MENU:
|
||||
keyInput = KeyKeyboard.contextMenu;
|
||||
break;
|
||||
case KeyEvent.VK_NUM_LOCK:
|
||||
keyInput = KeyKeyboard.numLock;
|
||||
guiKeyBoardMode.setNumLock(pressed == true);
|
||||
break;
|
||||
case KeyEvent.VK_DELETE: // Suppr on keypad
|
||||
find = false;
|
||||
if(guiKeyBoardMode.getNumLock() == true){
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
KeyKeyboard.character,
|
||||
(pressed != true?KeyStatus.down:KeyStatus.up),
|
||||
thisIsAReapeateKey,
|
||||
'.');
|
||||
}
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
KeyKeyboard.character,
|
||||
(pressed == true?KeyStatus.down:KeyStatus.up),
|
||||
thisIsAReapeateKey,
|
||||
'.');
|
||||
} else {
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
KeyKeyboard.character,
|
||||
(pressed != true?KeyStatus.down:KeyStatus.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)0x7F);
|
||||
}
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
KeyKeyboard.character,
|
||||
(pressed == true?KeyStatus.down:KeyStatus.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)0x7F);
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_TAB: // special case for TAB
|
||||
find = false;
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
KeyKeyboard.character,
|
||||
(pressed==false?KeyStatus.down:KeyStatus.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)0x09);
|
||||
}
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
KeyKeyboard.character,
|
||||
(pressed == true?KeyStatus.down:KeyStatus.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)0x09);
|
||||
break;
|
||||
default:
|
||||
find = false;
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
KeyKeyboard.character,
|
||||
(pressed==false?KeyStatus.down:KeyStatus.up),
|
||||
thisIsAReapeateKey,
|
||||
e.getKeyChar());
|
||||
}
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
KeyKeyboard.character,
|
||||
(pressed==true?KeyStatus.down:KeyStatus.up),
|
||||
thisIsAReapeateKey,
|
||||
e.getKeyChar());
|
||||
}
|
||||
if (find == true) {
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
keyInput,
|
||||
(pressed==false?KeyStatus.down:KeyStatus.up),
|
||||
thisIsAReapeateKey);
|
||||
}
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
keyInput,
|
||||
(pressed == true?KeyStatus.down:KeyStatus.up),
|
||||
thisIsAReapeateKey);
|
||||
}
|
||||
}
|
||||
|
||||
public void keyTyped(KeyEvent e) {
|
||||
// not needed with my model ...
|
||||
//Log.info(" typed " + e.getKeyChar() + " " + e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
//Log.info("wheel_event : " + e);
|
||||
cursorPos.x = e.getX();
|
||||
cursorPos.y = e.getY();
|
||||
if (e.getWheelRotation()<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 (e.getWheelRotation()>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);
|
||||
}
|
||||
}
|
||||
public static float getFrameTimeSecconds() {
|
||||
return delta;
|
||||
}
|
||||
|
||||
private static long getCurrentTime() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int run() {
|
||||
Runnable renderLoop = new Runnable() {
|
||||
public void run() {
|
||||
// fps.tic();
|
||||
if (!canvas.isValid()) {
|
||||
System.exit(0);
|
||||
return;
|
||||
}
|
||||
canvas.render();
|
||||
// fps.toc();
|
||||
// fps.draw();
|
||||
SwingUtilities.invokeLater(this);
|
||||
}
|
||||
};
|
||||
SwingUtilities.invokeLater(renderLoop);
|
||||
|
||||
|
||||
// while (canvas != null && canvas.isValid()) {
|
||||
// canvas.render();
|
||||
// try {
|
||||
// Thread.sleep(10);
|
||||
// } catch (InterruptedException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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();
|
||||
// */
|
||||
//
|
||||
// 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) {
|
||||
|
||||
}
|
||||
private void hideCursor() {
|
||||
int[] pixels = new int[16 * 16];
|
||||
Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16));
|
||||
Cursor transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0), "invisiblecursor");
|
||||
frame.setCursor(transparentCursor);
|
||||
}
|
||||
private void showCursor() {
|
||||
frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
@Override
|
||||
public void grabPointerEvents(boolean _status, Vector2f _forcedPosition) {
|
||||
if (_status == true) {
|
||||
try {
|
||||
this.robot = new Robot();
|
||||
hideCursor();
|
||||
} catch (AWTException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
this.robot = null;
|
||||
showCursor();
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public boolean isGrabPointerEvents() { return this.robot != null; };
|
||||
@Override
|
||||
public void setFullScreen(boolean status){
|
||||
super.setFullScreen(status);
|
||||
if (status == true) {
|
||||
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
frame.setUndecorated(true);
|
||||
} else {
|
||||
frame.setExtendedState(JFrame.NORMAL);
|
||||
frame.setUndecorated(false);
|
||||
}
|
||||
};
|
||||
|
||||
public static Context create(Application application, String[] arg) {
|
||||
// TODO Auto-generated method stub
|
||||
return new ContextLWJGL_AWT(application, arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
559
src/org/atriaSoft/gale/resource/ResourceColored3DObject.java
Normal file
559
src/org/atriaSoft/gale/resource/ResourceColored3DObject.java
Normal file
@ -0,0 +1,559 @@
|
||||
package org.atriaSoft.gale.resource;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriaSoft.etk.Color;
|
||||
import org.atriaSoft.etk.Uri;
|
||||
import org.atriaSoft.etk.math.Matrix4f;
|
||||
import org.atriaSoft.etk.math.Vector3f;
|
||||
import org.atriaSoft.gale.Log;
|
||||
import org.atriaSoft.gale.backend3d.OpenGL;
|
||||
import org.atriaSoft.gale.backend3d.OpenGL.RenderMode;
|
||||
import org.atriaSoft.gameEngine.resource.ResourceListTexturedMesh;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL40;
|
||||
|
||||
public class ResourceColored3DObject extends Resource {
|
||||
private ResourceProgram program;
|
||||
private int GLPosition;
|
||||
private int GLColor;
|
||||
private int GLMatrixTransformation;
|
||||
private int GLMatrixProjection;
|
||||
private int GLMatrixView;
|
||||
protected ResourceColored3DObject() {
|
||||
super();
|
||||
addResourceType("ResourceColored3DObject");
|
||||
// get the shader resource :
|
||||
this.GLPosition = 0;
|
||||
this.program = ResourceProgram.create(new Uri("DATA_EGE", "simple3D.vert"), new Uri("DATA_EGE", "simple3D.frag"));
|
||||
if (this.program != null) {
|
||||
this.GLMatrixTransformation = this.program.getUniform("in_matrixTransformation");
|
||||
this.GLMatrixProjection = this.program.getUniform("in_matrixProjection");
|
||||
this.GLMatrixView = this.program.getUniform("in_matrixView");
|
||||
this.GLPosition = this.program.getAttribute("in_position");
|
||||
this.GLColor = this.program.getUniform("in_colors");
|
||||
}
|
||||
}
|
||||
public void draw(List<Vector3f> vertices,
|
||||
Color color,
|
||||
boolean updateDepthBuffer,
|
||||
boolean depthtest) {
|
||||
if (vertices.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
if (this.program == null) {
|
||||
Log.error("No shader ...");
|
||||
return;
|
||||
}
|
||||
if (true == depthtest) {
|
||||
OpenGL.enable(OpenGL.Flag.flag_depthTest);
|
||||
if (false == updateDepthBuffer) {
|
||||
OpenGL.setDeathMask(false);
|
||||
}
|
||||
}
|
||||
//Log.debug(" display " << this.coord.size() << " elements" );
|
||||
this.program.use();
|
||||
Matrix4f projectionMatrix = OpenGL.getMatrix();
|
||||
Matrix4f viewMatrix = OpenGL.getCameraMatrix();
|
||||
Matrix4f transformationMatrix = Matrix4f.identity();
|
||||
this.program.uniformMatrix(this.GLMatrixView, viewMatrix);
|
||||
this.program.uniformMatrix(this.GLMatrixProjection, projectionMatrix);
|
||||
this.program.uniformMatrix(this.GLMatrixTransformation, transformationMatrix);
|
||||
// color :
|
||||
this.program.uniformColor(this.GLColor, color);
|
||||
// position :
|
||||
FloatBuffer buffer = storeDataInFloatBuffer(convertInFloat(vertices));
|
||||
this.program.sendAttribute(this.GLPosition, 3, buffer, 3);
|
||||
if (color.a < 1.0f) {
|
||||
OpenGL.enable(OpenGL.Flag.flag_blend);
|
||||
}
|
||||
// Request the draw of the elements:
|
||||
OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size());
|
||||
if (color.a < 1.0f) {
|
||||
OpenGL.disable(OpenGL.Flag.flag_blend);
|
||||
}
|
||||
this.program.unUse();
|
||||
// Request the draw od the elements:
|
||||
//glDrawArrays(GLLINES, 0, vertices.size());
|
||||
//this.GLprogram.UnUse();
|
||||
if (true == depthtest) {
|
||||
if (false == updateDepthBuffer) {
|
||||
OpenGL.setDeathMask(true);
|
||||
}
|
||||
OpenGL.disable(OpenGL.Flag.flag_depthTest);
|
||||
}
|
||||
}
|
||||
private float[] convertInFloat(List<Vector3f> data) {
|
||||
float[] out = new float[data.size()*3];
|
||||
for (int iii=0; iii<data.size(); iii++) {
|
||||
out[iii*3] = data.get(iii).x;
|
||||
out[iii*3+1] = data.get(iii).y;
|
||||
out[iii*3+2] = data.get(iii).z;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
private FloatBuffer storeDataInFloatBuffer(float[] data) {
|
||||
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
|
||||
buffer.put(data);
|
||||
buffer.flip();
|
||||
return buffer;
|
||||
}
|
||||
public void draw(List<Vector3f> vertices,
|
||||
Color color,
|
||||
Matrix4f transformationMatrix,
|
||||
boolean updateDepthBuffer,
|
||||
boolean depthtest) {
|
||||
if (vertices.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
if (this.program == null) {
|
||||
Log.error("No shader ...");
|
||||
return;
|
||||
}
|
||||
if (true == depthtest) {
|
||||
OpenGL.enable(OpenGL.Flag.flag_depthTest);
|
||||
if (false == updateDepthBuffer) {
|
||||
OpenGL.setDeathMask(false);
|
||||
}
|
||||
}
|
||||
//Log.debug(" display " << this.coord.size() << " elements" );
|
||||
this.program.use();
|
||||
// set Matrix: translation/positionMatrix
|
||||
Matrix4f projectionMatrix = OpenGL.getMatrix();
|
||||
Matrix4f viewMatrix = OpenGL.getCameraMatrix();
|
||||
this.program.uniformMatrix(this.GLMatrixView, viewMatrix);
|
||||
this.program.uniformMatrix(this.GLMatrixProjection, projectionMatrix);
|
||||
this.program.uniformMatrix(this.GLMatrixTransformation, transformationMatrix);
|
||||
// position :
|
||||
FloatBuffer buffer = storeDataInFloatBuffer(convertInFloat(vertices));
|
||||
this.program.sendAttribute(this.GLPosition, 3, buffer, 3);
|
||||
// color :
|
||||
Log.info("color= " + color + " " + this.GLPosition);
|
||||
this.program.uniformColor(this.GLColor, color);
|
||||
if (color.a < 1.0f) {
|
||||
OpenGL.enable(OpenGL.Flag.flag_blend);
|
||||
}
|
||||
// Request the draw of the elements:
|
||||
OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, vertices.size());
|
||||
if (color.a < 1.0f) {
|
||||
OpenGL.disable(OpenGL.Flag.flag_blend);
|
||||
}
|
||||
this.program.unUse();
|
||||
if (true == depthtest) {
|
||||
if (false == updateDepthBuffer) {
|
||||
OpenGL.setDeathMask(true);
|
||||
}
|
||||
OpenGL.disable(OpenGL.Flag.flag_depthTest);
|
||||
}
|
||||
}
|
||||
public void drawLine(List<Vector3f> vertices,
|
||||
Color color,
|
||||
Matrix4f transformationMatrix,
|
||||
boolean updateDepthBuffer,
|
||||
boolean depthtest) {
|
||||
if (vertices.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
if (this.program == null) {
|
||||
Log.error("No shader ...");
|
||||
return;
|
||||
}
|
||||
if (true == depthtest) {
|
||||
OpenGL.enable(OpenGL.Flag.flag_depthTest);
|
||||
if (false == updateDepthBuffer) {
|
||||
OpenGL.setDeathMask(false);
|
||||
}
|
||||
}
|
||||
//Log.debug(" display " << this.coord.size() << " elements" );
|
||||
this.program.use();
|
||||
// set Matrix: translation/positionMatrix
|
||||
Matrix4f projectionMatrix = OpenGL.getMatrix();
|
||||
Matrix4f viewMatrix = OpenGL.getCameraMatrix();
|
||||
this.program.uniformMatrix(this.GLMatrixView, viewMatrix);
|
||||
this.program.uniformMatrix(this.GLMatrixProjection, projectionMatrix);
|
||||
this.program.uniformMatrix(this.GLMatrixTransformation, transformationMatrix);
|
||||
// position :
|
||||
FloatBuffer buffer = storeDataInFloatBuffer(convertInFloat(vertices));
|
||||
this.program.sendAttribute(this.GLPosition, 3, buffer, 3);
|
||||
// color :
|
||||
this.program.uniformColor(this.GLColor, color);
|
||||
if (color.a < 1.0f) {
|
||||
OpenGL.enable(OpenGL.Flag.flag_blend);
|
||||
}
|
||||
// Request the draw od the elements:
|
||||
OpenGL.drawArrays(OpenGL.RenderMode.line, 0, vertices.size());
|
||||
if (color.a < 1.0f) {
|
||||
OpenGL.disable(OpenGL.Flag.flag_blend);
|
||||
}
|
||||
this.program.unUse();
|
||||
if (true == depthtest) {
|
||||
if (false == updateDepthBuffer) {
|
||||
OpenGL.setDeathMask(true);
|
||||
}
|
||||
OpenGL.disable(OpenGL.Flag.flag_depthTest);
|
||||
}
|
||||
}
|
||||
public void drawCubeLine(Vector3f min,
|
||||
Vector3f max,
|
||||
Color color,
|
||||
Matrix4f transformationMatrix,
|
||||
boolean updateDepthBuffer,
|
||||
boolean depthtest) {
|
||||
List<Vector3f> vertices = new ArrayList<Vector3f>();
|
||||
vertices.add(new Vector3f(min.x, min.y,min.z));
|
||||
vertices.add(new Vector3f(max.x, min.y,min.z));
|
||||
|
||||
vertices.add(new Vector3f(max.x, min.y,min.z));
|
||||
vertices.add(new Vector3f(max.x, min.y,max.z));
|
||||
|
||||
vertices.add(new Vector3f(max.x, min.y,max.z));
|
||||
vertices.add(new Vector3f(min.x, min.y,max.z));
|
||||
|
||||
vertices.add(new Vector3f(min.x, min.y,max.z));
|
||||
vertices.add(new Vector3f(min.x, min.y,min.z));
|
||||
|
||||
|
||||
vertices.add(new Vector3f(min.x, max.y,min.z));
|
||||
vertices.add(new Vector3f(max.x, max.y,min.z));
|
||||
|
||||
vertices.add(new Vector3f(max.x, max.y,min.z));
|
||||
vertices.add(new Vector3f(max.x, max.y,max.z));
|
||||
|
||||
vertices.add(new Vector3f(max.x, max.y,max.z));
|
||||
vertices.add(new Vector3f(min.x, max.y,max.z));
|
||||
|
||||
vertices.add(new Vector3f(min.x, max.y,max.z));
|
||||
vertices.add(new Vector3f(min.x, max.y,min.z));
|
||||
|
||||
|
||||
vertices.add(new Vector3f(min.x, min.y,min.z));
|
||||
vertices.add(new Vector3f(min.x, max.y,min.z));
|
||||
|
||||
vertices.add(new Vector3f(max.x, min.y,min.z));
|
||||
vertices.add(new Vector3f(max.x, max.y,min.z));
|
||||
|
||||
vertices.add(new Vector3f(max.x, min.y,max.z));
|
||||
vertices.add(new Vector3f(max.x, max.y,max.z));
|
||||
|
||||
vertices.add(new Vector3f(min.x, min.y,max.z));
|
||||
vertices.add(new Vector3f(min.x, max.y,max.z));
|
||||
drawLine(vertices, color, transformationMatrix, updateDepthBuffer, depthtest);
|
||||
}
|
||||
public void drawSquare(Vector3f size,
|
||||
Matrix4f transformationMatrix,
|
||||
Color tmpColor) {
|
||||
List<Vector3f> tmpVertices = new ArrayList<Vector3f>();
|
||||
int indices[] = { 0,1,2, 3,2,1, 4,0,6,
|
||||
6,0,2, 5,1,4, 4,1,0,
|
||||
7,3,1, 7,1,5, 5,4,7,
|
||||
7,4,6, 7,2,3, 7,6,2};
|
||||
Vector3f vertices[]={ new Vector3f(size.x,size.y,size.z),
|
||||
new Vector3f(-size.x,size.y,size.z),
|
||||
new Vector3f(size.x,-size.y,size.z),
|
||||
new Vector3f(-size.x,-size.y,size.z),
|
||||
new Vector3f(size.x,size.y,-size.z),
|
||||
new Vector3f(-size.x,size.y,-size.z),
|
||||
new Vector3f(size.x,-size.y,-size.z),
|
||||
new Vector3f(-size.x,-size.y,-size.z)};
|
||||
tmpVertices.clear();
|
||||
for (int iii=0 ; iii<36 ; iii+=3) {
|
||||
// normal calculation :
|
||||
//btVector3 normal = (vertices[indices[iii+2]]-vertices[indices[iii]]).cross(vertices[indices[iii+1]]-vertices[indices[iii]]);
|
||||
//normal.normalize ();
|
||||
tmpVertices.add(vertices[indices[iii]]);
|
||||
tmpVertices.add(vertices[indices[iii+1]]);
|
||||
tmpVertices.add(vertices[indices[iii+2]]);
|
||||
}
|
||||
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
|
||||
}
|
||||
public void drawSphere(float radius,
|
||||
int lats,
|
||||
int longs,
|
||||
Matrix4f transformationMatrix,
|
||||
Color tmpColor) {
|
||||
List<Vector3f> tmpVertices = new ArrayList<Vector3f>();;
|
||||
for(int iii=0; iii<=lats; ++iii) {
|
||||
float lat0 = (float)Math.PI * (-0.5f + (float)(iii - 1) / lats);
|
||||
float z0 = radius*(float)Math.sin(lat0);
|
||||
float zr0 = radius*(float)Math.cos(lat0);
|
||||
|
||||
float lat1 = (float)Math.PI * (-0.5f + (float)(iii) / lats);
|
||||
float z1 = radius*(float)Math.sin(lat1);
|
||||
float zr1 = radius*(float)Math.cos(lat1);
|
||||
|
||||
for(int jjj=0; jjj<longs; ++jjj) {
|
||||
float lng = 2.0f * (float)Math.PI * (float)(jjj - 1) / longs;
|
||||
float x = (float)Math.cos(lng);
|
||||
float y = (float)Math.sin(lng);
|
||||
Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1);
|
||||
Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0);
|
||||
|
||||
lng = 2 * (float)Math.PI * (float)(jjj) / longs;
|
||||
x = (float)Math.cos(lng);
|
||||
y = (float)Math.sin(lng);
|
||||
Vector3f v2 = new Vector3f(x * zr1, y * zr1, z1);
|
||||
Vector3f v3 = new Vector3f(x * zr0, y * zr0, z0);
|
||||
|
||||
tmpVertices.add(v1);
|
||||
tmpVertices.add(v2);
|
||||
tmpVertices.add(v3);
|
||||
|
||||
tmpVertices.add(v1);
|
||||
tmpVertices.add(v3);
|
||||
tmpVertices.add(v4);
|
||||
}
|
||||
}
|
||||
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
|
||||
}
|
||||
public void drawCylinder(float radius,
|
||||
float size,
|
||||
int lats,
|
||||
int longs,
|
||||
Matrix4f transformationMatrix,
|
||||
Color tmpColor) {
|
||||
List<Vector3f> tmpVertices = new ArrayList<Vector3f>();;
|
||||
// center to border (TOP)
|
||||
|
||||
// center to border (TOP)
|
||||
for(int jjj=0; jjj<longs; ++jjj) {
|
||||
float lng = 2.0f * (float)Math.PI * (float)(jjj - 1) / longs;
|
||||
|
||||
float z = size*0.5f;
|
||||
Vector3f v1 = new Vector3f(0.0f, 0.0f, z);
|
||||
|
||||
float x = (float) Math.cos(lng)*radius;
|
||||
float y = (float) Math.sin(lng)*radius;
|
||||
Vector3f v2 = new Vector3f(x, y, z);
|
||||
|
||||
lng = 2.0f * (float)Math.PI * (float)(jjj) / longs;
|
||||
x = (float) Math.cos(lng)*radius;
|
||||
y = (float)Math.sin(lng)*radius;
|
||||
Vector3f v3 = new Vector3f(x, y, z);
|
||||
tmpVertices.add(v1);
|
||||
tmpVertices.add(v3);
|
||||
tmpVertices.add(v2);
|
||||
}
|
||||
// Cylinder
|
||||
for(int jjj=0; jjj<longs; ++jjj) {
|
||||
float lng = 2.0f * (float)Math.PI * (float)(jjj - 1) / longs;
|
||||
|
||||
float z = size*0.5f;
|
||||
|
||||
float x = (float) Math.cos(lng)*radius;
|
||||
float y = (float) Math.sin(lng)*radius;
|
||||
Vector3f v2 = new Vector3f(x, y, z);
|
||||
Vector3f v2b = new Vector3f(x, y, -z);
|
||||
|
||||
lng = 2.0f * (float)Math.PI * (float)(jjj) / longs;
|
||||
x = (float) Math.cos(lng)*radius;
|
||||
y = (float) Math.sin(lng)*radius;
|
||||
Vector3f v3 = new Vector3f(x, y, z);
|
||||
Vector3f v3b = new Vector3f(x, y, -z);
|
||||
|
||||
tmpVertices.add(v2);
|
||||
tmpVertices.add(v3);
|
||||
tmpVertices.add(v3b);
|
||||
|
||||
tmpVertices.add(v2);
|
||||
tmpVertices.add(v3b);
|
||||
tmpVertices.add(v2b);
|
||||
}
|
||||
// center to border (BUTTOM)
|
||||
for(int jjj=0; jjj<longs; ++jjj) {
|
||||
float lng = 2.0f * (float)Math.PI * (float)(jjj - 1) / longs;
|
||||
|
||||
float z = size*-0.5f;
|
||||
Vector3f v1 = new Vector3f(0.0f, 0.0f, z);
|
||||
|
||||
float x = (float)Math.cos(lng)*radius;
|
||||
float y = (float)Math.sin(lng)*radius;
|
||||
Vector3f v2 = new Vector3f(x, y, z);
|
||||
|
||||
lng = 2.0f * (float)Math.PI * (float)(jjj) / longs;
|
||||
x = (float)Math.cos(lng)*radius;
|
||||
y = (float)Math.sin(lng)*radius;
|
||||
Vector3f v3 = new Vector3f(x, y, z);
|
||||
tmpVertices.add(v1);
|
||||
tmpVertices.add(v2);
|
||||
tmpVertices.add(v3);
|
||||
}
|
||||
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
|
||||
}
|
||||
public void drawCapsule(float radius,
|
||||
float size,
|
||||
int lats,
|
||||
int longs,
|
||||
Matrix4f transformationMatrix,
|
||||
Color tmpColor) {
|
||||
List<Vector3f> tmpVertices = new ArrayList<Vector3f>();;
|
||||
lats = (int)(lats / 2)*2;
|
||||
|
||||
// center to border (TOP)
|
||||
float offset = size*0.5f;
|
||||
for(int iii=lats/2+1; iii<=lats; ++iii) {
|
||||
float lat0 = (float)Math.PI * (-0.5f + (float)(iii - 1) / lats);
|
||||
float z0 = radius*(float)Math.sin(lat0);
|
||||
float zr0 = radius*(float)Math.cos(lat0);
|
||||
|
||||
float lat1 = (float)Math.PI * (-0.5f + (float)(iii) / lats);
|
||||
float z1 = radius*(float)Math.sin(lat1);
|
||||
float zr1 = radius*(float)Math.cos(lat1);
|
||||
|
||||
for(int jjj=0; jjj<longs; ++jjj) {
|
||||
float lng = 2.0f * (float)Math.PI * (float)(jjj - 1) / longs;
|
||||
float x = (float)Math.cos(lng);
|
||||
float y = (float)Math.sin(lng);
|
||||
Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1+offset);
|
||||
Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0+offset);
|
||||
|
||||
lng = 2 * (float)Math.PI * (float)(jjj) / longs;
|
||||
x = (float)Math.cos(lng);
|
||||
y = (float)Math.sin(lng);
|
||||
Vector3f v2 = new Vector3f(x * zr1, y * zr1, z1+offset);
|
||||
Vector3f v3 = new Vector3f(x * zr0, y * zr0, z0+offset);
|
||||
tmpVertices.add(v1);
|
||||
tmpVertices.add(v2);
|
||||
tmpVertices.add(v3);
|
||||
|
||||
tmpVertices.add(v1);
|
||||
tmpVertices.add(v3);
|
||||
tmpVertices.add(v4);
|
||||
}
|
||||
}
|
||||
// Cylinder
|
||||
for(int jjj=0; jjj<longs; ++jjj) {
|
||||
float lng = 2.0f * (float)Math.PI * (float)(jjj - 1) / longs;
|
||||
|
||||
float z = size*0.5f;
|
||||
|
||||
float x = (float)Math.cos(lng)*radius;
|
||||
float y = (float)Math.sin(lng)*radius;
|
||||
Vector3f v2 = new Vector3f(x, y, z);
|
||||
Vector3f v2b = new Vector3f(x, y, -z);
|
||||
|
||||
lng = 2.0f * (float)Math.PI * (float)(jjj) / longs;
|
||||
x = (float)Math.cos(lng)*radius;
|
||||
y = (float)Math.sin(lng)*radius;
|
||||
Vector3f v3 = new Vector3f(x, y, z);
|
||||
Vector3f v3b = new Vector3f(x, y, -z);
|
||||
|
||||
tmpVertices.add(v2);
|
||||
tmpVertices.add(v3);
|
||||
tmpVertices.add(v3b);
|
||||
|
||||
tmpVertices.add(v2);
|
||||
tmpVertices.add(v3b);
|
||||
tmpVertices.add(v2b);
|
||||
}
|
||||
// center to border (BUTTOM)
|
||||
offset = -size*0.5f;
|
||||
for(int iii=0; iii<=lats/2; ++iii) {
|
||||
float lat0 = (float)Math.PI * (-0.5f + (float)(iii - 1) / lats);
|
||||
float z0 = radius*(float)Math.sin(lat0);
|
||||
float zr0 = radius*(float)Math.cos(lat0);
|
||||
|
||||
float lat1 = (float)Math.PI * (-0.5f + (float)(iii) / lats);
|
||||
float z1 = radius*(float)Math.sin(lat1);
|
||||
float zr1 = radius*(float)Math.cos(lat1);
|
||||
|
||||
for(int jjj=0; jjj<longs; ++jjj) {
|
||||
float lng = 2.0f * (float)Math.PI * (float)(jjj - 1) / longs;
|
||||
float x = (float)Math.cos(lng);
|
||||
float y = (float)Math.sin(lng);
|
||||
Vector3f v1 = new Vector3f(x * zr1, y * zr1, z1+offset);
|
||||
Vector3f v4 = new Vector3f(x * zr0, y * zr0, z0+offset);
|
||||
|
||||
lng = 2 * (float)Math.PI * (float)(jjj) / longs;
|
||||
x = (float)Math.cos(lng);
|
||||
y = (float)Math.sin(lng);
|
||||
Vector3f v2 = new Vector3f(x * zr1, y * zr1, z1+offset);
|
||||
Vector3f v3 = new Vector3f(x * zr0, y * zr0, z0+offset);
|
||||
tmpVertices.add(v1);
|
||||
tmpVertices.add(v2);
|
||||
tmpVertices.add(v3);
|
||||
|
||||
tmpVertices.add(v1);
|
||||
tmpVertices.add(v3);
|
||||
tmpVertices.add(v4);
|
||||
}
|
||||
}
|
||||
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
|
||||
}
|
||||
public void drawCone(float radius,
|
||||
float size,
|
||||
int lats,
|
||||
int longs,
|
||||
Matrix4f transformationMatrix,
|
||||
Color tmpColor) {
|
||||
List<Vector3f> tmpVertices = new ArrayList<Vector3f>();
|
||||
// center to border (TOP)
|
||||
for(int jjj=0; jjj<longs; ++jjj) {
|
||||
float lng = 2.0f * (float)Math.PI * (float)(jjj - 1) / longs;
|
||||
Vector3f v1 = new Vector3f(0.0f, 0.0f, -size/2);
|
||||
|
||||
float x = (float)Math.cos(lng)*radius;
|
||||
float y = (float)Math.sin(lng)*radius;
|
||||
Vector3f v2 = new Vector3f(x, y, size/2);
|
||||
|
||||
lng = 2.0f * (float)Math.PI * (float)(jjj) / longs;
|
||||
x = (float)Math.cos(lng)*radius;
|
||||
y = (float)Math.sin(lng)*radius;
|
||||
Vector3f v3 = new Vector3f(x, y, size/2);
|
||||
tmpVertices.add(v1);
|
||||
tmpVertices.add(v3);
|
||||
tmpVertices.add(v2);
|
||||
}
|
||||
// center to border (BUTTOM)
|
||||
for(int jjj=0; jjj<longs; ++jjj) {
|
||||
float lng = 2.0f * (float)Math.PI * (float)(jjj - 1) / longs;
|
||||
|
||||
Vector3f v1 = new Vector3f(0.0f, 0.0f, size/2);
|
||||
|
||||
float x = (float)Math.cos(lng)*radius;
|
||||
float y = (float)Math.sin(lng)*radius;
|
||||
Vector3f v2 = new Vector3f(x, y, size/2);
|
||||
|
||||
lng = 2.0f * (float)Math.PI * (float)(jjj) / longs;
|
||||
x = (float)Math.cos(lng)*radius;
|
||||
y = (float)Math.sin(lng)*radius;
|
||||
Vector3f v3 = new Vector3f(x, y, size/2);
|
||||
tmpVertices.add(v1);
|
||||
tmpVertices.add(v2);
|
||||
tmpVertices.add(v3);
|
||||
}
|
||||
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
|
||||
}
|
||||
public void drawTriangles(List<Vector3f> vertex,
|
||||
List<Integer> indice,
|
||||
Matrix4f transformationMatrix,
|
||||
Color tmpColor,
|
||||
Vector3f offset) {// = new Vector3f(0,0,0.1f)
|
||||
List<Vector3f> tmpVertices = new ArrayList<Vector3f>();;
|
||||
for (int iii=0; iii<indice.size()/3; ++iii) {
|
||||
tmpVertices.add(vertex.get(indice.get(iii*3 + 0)).add_new(offset));
|
||||
tmpVertices.add(vertex.get(indice.get(iii*3 + 1)).add_new(offset));
|
||||
tmpVertices.add(vertex.get(indice.get(iii*3 + 2)).add_new(offset));
|
||||
//Log.info(" indices " << indice[iii*3 + 0] << " " << indice[iii*3 + 1] << " " << indice[iii*3 + 2]);
|
||||
//Log.info(" triangle " << vertex[indice[iii*3 + 0]] << " " << vertex[indice[iii*3 + 1]] << " " << vertex[indice[iii*3 + 2]]);
|
||||
}
|
||||
//Log.info("display " << tmpVertices.size() << " vertices form " << indice.size());
|
||||
draw(tmpVertices, tmpColor, transformationMatrix, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanUp() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
public static ResourceColored3DObject create() {
|
||||
ResourceColored3DObject resource = new ResourceColored3DObject();
|
||||
if (resource.resourceHasBeenCorectlyInit() == false) {
|
||||
Log.critical("resource Is not correctly init: ResourceColored3DObject");
|
||||
}
|
||||
getManager().localAdd(resource);
|
||||
return resource;
|
||||
}
|
||||
}
|
@ -14,14 +14,8 @@ import org.atriaSoft.etk.math.Vector3f;
|
||||
import org.atriaSoft.etk.math.Vector3i;
|
||||
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.opengl.GL40;
|
||||
|
||||
|
||||
class ProgAttributeElement {
|
||||
@ -38,9 +32,9 @@ public class ResourceProgram extends Resource {
|
||||
private ResourceShader shaderVertex = null;
|
||||
private ResourceShader shaderFragment = null;
|
||||
private List<ProgAttributeElement> elementList = new ArrayList<ProgAttributeElement>(); //!< List of all the attribute requested by the user
|
||||
private List<Integer> listOfVBOUsed = new ArrayList<Integer>(); //!< retain the list of VBO used to disable it when unuse program ...
|
||||
private boolean hasTexture = false; //!< A texture has been set to the current shader
|
||||
private boolean hasTexture1 = false; //!< A texture has been set to the current shader
|
||||
// private List<Integer> listOfVBOUsed = new ArrayList<Integer>(); //!< retain the list of VBO used to disable it when unuse program ...
|
||||
// private boolean hasTexture = false; //!< A texture has been set to the current shader
|
||||
// private boolean hasTexture1 = false; //!< A texture has been set to the current shader
|
||||
/**
|
||||
* @brief Contructor of an opengl Program.
|
||||
* @param[in] uri Uri of the file
|
||||
@ -85,8 +79,8 @@ public class ResourceProgram extends Resource {
|
||||
this.shaderVertex = null;
|
||||
}
|
||||
this.elementList.clear();
|
||||
this.hasTexture = false;
|
||||
this.hasTexture1 = false;
|
||||
// this.hasTexture = false;
|
||||
// this.hasTexture1 = false;
|
||||
}
|
||||
/**
|
||||
* @brief Check If an Id is valid in the shader or not (sometime the shader have not some attribute, then we need to display some error)
|
||||
@ -240,18 +234,24 @@ public class ResourceProgram extends Resource {
|
||||
// GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0);
|
||||
// GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
// }
|
||||
|
||||
private float[] convertInFloat(List<Vector3f> data) {
|
||||
float[] out = new float[data.size()*3];
|
||||
for (int iii=0; iii<data.size(); iii++) {
|
||||
out[iii*3] = data.get(iii).x;
|
||||
out[iii*3+1] = data.get(iii).y;
|
||||
out[iii*3+2] = data.get(iii).z;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
/**
|
||||
* @brief Send attribute table to the spefified ID attribure (not send if does not really exist in the openGL program).
|
||||
* @param[in] idElem Id of the Attribute that might be sended.
|
||||
* @brief Send attribute table to the specified ID attribute (not send if does not really exist in the openGL program).
|
||||
* @param[in] idElem Id of the Attribute that might be sent.
|
||||
* @param[in] nbElement Specifies the number of elements that are to be modified.
|
||||
* @param[in] pointer Pointer on the data that might be sended.
|
||||
* @param[in] jumpBetweenSample Number of byte to jump between 2 vertex (this permit to enterlace informations)
|
||||
* @param[in] pointer Pointer on the data that might be sent.
|
||||
* @param[in] jumpBetweenSample Number of byte to jump between 2 vertex (this permit to interlace informations)
|
||||
*/
|
||||
// public void sendAttribute(int idElem,
|
||||
// int nbElement,
|
||||
// void* pointer,
|
||||
// int jumpBetweenSample=0) {
|
||||
//
|
||||
// public void sendAttribute3fv(int idElem, float[] data) {
|
||||
// if (this.exist == false) {
|
||||
// return;
|
||||
// }
|
||||
@ -263,23 +263,51 @@ public class ResourceProgram extends Resource {
|
||||
// if (this.elementList.get(idElem).isLinked == false) {
|
||||
// return;
|
||||
// }
|
||||
// //Log.error("[" + this.elementList.get(idElem).name + "] send " + nbElement + " element");
|
||||
// glVertexAttribPointer(this.elementList.get(idElem).elementId, // attribute ID of openGL
|
||||
// nbElement, // number of elements per vertex, here (r,g,b,a)
|
||||
// GLFLOAT, // the type of each element
|
||||
// GLFALSE, // take our values as-is
|
||||
// jumpBetweenSample, // no extra data between each position
|
||||
// pointer); // Pointer on the buffer
|
||||
// checkGlError("glVertexAttribPointer", LINE, idElem);
|
||||
// glEnableVertexAttribArray(this.elementList.get(idElem).elementId);
|
||||
// checkGlError("glEnableVertexAttribArray", LINE, idElem);
|
||||
// FloatBuffer buffer = storeDataInFloatBuffer(data);
|
||||
// //GL40.glBindVertexArray(this.elementList.get(idElem).elementId);
|
||||
// Log.error("[" + this.elementList.get(idElem).name + "] send " + data.length + " element");
|
||||
// GL40.glVertexAttribPointer(
|
||||
// this.elementList.get(idElem).elementId,
|
||||
// data.length,
|
||||
// GL40.GL_FLOAT,
|
||||
// false,
|
||||
// 0,
|
||||
// buffer);
|
||||
// //checkGlError("glVertexAttribPointer", LINE, idElem);
|
||||
// GL40.glEnableVertexAttribArray(this.elementList.get(idElem).elementId);
|
||||
// //checkGlError("glEnableVertexAttribArray", LINE, idElem);
|
||||
// }
|
||||
// public void sendAttribute(int idElem, etk::Vector<Vector2f> data) {
|
||||
// sendAttribute(idElem, 2/*u,v / x,y*/, data[0]);
|
||||
// }
|
||||
// public void sendAttribute(int idElem, etk::Vector<Vector3f> data) {
|
||||
// sendAttribute(idElem, 3/*x,y,z,unused*/, data[0], 4*sizeof(btScalar));
|
||||
//// public void sendAttribute(int idElem, etk::Vector<Vector2f> data) {
|
||||
//// sendAttribute(idElem, 2/*u,v / x,y*/, data[0]);
|
||||
//// }
|
||||
// public void sendAttribute(int idElem, List<Vector3f> data) {
|
||||
// sendAttribute3fv(idElem, convertInFloat(data));
|
||||
// }
|
||||
public void sendAttribute(int idElem, int nbElement, FloatBuffer data, int jumpBetweenSample) {
|
||||
if (this.exist == false) {
|
||||
return;
|
||||
}
|
||||
if ( idElem < 0
|
||||
|| (long)idElem > this.elementList.size()) {
|
||||
Log.error("idElem = " + idElem + " not in [0.." + (this.elementList.size()-1) + "]");
|
||||
return;
|
||||
}
|
||||
if (this.elementList.get(idElem).isLinked == false) {
|
||||
return;
|
||||
}
|
||||
//GL40.glBindVertexArray(this.elementList.get(idElem).elementId);
|
||||
Log.error("[" + this.elementList.get(idElem).name + "] send " + 3 + " element");
|
||||
GL40.glVertexAttribPointer(
|
||||
this.elementList.get(idElem).elementId,
|
||||
nbElement,
|
||||
GL40.GL_FLOAT,
|
||||
false,
|
||||
jumpBetweenSample*4, /* 4 is the size of float in the generic system...*/
|
||||
data);
|
||||
//checkGlError("glVertexAttribPointer", LINE, idElem);
|
||||
GL40.glEnableVertexAttribArray(this.elementList.get(idElem).elementId);
|
||||
//checkGlError("glEnableVertexAttribArray", LINE, idElem);
|
||||
}
|
||||
// public void sendAttribute(int idElem, etk::Vector<etk::Color<float>> data) {
|
||||
// sendAttribute(idElem, 4/*r,g,b,a*/, data[0]);
|
||||
// }
|
||||
@ -597,48 +625,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 +676,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);
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public class ResourceVirtualArrayObject extends Resource {
|
||||
GL30.glBindVertexArray(vaoID);
|
||||
if (positions != null) {
|
||||
GL20.glEnableVertexAttribArray(INDICE_VBO_POSITIONS);
|
||||
//Log.info("unbind POSITION");
|
||||
}
|
||||
if (textureCoordinates != null) {
|
||||
GL20.glEnableVertexAttribArray(INDICE_VBO_TEXTURE_COORDINATES);
|
||||
|
196
src/org/atriaSoft/gameEngine/ControlCameraPlayer.java
Normal file
196
src/org/atriaSoft/gameEngine/ControlCameraPlayer.java
Normal file
@ -0,0 +1,196 @@
|
||||
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 = 2.5f;
|
||||
private boolean fpsMode = false;
|
||||
private Entity playerEntity;
|
||||
private ComponentPositionPlayer playerPosition;
|
||||
private ComponentPlayer player;
|
||||
private boolean moveUp = false;
|
||||
private boolean moveDown = false;
|
||||
private boolean moveLeft = false;
|
||||
private boolean moveRight = false;
|
||||
private boolean walk = 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
|
||||
|| (event.getType() == KeyKeyboard.character && (event.getChar() == 'z' || event.getChar() == 'Z' ))) {
|
||||
moveUp = getState(event.getStatus(), moveUp);
|
||||
}
|
||||
if(event.getType() == KeyKeyboard.left
|
||||
|| (event.getType() == KeyKeyboard.character && (event.getChar() == 'q' || event.getChar() == 'Q' ))) {
|
||||
moveLeft = getState(event.getStatus(), moveLeft);
|
||||
}
|
||||
if(event.getType() == KeyKeyboard.right
|
||||
|| (event.getType() == KeyKeyboard.character && (event.getChar() == 'd' || event.getChar() == 'D' ))) {
|
||||
moveRight = getState(event.getStatus(), moveRight);
|
||||
}
|
||||
if(event.getType() == KeyKeyboard.down
|
||||
|| (event.getType() == KeyKeyboard.character && (event.getChar() == 's' || event.getChar() == 'S' ))) {
|
||||
moveDown = getState(event.getStatus(), moveDown);
|
||||
}
|
||||
if(event.getType() == KeyKeyboard.shiftLeft || event.getType() == KeyKeyboard.shiftRight) {
|
||||
walk = event.getSpecialKey().getShift();
|
||||
}
|
||||
if(event.getType() == KeyKeyboard.f10) {
|
||||
if (event.getStatus() == KeyStatus.up) {
|
||||
if (fpsMode == false) {
|
||||
fpsMode = true;
|
||||
distanceFromCenter = 0;
|
||||
} else {
|
||||
fpsMode = false;
|
||||
distanceFromCenter = 2.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(EventInput event, Vector2f relativePosition) {
|
||||
// Log.info("" + event);
|
||||
// TODO Auto-generated method stub
|
||||
if (fpsMode == false) {
|
||||
if (event.getInputId() == 4) {
|
||||
if (event.getStatus() == KeyStatus.down) {
|
||||
distanceFromCenter -= 0.2;
|
||||
}
|
||||
if (distanceFromCenter < 0.0) {
|
||||
distanceFromCenter = 0.0f;
|
||||
}
|
||||
return true;
|
||||
} else if (event.getInputId() == 5) {
|
||||
if (event.getStatus() == KeyStatus.down) {
|
||||
distanceFromCenter += 0.2;
|
||||
}
|
||||
if (distanceFromCenter < 0.3) {
|
||||
distanceFromCenter = 0.3f;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
distanceFromCenter = 0;
|
||||
}
|
||||
// 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 * this.player.getTurnSpeed()));
|
||||
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 * this.player.getTurnSpeed()));
|
||||
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()));
|
||||
*/
|
||||
float tmpAngle = this.playerPosition.getAngles().z + (float)Math.toRadians(delta.x * this.player.getTurnSpeed());
|
||||
|
||||
if (tmpAngle > Math.PI) {
|
||||
tmpAngle -= (float)Math.PI*2.0f;
|
||||
}
|
||||
if (tmpAngle < -Math.PI) {
|
||||
tmpAngle += (float)Math.PI*2.0f;
|
||||
}
|
||||
this.playerPosition.setAngles(new Vector3f(0,0,tmpAngle));
|
||||
this.camera.setRoll(-this.playerPosition.getAngles().z);
|
||||
Log.info("Change camera: " + this.camera.getYaw() + " " + this.camera.getPitch());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void periodicCall(EventTime event) {
|
||||
float speed = 0;
|
||||
float walkFactor = 1;
|
||||
if (this.walk == true) {
|
||||
walkFactor = this.player.getWalkFactor();
|
||||
}
|
||||
//distanceFromCenter = 6;
|
||||
if (moveUp != moveDown) {
|
||||
if (moveUp) {
|
||||
speed = this.player.getRunSpeed();
|
||||
} else {
|
||||
speed = -this.player.getRunSpeed();
|
||||
}
|
||||
}
|
||||
float distance = speed * walkFactor * event.getTimeDeltaCallSecond();
|
||||
float dx = -(float) (distance * Math.sin(this.playerPosition.getAngles().z));
|
||||
float dy = (float) (distance * Math.cos(this.playerPosition.getAngles().z));
|
||||
speed = 0;
|
||||
if (moveRight != moveLeft) {
|
||||
if (moveRight) {
|
||||
speed = this.player.getStrafSpeed();
|
||||
} else {
|
||||
speed = -this.player.getStrafSpeed();
|
||||
}
|
||||
}
|
||||
distance = speed * walkFactor * event.getTimeDeltaCallSecond();
|
||||
float dxStraf = (float) (distance * Math.sin((float)Math.PI*0.5f + this.playerPosition.getAngles().z));
|
||||
float dyStraf = -(float) (distance * Math.cos((float)Math.PI*0.5f + this.playerPosition.getAngles().z));
|
||||
//Log.error("update position ..." + dx + " " + dy);
|
||||
this.playerPosition.getTransform().getPosition().x += dx + dxStraf;
|
||||
this.playerPosition.getTransform().getPosition().y += dy + dyStraf;
|
||||
// here the camera is behind the player, we need to move the camera ...
|
||||
//Log.info(" pitch: " + Math.toDegrees(this.camera.getPitch()) + " " + Math.toDegrees(this.playerPosition.getAngles().z));
|
||||
float horinzontalDistance = (float) (distanceFromCenter * Math.sin(this.camera.getPitch()));
|
||||
float verticalDistance = (float) (distanceFromCenter * Math.cos(this.camera.getPitch()));
|
||||
//Log.info(" distanceFromCenter " + distanceFromCenter);
|
||||
float tmp = -horinzontalDistance;
|
||||
float theta = (float)Math.PI + this.playerPosition.getAngles().z;// - (float)Math.PI*0.5f;
|
||||
float offsetX = (float) (tmp * Math.sin(-theta));
|
||||
float offsetY = (float) (tmp * Math.cos(-theta));
|
||||
//Log.info(" res" + offsetX + " " + offsetY);
|
||||
this.camera.getPosition().x = this.playerPosition.getTransform().getPosition().x + offsetX;
|
||||
this.camera.getPosition().y = this.playerPosition.getTransform().getPosition().y + offsetY;
|
||||
this.camera.getPosition().z = this.playerPosition.getTransform().getPosition().z + 1.6f + verticalDistance;
|
||||
}
|
||||
|
||||
}
|
128
src/org/atriaSoft/gameEngine/ControlCameraPlayerFPS.java
Normal file
128
src/org/atriaSoft/gameEngine/ControlCameraPlayerFPS.java
Normal file
@ -0,0 +1,128 @@
|
||||
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 ControlCameraPlayerFPS implements ControlInterface {
|
||||
private Camera camera;
|
||||
private Entity playerEntity;
|
||||
private ComponentPositionPlayer playerPosition;
|
||||
private ComponentPlayer player;
|
||||
private boolean moveUp = false;
|
||||
private boolean moveDown = false;
|
||||
private boolean moveLeft = false;
|
||||
private boolean moveRight = false;
|
||||
|
||||
public ControlCameraPlayerFPS(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
|
||||
|| (event.getType() == KeyKeyboard.character && (event.getChar() == 'z' || event.getChar() == 'z' ))) {
|
||||
moveUp = getState(event.getStatus(), moveUp);
|
||||
}
|
||||
if(event.getType() == KeyKeyboard.left
|
||||
|| (event.getType() == KeyKeyboard.character && (event.getChar() == 'q' || event.getChar() == 'Q' ))) {
|
||||
moveLeft = getState(event.getStatus(), moveLeft);
|
||||
}
|
||||
if(event.getType() == KeyKeyboard.right
|
||||
|| (event.getType() == KeyKeyboard.character && (event.getChar() == 'd' || event.getChar() == 'D' ))) {
|
||||
moveRight = getState(event.getStatus(), moveRight);
|
||||
}
|
||||
if(event.getType() == KeyKeyboard.down
|
||||
|| (event.getType() == KeyKeyboard.character && (event.getChar() == 's' || event.getChar() == 'S' ))) {
|
||||
moveDown = getState(event.getStatus(), moveDown);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEventInput(EventInput event, Vector2f relativePosition) {
|
||||
// Log.info("" + event);
|
||||
// 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 * this.player.getTurnSpeed()));
|
||||
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 * this.player.getTurnSpeed()));
|
||||
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));
|
||||
speed = 0;
|
||||
if (moveRight != moveLeft) {
|
||||
if (moveRight) {
|
||||
speed = this.player.getStrafSpeed();
|
||||
} else {
|
||||
speed = -this.player.getStrafSpeed();
|
||||
}
|
||||
}
|
||||
distance = speed * event.getTimeDeltaCallSecond();
|
||||
float dxStraf = (float) (distance * Math.sin((float)Math.PI*0.5f + this.playerPosition.getAngles().z));
|
||||
float dyStraf = (float) (distance * Math.cos((float)Math.PI*0.5f + this.playerPosition.getAngles().z));
|
||||
//Log.error("update position ..." + dx + " " + dy);
|
||||
this.playerPosition.getTransform().getPosition().x += dx + dxStraf;
|
||||
this.playerPosition.getTransform().getPosition().y += dy + dyStraf;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -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,10 +42,11 @@ public class Environement {
|
||||
|
||||
public Environement() {
|
||||
// we add the 4 classical engines (the order is used to the global rendering cycle ...
|
||||
addEngine(new EnginePhysics(this));
|
||||
addEngine(new EnginePlayer(this));
|
||||
addEngine(new EngineAI(this));
|
||||
addEngine(new EngineDynamicMeshs(this));
|
||||
addEngine(new EngineRender(this));
|
||||
addEngine(new EnginePhysics(this));
|
||||
addEngine(new EngineParticle(this));
|
||||
addEngine(new EngineLight(this));
|
||||
}
|
||||
|
@ -0,0 +1,73 @@
|
||||
package org.atriaSoft.gameEngine.components;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.atriaSoft.etk.Color;
|
||||
import org.atriaSoft.etk.math.Matrix4f;
|
||||
import org.atriaSoft.gale.backend3d.OpenGL;
|
||||
import org.atriaSoft.gale.resource.ResourceColored3DObject;
|
||||
import org.atriaSoft.gale.test.sample2.Log;
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
import org.atriaSoft.gameEngine.physics.PhysicCollisionAABB;
|
||||
import org.atriaSoft.gameEngine.physics.PhysicShape;
|
||||
|
||||
import entities.Entity;
|
||||
|
||||
public class ComponentPhysics extends Component {
|
||||
private PhysicCollisionAABB aabb;
|
||||
private List<PhysicShape> shapes = new ArrayList<PhysicShape>();
|
||||
private ComponentPosition position;
|
||||
@Override
|
||||
public String getType() {
|
||||
return "physics";
|
||||
}
|
||||
@Override
|
||||
public void addFriendComponent(Component component) {
|
||||
if (component.getType().contentEquals("position")) {
|
||||
position = (ComponentPosition)component;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void removeFriendComponent(Component component) {
|
||||
// nothing to do.
|
||||
}
|
||||
|
||||
public void updateAABB() {
|
||||
if (position == null) {
|
||||
Log.info("No position in Entity ");
|
||||
return;
|
||||
}
|
||||
// TODO: Add a flag to check if it is needed to update the AABB...
|
||||
PhysicCollisionAABB aabb_new = PhysicCollisionAABB.beforeCalculated();
|
||||
for (PhysicShape shape : shapes) {
|
||||
shape.updateAABB(position.getTransform(), aabb_new);
|
||||
}
|
||||
aabb = aabb_new;
|
||||
}
|
||||
|
||||
public PhysicCollisionAABB getcurrentAABB() {
|
||||
return aabb;
|
||||
}
|
||||
public void applyForces(float timeStep) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
public void renderDebug(ResourceColored3DObject debugDrawProperty) {
|
||||
if (aabb != null) {
|
||||
debugDrawProperty.drawCubeLine(aabb.getMin(), aabb.getMax(), new Color(1,1,1,1), Matrix4f.identity(), true, true);
|
||||
//debugDrawProperty.drawCubeLine(new Vector3f(0,0,0), new Vector3f(32,32,32), new Color(1,0,1,1), Matrix4f.identity(), true, true);
|
||||
} else {
|
||||
Log.error("no AABB");
|
||||
}
|
||||
for (PhysicShape shape : shapes) {
|
||||
shape.renderDebug(position.getTransform(), debugDrawProperty);
|
||||
}
|
||||
}
|
||||
public void addShape(PhysicShape shape) {
|
||||
shapes.add(shape);
|
||||
}
|
||||
public void clearShape() {
|
||||
shapes.clear();
|
||||
}
|
||||
}
|
68
src/org/atriaSoft/gameEngine/components/ComponentPlayer.java
Normal file
68
src/org/atriaSoft/gameEngine/components/ComponentPlayer.java
Normal file
@ -0,0 +1,68 @@
|
||||
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 strafSpeed = 25;
|
||||
private float turnSpeed = 0.45f;
|
||||
private float jumpPower = 30;
|
||||
private float walkFactor = 0.37f;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public float getStrafSpeed() {
|
||||
return strafSpeed;
|
||||
}
|
||||
|
||||
public void setStrafSpeed(float strafSpeed) {
|
||||
this.strafSpeed = strafSpeed;
|
||||
}
|
||||
|
||||
public float getWalkFactor() {
|
||||
return walkFactor;
|
||||
}
|
||||
|
||||
public void setWalkFactor(float walkFactor) {
|
||||
this.walkFactor = walkFactor;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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.clone();
|
||||
// TODO: update transform3D
|
||||
this.transform.getOrientation().setEulerAngles(this.angles);
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package org.atriaSoft.gameEngine.components;
|
||||
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
|
||||
public class CoponentPhysics extends Component {
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return "physics";
|
||||
}
|
||||
}
|
16
src/org/atriaSoft/gameEngine/data/simple3D.frag
Normal file
16
src/org/atriaSoft/gameEngine/data/simple3D.frag
Normal file
@ -0,0 +1,16 @@
|
||||
#version 400 core
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
in vec4 io_color;
|
||||
|
||||
// output:
|
||||
out vec4 out_Color;
|
||||
|
||||
void main(void) {
|
||||
out_Color = io_color;
|
||||
}
|
||||
|
21
src/org/atriaSoft/gameEngine/data/simple3D.vert
Normal file
21
src/org/atriaSoft/gameEngine/data/simple3D.vert
Normal file
@ -0,0 +1,21 @@
|
||||
#version 400 core
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
// Input :
|
||||
in vec3 in_position;
|
||||
uniform vec4 in_colors;
|
||||
uniform mat4 in_matrixTransformation;
|
||||
uniform mat4 in_matrixProjection;
|
||||
uniform mat4 in_matrixView;
|
||||
|
||||
// output :
|
||||
out vec4 io_color;
|
||||
|
||||
void main(void) {
|
||||
gl_Position = in_matrixProjection * in_matrixView * in_matrixTransformation * vec4(in_position, 1.0);
|
||||
io_color = vec4(in_colors.xyz, 0.3);
|
||||
}
|
@ -1,13 +1,27 @@
|
||||
package org.atriaSoft.gameEngine.engines;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.atriaSoft.etk.Color;
|
||||
import org.atriaSoft.etk.math.Matrix4f;
|
||||
import org.atriaSoft.etk.math.Vector3f;
|
||||
import org.atriaSoft.gale.resource.ResourceColored3DObject;
|
||||
import org.atriaSoft.gale.test.sample2.Log;
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
import org.atriaSoft.gameEngine.Engine;
|
||||
import org.atriaSoft.gameEngine.Environement;
|
||||
import org.atriaSoft.gameEngine.camera.Camera;
|
||||
import org.atriaSoft.gameEngine.components.ComponentAI;
|
||||
import org.atriaSoft.gameEngine.components.ComponentPhysics;
|
||||
import org.atriaSoft.gameEngine.components.ComponentRender;
|
||||
|
||||
public class EnginePhysics extends Engine {
|
||||
public static final String ENGINE_NAME = "physics";
|
||||
|
||||
private float accumulator = 0;
|
||||
private static float TIME_STEP = 0.02f;
|
||||
private Vector<ComponentPhysics> components = new Vector<ComponentPhysics>();
|
||||
private ResourceColored3DObject debugDrawProperty = ResourceColored3DObject.create();
|
||||
|
||||
public EnginePhysics(Environement env) {
|
||||
super(env);
|
||||
// TODO Auto-generated constructor stub
|
||||
@ -15,26 +29,62 @@ public class EnginePhysics extends Engine {
|
||||
|
||||
@Override
|
||||
public void componentRemove(Component ref) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
components.remove(ref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentAdd(Component ref) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (ref instanceof ComponentPhysics == false) {
|
||||
return;
|
||||
}
|
||||
components.add((ComponentPhysics)ref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(long deltaMili) {
|
||||
// TODO Auto-generated method stub
|
||||
// Add the time difference in the accumulator
|
||||
accumulator += (float)deltaMili*0.0001f;
|
||||
// While there is enough accumulated time to take one or several physics steps
|
||||
while (accumulator >= TIME_STEP) {
|
||||
Log.info("update physic ... " + accumulator);
|
||||
applyForces(TIME_STEP);
|
||||
updateAABB(TIME_STEP);
|
||||
updateCollisions(TIME_STEP);
|
||||
GenerateResultCollisionsForces(TIME_STEP);
|
||||
// Decrease the accumulated time
|
||||
accumulator -= TIME_STEP;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void applyForces(float timeStep) {
|
||||
for (ComponentPhysics it: components) {
|
||||
it.applyForces(TIME_STEP);
|
||||
}
|
||||
}
|
||||
private void updateAABB(float timeStep) {
|
||||
for (ComponentPhysics it: components) {
|
||||
it.updateAABB();
|
||||
}
|
||||
}
|
||||
private void updateCollisions(float timeStep) {
|
||||
|
||||
}
|
||||
private void GenerateResultCollisionsForces(float timeStep) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(long deltaMili, Camera camera) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
for (ComponentPhysics it: this.components) {
|
||||
//Log.info("Render " + it);
|
||||
it.renderDebug(debugDrawProperty);
|
||||
}
|
||||
//debugDrawProperty.drawCone(2, 5, 9, 12, Matrix4f.identity(), new Color(1,1,0,1));
|
||||
//debugDrawProperty.drawSquare(new Vector3f(1,1,1), Matrix4f.identity(), new Color(1,1,0,1));
|
||||
//debugDrawProperty.drawCubeLine(new Vector3f(1,1,1), new Vector3f(5,5,5), new Color(1,0,1,1), Matrix4f.identity(), true, true);
|
||||
//debugDrawProperty.drawCubeLine(new Vector3f(0,0,0), new Vector3f(32,32,32), new Color(1,0,1,1), Matrix4f.identity(), true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
56
src/org/atriaSoft/gameEngine/engines/EnginePlayer.java
Normal file
56
src/org/atriaSoft/gameEngine/engines/EnginePlayer.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
@ -14,6 +14,7 @@ import org.atriaSoft.gameEngine.Material;
|
||||
import org.atriaSoft.gameEngine.components.ComponentLight;
|
||||
import org.atriaSoft.gameEngine.components.ComponentLightSun;
|
||||
import org.atriaSoft.gameEngine.components.ComponentMaterials;
|
||||
import org.atriaSoft.gameEngine.components.ComponentPhysics;
|
||||
import org.atriaSoft.gameEngine.components.ComponentPosition;
|
||||
import org.atriaSoft.gameEngine.components.ComponentRenderTexturedMaterialsDynamicMeshs;
|
||||
import org.atriaSoft.gameEngine.components.ComponentRenderTexturedMaterialsStaticMeshs;
|
||||
@ -24,6 +25,8 @@ import org.atriaSoft.gameEngine.components.ComponentTexture;
|
||||
import org.atriaSoft.gameEngine.components.ComponentTextures;
|
||||
import org.atriaSoft.gameEngine.engines.EngineLight;
|
||||
import org.atriaSoft.gameEngine.engines.EngineMap;
|
||||
import org.atriaSoft.gameEngine.physics.PhysicBox;
|
||||
import org.atriaSoft.gameEngine.physics.PhysicMapVoxel;
|
||||
|
||||
public class MapVoxel extends EngineMap {
|
||||
//List<VoxelChunk> listOfChunks = new ArrayList<VoxelChunk>();
|
||||
@ -71,6 +74,10 @@ public class MapVoxel extends EngineMap {
|
||||
new Uri("DATA", "basicMaterial.vert"),
|
||||
new Uri("DATA", "basicMaterial.frag"),
|
||||
(EngineLight)env.getEngine(EngineLight.ENGINE_NAME)));
|
||||
ComponentPhysics physics = new ComponentPhysics();
|
||||
PhysicMapVoxel box = new PhysicMapVoxel(tmpVoxelChunk);
|
||||
physics.addShape(box);
|
||||
tmpEntity.addComponent(physics);
|
||||
this.env.addEntity(tmpEntity);
|
||||
|
||||
}
|
||||
|
36
src/org/atriaSoft/gameEngine/physics/PhysicBox.java
Normal file
36
src/org/atriaSoft/gameEngine/physics/PhysicBox.java
Normal file
@ -0,0 +1,36 @@
|
||||
package org.atriaSoft.gameEngine.physics;
|
||||
|
||||
import org.atriaSoft.etk.Color;
|
||||
import org.atriaSoft.etk.math.Transform3D;
|
||||
import org.atriaSoft.etk.math.Vector3f;
|
||||
import org.atriaSoft.gale.resource.ResourceColored3DObject;
|
||||
|
||||
public class PhysicBox extends PhysicShape {
|
||||
// Box size property in X, Y and Z
|
||||
private Vector3f size = new Vector3f(1,1,1);
|
||||
public PhysicBox() {
|
||||
super(PhysicShapeType.BOX);
|
||||
}
|
||||
public Vector3f getSize() {
|
||||
return size;
|
||||
}
|
||||
public void setSize(Vector3f size) {
|
||||
this.size = size;
|
||||
}
|
||||
@Override
|
||||
public void updateAABB(Transform3D transform, PhysicCollisionAABB aabb) {
|
||||
// TODO Auto-generated method stub
|
||||
aabb.update(transform.multiply(this.transform.multiply(new Vector3f(this.size.x*0.5f,this.size.y*0.5f,this.size.z*0.5f))));
|
||||
aabb.update(transform.multiply(this.transform.multiply(new Vector3f(-this.size.x*0.5f,this.size.y*0.5f,this.size.z*0.5f))));
|
||||
aabb.update(transform.multiply(this.transform.multiply(new Vector3f(-this.size.x*0.5f,-this.size.y*0.5f,this.size.z*0.5f))));
|
||||
aabb.update(transform.multiply(this.transform.multiply(new Vector3f(this.size.x*0.5f,-this.size.y*0.5f,this.size.z*0.5f))));
|
||||
aabb.update(transform.multiply(this.transform.multiply(new Vector3f(this.size.x*0.5f,this.size.y*0.5f,-this.size.z*0.5f))));
|
||||
aabb.update(transform.multiply(this.transform.multiply(new Vector3f(-this.size.x*0.5f,this.size.y*0.5f,-this.size.z*0.5f))));
|
||||
aabb.update(transform.multiply(this.transform.multiply(new Vector3f(-this.size.x*0.5f,-this.size.y*0.5f,-this.size.z*0.5f))));
|
||||
aabb.update(transform.multiply(this.transform.multiply(new Vector3f(this.size.x*0.5f,-this.size.y*0.5f,-this.size.z*0.5f))));
|
||||
}
|
||||
@Override
|
||||
public void renderDebug(Transform3D transform, ResourceColored3DObject debugDrawProperty) {
|
||||
debugDrawProperty.drawSquare(this.size.multiply_new(0.5f), this.transform.getOpenGLMatrix().multiply_new(transform.getOpenGLMatrix()), new Color(0,1,0,0.25f));
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package org.atriaSoft.gameEngine.physics;
|
||||
|
||||
import org.atriaSoft.etk.math.Vector3f;
|
||||
|
||||
public class PhysicCollisionAABB {
|
||||
public float minX;
|
||||
public float minY;
|
||||
public float minZ;
|
||||
public float maxX;
|
||||
public float maxY;
|
||||
public float maxZ;
|
||||
public PhysicCollisionAABB(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
|
||||
super();
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
public boolean intersect(PhysicCollisionAABB other) {
|
||||
if (minX > other.maxX) {
|
||||
return false;
|
||||
}
|
||||
if (maxX < other.minX) {
|
||||
return false;
|
||||
}
|
||||
if (minY > other.maxY) {
|
||||
return false;
|
||||
}
|
||||
if (maxY < other.minY) {
|
||||
return false;
|
||||
}
|
||||
if (minZ > other.maxZ) {
|
||||
return false;
|
||||
}
|
||||
if (maxZ < other.minZ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void update(Vector3f point) {
|
||||
if (minX > point.x) {
|
||||
minX = point.x;
|
||||
}
|
||||
if (maxX < point.x) {
|
||||
maxX = point.x;
|
||||
}
|
||||
if (minY > point.y) {
|
||||
minY = point.y;
|
||||
}
|
||||
if (maxY < point.y) {
|
||||
maxY = point.y;
|
||||
}
|
||||
if (minZ > point.z) {
|
||||
minZ = point.z;
|
||||
}
|
||||
if (maxZ < point.z) {
|
||||
maxZ = point.z;
|
||||
}
|
||||
}
|
||||
public Vector3f getMin() {
|
||||
return new Vector3f(minX, minY, minZ);
|
||||
}
|
||||
public Vector3f getMax() {
|
||||
return new Vector3f(maxX, maxY, maxZ);
|
||||
}
|
||||
public static PhysicCollisionAABB beforeCalculated() {
|
||||
// TODO Auto-generated method stub
|
||||
return new PhysicCollisionAABB(999999,999999,999999,-999999,-999999,-999999);
|
||||
}
|
||||
}
|
||||
|
||||
|
31
src/org/atriaSoft/gameEngine/physics/PhysicMapVoxel.java
Normal file
31
src/org/atriaSoft/gameEngine/physics/PhysicMapVoxel.java
Normal file
@ -0,0 +1,31 @@
|
||||
package org.atriaSoft.gameEngine.physics;
|
||||
|
||||
import org.atriaSoft.etk.math.Transform3D;
|
||||
import org.atriaSoft.etk.math.Vector3f;
|
||||
import org.atriaSoft.gale.resource.ResourceColored3DObject;
|
||||
import org.atriaSoft.gameEngine.map.VoxelChunk;
|
||||
|
||||
public class PhysicMapVoxel extends PhysicShape {
|
||||
// Box size property in X, Y and Z
|
||||
private VoxelChunk chunk;
|
||||
public PhysicMapVoxel(VoxelChunk chunk) {
|
||||
super(PhysicShapeType.MAP_VOXEL);
|
||||
this.chunk = chunk;
|
||||
}
|
||||
@Override
|
||||
public void updateAABB(Transform3D transform, PhysicCollisionAABB aabb) {
|
||||
if (this.chunk == null) {
|
||||
return;
|
||||
}
|
||||
aabb.update(new Vector3f(this.chunk.getPosition().x,this.chunk.getPosition().y,this.chunk.getPosition().z));
|
||||
aabb.update(new Vector3f(
|
||||
this.chunk.getPosition().x + VoxelChunk.VOXEL_CHUNK_SIZE,
|
||||
this.chunk.getPosition().y + VoxelChunk.VOXEL_CHUNK_SIZE,
|
||||
this.chunk.getPosition().z + VoxelChunk.VOXEL_CHUNK_SIZE));
|
||||
}
|
||||
@Override
|
||||
public void renderDebug(Transform3D transform, ResourceColored3DObject debugDrawProperty) {
|
||||
|
||||
|
||||
}
|
||||
}
|
59
src/org/atriaSoft/gameEngine/physics/PhysicShape.java
Normal file
59
src/org/atriaSoft/gameEngine/physics/PhysicShape.java
Normal file
@ -0,0 +1,59 @@
|
||||
package org.atriaSoft.gameEngine.physics;
|
||||
|
||||
import org.atriaSoft.etk.math.Quaternion;
|
||||
import org.atriaSoft.etk.math.Transform3D;
|
||||
import org.atriaSoft.etk.math.Vector3f;
|
||||
import org.atriaSoft.gale.resource.ResourceColored3DObject;
|
||||
|
||||
public abstract class PhysicShape {
|
||||
// protected Quaternion quaternion;
|
||||
// protected Vector3f origin;
|
||||
protected Transform3D transform;
|
||||
protected float mass = 0;
|
||||
protected final PhysicShapeType type;
|
||||
|
||||
public PhysicShape(PhysicShapeType type) {
|
||||
this.type = type;
|
||||
this.transform = new Transform3D();
|
||||
// this.quaternion = Quaternion.identity();
|
||||
// this.origin = Vector3f.zero();
|
||||
this.mass = 0;
|
||||
}
|
||||
public PhysicShape(PhysicShapeType type, Quaternion quaternion, Vector3f origin, float mass) {
|
||||
this.type = type;
|
||||
this.transform = new Transform3D(origin, quaternion);
|
||||
// this.quaternion = quaternion;
|
||||
// this.origin = origin;
|
||||
this.mass = mass;
|
||||
}
|
||||
public Quaternion getQuaternion() {
|
||||
return transform.getOrientation();
|
||||
}
|
||||
public void setQuaternion(Quaternion quaternion) {
|
||||
this.transform.setOrientation(quaternion);
|
||||
}
|
||||
public Vector3f getOrigin() {
|
||||
return this.transform.getPosition();
|
||||
}
|
||||
public void setOrigin(Vector3f origin) {
|
||||
this.transform.setPosition(origin);
|
||||
}
|
||||
public Transform3D getTransform() {
|
||||
return transform;
|
||||
}
|
||||
public void setTransform(Transform3D transform) {
|
||||
this.transform = transform;
|
||||
}
|
||||
public float getMass() {
|
||||
return mass;
|
||||
}
|
||||
public void setMass(float mass) {
|
||||
this.mass = mass;
|
||||
}
|
||||
public PhysicShapeType getType() {
|
||||
return type;
|
||||
}
|
||||
public abstract void updateAABB(Transform3D transform, PhysicCollisionAABB aabb);
|
||||
public abstract void renderDebug(Transform3D transform, ResourceColored3DObject debugDrawProperty);
|
||||
|
||||
}
|
13
src/org/atriaSoft/gameEngine/physics/PhysicShapeType.java
Normal file
13
src/org/atriaSoft/gameEngine/physics/PhysicShapeType.java
Normal file
@ -0,0 +1,13 @@
|
||||
package org.atriaSoft.gameEngine.physics;
|
||||
|
||||
public enum PhysicShapeType {
|
||||
UNKNOWN,
|
||||
BOX,
|
||||
CAPSULE,
|
||||
CONE,
|
||||
CONVEXHULL,
|
||||
CYLINDER,
|
||||
SPHERE,
|
||||
CONCAVE,
|
||||
MAP_VOXEL
|
||||
}
|
34
src/org/atriaSoft/gameEngine/physics/PhysicSphere.java
Normal file
34
src/org/atriaSoft/gameEngine/physics/PhysicSphere.java
Normal file
@ -0,0 +1,34 @@
|
||||
package org.atriaSoft.gameEngine.physics;
|
||||
|
||||
import org.atriaSoft.etk.Color;
|
||||
import org.atriaSoft.etk.math.Transform3D;
|
||||
import org.atriaSoft.etk.math.Vector3f;
|
||||
import org.atriaSoft.gale.resource.ResourceColored3DObject;
|
||||
|
||||
public class PhysicSphere extends PhysicShape {
|
||||
// Box size property in X, Y and Z
|
||||
private float size;
|
||||
public PhysicSphere() {
|
||||
super(PhysicShapeType.SPHERE);
|
||||
}
|
||||
public float getSize() {
|
||||
return size;
|
||||
}
|
||||
public void setSize(float size) {
|
||||
this.size = size;
|
||||
}
|
||||
@Override
|
||||
public void updateAABB(Transform3D transform, PhysicCollisionAABB aabb) {
|
||||
aabb.update(transform.multiply(this.transform.getPosition()).add_new(new Vector3f(this.size,0,0)));
|
||||
aabb.update(transform.multiply(this.transform.getPosition()).add_new(new Vector3f(-this.size,0,0)));
|
||||
aabb.update(transform.multiply(this.transform.getPosition()).add_new(new Vector3f(0,this.size,0)));
|
||||
aabb.update(transform.multiply(this.transform.getPosition()).add_new(new Vector3f(0,-this.size,0)));
|
||||
aabb.update(transform.multiply(this.transform.getPosition()).add_new(new Vector3f(0,0,this.size)));
|
||||
aabb.update(transform.multiply(this.transform.getPosition()).add_new(new Vector3f(0,0,-this.size)));
|
||||
}
|
||||
@Override
|
||||
public void renderDebug(Transform3D transform, ResourceColored3DObject debugDrawProperty) {
|
||||
debugDrawProperty.drawSphere(this.size, 9, 9, this.transform.getOpenGLMatrix().multiply_new(transform.getOpenGLMatrix()), new Color(0,1,0,1));
|
||||
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package org.atriaSoft.gameEngine.sample.LoxelEngine;
|
||||
|
||||
public class Log {
|
||||
private static String LIBNAME = "Sample1";
|
||||
private static String LIBNAME = "LoxelEngine";
|
||||
public static void print(String data) {
|
||||
System.out.println(data);
|
||||
}
|
||||
|
@ -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,10 @@ 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.ComponentPhysics;
|
||||
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;
|
||||
@ -29,6 +34,7 @@ import org.atriaSoft.gameEngine.components.ComponentStaticMesh;
|
||||
import org.atriaSoft.gameEngine.components.ComponentTexture;
|
||||
import org.atriaSoft.gameEngine.engines.EngineLight;
|
||||
import org.atriaSoft.gameEngine.map.MapVoxel;
|
||||
import org.atriaSoft.gameEngine.physics.PhysicBox;
|
||||
import org.atriaSoft.gameEngine.tools.MeshGenerator;
|
||||
import org.atriaSoft.gale.key.KeyKeyboard;
|
||||
import org.atriaSoft.gale.key.KeySpecial;
|
||||
@ -41,16 +47,17 @@ public class LoxelApplication extends Application {
|
||||
private Quaternion basicRotation = Quaternion.identity();
|
||||
private Quaternion basicRotation2 = Quaternion.identity();
|
||||
private boolean creationDone;
|
||||
private ControlCameraSimple simpleControl;
|
||||
private Material materialCube;
|
||||
private ControlCameraPlayer simpleControl;
|
||||
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 +74,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 +85,33 @@ 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(
|
||||
Entity player = new Entity(this.env);
|
||||
objectPosition = new ComponentPositionPlayer(new Transform3D(new Vector3f(5,5,13)));
|
||||
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 ComponentStaticMesh(new Uri("RES", "person_-yfw_zup.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(basicTree);
|
||||
ComponentPhysics physics = new ComponentPhysics();
|
||||
PhysicBox box = new PhysicBox();
|
||||
box.setSize(new Vector3f(0.6f,0.6f,1.8f));
|
||||
box.setOrigin(new Vector3f(0,0,0.9f));
|
||||
physics.addShape(box);
|
||||
player.addComponent(physics);
|
||||
env.addEntity(player);
|
||||
|
||||
|
||||
Camera mainView = new Camera();
|
||||
@ -104,7 +119,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.
|
||||
@ -123,13 +138,9 @@ public class LoxelApplication extends Application {
|
||||
if (this.creationDone == false) {
|
||||
return;
|
||||
}
|
||||
//materialCube.setAmbientFactor(new Vector3f(1.0f,1.0f,1.0f));
|
||||
// apply a little rotation to show the element move
|
||||
//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 +165,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);
|
||||
@ -162,7 +173,6 @@ public class LoxelApplication extends Application {
|
||||
OpenGL.enable(Flag.flag_depthTest);
|
||||
|
||||
env.render(20, "default");
|
||||
|
||||
// Restore context of matrix
|
||||
OpenGL.pop();
|
||||
}
|
||||
@ -179,6 +189,15 @@ public class LoxelApplication extends Application {
|
||||
KeyKeyboard type,
|
||||
Character value,
|
||||
KeyStatus state) {
|
||||
if (type == KeyKeyboard.f1 ) {
|
||||
Gale.getContext().grabPointerEvents(false, new Vector2f(0,0));
|
||||
}
|
||||
if (type == KeyKeyboard.f2 ) {
|
||||
Gale.getContext().grabPointerEvents(true, new Vector2f(0,0));
|
||||
}
|
||||
if (type == KeyKeyboard.f12 ) {
|
||||
Gale.getContext().setFullScreen(!Gale.getContext().getFullScreen());
|
||||
}
|
||||
env.onKeyboard(special, type, value, state);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user