Various fixes
- GLFW display mode array, fix 0x0 resolution bug
- OSMesa library (copied back 64f4042)
- Hacks for getting Spiral Knights to launch
- Error is now logged properly
This commit is contained in:
1 parent
1d2d7edaec
commit
ae1c86b113
15 files changed
+104
-236
No files matched your search
@@ -1,6 +1,8 @@
|
||||
package net.kdt.pojavlaunch;
|
||||
|
||||
import java.beans.Beans;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
@@ -15,15 +17,20 @@ public class PojavLauncher {
|
||||
private static float currProgress, maxProgress;
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
/*
|
||||
try {
|
||||
Runtime.getRuntime().exec("/usr/bin/true");
|
||||
} catch (IOException e) {}
|
||||
*/
|
||||
// Skip calling to com.apple.eawt.Application.nativeInitializeApplicationDelegate()
|
||||
Beans.setDesignTime(true);
|
||||
try {
|
||||
// Some places use macOS-specific code, which is unavailable on iOS
|
||||
// In this case, try to get it to use Linux-specific code instead.
|
||||
com.apple.eawt.Application.getApplication();
|
||||
Class clazz = Class.forName("com.apple.eawt.Application");
|
||||
Field field = clazz.getDeclaredField("sApplication");
|
||||
field.setAccessible(true);
|
||||
field.set(null, null);
|
||||
sun.font.FontUtilities.isLinux = true;
|
||||
} catch (Throwable th) {
|
||||
// Not on JRE8, ignore exception
|
||||
//Tools.showError(th);
|
||||
}
|
||||
|
||||
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
|
||||
@@ -321,8 +321,6 @@ public final class Tools
|
||||
e.printStackTrace(pw);
|
||||
pw.flush();
|
||||
|
||||
System.err.println(sw.toString());
|
||||
|
||||
UIKit.showError(title, sw.toString(), exitIfOk);
|
||||
|
||||
/*
|
||||
|
||||
@@ -13,6 +13,9 @@ public class JSONUtils {
|
||||
public static String insertSingleJSONValue(String value, Map<String, String> keyValueMap) {
|
||||
String valueInserted = value;
|
||||
for (Map.Entry<String, String> keyValue : keyValueMap.entrySet()) {
|
||||
if (keyValue.getValue() == null) {
|
||||
keyValue.setValue("");
|
||||
}
|
||||
valueInserted = valueInserted.replace("${" + keyValue.getKey() + "}", keyValue.getValue());
|
||||
}
|
||||
return valueInserted;
|
||||
|
||||
@@ -518,12 +518,11 @@ public class GLFW
|
||||
mGLFWVideoMode = new GLFWVidMode(ByteBuffer.allocateDirect(GLFWVidMode.SIZEOF));
|
||||
internalChangeMonitorSize(Tools.mGLFWWindowWidth, Tools.mGLFWWindowHeight);
|
||||
|
||||
/*
|
||||
memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.REDBITS, 8);
|
||||
memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.GREENBITS, 8);
|
||||
memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.BLUEBITS, 8);
|
||||
memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.REFRESHRATE, 60);
|
||||
*/
|
||||
|
||||
// A way to generate key code names
|
||||
Field[] thisFieldArr = GLFW.class.getFields();
|
||||
try {
|
||||
@@ -912,7 +911,9 @@ public class GLFW
|
||||
try {
|
||||
// long __result = nglfwGetVideoModes(monitor, memAddress(count));
|
||||
long __result = memAddress(stack.callocLong(1));
|
||||
return GLFWVidMode.createSafe(__result, 1);
|
||||
GLFWVidMode.Buffer buffer = GLFWVidMode.createSafe(__result, 1);
|
||||
buffer.put(glfwGetVideoMode(monitor));
|
||||
return buffer;
|
||||
} finally {
|
||||
stack.setPointer(stackPointer);
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@ public class GLFWVidMode extends Struct {
|
||||
|
||||
/** The struct member offsets. */
|
||||
public static final int
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
REDBITS,
|
||||
GREENBITS,
|
||||
BLUEBITS,
|
||||
REFRESHRATE;
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
REDBITS,
|
||||
GREENBITS,
|
||||
BLUEBITS,
|
||||
REFRESHRATE;
|
||||
|
||||
static {
|
||||
Layout layout = __struct(
|
||||
@@ -140,13 +140,13 @@ public class GLFWVidMode extends Struct {
|
||||
/** Unsafe version of {@link #height}. */
|
||||
public static int nheight(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.HEIGHT); }
|
||||
/** Unsafe version of {@link #redBits}. */
|
||||
public static int nredBits(long struct) { return 8; } // UNSAFE.getInt(null, struct + GLFWVidMode.REDBITS); }
|
||||
public static int nredBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REDBITS); }
|
||||
/** Unsafe version of {@link #greenBits}. */
|
||||
public static int ngreenBits(long struct) { return 8; } // UNSAFE.getInt(null, struct + GLFWVidMode.GREENBITS); }
|
||||
public static int ngreenBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.GREENBITS); }
|
||||
/** Unsafe version of {@link #blueBits}. */
|
||||
public static int nblueBits(long struct) { return 8; } // UNSAFE.getInt(null, struct + GLFWVidMode.BLUEBITS); }
|
||||
public static int nblueBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.BLUEBITS); }
|
||||
/** Unsafe version of {@link #refreshRate}. */
|
||||
public static int nrefreshRate(long struct) { return 60; } // UNSAFE.getInt(null, struct + GLFWVidMode.REFRESHRATE); }
|
||||
public static int nrefreshRate(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REFRESHRATE); }
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
@@ -201,4 +201,4 @@ public class GLFWVidMode extends Struct {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,204 +0,0 @@
|
||||
/*
|
||||
* Copyright LWJGL. All rights reserved.
|
||||
* License terms: https://www.lwjgl.org/license
|
||||
* MACHINE GENERATED FILE, DO NOT EDIT
|
||||
*/
|
||||
package org.lwjgl.glfw;
|
||||
|
||||
import javax.annotation.*;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
import org.lwjgl.system.*;
|
||||
|
||||
import static org.lwjgl.system.MemoryUtil.*;
|
||||
|
||||
/**
|
||||
* Describes a single video mode.
|
||||
*
|
||||
* <h3>Member documentation</h3>
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code width} – the width, in screen coordinates, of the video mode</li>
|
||||
* <li>{@code height} – the height, in screen coordinates, of the video mode</li>
|
||||
* <li>{@code redBits} – the bit depth of the red channel of the video mode</li>
|
||||
* <li>{@code greenBits} – the bit depth of the green channel of the video mode</li>
|
||||
* <li>{@code blueBits} – the bit depth of the blue channel of the video mode</li>
|
||||
* <li>{@code refreshRate} – the refresh rate, in Hz, of the video mode</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h3>Layout</h3>
|
||||
*
|
||||
* <pre><code>
|
||||
* struct GLFWvidmode {
|
||||
* int width;
|
||||
* int height;
|
||||
* int redBits;
|
||||
* int greenBits;
|
||||
* int blueBits;
|
||||
* int refreshRate;
|
||||
* }</code></pre>
|
||||
*/
|
||||
@NativeType("struct GLFWvidmode")
|
||||
public class GLFWVidMode extends Struct {
|
||||
|
||||
/** The struct size in bytes. */
|
||||
public static final int SIZEOF;
|
||||
|
||||
/** The struct alignment in bytes. */
|
||||
public static final int ALIGNOF;
|
||||
|
||||
/** The struct member offsets. */
|
||||
public static final int
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
REDBITS,
|
||||
GREENBITS,
|
||||
BLUEBITS,
|
||||
REFRESHRATE;
|
||||
|
||||
static {
|
||||
Layout layout = __struct(
|
||||
__member(4),
|
||||
__member(4),
|
||||
__member(4),
|
||||
__member(4),
|
||||
__member(4),
|
||||
__member(4)
|
||||
);
|
||||
|
||||
SIZEOF = layout.getSize();
|
||||
ALIGNOF = layout.getAlignment();
|
||||
|
||||
WIDTH = layout.offsetof(0);
|
||||
HEIGHT = layout.offsetof(1);
|
||||
REDBITS = layout.offsetof(2);
|
||||
GREENBITS = layout.offsetof(3);
|
||||
BLUEBITS = layout.offsetof(4);
|
||||
REFRESHRATE = layout.offsetof(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@code GLFWVidMode} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be
|
||||
* visible to the struct instance and vice versa.
|
||||
*
|
||||
* <p>The created instance holds a strong reference to the container object.</p>
|
||||
*/
|
||||
public GLFWVidMode(ByteBuffer container) {
|
||||
super(memAddress(container), __checkContainer(container, SIZEOF));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sizeof() { return SIZEOF; }
|
||||
|
||||
/** Returns the value of the {@code width} field. */
|
||||
public int width() { return nwidth(address()); }
|
||||
/** Returns the value of the {@code height} field. */
|
||||
public int height() { return nheight(address()); }
|
||||
/** Returns the value of the {@code redBits} field. */
|
||||
public int redBits() { return nredBits(address()); }
|
||||
/** Returns the value of the {@code greenBits} field. */
|
||||
public int greenBits() { return ngreenBits(address()); }
|
||||
/** Returns the value of the {@code blueBits} field. */
|
||||
public int blueBits() { return nblueBits(address()); }
|
||||
/** Returns the value of the {@code refreshRate} field. */
|
||||
public int refreshRate() { return nrefreshRate(address()); }
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** Returns a new {@code GLFWVidMode} instance for the specified memory address. */
|
||||
public static GLFWVidMode create(long address) {
|
||||
return wrap(GLFWVidMode.class, address);
|
||||
}
|
||||
|
||||
/** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
|
||||
@Nullable
|
||||
public static GLFWVidMode createSafe(long address) {
|
||||
return address == NULL ? null : wrap(GLFWVidMode.class, address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link GLFWVidMode.Buffer} instance at the specified memory.
|
||||
*
|
||||
* @param address the memory address
|
||||
* @param capacity the buffer capacity
|
||||
*/
|
||||
public static GLFWVidMode.Buffer create(long address, int capacity) {
|
||||
return wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
|
||||
/** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
|
||||
@Nullable
|
||||
public static GLFWVidMode.Buffer createSafe(long address, int capacity) {
|
||||
return address == NULL ? null : wrap(Buffer.class, address, capacity);
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** Unsafe version of {@link #width}. */
|
||||
public static int nwidth(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.WIDTH); }
|
||||
/** Unsafe version of {@link #height}. */
|
||||
public static int nheight(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.HEIGHT); }
|
||||
/** Unsafe version of {@link #redBits}. */
|
||||
public static int nredBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REDBITS); }
|
||||
/** Unsafe version of {@link #greenBits}. */
|
||||
public static int ngreenBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.GREENBITS); }
|
||||
/** Unsafe version of {@link #blueBits}. */
|
||||
public static int nblueBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.BLUEBITS); }
|
||||
/** Unsafe version of {@link #refreshRate}. */
|
||||
public static int nrefreshRate(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REFRESHRATE); }
|
||||
|
||||
// -----------------------------------
|
||||
|
||||
/** An array of {@link GLFWVidMode} structs. */
|
||||
public static class Buffer extends StructBuffer<GLFWVidMode, Buffer> {
|
||||
|
||||
private static final GLFWVidMode ELEMENT_FACTORY = GLFWVidMode.create(-1L);
|
||||
|
||||
/**
|
||||
* Creates a new {@code GLFWVidMode.Buffer} instance backed by the specified container.
|
||||
*
|
||||
* Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values
|
||||
* will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided
|
||||
* by {@link GLFWVidMode#SIZEOF}, and its mark will be undefined.
|
||||
*
|
||||
* <p>The created buffer instance holds a strong reference to the container object.</p>
|
||||
*/
|
||||
public Buffer(ByteBuffer container) {
|
||||
super(container, container.remaining() / SIZEOF);
|
||||
}
|
||||
|
||||
public Buffer(long address, int cap) {
|
||||
super(address, null, -1, 0, cap, cap);
|
||||
}
|
||||
|
||||
Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) {
|
||||
super(address, container, mark, pos, lim, cap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Buffer self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GLFWVidMode getElementFactory() {
|
||||
return ELEMENT_FACTORY;
|
||||
}
|
||||
|
||||
/** Returns the value of the {@code width} field. */
|
||||
public int width() { return GLFWVidMode.nwidth(address()); }
|
||||
/** Returns the value of the {@code height} field. */
|
||||
public int height() { return GLFWVidMode.nheight(address()); }
|
||||
/** Returns the value of the {@code redBits} field. */
|
||||
public int redBits() { return GLFWVidMode.nredBits(address()); }
|
||||
/** Returns the value of the {@code greenBits} field. */
|
||||
public int greenBits() { return GLFWVidMode.ngreenBits(address()); }
|
||||
/** Returns the value of the {@code blueBits} field. */
|
||||
public int blueBits() { return GLFWVidMode.nblueBits(address()); }
|
||||
/** Returns the value of the {@code refreshRate} field. */
|
||||
public int refreshRate() { return GLFWVidMode.nrefreshRate(address()); }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,8 +19,8 @@ public static int getControllerCount() {
|
||||
ctrlr.poll();
|
||||
}
|
||||
public static boolean next() {
|
||||
ctrlr.poll();
|
||||
return true;
|
||||
//ctrlr.poll();
|
||||
return false;//true;
|
||||
}
|
||||
public static boolean isCreated() {
|
||||
return true;
|
||||
@@ -76,4 +76,4 @@ public static int getControllerCount() {
|
||||
public static float getEventYAxisValue() {
|
||||
return ctrlr.getYAxisValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class GLFWController implements Controller{
|
||||
|
||||
@Override
|
||||
public boolean isButtonPressed(int index) {
|
||||
return (buttonData.get(index) == 1);
|
||||
return (buttonData.remaining() > index) && (buttonData.get(index) == 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,7 +54,62 @@ public final class AL {
|
||||
static ALCapabilities alCaps;
|
||||
|
||||
private static boolean created_lwjgl2 = false;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an OpenAL instance. Using this constructor will cause OpenAL to
|
||||
* open the device using supplied device argument, and create a context using the context values
|
||||
* supplied.
|
||||
*
|
||||
* @param deviceArguments Arguments supplied to native device
|
||||
* @param contextFrequency Frequency for mixing output buffer, in units of Hz (Common values include 11025, 22050, and 44100).
|
||||
* @param contextRefresh Refresh intervalls, in units of Hz.
|
||||
* @param contextSynchronized Flag, indicating a synchronous context.*
|
||||
*/
|
||||
public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized)
|
||||
throws LWJGLException {
|
||||
create(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param openDevice Whether to automatically open the device
|
||||
* @see #create(String, int, int, boolean)
|
||||
*/
|
||||
public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized, boolean openDevice)
|
||||
throws LWJGLException {
|
||||
if (alContext == MemoryUtil.NULL && openDevice) {
|
||||
//ALDevice alDevice = ALDevice.create();
|
||||
long alDevice = ALC10.alcOpenDevice(deviceArguments);
|
||||
if(alDevice == MemoryUtil.NULL){
|
||||
throw new LWJGLException("Cannot open the device");
|
||||
}
|
||||
|
||||
IntBuffer attribs = BufferUtils.createIntBuffer(16);
|
||||
|
||||
attribs.put(ALC10.ALC_FREQUENCY);
|
||||
attribs.put(contextFrequency);
|
||||
|
||||
attribs.put(ALC10.ALC_REFRESH);
|
||||
attribs.put(contextRefresh);
|
||||
|
||||
attribs.put(ALC10.ALC_SYNC);
|
||||
attribs.put(contextSynchronized ? ALC10.ALC_TRUE : ALC10.ALC_FALSE);
|
||||
|
||||
attribs.put(0);
|
||||
attribs.flip();
|
||||
|
||||
long contextHandle = ALC10.alcCreateContext(alDevice, attribs);
|
||||
ALC10.alcMakeContextCurrent(contextHandle);
|
||||
//alContext = new ALContext(alDevice, contextHandle);
|
||||
alContext = ALC10.alcCreateContext(contextHandle, (IntBuffer)null);
|
||||
alContextCaps = ALC.createCapabilities(alContext);
|
||||
|
||||
alCaps = AL.createCapabilities(alContextCaps);
|
||||
|
||||
alcDevice = new ALCdevice(alDevice);
|
||||
created_lwjgl2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void create() throws LWJGLException {
|
||||
if (alContext == MemoryUtil.NULL) {
|
||||
//ALDevice alDevice = ALDevice.create();
|
||||
|
||||
@@ -949,7 +949,7 @@ public class Display {
|
||||
} else {
|
||||
glfwSetWindowIcon(Window.handle, new GLFWImage.Buffer(icons[0]));
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
} catch (Exception e) {
|
||||
LWJGLUtil.log("Couldn't set icon");
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -982,8 +982,10 @@ public class Display {
|
||||
}
|
||||
|
||||
public static void setDisplayModeAndFullscreen(DisplayMode dm) throws LWJGLException {
|
||||
Display.mode = dm;
|
||||
GLFW.glfwSetWindowSize(Window.handle, dm.getWidth(), dm.getHeight());
|
||||
if(Window.handle != 0) {
|
||||
Display.mode = dm;
|
||||
GLFW.glfwSetWindowSize(Window.handle, dm.getWidth(), dm.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
public static void setFullscreen(boolean fullscreen) throws LWJGLException {
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class DisplayMode {
|
||||
* @see Display
|
||||
*/
|
||||
public DisplayMode(int width, int height) {
|
||||
this(width, height, 0, 0, false);
|
||||
this(width, height, 0, 0, true);
|
||||
}
|
||||
|
||||
DisplayMode(int width, int height, int bpp, int freq) {
|
||||
|
||||
Reference in new issue
Block a user