1
0
Fork 0

Add Game Engine Main File

This commit is contained in:
MrDev023 2017-01-14 13:13:28 +01:00
parent 929fcb19f2
commit 569f2dfb00
39 changed files with 2503 additions and 29 deletions

2
.gitignore vendored
View file

@ -11,3 +11,5 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea/*

View file

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="lwjgl">
<CLASSES>
<root url="jar://$PROJECT_DIR$/libs/lwjgl.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -1,7 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="00f293cb-c755-478c-9b6f-422f827454e0" name="Default" comment="" />
<list default="true" id="00f293cb-c755-478c-9b6f-422f827454e0" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/lwjgl.xml" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
<change type="DELETED" beforePath="$PROJECT_DIR$/src/com/company/Main.java" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.gitignore" afterPath="$PROJECT_DIR$/.gitignore" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
</list>
<ignored path="$PROJECT_DIR$/out/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -16,11 +22,109 @@
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="Main.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/com/company/Main.java">
<file leaf-file-name="Main.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-740">
<caret line="19" column="3" lean-forward="false" selection-start-line="19" selection-start-column="3" selection-end-line="19" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name=".gitignore" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="7" lean-forward="true" selection-start-line="14" selection-start-column="7" selection-end-line="14" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Quaternion.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Quaternion.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="3" lean-forward="false" selection-start-line="4" selection-start-column="3" selection-end-line="4" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Vector2f.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Vector2f.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
<caret line="7" column="3" lean-forward="false" selection-start-line="7" selection-start-column="3" selection-end-line="7" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Vector3f.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Vector3f.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
<caret line="7" column="3" lean-forward="false" selection-start-line="7" selection-start-column="3" selection-end-line="7" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Vector4f.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Vector4f.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="3" lean-forward="false" selection-start-line="4" selection-start-column="3" selection-end-line="4" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Camera.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/Camera.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="12" column="3" lean-forward="false" selection-start-line="12" selection-start-column="3" selection-end-line="12" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="DisplayManager.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/DisplayManager.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" column="3" lean-forward="false" selection-start-line="9" selection-start-column="3" selection-end-line="9" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Shaders.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/Shaders.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" column="3" lean-forward="false" selection-start-line="9" selection-start-column="3" selection-end-line="9" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Texture.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/Texture.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="5" column="27" lean-forward="true" selection-start-line="5" selection-start-column="27" selection-end-line="5" selection-end-column="27" />
<caret line="14" column="3" lean-forward="false" selection-start-line="14" selection-start-column="3" selection-end-line="14" selection-end-column="3" />
<folding />
</state>
</provider>
@ -28,11 +132,47 @@
</file>
</leaf>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>fr.technicalgames</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="GradleLocalSettings">
<option name="externalProjectsViewState">
<projects_view />
</option>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/com/company/Main.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/render/Asset.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/render/gui/GUIComponent.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/audio/Audio.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/audio/Sound3D.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/game/Game.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/game/MainGame.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/input/Input.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/input/IO.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/math/Color4f.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/math/Mathf.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/math/Matrix4f.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/math/Quaternion.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/math/Vector2f.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/math/Vector3f.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/math/Vector4f.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/render/Camera.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/render/DisplayManager.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/render/Shaders.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/render/Texture.java" />
<option value="$PROJECT_DIR$/src/globalgamejam/Main.java" />
<option value="$PROJECT_DIR$/.gitignore" />
</list>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="x" value="-8" />
<option name="y" value="-8" />
@ -59,27 +199,21 @@
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="untitled104" />
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
@ -87,7 +221,117 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="company" />
<option name="myItemId" value="globalgamejam" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="globalgamejam" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="render" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="globalgamejam" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="math" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="globalgamejam" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="input" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="globalgamejam" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="game" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="GGL-2017" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="globalgamejam" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="audio" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
@ -97,15 +341,21 @@
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$/libs/lwjgl.jar!/" />
<property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.2" />
</component>
<component name="RunManager" selected="Application.Main">
<configuration default="false" name="Main" type="Application" factoryName="Application" temporary="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="com.company.Main" />
<option name="VM_PARAMETERS" value="" />
<option name="MAIN_CLASS_NAME" value="globalgamejam.Main" />
<option name="VM_PARAMETERS" value="-Djava.library.path=./libs/" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
@ -115,6 +365,61 @@
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
<configuration default="true" type="AndroidRunConfigurationType" factoryName="Android App">
<module name="" />
<option name="DEPLOY" value="true" />
<option name="ARTIFACT_NAME" value="" />
<option name="PM_INSTALL_OPTIONS" value="" />
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
<option name="MODE" value="default_activity" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="PREFERRED_AVD" value="" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="DEBUGGER_TYPE" value="Java" />
<option name="USE_LAST_SELECTED_DEVICE" value="false" />
<option name="PREFERRED_AVD" value="" />
<Java />
<Profilers>
<option name="ENABLE_ADVANCED_PROFILING" value="true" />
<option name="GAPID_ENABLED" value="false" />
<option name="GAPID_DISABLE_PCS" value="false" />
<option name="SUPPORT_LIB_ENABLED" value="true" />
<option name="INSTRUMENTATION_ENABLED" value="true" />
</Profilers>
<option name="DEEP_LINK" value="" />
<option name="ACTIVITY_CLASS" value="" />
<method />
</configuration>
<configuration default="true" type="AndroidTestRunConfigurationType" factoryName="Android Tests">
<module name="" />
<option name="TESTING_TYPE" value="0" />
<option name="INSTRUMENTATION_RUNNER_CLASS" value="" />
<option name="METHOD_NAME" value="" />
<option name="CLASS_NAME" value="" />
<option name="PACKAGE_NAME" value="" />
<option name="EXTRA_OPTIONS" value="" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="PREFERRED_AVD" value="" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="DEBUGGER_TYPE" value="Java" />
<option name="USE_LAST_SELECTED_DEVICE" value="false" />
<option name="PREFERRED_AVD" value="" />
<Java />
<Profilers>
<option name="ENABLE_ADVANCED_PROFILING" value="true" />
<option name="GAPID_ENABLED" value="false" />
<option name="GAPID_DISABLE_PCS" value="false" />
<option name="SUPPORT_LIB_ENABLED" value="true" />
<option name="INSTRUMENTATION_ENABLED" value="true" />
</Profilers>
<method />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
@ -130,6 +435,117 @@
<envs />
<method />
</configuration>
<configuration default="true" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list />
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<method />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<envs />
<patterns />
<method />
</configuration>
<configuration default="true" type="JarApplication" factoryName="JAR Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<envs />
<method />
</configuration>
<configuration default="true" type="Java Scratch" factoryName="Java Scratch">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="SCRATCH_FILE_ID" value="0" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method />
</configuration>
<configuration default="true" type="JetRunConfigurationType" factoryName="Kotlin">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" />
<option name="PROGRAM_PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="GGL-2017" />
<envs />
<method />
</configuration>
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType" factoryName="Kotlin script">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="filePath" />
<option name="vmParameters" />
<option name="alternativeJrePath" />
<option name="programParameters" />
<option name="passParentEnvs" value="true" />
<option name="workingDirectory" />
<option name="isAlternativeJrePathEnabled" value="false" />
<envs />
<method />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" />
<option name="OUTPUT_DIRECTORY" />
<option name="ANNOTATION_TYPE" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<envs />
<properties />
<listeners />
<method />
</configuration>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="Application.Main" />
</list>
@ -160,7 +576,7 @@
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Properties" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
@ -188,13 +604,291 @@
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/com/company/Main.java">
<entry file="file://$USER_HOME$/AppData/Local/Temp/Rar$DIa0.122/Shadow.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-247">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Local/Temp/Rar$DIa0.200/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="30" column="28" lean-forward="true" selection-start-line="0" selection-start-column="0" selection-end-line="113" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/Asset.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1284">
<caret line="11" column="13" lean-forward="false" selection-start-line="11" selection-start-column="13" selection-end-line="11" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/gui/GLFont.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="6" column="13" lean-forward="false" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/gui/GUIComponent.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="22" lean-forward="false" selection-start-line="4" selection-start-column="22" selection-end-line="4" selection-end-column="22" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/audio/Audio.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="21" column="59" lean-forward="false" selection-start-line="21" selection-start-column="59" selection-end-line="21" selection-end-column="59" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/audio/Sound3D.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="0" lean-forward="true" selection-start-line="4" selection-start-column="0" selection-end-line="6" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/game/Game.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136">
<caret line="8" column="3" lean-forward="false" selection-start-line="8" selection-start-column="3" selection-end-line="8" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/game/MainGame.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136">
<caret line="8" column="3" lean-forward="false" selection-start-line="8" selection-start-column="3" selection-end-line="8" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/input/Input.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="15" column="3" lean-forward="false" selection-start-line="15" selection-start-column="3" selection-end-line="15" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/input/IO.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="5" column="27" lean-forward="true" selection-start-line="5" selection-start-column="27" selection-end-line="5" selection-end-column="27" />
<caret line="5" column="3" lean-forward="false" selection-start-line="5" selection-start-column="3" selection-end-line="5" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Color4f.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
<caret line="7" column="3" lean-forward="false" selection-start-line="7" selection-start-column="3" selection-end-line="7" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Mathf.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="5" column="3" lean-forward="false" selection-start-line="5" selection-start-column="3" selection-end-line="5" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Matrix4f.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="3" lean-forward="false" selection-start-line="10" selection-start-column="3" selection-end-line="10" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Quaternion.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="3" lean-forward="false" selection-start-line="4" selection-start-column="3" selection-end-line="4" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Vector2f.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
<caret line="7" column="3" lean-forward="false" selection-start-line="7" selection-start-column="3" selection-end-line="7" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Vector3f.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
<caret line="7" column="3" lean-forward="false" selection-start-line="7" selection-start-column="3" selection-end-line="7" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/math/Vector4f.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="3" lean-forward="false" selection-start-line="4" selection-start-column="3" selection-end-line="4" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/Camera.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="12" column="3" lean-forward="false" selection-start-line="12" selection-start-column="3" selection-end-line="12" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/DisplayManager.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" column="3" lean-forward="false" selection-start-line="9" selection-start-column="3" selection-end-line="9" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/Shaders.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="9" column="3" lean-forward="false" selection-start-line="9" selection-start-column="3" selection-end-line="9" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/render/Texture.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="14" column="3" lean-forward="false" selection-start-line="14" selection-start-column="3" selection-end-line="14" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/globalgamejam/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-740">
<caret line="19" column="3" lean-forward="false" selection-start-line="19" selection-start-column="3" selection-end-line="19" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
<caret line="14" column="7" lean-forward="true" selection-start-line="14" selection-start-column="7" selection-end-line="14" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<last-edited>No facets are configured</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>GGL-2017</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.6" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<last-edited>lwjgl</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

BIN
libs/OpenAL.dll Normal file

Binary file not shown.

BIN
libs/OpenAL32.dll Normal file

Binary file not shown.

BIN
libs/glfw.dll Normal file

Binary file not shown.

BIN
libs/glfw32.dll Normal file

Binary file not shown.

BIN
libs/jemalloc.dll Normal file

Binary file not shown.

BIN
libs/jemalloc32.dll Normal file

Binary file not shown.

BIN
libs/libglfw.dylib Normal file

Binary file not shown.

BIN
libs/libglfw.so Normal file

Binary file not shown.

BIN
libs/libjemalloc.dylib Normal file

Binary file not shown.

BIN
libs/libjemalloc.so Normal file

Binary file not shown.

BIN
libs/liblwjgl.dylib Normal file

Binary file not shown.

BIN
libs/liblwjgl.so Normal file

Binary file not shown.

BIN
libs/libopenal.dylib Normal file

Binary file not shown.

BIN
libs/libopenal.so Normal file

Binary file not shown.

BIN
libs/lwjgl.dll Normal file

Binary file not shown.

BIN
libs/lwjgl32.dll Normal file

Binary file not shown.

View file

@ -1,8 +0,0 @@
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
}
}

111
src/globalgamejam/Main.java Normal file
View file

@ -0,0 +1,111 @@
package globalgamejam;
//http://www.tomdalling.com/blog/modern-opengl/08-even-more-lighting-directional-lights-spotlights-multiple-lights/
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.system.MemoryUtil.*;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import globalgamejam.audio.*;
import globalgamejam.game.*;
import globalgamejam.input.*;
import globalgamejam.math.*;
import globalgamejam.render.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Main {
//Valeur de la fenetre
public static final int WIDTH = 800,HEIGHT = 600;
public static final String TITLE = "Test Shader OpenGL";
//Variable pour la gestion de la fenetre
public static long windowID = 0;
public static GLFWErrorCallback errorCallback;
//variable du moteur du jeu
public static float delta = 0;
public static Game game;
public static long previous = System.currentTimeMillis(),previousInfo = System.currentTimeMillis(),previousTicks = System.currentTimeMillis();
public static int FPS = 0,TICKS = 0;
public static void main(String[] args) throws Exception {
//Creation de la fenetre
//------------------------------------------------------------------------------------
errorCallback = new GLFWErrorCallback() {
public void invoke(int error, long description) {
System.err.println("ID : " + error + " | Description :" + description);
}
};
// glfwSetErrorCallback(errorCallback);
if(glfwInit())throw new Exception("GLFW not init");
glfwDefaultWindowHints();
glfwWindowHint(GLFW_VISIBLE, GL11.GL_FALSE);
glfwWindowHint(GLFW_RESIZABLE, GL11.GL_FALSE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
windowID = glfwCreateWindow(WIDTH,HEIGHT,TITLE,NULL,NULL);
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
glfwSetWindowPos(windowID,(vidmode.width()-WIDTH)/2,(vidmode.height()-HEIGHT)/2);
glfwShowWindow(windowID);
glfwMakeContextCurrent(windowID);
GL.createCapabilities();
System.out.println("OpenGL Version :" + glGetString(GL_VERSION));
System.out.println("GLSL Shader Version :" + glGetString(GL20.GL_SHADING_LANGUAGE_VERSION));
//------------------------------------------------------------------------------------
//Creation du device audio
//------------------------------------------------------------------------------------
Audio.create();
//------------------------------------------------------------------------------------
//initialisation
//------------------------------------------------------------------------------------
Input.init();
game = new MainGame();
Camera.transform();
//------------------------------------------------------------------------------------
while(glfwWindowShouldClose(windowID)){
if(System.currentTimeMillis() - previousTicks >= 1000/60){//Update TICKS
glfwPollEvents();
Input.update();
game.update();
previousTicks = System.currentTimeMillis();
delta = (float)(System.currentTimeMillis() - previous)/1000.0f;
previous = System.currentTimeMillis();
TICKS++;
}else{//Update FPS
DisplayManager.clear();
DisplayManager.preRender2D();
DisplayManager.render2D();
DisplayManager.preRenderGUI();
DisplayManager.renderGUI();
glfwSwapBuffers(windowID);
FPS++;
}
if(System.currentTimeMillis() - previousInfo >= 1000){
glfwSetWindowTitle(windowID, TITLE + " | FPS:" + FPS + " TICKS:" + TICKS);
FPS = 0;
TICKS = 0;
previousInfo = System.currentTimeMillis();
}
}
Audio.destroy();
glfwDestroyWindow(windowID);
glfwTerminate();
}
}

View file

@ -0,0 +1,325 @@
package globalgamejam.audio;
import static org.lwjgl.openal.AL.createCapabilities;
import static org.lwjgl.openal.AL10.*;
import static org.lwjgl.openal.ALC10.*;
import static org.lwjgl.stb.STBVorbis.*;
import static org.lwjgl.system.MemoryUtil.*;
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import javax.sound.sampled.*;
import org.lwjgl.*;
import org.lwjgl.openal.*;
import org.lwjgl.stb.STBVorbisInfo;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Audio {
//Variables global
//------------------------------------------------------
public static long device;
public static ALCCapabilities caps;
public static long context;
public static final int INITIAL_STATE = 4113,PAUSED_STATE = 4115,STOPPED_STATE = 4116,PLAYING_STATE = 4114;
//------------------------------------------------------
//Variable de l'objet audio ou du son a lire
//------------------------------------------------------
private int buffer,source;
private String fileName;
private String format;
//------------------------------------------------------
//Fonction global
//------------------------------------------------------
public static void create(){
device = alcOpenDevice((ByteBuffer)null);
ALCCapabilities deviceCaps = ALC.createCapabilities(device);
context = alcCreateContext(device, (IntBuffer)null);
alcMakeContextCurrent(context);
createCapabilities(deviceCaps);
}
public static void destroy(){
alcCloseDevice(device);
alcDestroyContext(context);
}
//------------------------------------------------------
//Fonction de l'objet audio ou du son a lire
//------------------------------------------------------
public Audio(String fileName) throws Exception{
this.fileName = fileName;
setSound();
}
private void setSound() throws Exception{
if(fileName.endsWith(".ogg")){
loadOGGFormat();
format = "OGG";
}else if(fileName.endsWith(".wav")){
loadWavFormat();
format = "WAV";
}else{
throw new Exception("Format not supported !");
}
alSourcei(source, AL_BUFFER, buffer);
int size = alGetBufferi(buffer,AL_SIZE);
int bits = alGetBufferi(buffer, AL_BITS);
int channels = alGetBufferi(buffer, AL_CHANNELS);
int freq = alGetBufferi(buffer, AL_FREQUENCY);
System.out.println(fileName + " loaded !" + " | TIME : " + (size/channels/(bits/8)/freq) + "s | BITS : " + bits + " | CHANNELS : " + channels + " | FREQUENCE : " + freq + " FORMAT : " + format);
}
public void loadWavFormat() throws Exception{
AudioInputStream ais = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream(fileName)));
AudioFormat audioformat = ais.getFormat();
// get channels
int channels = 0;
if (audioformat.getChannels() == 1) {
if (audioformat.getSampleSizeInBits() == 8) {
channels = AL10.AL_FORMAT_MONO8;
} else if (audioformat.getSampleSizeInBits() == 16) {
channels = AL10.AL_FORMAT_MONO16;
} else {
assert false : "Illegal sample size";
}
} else if (audioformat.getChannels() == 2) {
if (audioformat.getSampleSizeInBits() == 8) {
channels = AL10.AL_FORMAT_STEREO8;
} else if (audioformat.getSampleSizeInBits() == 16) {
channels = AL10.AL_FORMAT_STEREO16;
} else {
assert false : "Illegal sample size";
}
} else {
assert false : "Only mono or stereo is supported";
}
int available = ais.available();
if(available <= 0) {
available = ais.getFormat().getChannels() * (int) ais.getFrameLength() * ais.getFormat().getSampleSizeInBits() / 8;
}
byte[] buf = new byte[ais.available()];
int read = 0, total = 0;
while ((read = ais.read(buf, total, buf.length - total)) != -1
&& total < buf.length) {
total += read;
}
byte[] audio_bytes = buf;
boolean two_bytes_data = audioformat.getSampleSizeInBits() == 16;
ByteOrder order = audioformat.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
dest.order(ByteOrder.nativeOrder());
ByteBuffer src = ByteBuffer.wrap(audio_bytes);
src.order(order);
if (two_bytes_data) {
ShortBuffer dest_short = dest.asShortBuffer();
ShortBuffer src_short = src.asShortBuffer();
while (src_short.hasRemaining())
dest_short.put(src_short.get());
} else {
while (src.hasRemaining())
dest.put(src.get());
}
dest.rewind();
this.buffer = alGenBuffers();
this.source = alGenSources();
alBufferData(this.buffer, channels, dest, (int)audioformat.getSampleRate());
dest.clear();
}
public void loadOGGFormat(){
STBVorbisInfo info = STBVorbisInfo.malloc();
ByteBuffer buff = BufferUtils.createByteBuffer(0);
//lecture du fichier
//----------------------------------------------------------------------------------------------------------------
try {
File file = new File(fileName);
if ( file.isFile() ) {
FileInputStream fis = new FileInputStream(file);
FileChannel fc = fis.getChannel();
buff = BufferUtils.createByteBuffer((int)fc.size() + 1);
while ( fc.read(buff) != -1 ) ;
fis.close();
fc.close();
} else {
System.err.println("File not found !");
return;
}
buff.flip();
} catch (IOException e) {
throw new RuntimeException(e);
}
//----------------------------------------------------------------------------------------------------------------
IntBuffer error = BufferUtils.createIntBuffer(1);
long decoder = stb_vorbis_open_memory(buff, error, null);
if ( decoder == NULL )
throw new RuntimeException("Failed to open Ogg Vorbis file. Error: " + error.get(0));
stb_vorbis_get_info(decoder, info);
int channels = info.channels();
stb_vorbis_seek_start(decoder);
int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);
ShortBuffer pcm = BufferUtils.createShortBuffer(lengthSamples * channels);
stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm);
stb_vorbis_close(decoder);
buffer = alGenBuffers();
source = alGenSources();
if(channels == 1)alBufferData(buffer, AL_FORMAT_MONO16, pcm, info.sample_rate());
else alBufferData(buffer, AL_FORMAT_STEREO16, pcm, info.sample_rate());
}
public void playSound(){
if(source == 0 || buffer == 0) return;
alSourcePlay(source);
}
public int getPosition(){
return alGetSourcei(source, AL_POSITION);
}
public int getDurationInSeconds(){
if(source == 0 || buffer == 0) return 0;
int size = alGetBufferi(buffer,AL_SIZE);
int bits = alGetBufferi(buffer, AL_BITS);
int channels = alGetBufferi(buffer, AL_CHANNELS);
int freq = alGetBufferi(buffer, AL_FREQUENCY);
return size/channels/(bits/8)/freq;
}
public int getStateSound(){
if(source == 0 || buffer == 0) return 0;
return alGetSourcei(source, AL_SOURCE_STATE);
}
public boolean isStopped(){
if(source == 0 || buffer == 0) return false;
if(alGetSourcei(source, AL_SOURCE_STATE) == STOPPED_STATE)return true;
else return false;
}
public boolean isPaused(){
if(source == 0 || buffer == 0) return false;
if(alGetSourcei(source, AL_SOURCE_STATE) == PAUSED_STATE)return true;
else return false;
}
public boolean isPlaying(){
if(source == 0 || buffer == 0) return false;
if(alGetSourcei(source, AL_SOURCE_STATE) == PLAYING_STATE)return true;
else return false;
}
public boolean isInitial(){
if(source == 0 || buffer == 0) return false;
if(alGetSourcei(source, AL_SOURCE_STATE) == INITIAL_STATE)return true;
else return false;
}
public void stopSound(){
if(source == 0 || buffer == 0) return;
alSourceStop(source);
}
public void pauseSound(){
if(source == 0 || buffer == 0) return;
alSourcePause(source);
}
public void rewindSound(){
if(source == 0 || buffer == 0) return;
alSourceRewind(source);
}
public void setGain(float gain){
if(source == 0 || buffer == 0) return;
if(gain > 1.0f)gain = 1.0f;
if(gain < 0.0f)gain = 0.0f;
alSourcef(source, AL_GAIN, gain);
}
public void setPitch(float pitch){
if(source == 0 || buffer == 0) return;
if(pitch < 0.0f)pitch = 0.0f;
alSourcef(source, AL_PITCH, pitch);
}
public float getGain(){
if(source == 0 || buffer == 0) return 0;
return alGetSourcef(source, AL_GAIN);
}
public float getPitch(){
if(source == 0 || buffer == 0) return 0;
return alGetSourcef(source, AL_PITCH);
}
public void setLooping(boolean looping){
if(source == 0 || buffer == 0) return;
if(looping){
alSourcef(source, AL_LOOPING, AL_TRUE);
}else{
alSourcef(source, AL_LOOPING, AL_FALSE);
}
}
public void destroySound(){
alDeleteSources(source);
alDeleteBuffers(buffer);
source = 0;
buffer = 0;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) throws Exception {
this.fileName = fileName;
destroySound();
setSound();
}
public int getBuffer() {
return buffer;
}
public void setBuffer(int buffer) {
this.buffer = buffer;
}
public int getSource() {
return source;
}
public void setSource(int source) {
this.source = source;
}
//------------------------------------------------------
}

View file

@ -0,0 +1,14 @@
package globalgamejam.audio;
import globalgamejam.math.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Sound3D extends Audio{
public Sound3D(String fileName,Vector3f position) throws Exception {
super(fileName);
}
}

View file

@ -0,0 +1,23 @@
package globalgamejam.game;
import java.util.*;
import globalgamejam.render.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public abstract class Game {
public Game(){
init();
}
public abstract void init();
public abstract void update();
public abstract void render2D();
public abstract void renderGUI();
public abstract void destroy();
}

View file

@ -0,0 +1,43 @@
package globalgamejam.game;
import globalgamejam.*;
import globalgamejam.math.*;
import globalgamejam.render.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class MainGame extends Game{
private float value = 0;
@Override
public void init() {
}
@Override
public void update() {
Camera.update();
Camera.transform();
}
@Override
public void render2D() {
}
@Override
public void renderGUI() {
}
@Override
public void destroy() {
}
}

View file

@ -0,0 +1,20 @@
package globalgamejam.input;
import java.io.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class IO {
public static String loadFile(String path) throws Exception{
String r = "";
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path)));
String buffer = "";
while ((buffer = reader.readLine()) != null) {
r += buffer + "\n";
}
reader.close();
return r;
}
}

View file

@ -0,0 +1,248 @@
package globalgamejam.input;
import static org.lwjgl.glfw.GLFW.*;
import java.util.*;
import java.util.Map.*;
import org.lwjgl.glfw.*;
import globalgamejam.*;
import globalgamejam.math.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Input{
public static GLFWScrollCallback scroll;
public static GLFWCursorPosCallback mousePos;
private static Vector2f mousePosition = new Vector2f();
private static Vector2f dMouse = new Vector2f();
private static Vector2f previousDMouse = new Vector2f();
public static final int NONE = 0,PRESSED = 1,RELEASED = 2,REPEATED = 3,UP = 4,DOWN = 5,
NBRE_KEY = 0x15D,NBRE_BUTTON = 10,
MOUSE_OFFSET = NBRE_KEY + 1,MOUSE_WHEEL_OFFSET = MOUSE_OFFSET + 1;
private static HashMap<Integer,Integer> state = new HashMap<Integer,Integer>();
private static double ywheel = 0;
public static void init(){
glfwSetScrollCallback(Main.windowID, scroll = new GLFWScrollCallback() {
public void invoke(long window, double xoffset, double yoffset) {
scroll(window, xoffset, yoffset);
}
});
glfwSetCursorPosCallback(Main.windowID, mousePos = new GLFWCursorPosCallback() {
public void invoke(long window, double xpos, double ypos) {
mousepos(window, xpos, ypos);
}
});
for(int i = 0;i < NBRE_KEY;i++){
state.put(i, NONE);
}
for(int i = 0;i < NBRE_BUTTON;i++){
state.put(i + MOUSE_OFFSET, NONE);
}
state.put(MOUSE_WHEEL_OFFSET, NONE);
}
public static void update(){
for(Entry<Integer, Integer> set : state.entrySet()){
int i = set.getKey();
int st = set.getValue();
if(i > -1 && i < NBRE_KEY){
if(glfwGetKey(Main.windowID, i) == 0 && st == NONE)continue;
if(glfwGetKey(Main.windowID, i) == 1 && st == NONE){
state.replace(i, PRESSED);
}else if(glfwGetKey(Main.windowID, i) == 1 && st == PRESSED){
state.replace(i, REPEATED);
}else if(glfwGetKey(Main.windowID, i) == 0 && (st == PRESSED || st == REPEATED)){
state.replace(i, RELEASED);
}else if(glfwGetKey(Main.windowID, i) == 0 && st == RELEASED){
state.replace(i, NONE);
}
}else if(i >= MOUSE_OFFSET && i < MOUSE_OFFSET + NBRE_BUTTON){
if(glfwGetMouseButton(Main.windowID, i - MOUSE_OFFSET) == 0 && st == NONE)continue;
if(glfwGetMouseButton(Main.windowID, i - MOUSE_OFFSET) == 1 && st == NONE){
state.replace(i, PRESSED);
}else if(glfwGetMouseButton(Main.windowID, i - MOUSE_OFFSET) == 1 && st == PRESSED){
state.replace(i, REPEATED);
}else if(glfwGetMouseButton(Main.windowID, i - MOUSE_OFFSET) == 0 && (st == PRESSED || st == REPEATED)){
state.replace(i, RELEASED);
}else if(glfwGetMouseButton(Main.windowID, i - MOUSE_OFFSET) == 0 && st == RELEASED){
state.replace(i, NONE);
}
}
}
int st = state.get(MOUSE_WHEEL_OFFSET);
if(ywheel > 0 && (st == NONE || st == UP)){
state.replace(MOUSE_WHEEL_OFFSET, UP);
}else if(ywheel < 0 && (st == NONE || st == DOWN)){
state.replace(MOUSE_WHEEL_OFFSET, DOWN);
}else if(ywheel == 0 && (st == DOWN || st == UP)){
state.replace(MOUSE_WHEEL_OFFSET, NONE);
}
ywheel = 0;
if(dMouse.equals(previousDMouse)){
dMouse = new Vector2f();
}else{
previousDMouse = dMouse;
}
}
public static void destroy(){
mousePos.free();
scroll.free();
}
public static void scroll(long window, double xoffset, double yoffset) {
ywheel = yoffset;
}
public static void mousepos(long window, double xpos, double ypos) {
dMouse.x = (float) (xpos - mousePosition.x);
dMouse.y = (float) (ypos - mousePosition.y);
mousePosition.x = (float) xpos;
mousePosition.y = (float) ypos;
}
public static boolean isButtonDown(int button){
return state.get(button + MOUSE_OFFSET) == PRESSED;
}
public static boolean isButtonUp(int button){
return state.get(button + MOUSE_OFFSET) == RELEASED;
}
public static boolean isButton(int button){
return state.get(button + MOUSE_OFFSET) == PRESSED || state.get(button + MOUSE_OFFSET) == REPEATED;
}
public static int isButtonState(int button){
return state.get(button + MOUSE_OFFSET);
}
public static boolean isKeyDown(int key){
return state.get(key) == PRESSED;
}
public static boolean isKeyUp(int key){
return state.get(key) == RELEASED;
}
public static boolean isKey(int key){
return state.get(key) == PRESSED || state.get(key) == REPEATED;
}
public static int isKeyState(int key){
return state.get(key);
}
public static int isMouseWheelState(){
return state.get(MOUSE_WHEEL_OFFSET);
}
public static boolean isMouseWheelUp(){
return state.get(MOUSE_WHEEL_OFFSET) == UP;
}
public static boolean isMouseWheelDown(){
return state.get(MOUSE_WHEEL_OFFSET) == DOWN;
}
public static GLFWScrollCallback getScroll() {
return scroll;
}
public static void setScroll(GLFWScrollCallback scroll) {
Input.scroll = scroll;
}
public static GLFWCursorPosCallback getMousePos() {
return mousePos;
}
public static void setMousePos(GLFWCursorPosCallback mousePos) {
Input.mousePos = mousePos;
}
public static Vector2f getMousePosition() {
return mousePosition;
}
public static void setMousePosition(Vector2f mousePosition) {
Input.mousePosition = mousePosition;
}
public static Vector2f getDMouse() {
return dMouse;
}
public static void setDMouse(Vector2f dMouse) {
Input.dMouse = dMouse;
}
public static HashMap<Integer, Integer> getState() {
return state;
}
public static void setState(HashMap<Integer, Integer> state) {
Input.state = state;
}
public static double getYwheel() {
return ywheel;
}
public static void setYwheel(double ywheel) {
Input.ywheel = ywheel;
}
public static int getNone() {
return NONE;
}
public static int getPressed() {
return PRESSED;
}
public static int getReleased() {
return RELEASED;
}
public static int getRepeated() {
return REPEATED;
}
public static int getUp() {
return UP;
}
public static int getDown() {
return DOWN;
}
public static int getNbreKey() {
return NBRE_KEY;
}
public static int getNbreButton() {
return NBRE_BUTTON;
}
public static int getMouseOffset() {
return MOUSE_OFFSET;
}
public static int getMouseWheelOffset() {
return MOUSE_WHEEL_OFFSET;
}
}

View file

@ -0,0 +1,113 @@
package globalgamejam.math;
import static org.lwjgl.opengl.GL11.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Color4f {
public static final Color4f
RED = new Color4f(1,0,0,1),
BLUE = new Color4f(0,0,1,1),
GREEN = new Color4f(0,1,0,1),
YELLOW = new Color4f(1,1,0,1),
PURPLE = new Color4f(1,0,1,1),
CYAN = new Color4f(0,1,1,1),
BLACK = new Color4f(0,0,0,1),
WHITE = new Color4f(1,1,1,1);
public float r,g,b,a;
public Color4f(float r,float g,float b,float a){
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
public static Color4f mul (Color4f a, float b){
return new Color4f(a.r * b,a.g * b,a.b * b,a.a * b);
}
public static Color4f mul (float o,Color4f... a){
float r = 0;
float b = 0;
float g = 0;
float al = 0;
for(Color4f c : a){
r += c.r;
g += c.g;
b += c.b;
al += c.a;
}
r /= a.length;
g /= a.length;
b /= a.length;
al /= a.length;
return new Color4f(r * o,g * o,b * o,al * o);
}
public static Color4f mul (Color4f... a){
float r = 0;
float b = 0;
float g = 0;
float al = 0;
for(Color4f c : a){
r += c.r;
g += c.g;
b += c.b;
al += c.a;
}
r /= a.length;
g /= a.length;
b /= a.length;
al /= a.length;
return new Color4f(r,g,b,al);
}
public Color4f() {
}
public float getR() {
return r;
}
public void setR(float r) {
this.r = r;
}
public float getG() {
return g;
}
public void setG(float g) {
this.g = g;
}
public float getB() {
return b;
}
public void setB(float b) {
this.b = b;
}
public float getA() {
return a;
}
public void setA(float a) {
this.a = a;
}
public void bind(){
glColor4f(r,g,b,a);
}
public void unbind(){
BLACK.bind();
}
}

View file

@ -0,0 +1,70 @@
package globalgamejam.math;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Mathf {
public static final float PI = 3.14159265358979323846f;
public static final float EPSILON = 1.401298e-45f;
public static float cos(float angle){
return (float)Math.cos(angle);
}
public static float acos(float angle){
return (float)Math.acos(angle);
}
public static float sin(float angle){
return (float)Math.sin(angle);
}
public static float asin(float angle){
return (float)Math.asin(angle);
}
public static float toRadians(float angle){
return (float)Math.toRadians(angle);
}
public static float toDegrees(float angle){
return (float)Math.toDegrees(angle);
}
public static float atan2(float a,float b){
return (float)Math.atan2(a,b);
}
public static float cut(float nbre,float a){
return (float)((int)(nbre*Math.pow(10, a))/Math.pow(10, a));
}
public static boolean equals(float a,float b,float tolerance){
return (a + tolerance >= b) && (a - tolerance <= b);
}
public static float sqrt(float a){
return (float)Math.sqrt(a);
}
public static float exp(float a){
return (float)Math.sqrt(a);
}
public static float log(float a){
return (float)Math.log(a);
}
public static float clamp(float value, float min, float max) {
if(value < min){
value = min;
}
if(value > max){
value = max;
}
return value;
}
}

View file

@ -0,0 +1,192 @@
package globalgamejam.math;
import java.nio.*;
import java.util.*;
import org.lwjgl.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Matrix4f {
public float[][] m = null;
public Matrix4f(){
m = new float[][]{
{1,0,0,0},
{0,1,0,0},
{0,0,1,0},
{0,0,0,1}
};
}
public Matrix4f(float[][] m){
this.m = m;
}
public Matrix4f loadIdentity(){
m = new float[][]{
{1,0,0,0},
{0,1,0,0},
{0,0,1,0},
{0,0,0,1}
};
return this;
}
public Matrix4f rotate(Quaternion q){
Matrix4f rot = q.toMatrixRotation();
m = mul(rot).getM();
return this;
}
public void rotate(float x,float y,float z){
x = Mathf.toRadians(x);
y = Mathf.toRadians(y);
z = Mathf.toRadians(z);
Matrix4f rx = new Matrix4f(new float[][]{
{1,0,0,0},
{0,Mathf.cos(x),-Mathf.sin(x),0},
{0,Mathf.sin(x),Mathf.cos(x),0},
{0,0,0,1}
});
Matrix4f ry = new Matrix4f(new float[][]{
{Mathf.cos(y),0,Mathf.sin(y),0},
{0,1,0,0},
{-Mathf.sin(y),0,Mathf.cos(y),0},
{0,0,0,1}
});
Matrix4f rz = new Matrix4f(new float[][]{
{Mathf.cos(z),-Mathf.sin(z),0,0},
{Mathf.sin(z),Mathf.cos(z),0,0},
{0,0,1,0},
{0,0,0,1}
});
Matrix4f m1 = (rz.mul(ry.mul(rx)));
m = mul(m1).getM();
}
public static Matrix4f rotate(Vector3f forward, Vector3f up, Vector3f right)
{
Matrix4f mat = new Matrix4f(new float[][]{
{right.getX(), right.getY(), right.getZ() ,0},
{up.getX(), up.getY(), up.getZ() ,0},
{forward.getX(),forward.getY(), forward.getZ() ,0},
{0,0,0,1}
});
return mat;
}
public Matrix4f tranlate(float x,float y,float z){
Matrix4f mat = new Matrix4f(new float[][]{
{1,0,0,x},
{0,1,0,y},
{0,0,1,z},
{0,0,0,1}
});
m = mul(mat).getM();
return this;
}
public Matrix4f scale(float x,float y,float z){
Matrix4f mat = new Matrix4f(new float[][]{
{x,0,0,0},
{0,y,0,0},
{0,0,z,0},
{0,0,0,1}
});
m = mul(mat).getM();
return this;
}
public Matrix4f mul(Matrix4f mat){
Matrix4f ma = new Matrix4f();
for(int i = 0;i < 4;i++){
for(int j = 0;j < 4;j++){
ma.m[i][j] = m[i][0] * mat.m[0][j] +
m[i][1] * mat.m[1][j] +
m[i][2] * mat.m[2][j] +
m[i][3] * mat.m[3][j];
}
}
return ma;
}
public Matrix4f Ortho2D(float left, float right, float bottom, float top, float near, float far)
{
float width = right - left;
float height = top - bottom;
float depth = far - near;
m = new float[][]{
{2/width,0,0,-(right + left)/width},
{0,2/height,0,-(top + bottom)/height},
{0,0,-2/depth,-(far + near)/depth},
{0,0,0,1}
};
return this;
}
public Matrix4f perspective(float fov, float aspectRatio, float zNear, float zFar)
{
float f = fov;
fov = Mathf.toRadians(f);
float tanHalfFOV = (float)Math.tan(fov / 2);
float zRange = zNear - zFar;
m = new float[][]{
{1.0f / (tanHalfFOV * aspectRatio),0,0,0},
{0,1.0f / tanHalfFOV,0,0},
{0,0,(-zNear -zFar)/zRange,2.0f * zFar * zNear / zRange},
{0,0,1,0}
};
return this;
}
public FloatBuffer getBuffer(){
FloatBuffer buffer = BufferUtils.createFloatBuffer(4 * 4);
for(int i = 0;i < 4;i++){
buffer.put(m[i]);
}
buffer.flip();
return buffer;
}
public String toString(){
int size = 3;
int max = 10;
StringJoiner st = new StringJoiner("\n","--------Mat4-Begin--------\n","\n--------Mat4-End----------");
for(int i = 0;i < 4;i++){
StringJoiner st2 = new StringJoiner(" | ");
for(int j = 0;j < 4;j++){
String value = Mathf.cut(m[i][j], size) + "";
for(int k = value.length();k < max;k++){
value += " ";
}
st2.add(value);
}
st.add(st2.toString());
}
return st.toString();
}
public float[][] getM() {
return m;
}
public void setM(float[][] m) {
this.m = m;
}
public Matrix4f copy(){
return new Matrix4f(this.getM());
}
}

View file

@ -0,0 +1,134 @@
package globalgamejam.math;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Quaternion {
public float x,y,z,w;
public Quaternion(){
x = 0;
y = 0;
z = 0;
w = 0;
}
public Quaternion(Vector3f axis,float angle){
float sin = Mathf.sin(Mathf.toRadians(angle/2.0f));
float cos = Mathf.cos(Mathf.toRadians(angle/2.0f));
x = axis.getX() * sin;
y = axis.getY() * sin;
z = axis.getZ() * sin;
w = cos;
}
public Quaternion(Vector3f rot){
this(rot.x,rot.y,rot.z);
}
public Quaternion (float yaw, float roll, float pitch) {
yaw = Mathf.toRadians(yaw);
roll = Mathf.toRadians(roll);
pitch = Mathf.toRadians(pitch);
float angle;
float sinRoll, sinPitch, sinYaw, cosRoll, cosPitch, cosYaw;
angle = pitch * 0.5f;
sinPitch = Mathf.sin(angle);
cosPitch = Mathf.cos(angle);
angle = roll * 0.5f;
sinRoll = Mathf.sin(angle);
cosRoll = Mathf.cos(angle);
angle = yaw * 0.5f;
sinYaw = Mathf.sin(angle);
cosYaw = Mathf.cos(angle);
// variables used to reduce multiplication calls.
float cosRollXcosPitch = cosRoll * cosPitch;
float sinRollXsinPitch = sinRoll * sinPitch;
float cosRollXsinPitch = cosRoll * sinPitch;
float sinRollXcosPitch = sinRoll * cosPitch;
w = (cosRollXcosPitch * cosYaw - sinRollXsinPitch * sinYaw);
x = (cosRollXcosPitch * sinYaw + sinRollXsinPitch * cosYaw);
y = (sinRollXcosPitch * cosYaw + cosRollXsinPitch * sinYaw);
z = (cosRollXsinPitch * cosYaw - sinRollXcosPitch * sinYaw);
normalize();
}
public void normalize(){
float n = (float)(1.0/Math.sqrt(norm()));
x *= n;
y *= n;
z *= n;
w *= n;
}
public float norm(){
return w * w + x * x + y * y + z * z;
}
public Quaternion Euler(Vector3f rot) {
x = Mathf.toRadians(rot.x);
y = Mathf.toRadians(rot.y);
z = Mathf.toRadians(rot.z);
float c1 = Mathf.cos(y/2);
float s1 = Mathf.sin(y/2);
float c2 = Mathf.cos(z/2);
float s2 = Mathf.sin(z/2);
float c3 = Mathf.cos(x/2);
float s3 = Mathf.sin(x/2);
float c1c2 = c1*c2;
float s1s2 = s1*s2;
this.w =c1c2*c3 - s1s2*s3;
this.x =c1c2*s3 + s1s2*c3;
this.y =s1*c2*c3 + c1*s2*s3;
this.z =c1*s2*c3 - s1*c2*s3;
return new Quaternion(x, y, z, w);
}
public Vector3f toEulerAngles(){
Vector3f euler = new Vector3f();
float sqw = w * w;
float sqx = x * x;
float sqy = y * y;
float sqz = z * z;
float unit = sqx + sqy + sqz + sqw; // if normalized is one, otherwise
// is correction factor
float test = x * y + z * w;
if (test > 0.499 * unit) { // singularity at north pole
euler.y = 2 * Mathf.atan2(x, w);
euler.z = Mathf.PI/2.0f;
euler.x = 0;
} else if (test < -0.499 * unit) { // singularity at south pole
euler.y = -2 * Mathf.atan2(x, w);
euler.z = -Mathf.PI/2.0f;
euler.x = 0;
} else {
euler.y = Mathf.atan2(2 * y * w - 2 * x * z, sqx - sqy - sqz + sqw); // roll or heading
euler.z = Mathf.asin(2 * test / unit); // pitch or attitude
euler.x = Mathf.atan2(2 * x * w - 2 * y * z, -sqx + sqy - sqz + sqw); // yaw or bank
}
return euler.toDegrees();
}
public Quaternion(float axisX,float axisY,float axisZ,float angle){
float sin = Mathf.sin(Mathf.toRadians(angle/2.0f));
float cos = Mathf.cos(Mathf.toRadians(angle/2.0f));
x = axisX * sin;
y = axisY * sin;
z = axisZ * sin;
w = cos;
}
public Matrix4f toMatrixRotation(){
Vector3f forward = new Vector3f(2.0f * (x * z - w * y), 2.0f * (y * z + w * x), 1.0f - 2.0f * (x * x + y * y));
Vector3f up = new Vector3f(2.0f * (x * y + w * z), 1.0f - 2.0f * (x * x + z * z), 2.0f * (y * z - w * x));
Vector3f right = new Vector3f(1.0f - 2.0f * (y * y + z * z), 2.0f * (x * y - w * z), 2.0f * (x * z + w * y));
return Matrix4f.rotate(forward, up, right);
}
}

View file

@ -0,0 +1,45 @@
package globalgamejam.math;
import java.util.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Vector2f {
public float x,y;
public Vector2f(){
x = 0;
y = 0;
}
public Vector2f(float x,float y){
this.x = x;
this.y = y;
}
public float getX() {
return x;
}
public void setX(float x) {
this.x = x;
}
public float getY() {
return y;
}
public void setY(float y) {
this.y = y;
}
public String toString(){
StringJoiner st = new StringJoiner(",","vec2(",")");
st.add("" + x);
st.add("" + y);
return st.toString();
}
}

View file

@ -0,0 +1,107 @@
package globalgamejam.math;
import java.util.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Vector3f {
public float x,y,z;
public Vector3f(){
x = 0;
y = 0;
z = 0;
}
public Vector3f(float x,float y,float z){
this.x = x;
this.y = y;
this.z = z;
}
public Vector3f(Vector2f vec,float z){
this(vec.x,vec.y,z);
}
public Vector3f(Vector3f vec){
this(vec.x,vec.y,vec.z);
}
public float getX() {
return x;
}
public void setX(float x) {
this.x = x;
}
public float getY() {
return y;
}
public void setY(float y) {
this.y = y;
}
public float getZ() {
return z;
}
public void setZ(float z) {
this.z = z;
}
public float length(){
return Mathf.sqrt(x * x + y * y + z * z);
}
public Vector3f lookAt(Vector3f d){
Vector3f rot = new Vector3f();
float x1 = d.x - x;
float y1 = d.y - y;
float z1 = d.z - z;
return rot;
}
public Vector3f normalize(){
float length = length();
x /= length;
y /= length;
z /= length;
return this;
}
public Vector3f mul(float m){
x *= m;
y *= m;
z *= m;
return this;
}
public String toString(){
StringJoiner st = new StringJoiner(",","vec3(",")");
st.add("" + x);
st.add("" + y);
st.add("" + z);
return st.toString();
}
public Vector3f toRadians() {
x = Mathf.toRadians(x);
y = Mathf.toRadians(y);
z = Mathf.toRadians(z);
return this;
}
public Vector3f toDegrees() {
x = Mathf.toDegrees(x);
y = Mathf.toDegrees(y);
z = Mathf.toDegrees(z);
return this;
}
}

View file

@ -0,0 +1,59 @@
package globalgamejam.math;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Vector4f {
public float x,y,z,w;
public Vector4f(float x,float y,float z,float w){
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
public Vector4f(Vector3f v,float w){
this.x = v.x;
this.y = v.y;
this.z = v.z;
this.w = w;
}
public float getX() {
return x;
}
public void setX(float x) {
this.x = x;
}
public float getY() {
return y;
}
public void setY(float y) {
this.y = y;
}
public float getZ() {
return z;
}
public void setZ(float z) {
this.z = z;
}
public float getW() {
return w;
}
public void setW(float w) {
this.w = w;
}
}

View file

@ -0,0 +1,36 @@
package globalgamejam.render;
import static org.lwjgl.glfw.GLFW.*;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import globalgamejam.*;
import globalgamejam.input.*;
import globalgamejam.math.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Camera {
public static Matrix4f matrix = new Matrix4f();
public static final float SPEED = 1.0f;//Speed de base
public static float rot = 0.0f;//rotation de la camera
public static Vector2f pos = new Vector2f();
public static void update(){
float speed = SPEED * Main.delta;//speed reel par frame en fonction des fps
//class Input pour tous ce qui est entrer et sortis
}
public static void transform(){
matrix.loadIdentity();
matrix.rotate(new Quaternion(new Vector3f(0,0,1),rot));
matrix.tranlate(-pos.x, -pos.y, 0);
}
}

View file

@ -0,0 +1,46 @@
package globalgamejam.render;
import static org.lwjgl.opengl.GL11.*;
import globalgamejam.*;
import globalgamejam.math.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class DisplayManager {
public static Matrix4f projection = new Matrix4f();
public static void clear(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
public static void preRender2D(){
projection.loadIdentity();
projection.Ortho2D(0, Main.WIDTH, 0, Main.HEIGHT, -1, 1);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
public static void preRenderGUI(){
projection.loadIdentity();
//Permet de centrer la camera au centre de l'ecran
projection.Ortho2D(-Main.WIDTH/2.0f, Main.WIDTH/2.0f, -Main.HEIGHT/2.0f, Main.HEIGHT/2.0f, -1, 1);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
public static void render2D(){
Main.game.render2D();
}
public static void renderGUI(){
Main.game.renderGUI();
}
}

View file

@ -0,0 +1,89 @@
package globalgamejam.render;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL20.*;
import globalgamejam.input.*;
import globalgamejam.math.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Shaders {
public int program;
public Shaders(String vertexFile,String fragmentFile) throws Exception{
String fragmentShader = IO.loadFile(fragmentFile);
String vertexShader = IO.loadFile(vertexFile);
if(program != -1)glDeleteProgram(program);
program = glCreateProgram();
int vert = glCreateShader(GL_VERTEX_SHADER);
int frag = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(vert, vertexShader);
glShaderSource(frag, fragmentShader);
glCompileShader(vert);
if (glGetShaderi(vert, GL_COMPILE_STATUS) == GL_FALSE) {
System.err.println(glGetShaderInfoLog(vert, 2048));
System.exit(1);
}else{
System.out.println("Vertex compiled !");
}
glCompileShader(frag);
if (glGetShaderi(frag, GL_COMPILE_STATUS) == GL_FALSE) {
System.err.println(glGetShaderInfoLog(frag, 2048));
System.exit(1);
}else{
System.out.println("Fragment compiled !");
}
glAttachShader(program, vert);
glAttachShader(program, frag);
glLinkProgram(program);
glValidateProgram(program);
glDeleteShader(frag);
glDeleteShader(vert);
}
public void bind(){
glUseProgram(program);
}
public void unbind(){
glUseProgram(0);
}
public int getAttribLocation(String name){
return glGetAttribLocation(program, name);
}
public void destroy(){
if(program == 0)return;
if(glIsProgram(program))unbind();
glDeleteProgram(program);
}
public void uniform(String name,float v){
glUniform1f(glGetUniformLocation(program, name), v);
}
public void uniform(String name,Vector3f vec){
glUniform3f(glGetUniformLocation(program, name), vec.x,vec.y,vec.z);
}
public void uniform(String name,Vector4f vec){
glUniform4f(glGetUniformLocation(program, name), vec.x,vec.y,vec.z,vec.w);
}
public void uniform(String name,Matrix4f mat){
glUniformMatrix4fv(glGetUniformLocation(program, name),true, mat.getBuffer());
}
public void uniform(String name, Color4f v) {
glUniform4f(glGetUniformLocation(program, name), v.getR(),v.getG(),v.getB(),v.getA());
}
public void uniform(String name,int v){
glUniform1i(glGetUniformLocation(program,name), v);
}
}

View file

@ -0,0 +1,96 @@
package globalgamejam.render;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL12.*;
import java.awt.image.*;
import java.io.*;
import java.nio.*;
import javax.imageio.*;
import org.lwjgl.*;
/**
* Class created by MrDev023 (Florian RICHER) on 14/01/2017
*/
public class Texture {
int width, height;
int id;
public Texture(int width,int height,int id){
this.id = id;
this.width = width;
this.height = height;
}
public static Texture loadTexture(String path){
try {
BufferedImage image = ImageIO.read(new File(path));
int width = image.getWidth();
int height = image.getHeight();
int[] pixels = new int[width * height];
image.getRGB(0, 0, width, height, pixels, 0,width);
int[] data = new int[pixels.length];
for (int i = 0; i < data.length; i++) {
int a = (pixels[i] & 0xff000000) >> 24;
int r = (pixels[i] & 0xff0000) >> 16;
int g = (pixels[i] & 0xff00) >> 8;
int b = (pixels[i] & 0xff);
data[i] = a << 24 | b << 16 | g << 8 | r;
}
IntBuffer buffer = BufferUtils.createIntBuffer(data.length);
buffer.put(data);
buffer.flip();
int id = glGenTextures();
glBindTexture(GL_TEXTURE_2D, id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
glBindTexture(GL_TEXTURE_2D, 0);
System.out.println("Texture loaded ! " + width + "x" + height + " id:" + id);
return new Texture(width, height, id);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public int getID(){
return id;
}
public void bind(){
glBindTexture(GL_TEXTURE_2D, id);
}
public void unbind(){
glBindTexture(GL_TEXTURE_2D, 0);
}
public void destroy(){
glDeleteTextures(id);
}
}