Skip to content

tisoft/lwjgl3-awt

 
 

Repository files navigation

Build-and-publish Actions Status Maven Central Maven Snapshot

What is it?

OpenGL and Vulkan support for AWT with LWJGL 3.

What does it get me?

Support for OpenGL:

  • creating OpenGL 3.0 and 3.2 core/compatibility contexts (including debug/forward compatible)
  • OpenGL ES contexts
  • floating-point and sRGB pixel formats
  • multisampled framebuffers (also with different number of color samples - Nvidia only)
  • v-sync/swap control
  • context flush control
  • robust buffer access (with application/share-group isolation)
  • sync'ing buffer swaps over multiple windows and cards - Nvidia only
  • delay before swap - Nvidia only

Why does it exist?

Because there is currently no other way to use OpenGL or Vulkan with AWT.

How to use it with OpenGL?

In order to create an OpenGL 3.3 core profile context with 4 sample MSAA, use:

JFrame frame = new JFrame("AWT test");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLayout(new BorderLayout());
GLData data = new GLData();
data.majorVersion = 3;
data.minorVersion = 3;
data.profile = GLData.Profile.CORE;
data.samples = 4;
frame.add(new AWTGLCanvas(data) {
  public void initGL() {
  }
  public void paintGL() {
  }
});

How to use it with Vulkan?

JFrame frame = new JFrame("AWT test");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLayout(new BorderLayout());
VkInstance instance = ...; // <- Vulkan instance created somewhere else
VKData data = new VKData();
data.instance = instance; // <- set Vulkan instance
frame.add(new AWTVKCanvas(data) {
    public void initVK() {
        long surface = this.surface;
        // Do something with surface...
    }
    public void paintVK() {
    }
});

How to rebuild the MacOS native library

gcc -dynamiclib lwjgl3awt/*.m -o native/macosx/liblwjgl3awt.dylib -framework CoreFoundation -framework AppKit -framework MetalKit -framework Metal 

About

AWT support for LWJGL3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 98.3%
  • Other 1.7%