diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 32858aa..acfb534 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,5 @@ -*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* +save/* +.settings/* +.classpath +.project +bin/* diff --git a/.travis.yml b/.travis.yml new file mode 100755 index 0000000..684811b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: java +jdk: + - oraclejdk8 diff --git a/First Game Engine Project/.classpath b/First Game Engine Project/.classpath deleted file mode 100644 index e866d18..0000000 --- a/First Game Engine Project/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/First Game Engine Project/.gitignore b/First Game Engine Project/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/First Game Engine Project/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/First Game Engine Project/.project b/First Game Engine Project/.project deleted file mode 100644 index 4491e84..0000000 --- a/First Game Engine Project/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - First 2D Game UDP - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/First Game Engine Project/.settings/org.eclipse.jdt.core.prefs b/First Game Engine Project/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index bb35fa0..0000000 --- a/First Game Engine Project/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/First Game Engine Project/src/mrdev023/audio/Audio.java b/First Game Engine Project/src/mrdev023/audio/Audio.java deleted file mode 100644 index 5749740..0000000 --- a/First Game Engine Project/src/mrdev023/audio/Audio.java +++ /dev/null @@ -1,341 +0,0 @@ -package mrdev023.audio; - -import static org.lwjgl.openal.AL10.*; -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.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; - -public class Audio { - - //Variables global - //------------------------------------------------------ - public static ALDevice device; - public static ALCCapabilities caps; - public static ALContext 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 = ALDevice.create(null); - if ( device == null ) - 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); - System.out.println("Default device: " + defaultDeviceSpecifier); - - 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(){ - context.destroy(); - device.destroy(); - } - //------------------------------------------------------ - - //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); - checkALError(); - 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); - - ByteBuffer pcm = BufferUtils.createByteBuffer(lengthSamples * 2 * channels); - - stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm, lengthSamples); - stb_vorbis_close(decoder); - - buffer = alGenBuffers(); - checkALError(); - - source = alGenSources(); - checkALError(); - - if(channels == 1)alBufferData(buffer, AL_FORMAT_MONO16, pcm, info.sample_rate()); - else alBufferData(buffer, AL_FORMAT_STEREO16, pcm, info.sample_rate()); - checkALError(); - } - - 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; - } - //------------------------------------------------------ - -} diff --git a/README.md b/README.md new file mode 100755 index 0000000..57e5f19 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# My First Voxel + +Compile status: ![Status](https://travis-ci.org/mrdev023/MyFirstVoxel.svg?branch=master) + +Ce projet est un Voxel que j'ai creer et optimiser en JAVA et avec LWJGL 2 en OpenGL Modern. +Le projet n'est pas aboutie par manque d'idee. + +![Image](https://pbs.twimg.com/media/CPWaGv4WsAAXPhU.png:large) diff --git a/build.xml b/build.xml new file mode 100755 index 0000000..ec998f3 --- /dev/null +++ b/build.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/OpenAL.dll b/libs/OpenAL.dll new file mode 100755 index 0000000..f29c3ce Binary files /dev/null and b/libs/OpenAL.dll differ diff --git a/libs/OpenAL32.dll b/libs/OpenAL32.dll new file mode 100755 index 0000000..31d639d Binary files /dev/null and b/libs/OpenAL32.dll differ diff --git a/libs/glfw.dll b/libs/glfw.dll new file mode 100755 index 0000000..f8c3dc7 Binary files /dev/null and b/libs/glfw.dll differ diff --git a/libs/glfw32.dll b/libs/glfw32.dll new file mode 100755 index 0000000..3291dce Binary files /dev/null and b/libs/glfw32.dll differ diff --git a/libs/jemalloc.dll b/libs/jemalloc.dll new file mode 100755 index 0000000..c71efc1 Binary files /dev/null and b/libs/jemalloc.dll differ diff --git a/libs/jemalloc32.dll b/libs/jemalloc32.dll new file mode 100755 index 0000000..6bea0b3 Binary files /dev/null and b/libs/jemalloc32.dll differ diff --git a/libs/libglfw.dylib b/libs/libglfw.dylib new file mode 100755 index 0000000..905c1bd Binary files /dev/null and b/libs/libglfw.dylib differ diff --git a/libs/libglfw.so b/libs/libglfw.so new file mode 100755 index 0000000..e97463b Binary files /dev/null and b/libs/libglfw.so differ diff --git a/libs/libjemalloc.dylib b/libs/libjemalloc.dylib new file mode 100755 index 0000000..1d7cc79 Binary files /dev/null and b/libs/libjemalloc.dylib differ diff --git a/libs/libjemalloc.so b/libs/libjemalloc.so new file mode 100755 index 0000000..dc95c65 Binary files /dev/null and b/libs/libjemalloc.so differ diff --git a/libs/liblwjgl.dylib b/libs/liblwjgl.dylib new file mode 100755 index 0000000..aeda823 Binary files /dev/null and b/libs/liblwjgl.dylib differ diff --git a/libs/liblwjgl.so b/libs/liblwjgl.so new file mode 100755 index 0000000..229b3c9 Binary files /dev/null and b/libs/liblwjgl.so differ diff --git a/libs/libopenal.dylib b/libs/libopenal.dylib new file mode 100755 index 0000000..7f0047b Binary files /dev/null and b/libs/libopenal.dylib differ diff --git a/libs/libopenal.so b/libs/libopenal.so new file mode 100755 index 0000000..0c8e888 Binary files /dev/null and b/libs/libopenal.so differ diff --git a/libs/lwjgl.dll b/libs/lwjgl.dll new file mode 100755 index 0000000..8f385e5 Binary files /dev/null and b/libs/lwjgl.dll differ diff --git a/libs/lwjgl.jar b/libs/lwjgl.jar new file mode 100755 index 0000000..185260c Binary files /dev/null and b/libs/lwjgl.jar differ diff --git a/libs/lwjgl32.dll b/libs/lwjgl32.dll new file mode 100755 index 0000000..6177778 Binary files /dev/null and b/libs/lwjgl32.dll differ diff --git a/First Game Engine Project/res/font/Thumbs.db b/res/font/Thumbs.db similarity index 100% rename from First Game Engine Project/res/font/Thumbs.db rename to res/font/Thumbs.db diff --git a/First Game Engine Project/res/font/font.png b/res/font/font.png similarity index 100% rename from First Game Engine Project/res/font/font.png rename to res/font/font.png diff --git a/First Game Engine Project/src/mrdev023/Main.java b/src/mrdev023/Main.java similarity index 100% rename from First Game Engine Project/src/mrdev023/Main.java rename to src/mrdev023/Main.java diff --git a/src/mrdev023/audio/Audio.java b/src/mrdev023/audio/Audio.java new file mode 100755 index 0000000..2d2e467 --- /dev/null +++ b/src/mrdev023/audio/Audio.java @@ -0,0 +1,322 @@ +package mrdev023.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; + +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; + } + //------------------------------------------------------ + +} diff --git a/First Game Engine Project/src/mrdev023/entities/Entity.java b/src/mrdev023/entities/Entity.java similarity index 100% rename from First Game Engine Project/src/mrdev023/entities/Entity.java rename to src/mrdev023/entities/Entity.java diff --git a/First Game Engine Project/src/mrdev023/entities/Player.java b/src/mrdev023/entities/Player.java similarity index 100% rename from First Game Engine Project/src/mrdev023/entities/Player.java rename to src/mrdev023/entities/Player.java diff --git a/First Game Engine Project/src/mrdev023/gameengine/GameEngine.java b/src/mrdev023/gameengine/GameEngine.java similarity index 100% rename from First Game Engine Project/src/mrdev023/gameengine/GameEngine.java rename to src/mrdev023/gameengine/GameEngine.java diff --git a/First Game Engine Project/src/mrdev023/gameengine/gamestate/MainState.java b/src/mrdev023/gameengine/gamestate/MainState.java similarity index 100% rename from First Game Engine Project/src/mrdev023/gameengine/gamestate/MainState.java rename to src/mrdev023/gameengine/gamestate/MainState.java diff --git a/First Game Engine Project/src/mrdev023/gameengine/gamestate/main/GameState.java b/src/mrdev023/gameengine/gamestate/main/GameState.java similarity index 100% rename from First Game Engine Project/src/mrdev023/gameengine/gamestate/main/GameState.java rename to src/mrdev023/gameengine/gamestate/main/GameState.java diff --git a/First Game Engine Project/src/mrdev023/gameengine/gamestate/main/IGameState.java b/src/mrdev023/gameengine/gamestate/main/IGameState.java similarity index 100% rename from First Game Engine Project/src/mrdev023/gameengine/gamestate/main/IGameState.java rename to src/mrdev023/gameengine/gamestate/main/IGameState.java diff --git a/First Game Engine Project/src/mrdev023/io/IOFile.java b/src/mrdev023/io/IOFile.java similarity index 100% rename from First Game Engine Project/src/mrdev023/io/IOFile.java rename to src/mrdev023/io/IOFile.java diff --git a/First Game Engine Project/src/mrdev023/math/Color4f.java b/src/mrdev023/math/Color4f.java similarity index 100% rename from First Game Engine Project/src/mrdev023/math/Color4f.java rename to src/mrdev023/math/Color4f.java diff --git a/First Game Engine Project/src/mrdev023/math/Mathf.java b/src/mrdev023/math/Mathf.java similarity index 100% rename from First Game Engine Project/src/mrdev023/math/Mathf.java rename to src/mrdev023/math/Mathf.java diff --git a/First Game Engine Project/src/mrdev023/math/Vector2f.java b/src/mrdev023/math/Vector2f.java similarity index 100% rename from First Game Engine Project/src/mrdev023/math/Vector2f.java rename to src/mrdev023/math/Vector2f.java diff --git a/First Game Engine Project/src/mrdev023/network/client/MainClient.java b/src/mrdev023/network/client/MainClient.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/client/MainClient.java rename to src/mrdev023/network/client/MainClient.java diff --git a/First Game Engine Project/src/mrdev023/network/common/Client.java b/src/mrdev023/network/common/Client.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/common/Client.java rename to src/mrdev023/network/common/Client.java diff --git a/First Game Engine Project/src/mrdev023/network/common/DataBuffer.java b/src/mrdev023/network/common/DataBuffer.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/common/DataBuffer.java rename to src/mrdev023/network/common/DataBuffer.java diff --git a/First Game Engine Project/src/mrdev023/network/common/Register.java b/src/mrdev023/network/common/Register.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/common/Register.java rename to src/mrdev023/network/common/Register.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/ChangePseudoPacket.java b/src/mrdev023/network/packet/ChangePseudoPacket.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/ChangePseudoPacket.java rename to src/mrdev023/network/packet/ChangePseudoPacket.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/ClientConnect.java b/src/mrdev023/network/packet/ClientConnect.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/ClientConnect.java rename to src/mrdev023/network/packet/ClientConnect.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/ClientDisconnect.java b/src/mrdev023/network/packet/ClientDisconnect.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/ClientDisconnect.java rename to src/mrdev023/network/packet/ClientDisconnect.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/MessagePacket.java b/src/mrdev023/network/packet/MessagePacket.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/MessagePacket.java rename to src/mrdev023/network/packet/MessagePacket.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/MessageTestPacket.java b/src/mrdev023/network/packet/MessageTestPacket.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/MessageTestPacket.java rename to src/mrdev023/network/packet/MessageTestPacket.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/OutOfSocketPacket.java b/src/mrdev023/network/packet/OutOfSocketPacket.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/OutOfSocketPacket.java rename to src/mrdev023/network/packet/OutOfSocketPacket.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/PingClientPacket.java b/src/mrdev023/network/packet/PingClientPacket.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/PingClientPacket.java rename to src/mrdev023/network/packet/PingClientPacket.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/UpdateColor.java b/src/mrdev023/network/packet/UpdateColor.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/UpdateColor.java rename to src/mrdev023/network/packet/UpdateColor.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/UpdatePseudoPacket.java b/src/mrdev023/network/packet/UpdatePseudoPacket.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/UpdatePseudoPacket.java rename to src/mrdev023/network/packet/UpdatePseudoPacket.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/UpdateXPacket.java b/src/mrdev023/network/packet/UpdateXPacket.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/UpdateXPacket.java rename to src/mrdev023/network/packet/UpdateXPacket.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/UpdateYPacket.java b/src/mrdev023/network/packet/UpdateYPacket.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/UpdateYPacket.java rename to src/mrdev023/network/packet/UpdateYPacket.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/main/IPacket.java b/src/mrdev023/network/packet/main/IPacket.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/main/IPacket.java rename to src/mrdev023/network/packet/main/IPacket.java diff --git a/First Game Engine Project/src/mrdev023/network/packet/main/Utils.java b/src/mrdev023/network/packet/main/Utils.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/packet/main/Utils.java rename to src/mrdev023/network/packet/main/Utils.java diff --git a/First Game Engine Project/src/mrdev023/network/server/MainServer.java b/src/mrdev023/network/server/MainServer.java similarity index 100% rename from First Game Engine Project/src/mrdev023/network/server/MainServer.java rename to src/mrdev023/network/server/MainServer.java diff --git a/First Game Engine Project/src/mrdev023/opengl/DisplayManager.java b/src/mrdev023/opengl/DisplayManager.java similarity index 100% rename from First Game Engine Project/src/mrdev023/opengl/DisplayManager.java rename to src/mrdev023/opengl/DisplayManager.java diff --git a/First Game Engine Project/src/mrdev023/opengl/Frame.java b/src/mrdev023/opengl/Frame.java similarity index 93% rename from First Game Engine Project/src/mrdev023/opengl/Frame.java rename to src/mrdev023/opengl/Frame.java index 8763658..c3472c7 100644 --- a/First Game Engine Project/src/mrdev023/opengl/Frame.java +++ b/src/mrdev023/opengl/Frame.java @@ -8,7 +8,6 @@ import mrdev023.opengl.exception.*; import static org.lwjgl.glfw.GLFW.*; import static org.lwjgl.system.MemoryUtil.*; import static org.lwjgl.glfw.Callbacks.*; -import org.lwjgl.glfw.GLFWWindowSizeCallback.SAM; import java.nio.*; @@ -42,7 +41,7 @@ public class Frame { glfwSetErrorCallback(errorCallback); //init - if(glfwInit() != GL11.GL_TRUE)throw new FrameException("GLFW not init"); + if(!glfwInit())throw new FrameException("GLFW not init"); //config de la fenetre glfwDefaultWindowHints(); @@ -100,7 +99,7 @@ public class Frame { glfwSetErrorCallback(errorCallback); //init - if(glfwInit() != GL11.GL_TRUE)throw new FrameException("GLFW not init"); + if(!glfwInit())throw new FrameException("GLFW not init"); //config de la fenetre glfwDefaultWindowHints(); @@ -216,14 +215,11 @@ public class Frame { } /** - * @return true si la croix rouge a été cliquer + * @return true si la croix rouge a ete cliquer */ public boolean isClosedRequested(){ - if(glfwWindowShouldClose(windowID) == GL11.GL_FALSE){ - return false; - }else{ - return true; - } + return glfwWindowShouldClose(windowID); + } public void setTitle(String title){ diff --git a/First Game Engine Project/src/mrdev023/opengl/Input.java b/src/mrdev023/opengl/Input.java similarity index 95% rename from First Game Engine Project/src/mrdev023/opengl/Input.java rename to src/mrdev023/opengl/Input.java index 880436d..ffffda5 100644 --- a/First Game Engine Project/src/mrdev023/opengl/Input.java +++ b/src/mrdev023/opengl/Input.java @@ -93,8 +93,8 @@ public class Input{ } public static void destroy(){ - mousePos.release(); - scroll.release(); + mousePos.free(); + scroll.free(); } public static void scroll(long window, double xoffset, double yoffset) { diff --git a/First Game Engine Project/src/mrdev023/opengl/TextFont.java b/src/mrdev023/opengl/TextFont.java similarity index 100% rename from First Game Engine Project/src/mrdev023/opengl/TextFont.java rename to src/mrdev023/opengl/TextFont.java diff --git a/First Game Engine Project/src/mrdev023/opengl/Texture.java b/src/mrdev023/opengl/Texture.java similarity index 100% rename from First Game Engine Project/src/mrdev023/opengl/Texture.java rename to src/mrdev023/opengl/Texture.java diff --git a/First Game Engine Project/src/mrdev023/opengl/VAO.java b/src/mrdev023/opengl/VAO.java similarity index 100% rename from First Game Engine Project/src/mrdev023/opengl/VAO.java rename to src/mrdev023/opengl/VAO.java diff --git a/First Game Engine Project/src/mrdev023/opengl/exception/FrameException.java b/src/mrdev023/opengl/exception/FrameException.java similarity index 100% rename from First Game Engine Project/src/mrdev023/opengl/exception/FrameException.java rename to src/mrdev023/opengl/exception/FrameException.java diff --git a/First Game Engine Project/src/mrdev023/opengl/gui/Button.java b/src/mrdev023/opengl/gui/Button.java similarity index 100% rename from First Game Engine Project/src/mrdev023/opengl/gui/Button.java rename to src/mrdev023/opengl/gui/Button.java diff --git a/First Game Engine Project/src/mrdev023/opengl/gui/GUIComponent.java b/src/mrdev023/opengl/gui/GUIComponent.java similarity index 100% rename from First Game Engine Project/src/mrdev023/opengl/gui/GUIComponent.java rename to src/mrdev023/opengl/gui/GUIComponent.java diff --git a/First Game Engine Project/src/mrdev023/opengl/gui/Message.java b/src/mrdev023/opengl/gui/Message.java similarity index 100% rename from First Game Engine Project/src/mrdev023/opengl/gui/Message.java rename to src/mrdev023/opengl/gui/Message.java