diff --git a/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java b/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java index 6683dcb6..32c50282 100644 --- a/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java +++ b/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java @@ -516,12 +516,19 @@ public class GLFW mGLFWWindowMap = new ArrayMap<>(); mGLFWVideoMode = new GLFWVidMode(ByteBuffer.allocateDirect(GLFWVidMode.SIZEOF)); +/* memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.WIDTH, mGLFWWindowWidth); memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.HEIGHT, mGLFWWindowHeight); memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.REDBITS, 8); memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.GREENBITS, 8); memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.BLUEBITS, 8); memPutInt(mGLFWVideoMode.address() + mGLFWVideoMode.REFRESHRATE, 60); +*/ + + GLFWVidMode.WIDTH = mGLFWWindowWidth; + GLFWVidMode.HEIGHT = mGFLWWindowHeight; + GLFWVidMode.REDBITS = GFLWVidMode.GREENBITS = GLFWVidMode.BLUEBITS = 8; + GLFWVidMode.REFRESHRATE = 60; // A way to generate key code names Field[] thisFieldArr = GLFW.class.getFields(); diff --git a/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java b/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java index 5e06259d..9ed61258 100644 --- a/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java +++ b/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java @@ -49,7 +49,7 @@ public class GLFWVidMode extends Struct { public static final int ALIGNOF; /** The struct member offsets. */ - public static final int + public static /* final */ int WIDTH, HEIGHT, REDBITS, @@ -69,13 +69,6 @@ public class GLFWVidMode extends Struct { 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); } /** @@ -136,17 +129,17 @@ public class GLFWVidMode extends Struct { // ----------------------------------- /** Unsafe version of {@link #width}. */ - public static int nwidth(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.WIDTH); } + public static int nwidth(long struct) { return WIDTH; } /** Unsafe version of {@link #height}. */ - public static int nheight(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.HEIGHT); } + public static int nheight(long struct) { return HEIGHT; } /** Unsafe version of {@link #redBits}. */ - public static int nredBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REDBITS); } + public static int nredBits(long struct) { return REDBITS; } /** Unsafe version of {@link #greenBits}. */ - public static int ngreenBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.GREENBITS); } + public static int ngreenBits(long struct) { return GREENBITS; } /** Unsafe version of {@link #blueBits}. */ - public static int nblueBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.BLUEBITS); } + public static int nblueBits(long struct) { return BLUEBITS; } /** Unsafe version of {@link #refreshRate}. */ - public static int nrefreshRate(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REFRESHRATE); } + public static int nrefreshRate(long struct) { return REFRESHRATE; } // ----------------------------------- diff --git a/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java.real b/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java.real new file mode 100644 index 00000000..5e06259d --- /dev/null +++ b/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java.real @@ -0,0 +1,204 @@ +/* + * 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. + * + *
+ * struct GLFWvidmode {
+ * int width;
+ * int height;
+ * int redBits;
+ * int greenBits;
+ * int blueBits;
+ * int refreshRate;
+ * }
+ */
+@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.
+ *
+ * The created instance holds a strong reference to the container object.
+ */ + 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 StructBufferThe created buffer instance holds a strong reference to the container object.
+ */ + 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()); } + + } + +} \ No newline at end of file