fixed some crap to work with stupid lwjgl display-mouse-keyboard combo

master
Ondřej Hruška 10 years ago
parent 476ca8ba61
commit d2fe36f745
  1. 12
      .classpath
  2. 27
      src/mightypork/gamecore/backends/lwjgl/LwjglInputModule.java
  3. 2
      src/mightypork/gamecore/backends/lwjgl/audio/SlickAudio.java
  4. 7
      src/mightypork/gamecore/backends/lwjgl/graphics/LwjglGraphicsModule.java

@ -6,8 +6,16 @@
<classpathentry combineaccessrules="false" kind="src" path="/MightyUtils"/>
<classpathentry kind="lib" path="lib/jogg-0.0.7.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"/>
<classpathentry kind="lib" path="lib/jorbis-0.0.15.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"/>
<classpathentry kind="lib" path="lib/lwjgl_util.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"/>
<classpathentry kind="lib" path="lib/lwjgl.jar" sourcepath="lib/lwjgl-source-2.8.4.zip"/>
<classpathentry kind="lib" path="lib/lwjgl_util.jar" sourcepath="lib/lwjgl-source-2.8.4.zip">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="GameCore-LWJGL/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/lwjgl.jar" sourcepath="lib/lwjgl-source-2.8.4.zip">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="GameCore-LWJGL/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/slick-util.jar" sourcepath="lib/slick-util-src.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -9,6 +9,7 @@ import mightypork.gamecore.input.events.KeyEvent;
import mightypork.gamecore.input.events.MouseButtonEvent;
import mightypork.gamecore.input.events.MouseMotionEvent;
import mightypork.utils.interfaces.Updateable;
import mightypork.utils.logging.Log;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.var.VectVar;
@ -51,15 +52,25 @@ public class LwjglInputModule extends InputModule implements Updateable {
protected void initDevices()
{
try {
Mouse.create();
Keyboard.create();
tryCreate();
Keyboard.enableRepeatEvents(false);
} catch (final LWJGLException e) {
throw new RuntimeException("Failed to initialize input devices.", e);
}
}
private void tryCreate() throws LWJGLException
{
if (Display.isCreated()) {
Mouse.create();
Keyboard.create();
}
}
@Override
protected void initKeyCodes()
{
@ -206,8 +217,16 @@ public class LwjglInputModule extends InputModule implements Updateable {
{
// was destroyed or not initialized
if (!Display.isCreated()) return;
if (!Mouse.isCreated()) return;
if (!Keyboard.isCreated()) return;
if (!Mouse.isCreated() || !Keyboard.isCreated()) {
try {
tryCreate();
} catch (final LWJGLException e) {
Log.e(e);
}
}
if (!Mouse.isCreated() || !Keyboard.isCreated()) return;
Display.processMessages();

@ -48,6 +48,8 @@ public class SlickAudio extends DeferredAudio {
try(final InputStream stream = FileUtil.getResource(resource)) {
if (stream == null) throw new IOException("Not found: " + resource);
if (ext.equalsIgnoreCase("ogg")) {
backingAudio = SoundStore.get().getOgg(resource, stream);

@ -83,9 +83,16 @@ public class LwjglGraphicsModule extends GraphicsModule {
@Override
public void init()
{
}
@Override
public void createDisplay()
{
try {
Display.create();
} catch (final Exception e) {
throw new RuntimeException("Could not initialize display.", e);
}

Loading…
Cancel
Save