Add Ant compatibility
This commit is contained in:
parent
55fcb82edd
commit
84f1dca031
24 changed files with 375 additions and 348 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
bin/*
|
bin/*
|
||||||
.project
|
.project
|
||||||
.classpath
|
.classpath
|
||||||
|
*.jar
|
3
.travis.yml
Normal file
3
.travis.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
language: java
|
||||||
|
jdk:
|
||||||
|
- oraclejdk8
|
|
@ -1,4 +1,8 @@
|
||||||
# First-Game-Lighting
|
# First-Game-Lighting
|
||||||
|
|
||||||
|
Compile status: ![Status](https://travis-ci.org/mrdev023/First-Game-Lighting.svg?branch=master)
|
||||||
|
|
||||||
Ce projet est seulement a projet utiliser pour apprendre le forward rendering pour ensuite l'integrer dans mon moteur de jeu qui
|
Ce projet est seulement a projet utiliser pour apprendre le forward rendering pour ensuite l'integrer dans mon moteur de jeu qui
|
||||||
sera conçus avec ces derniere technologie pour ensuite faire des jeux avec celui-ci.
|
sera conçus avec ces derniere technologie pour ensuite faire des jeux avec celui-ci.
|
||||||
|
|
||||||
|
![Image](https://pbs.twimg.com/media/Cc3DuwnWIAII5Zw.jpg:large)
|
||||||
|
|
38
build.xml
Normal file
38
build.xml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<project name="lwjgl-examples">
|
||||||
|
|
||||||
|
<property file="build.properties" />
|
||||||
|
<property name="src.dir" value="src" />
|
||||||
|
<property name="build.dir" value="bin"/>
|
||||||
|
<property name="lwjgl_jars.dir" value="./libs/"/>
|
||||||
|
<property name="lwjgl_natives.dir" value="./libs/"/>
|
||||||
|
<property name="build.sysclasspath" value="last"/>
|
||||||
|
|
||||||
|
<path id="my_cp">
|
||||||
|
<fileset dir="${lwjgl_jars.dir}" includes="lwjgl.jar"/>
|
||||||
|
</path>
|
||||||
|
|
||||||
|
<target name="compile">
|
||||||
|
<mkdir dir="${build.dir}"/>
|
||||||
|
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="my_cp"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="clean">
|
||||||
|
<delete dir="${build.dir}"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="test" depends="compile">
|
||||||
|
<!--
|
||||||
|
fork="true" seems to be absolutely
|
||||||
|
necessary for the setting of java.library.path
|
||||||
|
to be effective.-->
|
||||||
|
|
||||||
|
<java fork="true" classname="fr/technicalgames/Main">
|
||||||
|
<classpath>
|
||||||
|
<path refid="my_cp"/>
|
||||||
|
<path location="${build.dir}"/>
|
||||||
|
</classpath>
|
||||||
|
<sysproperty key="java.library.path"
|
||||||
|
value="${lwjgl_natives.dir}"/>
|
||||||
|
</java>
|
||||||
|
</target>
|
||||||
|
</project>
|
BIN
libs/OpenAL.dll
Normal file
BIN
libs/OpenAL.dll
Normal file
Binary file not shown.
BIN
libs/OpenAL32.dll
Normal file
BIN
libs/OpenAL32.dll
Normal file
Binary file not shown.
BIN
libs/glfw.dll
Normal file
BIN
libs/glfw.dll
Normal file
Binary file not shown.
BIN
libs/glfw32.dll
Normal file
BIN
libs/glfw32.dll
Normal file
Binary file not shown.
BIN
libs/jemalloc.dll
Normal file
BIN
libs/jemalloc.dll
Normal file
Binary file not shown.
BIN
libs/jemalloc32.dll
Normal file
BIN
libs/jemalloc32.dll
Normal file
Binary file not shown.
BIN
libs/libglfw.dylib
Normal file
BIN
libs/libglfw.dylib
Normal file
Binary file not shown.
BIN
libs/libglfw.so
Normal file
BIN
libs/libglfw.so
Normal file
Binary file not shown.
BIN
libs/libjemalloc.dylib
Normal file
BIN
libs/libjemalloc.dylib
Normal file
Binary file not shown.
BIN
libs/libjemalloc.so
Normal file
BIN
libs/libjemalloc.so
Normal file
Binary file not shown.
BIN
libs/liblwjgl.dylib
Normal file
BIN
libs/liblwjgl.dylib
Normal file
Binary file not shown.
BIN
libs/liblwjgl.so
Normal file
BIN
libs/liblwjgl.so
Normal file
Binary file not shown.
BIN
libs/libopenal.dylib
Normal file
BIN
libs/libopenal.dylib
Normal file
Binary file not shown.
BIN
libs/libopenal.so
Normal file
BIN
libs/libopenal.so
Normal file
Binary file not shown.
BIN
libs/lwjgl.dll
Normal file
BIN
libs/lwjgl.dll
Normal file
Binary file not shown.
BIN
libs/lwjgl32.dll
Normal file
BIN
libs/lwjgl32.dll
Normal file
Binary file not shown.
|
@ -42,7 +42,7 @@ public class Main {
|
||||||
};
|
};
|
||||||
// glfwSetErrorCallback(errorCallback);
|
// glfwSetErrorCallback(errorCallback);
|
||||||
|
|
||||||
if(glfwInit() != GL11.GL_TRUE)throw new Exception("GLFW not init");
|
if(glfwInit())throw new Exception("GLFW not init");
|
||||||
glfwDefaultWindowHints();
|
glfwDefaultWindowHints();
|
||||||
glfwWindowHint(GLFW_VISIBLE, GL11.GL_FALSE);
|
glfwWindowHint(GLFW_VISIBLE, GL11.GL_FALSE);
|
||||||
glfwWindowHint(GLFW_RESIZABLE, GL11.GL_FALSE);
|
glfwWindowHint(GLFW_RESIZABLE, GL11.GL_FALSE);
|
||||||
|
@ -75,7 +75,7 @@ public class Main {
|
||||||
Camera.transform();
|
Camera.transform();
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
||||||
while(glfwWindowShouldClose(windowID) == GL11.GL_FALSE){
|
while(glfwWindowShouldClose(windowID)){
|
||||||
|
|
||||||
if(System.currentTimeMillis() - previousTicks >= 1000/60){//Update TICKS
|
if(System.currentTimeMillis() - previousTicks >= 1000/60){//Update TICKS
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package fr.technicalgames.audio;
|
package fr.technicalgames.audio;
|
||||||
|
|
||||||
|
import static org.lwjgl.openal.AL.createCapabilities;
|
||||||
import static org.lwjgl.openal.AL10.*;
|
import static org.lwjgl.openal.AL10.*;
|
||||||
import static org.lwjgl.openal.ALC10.*;
|
import static org.lwjgl.openal.ALC10.*;
|
||||||
import static org.lwjgl.openal.ALC11.*;
|
|
||||||
import static org.lwjgl.openal.ALUtil.*;
|
|
||||||
import static org.lwjgl.stb.STBVorbis.*;
|
import static org.lwjgl.stb.STBVorbis.*;
|
||||||
import static org.lwjgl.system.MemoryUtil.*;
|
import static org.lwjgl.system.MemoryUtil.*;
|
||||||
|
|
||||||
|
@ -19,13 +18,13 @@ import org.lwjgl.openal.*;
|
||||||
|
|
||||||
import org.lwjgl.stb.STBVorbisInfo;
|
import org.lwjgl.stb.STBVorbisInfo;
|
||||||
|
|
||||||
public abstract class Audio {
|
public class Audio {
|
||||||
|
|
||||||
//Variables global
|
//Variables global
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
public static ALDevice device;
|
public static long device;
|
||||||
public static ALCCapabilities caps;
|
public static ALCCapabilities caps;
|
||||||
public static ALContext context;
|
public static long context;
|
||||||
public static final int INITIAL_STATE = 4113,PAUSED_STATE = 4115,STOPPED_STATE = 4116,PLAYING_STATE = 4114;
|
public static final int INITIAL_STATE = 4113,PAUSED_STATE = 4115,STOPPED_STATE = 4116,PLAYING_STATE = 4114;
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
|
@ -39,31 +38,17 @@ public abstract class Audio {
|
||||||
//Fonction global
|
//Fonction global
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
public static void create(){
|
public static void create(){
|
||||||
device = ALDevice.create(null);
|
device = alcOpenDevice((ByteBuffer)null);
|
||||||
if ( device == null )
|
ALCCapabilities deviceCaps = ALC.createCapabilities(device);
|
||||||
throw new IllegalStateException("Failed to open the default device.");
|
|
||||||
caps = device.getCapabilities();
|
|
||||||
System.out.println("---------------------------- Create Audio Device -------------------------------------");
|
|
||||||
System.out.println("OpenALC10: " + caps.OpenALC10);
|
|
||||||
System.out.println("OpenALC11: " + caps.OpenALC11);
|
|
||||||
System.out.println("caps.ALC_EXT_EFX = " + caps.ALC_EXT_EFX);
|
|
||||||
|
|
||||||
String defaultDeviceSpecifier = alcGetString(0L, ALC_DEFAULT_DEVICE_SPECIFIER);
|
context = alcCreateContext(device, (IntBuffer)null);
|
||||||
System.out.println("Default device: " + defaultDeviceSpecifier);
|
alcMakeContextCurrent(context);
|
||||||
|
createCapabilities(deviceCaps);
|
||||||
context = ALContext.create(device);
|
|
||||||
|
|
||||||
System.out.println("ALC_FREQUENCY: " + alcGetInteger(device.address(), ALC_FREQUENCY) + "Hz");
|
|
||||||
System.out.println("ALC_REFRESH: " + alcGetInteger(device.address(), ALC_REFRESH) + "Hz");
|
|
||||||
System.out.println("ALC_SYNC: " + (alcGetInteger(device.address(), ALC_SYNC) == ALC_TRUE));
|
|
||||||
System.out.println("ALC_MONO_SOURCES: " + alcGetInteger(device.address(), ALC_MONO_SOURCES));
|
|
||||||
System.out.println("ALC_STEREO_SOURCES: " + alcGetInteger(device.address(), ALC_STEREO_SOURCES));
|
|
||||||
System.out.println("---------------------------------------------------------------------------------------");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void destroy(){
|
public static void destroy(){
|
||||||
context.destroy();
|
alcCloseDevice(device);
|
||||||
device.destroy();
|
alcDestroyContext(context);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
|
@ -86,7 +71,6 @@ public abstract class Audio {
|
||||||
throw new Exception("Format not supported !");
|
throw new Exception("Format not supported !");
|
||||||
}
|
}
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, buffer);
|
||||||
checkALError();
|
|
||||||
int size = alGetBufferi(buffer,AL_SIZE);
|
int size = alGetBufferi(buffer,AL_SIZE);
|
||||||
int bits = alGetBufferi(buffer, AL_BITS);
|
int bits = alGetBufferi(buffer, AL_BITS);
|
||||||
int channels = alGetBufferi(buffer, AL_CHANNELS);
|
int channels = alGetBufferi(buffer, AL_CHANNELS);
|
||||||
|
@ -193,20 +177,17 @@ public abstract class Audio {
|
||||||
stb_vorbis_seek_start(decoder);
|
stb_vorbis_seek_start(decoder);
|
||||||
int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);
|
int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);
|
||||||
|
|
||||||
ByteBuffer pcm = BufferUtils.createByteBuffer(lengthSamples * 2 * channels);
|
ShortBuffer pcm = BufferUtils.createShortBuffer(lengthSamples * channels);
|
||||||
|
|
||||||
stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm, lengthSamples);
|
stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm);
|
||||||
stb_vorbis_close(decoder);
|
stb_vorbis_close(decoder);
|
||||||
|
|
||||||
buffer = alGenBuffers();
|
buffer = alGenBuffers();
|
||||||
checkALError();
|
|
||||||
|
|
||||||
source = alGenSources();
|
source = alGenSources();
|
||||||
checkALError();
|
|
||||||
|
|
||||||
if(channels == 1)alBufferData(buffer, AL_FORMAT_MONO16, pcm, info.sample_rate());
|
if(channels == 1)alBufferData(buffer, AL_FORMAT_MONO16, pcm, info.sample_rate());
|
||||||
else alBufferData(buffer, AL_FORMAT_STEREO16, pcm, info.sample_rate());
|
else alBufferData(buffer, AL_FORMAT_STEREO16, pcm, info.sample_rate());
|
||||||
checkALError();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playSound(){
|
public void playSound(){
|
||||||
|
|
|
@ -93,8 +93,8 @@ public class Input{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void destroy(){
|
public static void destroy(){
|
||||||
mousePos.release();
|
mousePos.free();
|
||||||
scroll.release();
|
scroll.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void scroll(long window, double xoffset, double yoffset) {
|
public static void scroll(long window, double xoffset, double yoffset) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class Camera {
|
||||||
if(Input.isKey(GLFW.GLFW_KEY_SPACE)){
|
if(Input.isKey(GLFW.GLFW_KEY_SPACE)){
|
||||||
pos.y += speed;
|
pos.y += speed;
|
||||||
}
|
}
|
||||||
if(Input.isKeyDown(GLFW_KEY_ESCAPE))glfwSetWindowShouldClose(Main.windowID, GL11.GL_TRUE);
|
if(Input.isKeyDown(GLFW_KEY_ESCAPE))glfwSetWindowShouldClose(Main.windowID, true);
|
||||||
if(Input.isButtonDown(0))glfwSetInputMode(Main.windowID, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
if(Input.isButtonDown(0))glfwSetInputMode(Main.windowID, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||||
if(Input.isButtonDown(1))glfwSetInputMode(Main.windowID, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
if(Input.isButtonDown(1))glfwSetInputMode(Main.windowID, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue