https://github.com/ocelot5836/glfw-windows
Simplifies window management and creation in LWJGL GLFW
https://github.com/ocelot5836/glfw-windows
Last synced: 2 months ago
JSON representation
Simplifies window management and creation in LWJGL GLFW
- Host: GitHub
- URL: https://github.com/ocelot5836/glfw-windows
- Owner: Ocelot5836
- License: mit
- Created: 2022-11-19T23:32:59.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-03T03:06:40.000Z (about 1 year ago)
- Last Synced: 2025-01-28T22:51:59.785Z (4 months ago)
- Language: Java
- Size: 101 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GLFW Windows
Java wrapper for the LWJGL GLFW api. This makes it straightforward to set up and manage multiple windows with
customizable rendering APIs.# OpenGL Example
```java
import io.github.ocelot.window.Window;
import io.github.ocelot.window.WindowEventListener;
import io.github.ocelot.window.WindowManager;
import io.github.ocelot.window.input.KeyMods;
import org.lwjgl.opengl.GL;import static org.lwjgl.glfw.GLFW.*;
public class ExampleApp implements WindowEventListener {
private final WindowManager windowManager;
private final Window window;public ExampleApp() {
this.windowManager = new WindowManager();
this.window = this.windowManager.create(800, 600, false);
this.window.addListener(this);
}private void init() {
glfwDefaultWindowHints();
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);this.window.create("Test 1");
GL.createCapabilities();
glfwMakeContextCurrent(this.window.getHandle());
}public void run() {
this.init();while (!this.window.isClosed()) {
this.windowManager.update();
}this.windowManager.free();
}@Override
public void keyPressed(Window window, int key, int scanCode, KeyMods mods) {
if (key == GLFW_KEY_F && mods.shift()) {
System.out.println("Shift+F pressed");
} else if (key == GLFW_KEY_ESCAPE) {
this.window.close();
}
}public static void main(String[] args) {
new ExampleApp().run();
}
}
```